1 /*****************************************************************************
2 * wizard.h: MacOS X Streaming Wizard
3 *****************************************************************************
4 * Copyright (C) 2005 VideoLAN
7 * Authors: Felix Kühne <fkuehne@users.sf.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 /*****************************************************************************
26 * Note: this code is based upon ../wxwindows/wizard.cpp,
27 * written by Clément Stenac.
28 *****************************************************************************/
31 - implementation of the logic, i.e. handling of the collected values, respective manipulation of the GUI, start of the stream
32 - move some arrays to an external header file
33 - some GUI things (e.g. radio buttons on page 2, etc. - see FIXMEs)
34 - l10n string fixes (both in OSX and WX) */
37 /*****************************************************************************
39 *****************************************************************************/
44 /*****************************************************************************
45 * VLCWizard implementation
46 *****************************************************************************/
48 @implementation VLCWizard
50 static VLCWizard *_o_sharedInstance = nil;
52 + (VLCWizard *)sharedInstance
54 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
59 if (_o_sharedInstance) {
62 _o_sharedInstance = [super init];
65 return _o_sharedInstance;
70 /* some minor cleanup */
71 [o_t2_tbl_plst setEnabled:NO];
72 [o_wizardhelp_window setExcludedFromWindowsMenu:YES];
75 /* FIXME: make the both arrays global */
77 /* add audio-codecs for transcoding */
78 NSArray * audioBitratesArray;
79 audioBitratesArray = [NSArray arrayWithObjects: @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
80 [o_t4_pop_audioBitrate removeAllItems];
81 [o_t4_pop_audioBitrate addItemsWithTitles: audioBitratesArray];
82 [o_t4_pop_audioBitrate selectItemWithTitle: @"192"];
84 /* add video-codecs for transcoding */
85 NSArray * videoBitratesArray;
86 videoBitratesArray = [NSArray arrayWithObjects: @"3072", @"2048", @"1024", @"768", @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
87 [o_t4_pop_videoBitrate removeAllItems];
88 [o_t4_pop_videoBitrate addItemsWithTitles: videoBitratesArray];
89 [o_t4_pop_videoBitrate selectItemWithTitle: @"1024"];
91 /* FIXME: fill the codec-popups as well */
96 /* just present the window to the user */
97 /* we might need a method to reset the window first */
98 [o_tab_pageHolder selectFirstTabViewItem:self];
100 [o_wizard_window center];
101 [o_wizard_window displayIfNeeded];
102 [o_wizard_window makeKeyAndOrderFront:nil];
107 /* localise all strings to the users lang */
108 /* method is called from intf.m (in method openWizard) */
111 [o_btn_backward setTitle: _NS("< Back")];
112 [o_btn_cancel setTitle: _NS("Cancel")];
113 [o_btn_forward setTitle: _NS("Next >")];
114 [o_wizard_window setTitle: _NS("Streaming/Transcoding Wizard")];
116 /* page one ("Hello") */
117 [o_t1_txt_title setStringValue: _NS("Streaming/Transcoding Wizard")];
118 [o_t1_txt_text setStringValue: _NS("This wizard helps you to stream, transcode or save a stream")];
119 [o_t1_btn_mrInfo_strmg setTitle: _NS("More Info")];
120 [o_t1_btn_mrInfo_trnscd setTitle: _NS("More Info")];
121 [o_t1_txt_notice setStringValue: _NS("This wizard only gives access to a small subset of VLC's streaming and transcoding capabilities. Use the Open and Stream Output dialogs to get all of them")];
122 [o_t1_rdo_streaming setTitle: _NS("Stream to network")];
123 [o_t1_rdo_transcode setTitle: _NS("Transcode/Save to file")];
125 /* page two ("Input") */
126 [o_t2_title setStringValue: _NS("Choose input")];
127 [o_t2_text setStringValue: _NS("Choose here your input stream")];
128 [o_t2_rdo_newStrm setTitle: _NS("Select a stream")];
129 [o_t2_rdo_exstPlstItm setTitle: _NS("Existing playlist item")];
130 [o_t2_btn_chooseFile setTitle: _NS("Choose...")];
131 [[[o_t2_tbl_plst tableColumnWithIdentifier:@"name"] headerCell] setStringValue: _NS("Name")];
132 [o_t2_box_prtExtrct setTitle: _NS("Partial Extract")];
133 [o_t2_ckb_enblPartExtrct setTitle: _NS("Enable")];
134 [o_t2_txt_prtExtrctFrom setStringValue: _NS("From")];
135 [o_t2_txt_prtExtrctTo setStringValue: _NS("To")];
137 /* page three ("Streaming 1") */
138 [o_t3_txt_title setStringValue: _NS("Streaming")];
139 [o_t3_txt_text setStringValue: _NS("In this page, you will select how your input stream will be sent.")];
140 [o_t3_box_dest setTitle: _NS("Destination")];
141 [o_t3_box_strmgMthd setTitle: _NS("Streaming method")];
142 [o_t3_txt_destInfo setStringValue: _NS("Enter the address of the computer to stream to")];
143 [[o_t3_matrix_stmgMhd cellAtRow:1 column:0] setTitle: _NS("UDP Unicast")];
144 [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setTitle: _NS("UDP Multicast")];
146 /* page four ("Transcode 1") */
147 [o_t4_title setStringValue: _NS("Transcode")];
148 [o_t4_text setStringValue: _NS("If you want to change the compression format of the audio or video tracks, fill in this page. (If you only want to change the container format, proceed to next page).")];
149 [o_t4_box_audio setTitle: _NS("Audio")];
150 [o_t4_box_video setTitle: _NS("Video")];
151 [o_t4_ckb_audio setTitle: _NS("Transcode audio")];
152 [o_t4_ckb_video setTitle: _NS("Transcode video")];
153 [o_t4_txt_videoBitrate setStringValue: _NS("Bitrate (kb/s)")];
154 [o_t4_txt_videoCodec setStringValue: _NS("Codec")];
155 [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio and you want to " \
156 "transcode it, enable this")];
157 [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video and you want to " \
158 "transcode it, enable this")];
160 /* page five ("Encap") */
161 [o_t5_title setStringValue: _NS("Encapsulation format")];
162 [o_t5_text setStringValue: _NS("In this page, you will select how the stream will be "\
163 "encapsulated. Depending on the choices you made, all "\
164 "formats won't be available.")];
166 /* page six ("Streaming 2") */
167 [o_t6_title setStringValue: _NS("Additional streaming options")];
168 [o_t6_text setStringValue: _NS("In this page, you will define a few " \
169 "additional parameters for your stream.")];
170 [o_t6_txt_ttl setStringValue: _NS("Time-To-Live (TTL)")];
171 [o_t6_btn_mrInfo_ttl setTitle: _NS("More Info")];
172 [o_t6_ckb_sap setTitle: _NS("SAP Announce")];
173 [o_t6_btn_mrInfo_sap setTitle: _NS("More Info")];
175 /* page seven ("Transcode 2") */
176 [o_t7_title setStringValue: _NS("Additional transcode options")];
177 [o_t7_text setStringValue: _NS("In this page, you will define a few " \
178 "additionnal parameters for your transcoding.")];
179 [o_t7_txt_saveFileTo setStringValue: _NS("Select the file to save to")];
180 [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
182 /* wizard help window */
183 [o_wh_btn_okay setTitle: _NS("OK")];
186 - (IBAction)cancelRun:(id)sender
188 [o_wizard_window close];
191 - (IBAction)nextTab:(id)sender
193 /* only a stub atm; needs to be implemented correctly later on */
194 [o_tab_pageHolder selectNextTabViewItem:self];
197 - (IBAction)prevTab:(id)sender
199 /* only a stub atm; needs to be implemented correctly later on */
200 [o_tab_pageHolder selectPreviousTabViewItem:self];
203 - (IBAction)t1_mrInfo_streaming:(id)sender
205 /* show a sheet for the help */
206 /* since NSAlert does not exist on OSX < 10.3, we use our own implementation */
207 [o_wh_txt_title setStringValue: _NS("Stream to network")];
208 [o_wh_txt_text setStringValue: _NS("Use this to stream on a network.")];
209 [NSApp beginSheet: o_wizardhelp_window
210 modalForWindow: o_wizard_window
211 modalDelegate: o_wizardhelp_window
216 - (IBAction)t1_mrInfo_transcode:(id)sender
218 /* show a sheet for the help */
219 [o_wh_txt_title setStringValue: _NS("Transcode/Save to file")];
220 [o_wh_txt_text setStringValue: _NS("Use this to save a stream to a file. You "\
221 "have the possibility to reencode the stream. You can save whatever "\
222 "VLC can read.\nPlease notice that VLC is not very suited " \
223 "for file to file transcoding. You should use its transcoding " \
224 "features to save network streams, for example.")];
225 [NSApp beginSheet: o_wizardhelp_window
226 modalForWindow: o_wizard_window
227 modalDelegate: o_wizardhelp_window
232 - (IBAction)t2_addNewStream:(id)sender
234 NSOpenPanel * openPanel = [NSOpenPanel openPanel];
235 SEL sel = @selector(t2_getNewStreamFromDialog:returnCode:contextInfo:);
236 [openPanel beginSheetForDirectory:@"~" file:nil types:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
239 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
241 if (returnCode == NSOKButton)
243 [o_t2_fld_pathToNewStrm setStringValue:[sheet filename]];
244 /* FIXME: store path in a global variable */
248 - (IBAction)t2_chooseStreamOrPlst:(id)sender
250 /* enable and disable the respective items depending on user's choice */
254 - (IBAction)t2_enableExtract:(id)sender
256 /* enable/disable the respective items */
257 if([o_t2_ckb_enblPartExtrct state] == NSOnState)
259 [o_t2_fld_prtExtrctFrom setEnabled:YES];
260 [o_t2_fld_prtExtrctTo setEnabled:YES];
262 [o_t2_fld_prtExtrctFrom setEnabled:NO];
263 [o_t2_fld_prtExtrctTo setEnabled:NO];
267 - (IBAction)t3_addressEntered:(id)sender
269 /* check whether the entered address is valid */
272 - (IBAction)t4_AudCdcChanged:(id)sender
274 /* update codec info */
277 - (IBAction)t4_enblAudTrnscd:(id)sender
279 /* enable/disable the respective items */
280 if([o_t4_ckb_audio state] == NSOnState)
282 [o_t4_pop_audioCodec setEnabled:YES];
284 [o_t4_pop_audioBitrate setEnabled:YES];
286 [o_t4_pop_audioCodec setEnabled:NO];
287 [o_t4_pop_audioBitrate setEnabled:NO];
291 - (IBAction)t4_enblVidTrnscd:(id)sender
293 /* enable/disable the respective items */
294 if([o_t4_ckb_video state] == NSOnState)
296 [o_t4_pop_videoCodec setEnabled:YES];
297 [o_t4_pop_videoBitrate setEnabled:YES];
299 [o_t4_pop_videoCodec setEnabled:NO];
300 [o_t4_pop_videoBitrate setEnabled:NO];
304 - (IBAction)t4_VidCdcChanged:(id)sender
306 /* update codec info */
309 - (IBAction)t6_enblSapAnnce:(id)sender
311 /* enable/disable input fld */
312 if([o_t6_ckb_sap state] == NSOnState)
314 [o_t6_fld_sap setEnabled:YES];
316 [o_t6_fld_sap setEnabled:NO];
317 [o_t6_fld_sap setStringValue:@""];
321 - (IBAction)t6_mrInfo_ttl:(id)sender
323 /* show a sheet for the help */
324 [o_wh_txt_title setStringValue: _NS("Time-To-Live (TTL)")];
325 [o_wh_txt_text setStringValue: _NS("Define the TTL (Time-To-Live) of the stream. "\
326 "This parameter is the maximum number of routers your stream can go "
327 "through. If you don't know what it means, or if you want to stream on " \
328 "your local network only, leave this setting to 1.")];
329 [NSApp beginSheet: o_wizardhelp_window
330 modalForWindow: o_wizard_window
331 modalDelegate: o_wizardhelp_window
336 - (IBAction)t6_mrInfo_sap:(id)sender
338 /* show a sheet for the help */
339 [o_wh_txt_title setStringValue: _NS("SAP Announce")];
340 [o_wh_txt_text setStringValue: _NS("When streaming using UDP, you can " \
341 "announce your streams using the SAP/SDP announcing protocol. This " \
342 "way, the clients won't have to type in the multicast address, it " \
343 "will appear in their playlist if they enable the SAP extra interface.\n" \
344 "If you want to give a name to your stream, enter it here, " \
345 "else, a default name will be used.")];
346 [NSApp beginSheet: o_wizardhelp_window
347 modalForWindow: o_wizard_window
348 modalDelegate: o_wizardhelp_window
353 - (IBAction)t7_selectTrnscdDestFile:(id)sender
355 /* provide a save-to-dialogue, so the user can choose a location for his/her new file */
356 NSSavePanel * savePanel = [NSSavePanel savePanel];
357 SEL sel = @selector(t7_getTrnscdDestFile:returnCode:contextInfo:);
358 [savePanel beginSheetForDirectory:@"~" file:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
359 /* FIXME: insert a suffix in file depending on the chosen encap-format */
362 - (void)t7_getTrnscdDestFile: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
364 if (returnCode == NSOKButton)
366 [o_t7_fld_filePath setStringValue:[sheet filename]];
367 /* FIXME: store path in a global variable and add a suffix depending on the chosen encap-format, if needed */
371 - (IBAction)wh_closeSheet:(id)sender
373 /* close the help sheet */
374 [NSApp endSheet:o_wizardhelp_window];
375 [o_wizardhelp_window close];