]> git.sesse.net Git - vlc/blob - modules/gui/macosx/wizard.m
Copyright fixes
[vlc] / modules / gui / macosx / wizard.m
1 /*****************************************************************************
2  * wizard.h: MacOS X Streaming Wizard
3  *****************************************************************************
4  * Copyright (C) 2005 VideoLAN (Centrale Réseaux) and its contributors
5  * $Id$
6  *
7  * Authors: Felix Kühne <fkuehne@users.sf.net> 
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24  
25 /*****************************************************************************
26  * Note: this code is based upon ../wxwindows/wizard.cpp and 
27  *               ../wxwindows/streamdata.h; both written by Clément Stenac.
28  *****************************************************************************/ 
29
30 /* TODO:
31     - start of the streaming/transcoding
32     - some GUI things
33     - l10n string fixes (both in OSX and WX) 
34         - implementation of correct encap-selection for transcoding
35         - fill the playlist-table on t2
36         - implement l10n on t8?
37         - see FIXME's
38 */
39
40  
41 /*****************************************************************************
42  * Preamble
43  *****************************************************************************/ 
44 #import "wizard.h"
45 #import "intf.h"
46
47
48 /*****************************************************************************
49  * VLCWizard implementation
50  *****************************************************************************/
51
52 @implementation VLCWizard
53
54 static VLCWizard *_o_sharedInstance = nil;
55
56 + (VLCWizard *)sharedInstance
57 {
58     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
59 }
60
61 - (id)init 
62 {
63     if (_o_sharedInstance) {
64         [self dealloc];
65     } else {
66         _o_sharedInstance = [super init];
67     }
68     
69     return _o_sharedInstance;
70 }
71
72 - (void)awakeFromNib
73 {
74     /* some minor cleanup */
75     [o_t2_tbl_plst setEnabled:NO];
76         [o_wizardhelp_window setExcludedFromWindowsMenu:YES];
77         o_userSelections = [[NSMutableDictionary alloc] init];
78         [o_btn_backward setEnabled:NO];
79
80     /* add audio-bitrates for transcoding */
81     NSArray * audioBitratesArray;
82     audioBitratesArray = [NSArray arrayWithObjects: @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
83     [o_t4_pop_audioBitrate removeAllItems];
84     [o_t4_pop_audioBitrate addItemsWithTitles: audioBitratesArray];
85     [o_t4_pop_audioBitrate selectItemWithTitle: @"192"];
86     
87     /* add video-bitrates for transcoding */
88     NSArray * videoBitratesArray;
89     videoBitratesArray = [NSArray arrayWithObjects: @"3072", @"2048", @"1024", @"768", @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
90     [o_t4_pop_videoBitrate removeAllItems];
91     [o_t4_pop_videoBitrate addItemsWithTitles: videoBitratesArray];
92     [o_t4_pop_videoBitrate selectItemWithTitle: @"1024"];
93     
94         /* fill 2 global arrays with arrays containing all codec-related information
95          * - one array per codec named by its short name to define the encap-compability, 
96          *       cmd-names, real names, more info in the order: realName, shortName, 
97          *       moreInfo, encaps */
98         NSArray * o_mp1v;
99         NSArray * o_mp2v;
100         NSArray * o_mp4v;
101         NSArray * o_div1;
102         NSArray * o_div2;
103         NSArray * o_div3;
104         NSArray * o_h263;
105         NSArray * o_h264;
106         NSArray * o_wmv1;
107         NSArray * o_wmv2;
108         NSArray * o_mjpg;
109         NSArray * o_theo;
110         NSArray * o_dummyVid;
111         o_mp1v = [NSArray arrayWithObjects: @"MPEG-1 Video", @"mp1v", _NS("MPEG-1 Video codec"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_OGG", @"MUX_RAW", @"NO", @"NO", @"NO", @"NO", nil];
112         o_mp2v = [NSArray arrayWithObjects: @"MPEG-2 Video", @"mp2v", _NS("MPEG-2 Video codec"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_OGG", @"MUX_RAW", @"NO", @"NO", @"NO", @"NO", nil];
113         o_mp4v = [NSArray arrayWithObjects: @"MPEG-4 Video", @"mp4v", _NS("MPEG-4 Video codec"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4", @"MUX_OGG", @"MUX_RAW", @"NO", @"NO", nil];
114         o_div1 = [NSArray arrayWithObjects: @"DIVX 1", @"DIV1", _NS("DivX first version"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
115         o_div2 = [NSArray arrayWithObjects: @"DIVX 2", @"DIV2", _NS("DivX second version"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
116         o_div3 = [NSArray arrayWithObjects: @"DIVX 3", @"DIV3", _NS("DivX third version"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
117         o_h263 = [NSArray arrayWithObjects: @"H 263", @"H263", _NS("H263 is a video codec optimized for videoconference (low rates)"), @"MUX_TS", @"MUX_AVI", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
118         o_h264 = [NSArray arrayWithObjects: @"H 264", @"H264", _NS("H264 is a new video codec"), @"MUX_TS", @"MUX_AVI", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
119         o_wmv1 = [NSArray arrayWithObjects: @"WMV 1", @"WMV1", _NS("WMV (Windows Media Video) 1"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
120         o_wmv2 = [NSArray arrayWithObjects: @"WMV 2", @"WMV2", _NS("WMV (Windows Media Video) 2"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
121         o_mjpg = [NSArray arrayWithObjects: @"MJPEG", @"MJPG", _NS("MJPEG consists of a series of JPEG pictures"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
122         o_theo = [NSArray arrayWithObjects: @"Theora", @"theo", _NS("Theora is a free general-purpose codec"), @"MUX_TS", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
123         o_dummyVid = [NSArray arrayWithObjects: @"Dummy", @"dummy", _NS("Dummy codec (do not transcode)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4", @"MUX_OGG", @"MUX_WAV", @"MUX_RAW", @"MUX_MOV", nil];
124         o_videoCodecs = [[NSArray alloc] initWithObjects: o_mp1v, o_mp2v, o_mp4v, o_div1, o_div2, o_div3, o_h263, o_h264, o_wmv1, o_wmv2, o_mjpg, o_theo, o_dummyVid, nil];
125         [o_t4_pop_videoCodec removeAllItems];
126         unsigned int x;
127         x = 0;
128         while (x != [o_videoCodecs count])
129         {
130                 [o_t4_pop_videoCodec addItemWithTitle:[[o_videoCodecs objectAtIndex:x] objectAtIndex:0]];
131                 x = (x + 1);
132         }
133         
134         NSArray * o_mpga;
135         NSArray * o_mp3;
136         NSArray * o_mp4a;
137         NSArray * o_a52;
138         NSArray * o_vorb;
139         NSArray * o_flac;
140         NSArray * o_spx;
141         NSArray * o_s16l;
142         NSArray * o_fl32;
143         NSArray * o_dummyAud;
144         o_mpga = [NSArray arrayWithObjects: @"MPEG Audio", @"mpga", _NS("The standard MPEG audio (1/2) format"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", nil];
145         o_mp3 = [NSArray arrayWithObjects: @"MP3", @"mp3", _NS("MPEG Audio Layer 3"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", nil];
146         o_mp4a = [NSArray arrayWithObjects: @"MPEG 4 Audio", @"mp4a", _NS("Audio format for MPEG4"), @"MUX_TS", @"MUX_MP4", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
147         o_a52 = [NSArray arrayWithObjects: @"A/52", @"a52", _NS("DVD audio format"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", nil];
148         o_vorb = [NSArray arrayWithObjects: @"Vorbis", @"vorb", _NS("Vorbis is a free audio codec"), @"MUX_OGG", @"-1",  @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
149         o_flac = [NSArray arrayWithObjects: @"FLAC", @"flac", _NS("FLAC is a lossless audio codec"), @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
150         o_spx = [NSArray arrayWithObjects: @"Speex", @"spx", _NS("A free audio codec dedicated to compression of voice"), @"MUX_OGG", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
151         o_s16l = [NSArray arrayWithObjects: @"Uncompressed, integer", @"s16l", _NS("Uncompressed audio samples"), @"MUX_WAV", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
152         o_fl32 = [NSArray arrayWithObjects: @"Uncompressed, floating", @"fl32", _NS("Uncompressed audio samples"), @"MUX_WAV", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
153         o_dummyAud = [NSArray arrayWithObjects: @"Dummy", @"dummy", _NS("Dummy codec (do not transcode)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4", @"MUX_OGG", @"MUX_RAW", @"MUX_MOV", @"MUX_WAV", nil];
154         o_audioCodecs = [[NSArray alloc] initWithObjects: o_mpga, o_mp3, o_mp4a, o_a52, o_vorb, o_flac, o_spx, o_s16l, o_fl32, o_dummyAud, nil];
155         [o_t4_pop_audioCodec removeAllItems];
156         x = 0;
157         while (x != [o_audioCodecs count])
158         {
159                 [o_t4_pop_audioCodec addItemWithTitle:[[o_audioCodecs objectAtIndex:x] objectAtIndex:0]];
160                 x = (x + 1);
161         }
162 }
163
164 - (void)showWizard
165 {
166     /* just present the window to the user */
167     [o_tab_pageHolder selectFirstTabViewItem:self];
168     
169         [self resetWizard];
170         
171     [o_wizard_window center];
172     [o_wizard_window displayIfNeeded];
173     [o_wizard_window makeKeyAndOrderFront:nil];
174 }
175
176 - (void)resetWizard
177 {
178         /* reset the wizard-window to its default values */
179         
180         [o_userSelections removeAllObjects];
181         [o_t1_matrix_strmgOrTrnscd selectCellAtRow:0 column:0];
182         [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setState: NSOffState];
183         [o_btn_forward setTitle: [_NS("Next") stringByAppendingString:@" >"]];
184         
185         /* "Input" */
186         [o_t2_fld_pathToNewStrm setStringValue: @""];
187         [o_t2_ckb_enblPartExtrct setState: NSOffState];
188         [self t2_enableExtract:nil];
189         [o_t2_matrix_inputSourceType selectCellAtRow:0 column:0];
190         [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setState: NSOffState];
191         /* FIXME: we need to refresh the playlist-table as well */
192         [o_t2_tbl_plst setEnabled:NO];
193         [o_t2_fld_pathToNewStrm setEnabled:YES];
194         [o_t2_btn_chooseFile setEnabled:YES];
195         
196         /* "Streaming 1" */
197         [o_t3_fld_address setStringValue: @""];
198         [o_t3_matrix_stmgMhd selectCellAtRow:0 column:0];
199         [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setState: NSOffState];
200         [[o_t3_matrix_stmgMhd cellAtRow:1 column:2] setState: NSOffState];
201         
202         /* "Transcode 1" */
203         [o_t4_ckb_audio setState: NSOffState];
204         [o_t4_ckb_video setState: NSOffState];
205         [self t4_enblVidTrnscd:nil];
206         [self t4_enblAudTrnscd:nil];
207         
208         /* "Streaming 2" */
209         [o_t6_fld_ttl setStringValue: @"1"];
210         [o_t6_ckb_sap setState: NSOffState];
211         [self t6_enblSapAnnce:nil];
212         
213         /* "Transcode 2" */
214         [o_t7_fld_filePath setStringValue: @""];
215 }
216
217 - (void)initStrings
218 {
219     /* localise all strings to the users lang */
220     /* method is called from intf.m (in method openWizard) */
221     
222     /* general items */
223     [o_btn_backward setTitle: [@"< " stringByAppendingString: _NS("Back")]];
224     [o_btn_cancel setTitle: _NS("Cancel")];
225     [o_btn_forward setTitle: [_NS("Next") stringByAppendingString:@" >"]];
226     [o_wizard_window setTitle: _NS("Streaming/Transcoding Wizard")];
227     
228     /* page one ("Hello") */
229     [o_t1_txt_title setStringValue: _NS("Streaming/Transcoding Wizard")];
230     [o_t1_txt_text setStringValue: _NS("This wizard helps you to stream, transcode or save a stream")];
231     [o_t1_btn_mrInfo_strmg setTitle: _NS("More Info")];
232     [o_t1_btn_mrInfo_trnscd setTitle: _NS("More Info")];
233     [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")];
234         [[o_t1_matrix_strmgOrTrnscd cellAtRow:0 column:0] setTitle: _NS("Stream to network")];
235     [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setTitle: _NS("Transcode/Save to file")];
236     
237     /* page two ("Input") */
238     [o_t2_title setStringValue: _NS("Choose input")];
239     [o_t2_text setStringValue: _NS("Choose here your input stream")];
240     [[o_t2_matrix_inputSourceType cellAtRow:0 column:0] setTitle: _NS("Select a stream")];
241     [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setTitle: _NS("Existing playlist item")];
242     [o_t2_btn_chooseFile setTitle: _NS("Choose...")];
243     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"name"] headerCell] setStringValue: _NS("Name")];
244     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"uri"] headerCell] setStringValue: _NS("URI")];
245     [o_t2_box_prtExtrct setTitle: _NS("Partial Extract")];
246     [o_t2_ckb_enblPartExtrct setTitle: _NS("Enable")];
247     [o_t2_txt_prtExtrctFrom setStringValue: _NS("From")];
248     [o_t2_txt_prtExtrctTo setStringValue: _NS("To")];
249     
250     /* page three ("Streaming 1") */
251     [o_t3_txt_title setStringValue: _NS("Streaming")];
252     [o_t3_txt_text setStringValue: _NS("In this page, you will select how your input stream will be sent.")];
253     [o_t3_box_dest setTitle: _NS("Destination")];
254     [o_t3_box_strmgMthd setTitle: _NS("Streaming method")];
255     [o_t3_txt_destInfo setStringValue: _NS("Enter the address of the computer to stream to")];
256     [[o_t3_matrix_stmgMhd cellAtRow:1 column:0] setTitle: _NS("UDP Unicast")];
257     [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setTitle: _NS("UDP Multicast")];
258     
259     /* page four ("Transcode 1") */
260     [o_t4_title setStringValue: _NS("Transcode")];
261     [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).")];
262     [o_t4_box_audio setTitle: _NS("Audio")];
263     [o_t4_box_video setTitle: _NS("Video")];
264     [o_t4_ckb_audio setTitle: _NS("Transcode audio")];
265     [o_t4_ckb_video setTitle: _NS("Transcode video")];
266     [o_t4_txt_videoBitrate setStringValue: _NS("Bitrate (kb/s)")];
267     [o_t4_txt_videoCodec setStringValue: _NS("Codec")];
268     [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio and you want to " \
269                          "transcode it, enable this")];
270     [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video and you want to " \
271                          "transcode it, enable this")];
272     
273     /* page five ("Encap") */
274     [o_t5_title setStringValue: _NS("Encapsulation format")];
275     [o_t5_text setStringValue: _NS("In this page, you will select how the stream will be "\
276                      "encapsulated. Depending on the choices you made, all "\
277                      "formats won't be available.")];
278     
279     /* page six ("Streaming 2") */
280     [o_t6_title setStringValue: _NS("Additional streaming options")];
281     [o_t6_text setStringValue: _NS("In this page, you will define a few " \
282                               "additional parameters for your stream.")];
283     [o_t6_txt_ttl setStringValue: _NS("Time-To-Live (TTL)")];
284     [o_t6_btn_mrInfo_ttl setTitle: _NS("More Info")];
285     [o_t6_ckb_sap setTitle: _NS("SAP Announce")];
286     [o_t6_btn_mrInfo_sap setTitle: _NS("More Info")];
287      
288     /* page seven ("Transcode 2") */
289     [o_t7_title setStringValue: _NS("Additional transcode options")];
290     [o_t7_text setStringValue: _NS("In this page, you will define a few " \
291                               "additionnal parameters for your transcoding.")];
292     [o_t7_txt_saveFileTo setStringValue: _NS("Select the file to save to")];
293     [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
294         
295         /* page eight ("Summary") */
296         /* FIXME: currently not implemented as it unsure whether we show this tab
297          * to the public or use it for debugging only */
298         
299         /* wizard help window */
300         [o_wh_btn_okay setTitle: _NS("OK")];
301 }
302
303 - (IBAction)cancelRun:(id)sender
304 {
305     [o_wizard_window close];
306 }
307
308 - (IBAction)nextTab:(id)sender
309 {
310         if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Hello"])
311         {
312                 /* check whether the user wants to stream or just to transcode;
313                  * store information for later usage */
314                 NSString *o_mode;
315                 o_mode = [[o_t1_matrix_strmgOrTrnscd selectedCell] title];
316                 if( [o_mode isEqualToString: _NS("Stream to network")] )
317                 {
318                         [o_userSelections setObject:@"strmg" forKey:@"trnscdOrStrmg"];
319                 }else{
320                         [o_userSelections setObject:@"trnscd" forKey:@"trnscdOrStrmg"];
321                 }
322                 [o_btn_backward setEnabled:YES];
323                 [o_tab_pageHolder selectTabViewItemAtIndex:1];
324         }
325         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Input"])
326         {
327                 /* check whether partialExtract is enabled and store the values, if needed */
328                 if ([o_t2_ckb_enblPartExtrct state] == NSOnState)
329                 {
330                         [o_userSelections setObject:@"YES" forKey:@"partExtract"];
331                         [o_userSelections setObject:[o_t2_fld_prtExtrctFrom stringValue] forKey:@"partExtractFrom"];
332                         [o_userSelections setObject:[o_t2_fld_prtExtrctTo stringValue] forKey:@"partExtractTo"];
333                 }else{
334                         [o_userSelections setObject:@"NO" forKey:@"partExtract"];
335                 }
336                 
337                 /* check whether we use an existing pl-item or add an new one;
338                  * store the path or the index and set a flag.
339                  * complain to the user if s/he didn't provide a path */
340                 NSString *o_mode;
341                 o_mode = [[o_t2_matrix_inputSourceType selectedCell] title];
342                 if( [o_mode isEqualToString: _NS("Select a stream")] )
343                 {
344                         [o_userSelections setObject:@"YES" forKey:@"newStrm"];
345                         if ([[o_t2_fld_pathToNewStrm stringValue] isEqualToString: @""])
346                         {
347                                 /* FIXME: we should complain to the user that s/he didn't provide a path */
348                         }else{
349                                 [o_userSelections setObject:[o_t2_fld_pathToNewStrm stringValue] forKey:@"pathToNewStrm"];
350                         }
351                 }else{
352                         [o_userSelections setObject:@"NO" forKey:@"newStrm"];
353                         NSNumber * myNumber = [[NSNumber alloc] initWithInt:[o_t2_tbl_plst selectedRow]];
354                         [o_userSelections setObject:myNumber forKey:@"plItemIndex"];
355                 }
356                 
357                 /* show either "Streaming 1" or "Transcode 1" to the user */
358                 if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
359                 {
360                         /* we are streaming */
361                         [o_tab_pageHolder selectTabViewItemAtIndex:2];
362                 }else{
363                         /* we are just transcoding */
364                         [o_tab_pageHolder selectTabViewItemAtIndex:3];
365                 }
366         }
367         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 1"])
368         {
369                 /* check which streaming method is selected and store it */
370                 NSString *o_mode;
371                 o_mode = [[o_t3_matrix_stmgMhd selectedCell] title];
372                 if( [o_mode isEqualToString: _NS("HTTP")] )
373                 {
374                         [o_userSelections setObject:@"HTTP" forKey:@"stmgMhd"];
375                         /* enable MPEG PS, MPEG TS, MPEG 1, OGG, RAW and ASF; select MPEG PS */
376                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
377                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
378                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
379                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
380                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
381                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
382                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
383                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
384                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
385                         [o_t5_matrix_encap selectCellAtRow:0 column:0];
386                 } else {
387                         if( [o_mode isEqualToString: _NS("UDP Unicast")] )
388                         {
389                                 [o_userSelections setObject:@"UDP-Unicast" forKey:@"stmgMhd"];
390                         } else {
391                                 [o_userSelections setObject:@"UDP-Multicast" forKey:@"stmgMhd"];
392                         }
393                         /* disable all encap-formats but MPEG-TS and select it */
394                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
395                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
396                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
397                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
398                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
399                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
400                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
401                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
402                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
403                         [o_t5_matrix_encap selectCellAtRow:1 column:0];
404                 }
405                 
406                 /* store the destination and check whether is it empty */
407                 if( [[o_t3_fld_address stringValue] isEqualToString: @""] )
408                 {       /* FIXME: complain to the user that "" is no valid dest. */
409                 } else {
410                         [o_userSelections setObject:[o_t3_fld_address stringValue] forKey:@"stmgDest"];
411                 }
412                 
413                 /* let's go to the encap-tab */
414                 [o_tab_pageHolder selectTabViewItemAtIndex:4];
415         }
416         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 1"])
417         {
418                 /* check whether the user wants to transcode the video-track and store the related options */
419                 if ([o_t4_ckb_video state] == NSOnState)
420                 {
421                         NSNumber * theNum;
422                         theNum = [NSNumber numberWithInt:[o_t4_pop_videoCodec indexOfSelectedItem]];
423                         [o_userSelections setObject:@"YES" forKey:@"trnscdVideo"];
424                         [o_userSelections setObject:[o_t4_pop_videoBitrate titleOfSelectedItem] forKey:@"trnscdVideoBitrate"];
425                         [o_userSelections setObject:theNum forKey:@"trnscdVideoCodec"];
426                 } else {
427                         [o_userSelections setObject:@"NO" forKey:@"trnscdVideo"];
428                 }
429                 
430                 /* check whether the user wants to transcode the audio-track and store the related options */
431                 if ([o_t4_ckb_audio state] == NSOnState)
432                 {
433                         NSNumber * theNum;
434                         theNum = [NSNumber numberWithInt:[o_t4_pop_audioCodec indexOfSelectedItem]];
435                         [o_userSelections setObject:@"YES" forKey:@"trnscdAudio"];
436                         [o_userSelections setObject:[o_t4_pop_audioBitrate titleOfSelectedItem] forKey:@"trnscdAudioBitrate"];
437                         [o_userSelections setObject:theNum forKey:@"trnscdAudioCodec"];
438                 } else {
439                         [o_userSelections setObject:@"NO" forKey:@"trnscdAudio"];
440                 }
441                 
442                 /* FIXME: re-enable the "Encap"-tab depending on the chosen codecs */
443                 [o_tab_pageHolder selectTabViewItemAtIndex:4];
444         }
445         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Encap"])
446         {
447                 /* get the chosen encap format and store it */
448                 [o_userSelections setObject:[[o_t5_matrix_encap selectedCell] title] forKey:@"encapFormat"];
449                 
450                 /* show either "Streaming 2" or "Transcode 2" to the user */
451                 if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
452                 {
453                         /* we are streaming */
454                         [o_tab_pageHolder selectTabViewItemAtIndex:5];
455                 }else{
456                         /* we are just transcoding */
457                         [o_tab_pageHolder selectTabViewItemAtIndex:6];
458                 }
459         }
460         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 2"])
461         {
462                 /* store the chosen TTL */
463                 [o_userSelections setObject:[o_t6_fld_ttl stringValue] forKey:@"ttl"];
464                 
465                 /* check whether SAP is enabled and store the announce, if needed */
466                 if ([o_t6_ckb_sap state] == NSOnState)
467                 {
468                         [o_userSelections setObject:@"YES" forKey:@"sap"];
469                         [o_userSelections setObject:[o_t6_fld_sap stringValue] forKey:@"sapText"];
470                 } else {
471                         [o_userSelections setObject:@"NO" forKey:@"sap"];
472                 }
473                 
474                 /* go to "Summary" */
475                 [self showSummary];
476         }
477         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 2"])
478         {
479                 /* check whether the path != "" and store it */
480                 if( [[o_t7_fld_filePath stringValue] isEqualToString: @""] )
481                 {       /* FIXME: complain to the user that "" is no valid path */
482                 } else {
483                         [o_userSelections setObject:[o_t7_fld_filePath stringValue] forKey:@"trnscdFilePath"];
484                 }
485                 
486                 /* go to "Summary" */
487                 [self showSummary];
488         }
489 }
490
491 - (void)showSummary
492 {
493         [o_btn_forward setTitle: _NS("Finish")];
494         if ([[o_userSelections objectForKey:@"newStrm"] isEqualToString: @"YES"])
495         {
496                 [o_t8_fld_inptStream setStringValue:[o_userSelections objectForKey:@"pathToNewStrm"]];
497         } else {
498                 [o_t8_fld_inptStream setStringValue:[[o_userSelections objectForKey:@"plItemIndex"] stringValue]];
499         }
500         if ([[o_userSelections objectForKey:@"partExtract"] isEqualToString: @"YES"])
501         {
502                 [o_t8_fld_partExtract setStringValue: [[[[[_NS("yes") stringByAppendingString:@" - "] stringByAppendingString: _NS("from ")] stringByAppendingString: [o_userSelections objectForKey:@"partExtractFrom"]] stringByAppendingString: _NS(" to ")] stringByAppendingString: [o_userSelections objectForKey:@"partExtractTo"]]];
503         } else {
504                 [o_t8_fld_partExtract setStringValue: _NS("no")];
505         }
506         
507         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
508         {
509                 /* we are streaming; no transcoding allowed atm */
510                 [o_t8_fld_saveFileTo setStringValue: @"-"];
511                 [o_t8_fld_trnscdAudio setStringValue: @"-"];
512                 [o_t8_fld_trnscdVideo setStringValue: @"-"];
513                 [o_t8_fld_strmgMthd setStringValue: [o_userSelections objectForKey:@"stmgMhd"]];
514                 [o_t8_fld_destination setStringValue: [o_userSelections objectForKey:@"stmgDest"]];
515                 [o_t8_fld_ttl setStringValue: [o_userSelections objectForKey:@"ttl"]];
516                 if ([[o_userSelections objectForKey:@"sap"] isEqualToString: @"YES"])
517                 {
518                         [o_t8_fld_sap setStringValue: [[_NS("yes") stringByAppendingString:@": "] stringByAppendingString:[o_userSelections objectForKey:@"sapText"]]];
519                 }else{
520                         [o_t8_fld_sap setStringValue: _NS("no")];
521                 }
522         } else {
523                 /* we are transcoding */
524                 [o_t8_fld_strmgMthd setStringValue: @"-"];
525                 [o_t8_fld_destination setStringValue: @"-"];
526                 [o_t8_fld_ttl setStringValue: @"-"];
527                 [o_t8_fld_sap setStringValue: @"-"];
528                 if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"YES"])
529                 {
530                         [o_t8_fld_trnscdVideo setStringValue: [[[[[_NS("yes") stringByAppendingString:@": "] stringByAppendingString: [[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] objectAtIndex:0]] stringByAppendingString:@" @ "] stringByAppendingString: [o_userSelections objectForKey:@"trnscdVideoBitrate"]] stringByAppendingString:@" kb/s"]];
531                 }else{
532                         [o_t8_fld_trnscdVideo setStringValue: _NS("no")];
533                 }
534                 if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
535                 {
536                         [o_t8_fld_trnscdAudio setStringValue: [[[[[_NS("yes") stringByAppendingString:@": "] stringByAppendingString: [[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] objectAtIndex:0]] stringByAppendingString:@" @ "] stringByAppendingString: [o_userSelections objectForKey:@"trnscdAudioBitrate"]] stringByAppendingString:@" kb/s"]];
537                 }else{
538                         [o_t8_fld_trnscdAudio setStringValue: _NS("no")];
539                 }
540                 [o_t8_fld_saveFileTo setStringValue: [o_userSelections objectForKey:@"trnscdFilePath"]];
541         }
542         [o_t8_fld_encapFormat setStringValue: [o_userSelections objectForKey:@"encapFormat"]];
543         [o_tab_pageHolder selectTabViewItemAtIndex:7];
544 }
545
546 - (IBAction)prevTab:(id)sender
547 {
548     if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Summary"])
549         {       
550                 /* check whether we are streaming or transcoding and go back */
551                 if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
552                 {
553                         /* show "Streaming 2" */
554                         [o_tab_pageHolder selectTabViewItemAtIndex:5];
555                 }else{
556                         /* show "Transcode 2" */
557                         [o_tab_pageHolder selectTabViewItemAtIndex:6];
558                 }
559                 /* rename the forward-button */
560                 [o_btn_forward setTitle: [_NS("Next") stringByAppendingString:@" >"]];
561         }
562         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 2"])
563         {
564                 /* show "Encap" */
565                 [o_tab_pageHolder selectTabViewItemAtIndex:4];
566         }
567         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 2"])
568         {
569                 /* show "Encap" */
570                 [o_tab_pageHolder selectTabViewItemAtIndex:4];
571         }
572         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Encap"])
573         {
574                 /* check whether we are streaming or transcoding and go back */
575                 if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
576                 {
577                         /* show "Streaming 1" */
578                         [o_tab_pageHolder selectTabViewItemAtIndex:2];
579                 }else{
580                         /* show "Transcode 2" */
581                         [o_tab_pageHolder selectTabViewItemAtIndex:3];
582                 }
583         }
584         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 1"])
585         {
586                 /* show "Input" */
587                 [o_tab_pageHolder selectTabViewItemAtIndex:1];
588         }
589         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 1"])
590         {
591                 /* show "Input" */
592                 [o_tab_pageHolder selectTabViewItemAtIndex:1];
593         }
594         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Input"])
595         {
596                 /* show "Hello" */
597                 [o_tab_pageHolder selectTabViewItemAtIndex:0];
598                 /* disable backwards-btn */
599                 [o_btn_backward setEnabled:NO];
600         }
601 }
602
603 - (IBAction)t1_mrInfo_streaming:(id)sender
604 {
605     /* show a sheet for the help */
606         /* since NSAlert does not exist on OSX < 10.3, we use our own implementation */
607         [o_wh_txt_title setStringValue: _NS("Stream to network")];
608         [o_wh_txt_text setStringValue: _NS("Use this to stream on a network.")];
609         [NSApp beginSheet: o_wizardhelp_window
610             modalForWindow: o_wizard_window
611             modalDelegate: o_wizardhelp_window
612             didEndSelector: nil
613             contextInfo: nil];
614 }
615
616 - (IBAction)t1_mrInfo_transcode:(id)sender
617 {
618     /* show a sheet for the help */
619         [o_wh_txt_title setStringValue: _NS("Transcode/Save to file")];
620         [o_wh_txt_text setStringValue: _NS("Use this to save a stream to a file. You "\
621                 "have the possibility to reencode the stream. You can save whatever "\
622                 "VLC can read.\nPlease notice that VLC is not very suited " \
623                 "for file to file transcoding. You should use its transcoding " \
624         "features to save network streams, for example.")];
625         [NSApp beginSheet: o_wizardhelp_window
626             modalForWindow: o_wizard_window
627             modalDelegate: o_wizardhelp_window
628             didEndSelector: nil
629             contextInfo: nil];
630 }
631
632 - (IBAction)t2_addNewStream:(id)sender
633 {
634     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
635     SEL sel = @selector(t2_getNewStreamFromDialog:returnCode:contextInfo:);
636     [openPanel beginSheetForDirectory:nil file:nil types:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
637 }
638
639 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
640 {
641     if (returnCode == NSOKButton)
642     {
643         [o_t2_fld_pathToNewStrm setStringValue:[sheet filename]];
644         /* FIXME: store path in a global variable */
645     }
646 }
647
648 - (IBAction)t2_chooseStreamOrPlst:(id)sender
649 {
650     /* enable and disable the respective items depending on user's choice */
651     NSString *o_mode;
652     o_mode = [[o_t2_matrix_inputSourceType selectedCell] title];
653         
654         if( [o_mode isEqualToString: _NS("Select a stream")] )
655     {
656                 [o_t2_btn_chooseFile setEnabled:YES];
657                 [o_t2_fld_pathToNewStrm setEnabled:YES];
658                 [o_t2_tbl_plst setEnabled:NO];
659         } else {
660                 [o_t2_btn_chooseFile setEnabled:NO];
661                 [o_t2_fld_pathToNewStrm setEnabled:NO];
662                 [o_t2_tbl_plst setEnabled:YES];
663         }
664 }
665
666 - (IBAction)t2_enableExtract:(id)sender
667 {
668     /* enable/disable the respective items */
669     if([o_t2_ckb_enblPartExtrct state] == NSOnState)
670     {
671         [o_t2_fld_prtExtrctFrom setEnabled:YES];
672         [o_t2_fld_prtExtrctTo setEnabled:YES];
673     } else {
674         [o_t2_fld_prtExtrctFrom setEnabled:NO];
675         [o_t2_fld_prtExtrctTo setEnabled:NO];
676                 [o_t2_fld_prtExtrctFrom setStringValue:@""];
677                 [o_t2_fld_prtExtrctTo setStringValue:@""];
678     }
679 }
680
681 - (IBAction)t3_addressEntered:(id)sender
682 {
683     /* check whether the entered address is valid */
684 }
685
686 - (IBAction)t4_AudCdcChanged:(id)sender
687 {
688     /* update codec info */
689         [o_t4_txt_hintAudio setStringValue:[[o_audioCodecs objectAtIndex:[o_t4_pop_audioCodec indexOfSelectedItem]] objectAtIndex:2]];
690 }
691
692 - (IBAction)t4_enblAudTrnscd:(id)sender
693 {
694     /* enable/disable the respective items */
695     if([o_t4_ckb_audio state] == NSOnState)
696     {
697         [o_t4_pop_audioCodec setEnabled:YES];
698         [o_t4_pop_audioBitrate setEnabled:YES];
699                 [o_t4_txt_hintAudio setStringValue: _NS("Select your audio codec. "\
700                 "Click one to get more information.")];
701     } else {
702         [o_t4_pop_audioCodec setEnabled:NO];
703         [o_t4_pop_audioBitrate setEnabled:NO];
704                 [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio " \
705                 "and you want to transcode it, enable this.")];
706     }
707 }
708
709 - (IBAction)t4_enblVidTrnscd:(id)sender
710 {
711     /* enable/disable the respective items */
712     if([o_t4_ckb_video state] == NSOnState)
713     {
714         [o_t4_pop_videoCodec setEnabled:YES];
715         [o_t4_pop_videoBitrate setEnabled:YES];
716                 [o_t4_txt_hintVideo setStringValue: _NS("Select your video codec. "\
717                 "Click one to get more information.")];
718     } else {
719         [o_t4_pop_videoCodec setEnabled:NO];
720         [o_t4_pop_videoBitrate setEnabled:NO];
721                 [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video " \
722                 "and you want to transcode it, enable this.")];
723     }
724 }
725
726 - (IBAction)t4_VidCdcChanged:(id)sender
727 {
728     /* update codec info */
729         [o_t4_txt_hintVideo setStringValue:[[o_videoCodecs objectAtIndex:[o_t4_pop_videoCodec indexOfSelectedItem]] objectAtIndex:2]];
730 }
731
732 - (IBAction)t6_enblSapAnnce:(id)sender
733 {
734     /* enable/disable input fld */
735     if([o_t6_ckb_sap state] == NSOnState)
736     {
737         [o_t6_fld_sap setEnabled:YES];
738     } else {
739         [o_t6_fld_sap setEnabled:NO];
740         [o_t6_fld_sap setStringValue:@""];
741     }
742 }
743
744 - (IBAction)t6_mrInfo_ttl:(id)sender
745 {
746     /* show a sheet for the help */
747         [o_wh_txt_title setStringValue: _NS("Time-To-Live (TTL)")];
748         [o_wh_txt_text setStringValue: _NS("Define the TTL (Time-To-Live) of the stream. "\
749                         "This parameter is the maximum number of routers your stream can go "
750                         "through. If you don't know what it means, or if you want to stream on " \
751                         "your local network only, leave this setting to 1.")];
752         [NSApp beginSheet: o_wizardhelp_window
753             modalForWindow: o_wizard_window
754             modalDelegate: o_wizardhelp_window
755             didEndSelector: nil
756             contextInfo: nil];
757 }
758
759 - (IBAction)t6_mrInfo_sap:(id)sender
760 {
761     /* show a sheet for the help */
762         [o_wh_txt_title setStringValue: _NS("SAP Announce")];
763         [o_wh_txt_text setStringValue: _NS("When streaming using UDP, you can " \
764                 "announce your streams using the SAP/SDP announcing protocol. This " \
765                 "way, the clients won't have to type in the multicast address, it " \
766                 "will appear in their playlist if they enable the SAP extra interface.\n" \
767                 "If you want to give a name to your stream, enter it here, " \
768                 "else, a default name will be used.")];
769         [NSApp beginSheet: o_wizardhelp_window
770             modalForWindow: o_wizard_window
771             modalDelegate: o_wizardhelp_window
772             didEndSelector: nil
773             contextInfo: nil];
774 }
775
776 - (IBAction)t7_selectTrnscdDestFile:(id)sender
777 {
778     /* provide a save-to-dialogue, so the user can choose a location for his/her new file */
779     NSSavePanel * savePanel = [NSSavePanel savePanel];
780     SEL sel = @selector(t7_getTrnscdDestFile:returnCode:contextInfo:);
781     [savePanel beginSheetForDirectory:nil file:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
782     /* FIXME: insert a suffix in file depending on the chosen encap-format instead of providing file:nil */
783 }
784
785 - (void)t7_getTrnscdDestFile: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
786 {
787     if (returnCode == NSOKButton)
788     {
789         [o_t7_fld_filePath setStringValue:[sheet filename]];
790         /* FIXME: add a suffix depending on the chosen encap-format, if needed */
791     }
792 }
793
794 - (IBAction)wh_closeSheet:(id)sender
795 {
796         /* close the help sheet */
797         [NSApp endSheet:o_wizardhelp_window];
798         [o_wizardhelp_window close];
799 }
800
801 - (void)dealloc
802 {
803         [o_userSelections release];
804         [o_videoCodecs release];
805         [o_audioCodecs release];
806         [super dealloc];
807 }
808
809 @end