]> git.sesse.net Git - vlc/blob - modules/gui/macosx/wizard.m
* implemented 3 dialogues, which complain to the user, if s/he didn't provide a file...
[vlc] / modules / gui / macosx / wizard.m
1 /*****************************************************************************
2  * wizard.m: MacOS X Streaming Wizard
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
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 partially 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     - l10n string fixes (both in OSX and WX)
33         - fill the playlist-table on t2
34         - implement l10n on t8?
35         - see FIXME's
36 */
37
38  
39 /*****************************************************************************
40  * Preamble
41  *****************************************************************************/ 
42 #import "wizard.h"
43 #import "intf.h"
44
45
46 /*****************************************************************************
47  * VLCWizard implementation
48  *****************************************************************************/
49
50 @implementation VLCWizard
51
52 static VLCWizard *_o_sharedInstance = nil;
53
54 + (VLCWizard *)sharedInstance
55 {
56     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
57 }
58
59 - (id)init 
60 {
61     if (_o_sharedInstance) {
62         [self dealloc];
63     } else {
64         _o_sharedInstance = [super init];
65     }
66     
67     return _o_sharedInstance;
68 }
69
70 - (void)awakeFromNib
71 {
72     /* some minor cleanup */
73     [o_t2_tbl_plst setEnabled:NO];
74         [o_wizardhelp_window setExcludedFromWindowsMenu:YES];
75         o_userSelections = [[NSMutableDictionary alloc] init];
76         [o_btn_backward setEnabled:NO];
77
78     /* add audio-bitrates for transcoding */
79     NSArray * audioBitratesArray;
80     audioBitratesArray = [NSArray arrayWithObjects: @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
81     [o_t4_pop_audioBitrate removeAllItems];
82     [o_t4_pop_audioBitrate addItemsWithTitles: audioBitratesArray];
83     [o_t4_pop_audioBitrate selectItemWithTitle: @"192"];
84     
85     /* add video-bitrates for transcoding */
86     NSArray * videoBitratesArray;
87     videoBitratesArray = [NSArray arrayWithObjects: @"3072", @"2048", @"1024", @"768", @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
88     [o_t4_pop_videoBitrate removeAllItems];
89     [o_t4_pop_videoBitrate addItemsWithTitles: videoBitratesArray];
90     [o_t4_pop_videoBitrate selectItemWithTitle: @"1024"];
91     
92         /* fill 2 global arrays with arrays containing all codec-related information
93          * - one array per codec named by its short name to define the encap-compability, 
94          *       cmd-names, real names, more info in the order: realName, shortName, 
95          *       moreInfo, encaps */
96         NSArray * o_mp1v;
97         NSArray * o_mp2v;
98         NSArray * o_mp4v;
99         NSArray * o_div1;
100         NSArray * o_div2;
101         NSArray * o_div3;
102         NSArray * o_h263;
103         NSArray * o_h264;
104         NSArray * o_wmv1;
105         NSArray * o_wmv2;
106         NSArray * o_mjpg;
107         NSArray * o_theo;
108         NSArray * o_dummyVid;
109         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];
110         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];
111         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];
112         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];
113         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];
114         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];
115         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];
116         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];
117         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];
118         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];
119         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];
120         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];
121         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];
122         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];
123         [o_t4_pop_videoCodec removeAllItems];
124         unsigned int x;
125         x = 0;
126         while (x != [o_videoCodecs count])
127         {
128                 [o_t4_pop_videoCodec addItemWithTitle:[[o_videoCodecs objectAtIndex:x] objectAtIndex:0]];
129                 x = (x + 1);
130         }
131         
132         NSArray * o_mpga;
133         NSArray * o_mp3;
134         NSArray * o_mp4a;
135         NSArray * o_a52;
136         NSArray * o_vorb;
137         NSArray * o_flac;
138         NSArray * o_spx;
139         NSArray * o_s16l;
140         NSArray * o_fl32;
141         NSArray * o_dummyAud;
142         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];
143         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];
144         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];
145         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];
146         o_vorb = [NSArray arrayWithObjects: @"Vorbis", @"vorb", _NS("Vorbis is a free audio codec"), @"MUX_OGG", @"-1",  @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
147         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];
148         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];
149         o_s16l = [NSArray arrayWithObjects: @"Uncompressed, integer", @"s16l", _NS("Uncompressed audio samples"), @"MUX_WAV", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
150         o_fl32 = [NSArray arrayWithObjects: @"Uncompressed, floating", @"fl32", _NS("Uncompressed audio samples"), @"MUX_WAV", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
151         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];
152         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];
153         [o_t4_pop_audioCodec removeAllItems];
154         x = 0;
155         while (x != [o_audioCodecs count])
156         {
157                 [o_t4_pop_audioCodec addItemWithTitle:[[o_audioCodecs objectAtIndex:x] objectAtIndex:0]];
158                 x = (x + 1);
159         }
160 }
161
162 - (void)showWizard
163 {
164     /* just present the window to the user */
165     [o_tab_pageHolder selectFirstTabViewItem:self];
166     
167         [self resetWizard];
168         
169     [o_wizard_window center];
170     [o_wizard_window displayIfNeeded];
171     [o_wizard_window makeKeyAndOrderFront:nil];
172 }
173
174 - (void)resetWizard
175 {
176         /* reset the wizard-window to its default values */
177         
178         [o_userSelections removeAllObjects];
179         [o_t1_matrix_strmgOrTrnscd selectCellAtRow:0 column:0];
180         [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setState: NSOffState];
181         [o_btn_forward setTitle: [_NS("Next") stringByAppendingString:@" >"]];
182         
183         /* "Input" */
184         [o_t2_fld_pathToNewStrm setStringValue: @""];
185         [o_t2_ckb_enblPartExtrct setState: NSOffState];
186         [self t2_enableExtract:nil];
187         [o_t2_matrix_inputSourceType selectCellAtRow:0 column:0];
188         [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setState: NSOffState];
189         /* FIXME: we need to refresh the playlist-table as well */
190         [o_t2_tbl_plst setEnabled:NO];
191         [o_t2_fld_pathToNewStrm setEnabled:YES];
192         [o_t2_btn_chooseFile setEnabled:YES];
193         
194         /* "Streaming 1" */
195         [o_t3_fld_address setStringValue: @""];
196         [o_t3_matrix_stmgMhd selectCellAtRow:0 column:0];
197         [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setState: NSOffState];
198         [[o_t3_matrix_stmgMhd cellAtRow:1 column:2] setState: NSOffState];
199         
200         /* "Transcode 1" */
201         [o_t4_ckb_audio setState: NSOffState];
202         [o_t4_ckb_video setState: NSOffState];
203         [self t4_enblVidTrnscd:nil];
204         [self t4_enblAudTrnscd:nil];
205         
206         /* "Streaming 2" */
207         [o_t6_fld_ttl setStringValue: @"1"];
208         [o_t6_ckb_sap setState: NSOffState];
209         [self t6_enblSapAnnce:nil];
210         
211         /* "Transcode 2" */
212         [o_t7_fld_filePath setStringValue: @""];
213 }
214
215 - (void)initStrings
216 {
217     /* localise all strings to the users lang */
218     /* method is called from intf.m (in method openWizard) */
219     
220     /* general items */
221     [o_btn_backward setTitle: [@"< " stringByAppendingString: _NS("Back")]];
222     [o_btn_cancel setTitle: _NS("Cancel")];
223     [o_btn_forward setTitle: [_NS("Next") stringByAppendingString:@" >"]];
224     [o_wizard_window setTitle: _NS("Streaming/Transcoding Wizard")];
225     
226     /* page one ("Hello") */
227     [o_t1_txt_title setStringValue: _NS("Streaming/Transcoding Wizard")];
228     [o_t1_txt_text setStringValue: _NS("This wizard helps you to stream, transcode or save a stream")];
229     [o_t1_btn_mrInfo_strmg setTitle: _NS("More Info")];
230     [o_t1_btn_mrInfo_trnscd setTitle: _NS("More Info")];
231     [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")];
232         [[o_t1_matrix_strmgOrTrnscd cellAtRow:0 column:0] setTitle: _NS("Stream to network")];
233     [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setTitle: _NS("Transcode/Save to file")];
234     
235     /* page two ("Input") */
236     [o_t2_title setStringValue: _NS("Choose input")];
237     [o_t2_text setStringValue: _NS("Choose here your input stream")];
238     [[o_t2_matrix_inputSourceType cellAtRow:0 column:0] setTitle: _NS("Select a stream")];
239     [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setTitle: _NS("Existing playlist item")];
240     [o_t2_btn_chooseFile setTitle: _NS("Choose...")];
241     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"name"] headerCell] setStringValue: _NS("Name")];
242     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"uri"] headerCell] setStringValue: _NS("URI")];
243     [o_t2_box_prtExtrct setTitle: _NS("Partial Extract")];
244     [o_t2_ckb_enblPartExtrct setTitle: _NS("Enable")];
245     [o_t2_txt_prtExtrctFrom setStringValue: _NS("From")];
246     [o_t2_txt_prtExtrctTo setStringValue: _NS("To")];
247     
248     /* page three ("Streaming 1") */
249     [o_t3_txt_title setStringValue: _NS("Streaming")];
250     [o_t3_txt_text setStringValue: _NS("In this page, you will select how your input stream will be sent.")];
251     [o_t3_box_dest setTitle: _NS("Destination")];
252     [o_t3_box_strmgMthd setTitle: _NS("Streaming method")];
253     [o_t3_txt_destInfo setStringValue: _NS("Enter the address of the computer to stream to")];
254     [[o_t3_matrix_stmgMhd cellAtRow:1 column:0] setTitle: _NS("UDP Unicast")];
255     [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setTitle: _NS("UDP Multicast")];
256     
257     /* page four ("Transcode 1") */
258     [o_t4_title setStringValue: _NS("Transcode")];
259     [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).")];
260     [o_t4_box_audio setTitle: _NS("Audio")];
261     [o_t4_box_video setTitle: _NS("Video")];
262     [o_t4_ckb_audio setTitle: _NS("Transcode audio")];
263     [o_t4_ckb_video setTitle: _NS("Transcode video")];
264     [o_t4_txt_videoBitrate setStringValue: _NS("Bitrate (kb/s)")];
265     [o_t4_txt_videoCodec setStringValue: _NS("Codec")];
266     [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio and you want to " \
267                          "transcode it, enable this")];
268     [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video and you want to " \
269                          "transcode it, enable this")];
270     
271     /* page five ("Encap") */
272     [o_t5_title setStringValue: _NS("Encapsulation format")];
273     [o_t5_text setStringValue: _NS("In this page, you will select how the stream will be "\
274                      "encapsulated. Depending on the choices you made, all "\
275                      "formats won't be available.")];
276     
277     /* page six ("Streaming 2") */
278     [o_t6_title setStringValue: _NS("Additional streaming options")];
279     [o_t6_text setStringValue: _NS("In this page, you will define a few " \
280                               "additional parameters for your stream.")];
281     [o_t6_txt_ttl setStringValue: _NS("Time-To-Live (TTL)")];
282     [o_t6_btn_mrInfo_ttl setTitle: _NS("More Info")];
283     [o_t6_ckb_sap setTitle: _NS("SAP Announce")];
284     [o_t6_btn_mrInfo_sap setTitle: _NS("More Info")];
285      
286     /* page seven ("Transcode 2") */
287     [o_t7_title setStringValue: _NS("Additional transcode options")];
288     [o_t7_text setStringValue: _NS("In this page, you will define a few " \
289                               "additionnal parameters for your transcoding.")];
290     [o_t7_txt_saveFileTo setStringValue: _NS("Select the file to save to")];
291     [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
292         
293         /* page eight ("Summary") */
294         /* FIXME: currently not implemented as it unsure whether we show this tab
295          * to the public or use it for debugging only */
296         
297         /* wizard help window */
298         [o_wh_btn_okay setTitle: _NS("OK")];
299 }
300
301 - (IBAction)cancelRun:(id)sender
302 {
303     [o_wizard_window close];
304 }
305
306 - (IBAction)nextTab:(id)sender
307 {
308         if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Hello"])
309         {
310                 /* check whether the user wants to stream or just to transcode;
311                  * store information for later usage */
312                 NSString *o_mode;
313                 o_mode = [[o_t1_matrix_strmgOrTrnscd selectedCell] title];
314                 if( [o_mode isEqualToString: _NS("Stream to network")] )
315                 {
316                         [o_userSelections setObject:@"strmg" forKey:@"trnscdOrStrmg"];
317                 }else{
318                         [o_userSelections setObject:@"trnscd" forKey:@"trnscdOrStrmg"];
319                 }
320                 [o_btn_backward setEnabled:YES];
321                 [o_tab_pageHolder selectTabViewItemAtIndex:1];
322         }
323         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Input"])
324         {
325                 /* check whether partialExtract is enabled and store the values, if needed */
326                 if ([o_t2_ckb_enblPartExtrct state] == NSOnState)
327                 {
328                         [o_userSelections setObject:@"YES" forKey:@"partExtract"];
329                         [o_userSelections setObject:[o_t2_fld_prtExtrctFrom stringValue] forKey:@"partExtractFrom"];
330                         [o_userSelections setObject:[o_t2_fld_prtExtrctTo stringValue] forKey:@"partExtractTo"];
331                 }else{
332                         [o_userSelections setObject:@"NO" forKey:@"partExtract"];
333                 }
334                 
335                 /* check whether we use an existing pl-item or add an new one;
336                  * store the path or the index and set a flag.
337                  * complain to the user if s/he didn't provide a path */
338                 NSString *o_mode;
339                 BOOL stop;
340                 stop = NO;
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                 /* set a flag that no file is selected */
348                                 stop = YES;
349                         }else{
350                                 [o_userSelections setObject:[o_t2_fld_pathToNewStrm stringValue] forKey:@"pathToNewStrm"];
351                         }
352                 }else{
353                         if ([o_t2_tbl_plst selectedRow] != -1)
354                         {
355                                 [o_userSelections setObject:@"NO" forKey:@"newStrm"];
356                                 NSNumber * myNumber = [[NSNumber alloc] initWithInt:[o_t2_tbl_plst selectedRow]];
357                                 [o_userSelections setObject:myNumber forKey:@"plItemIndex"];
358             } else {
359                 /* set a flag that no item is selected */
360                 stop = YES;
361                         }
362                 }
363                 
364                 /* show either "Streaming 1" or "Transcode 1" to the user */
365                 if (stop == NO)
366                 {
367             if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
368             {
369                 /* we are streaming */
370                 [o_tab_pageHolder selectTabViewItemAtIndex:2];
371             }else{
372                 /* we are just transcoding */
373                 [o_tab_pageHolder selectTabViewItemAtIndex:3];
374             }
375         } else {
376             /* show a sheet that the user didn't select a file */
377                         [o_wh_txt_title setStringValue: _NS("No input selected")];
378                         [o_wh_txt_text setStringValue: _NS("You selected neither " \
379                                 "a new stream nor an existing playlist item. VLC is unable to " \
380                                 "guess, which input you want use. \n\n Choose one " \
381                                 "before going to the next page.")];
382                         [NSApp beginSheet: o_wizardhelp_window
383                                 modalForWindow: o_wizard_window
384                                 modalDelegate: o_wizardhelp_window
385                                 didEndSelector: nil
386                                 contextInfo: nil];
387         }
388         }
389         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 1"])
390         {
391                 /* check which streaming method is selected and store it */
392                 NSString *o_mode;
393                 o_mode = [[o_t3_matrix_stmgMhd selectedCell] title];
394                 if( [o_mode isEqualToString: _NS("HTTP")] )
395                 {
396                         [o_userSelections setObject:@"HTTP" forKey:@"stmgMhd"];
397                         /* enable MPEG PS, MPEG TS, MPEG 1, OGG, RAW and ASF; select MPEG PS */
398                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
399                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
400                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
401                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
402                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
403                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
404                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
405                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
406                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
407                         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
408                         [o_t5_matrix_encap selectCellAtRow:0 column:0];
409                 } else {
410                         if( [o_mode isEqualToString: _NS("UDP Unicast")] )
411                         {
412                                 [o_userSelections setObject:@"UDP-Unicast" forKey:@"stmgMhd"];
413                         } else {
414                                 [o_userSelections setObject:@"UDP-Multicast" forKey:@"stmgMhd"];
415                         }
416                         /* disable all encap-formats but MPEG-TS and select it */
417                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
418                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
419                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
420                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
421                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
422                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
423                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
424                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
425                         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
426                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
427                         [o_t5_matrix_encap selectCellAtRow:1 column:0];
428                 }
429                 
430                 /* store the destination and check whether is it empty */
431                 if( [[o_t3_fld_address stringValue] isEqualToString: @""] )
432                 {       /* complain to the user that "" is no valid dest. */
433                         [o_wh_txt_title setStringValue: _NS("No valid destination")];
434                         [o_wh_txt_text setStringValue: _NS("You need to enter " \
435                         "a valid destination you want to stream to. Enter either a " \
436                         "fixed Unicast-IP or a Multicast-IP.\n\n If you don't know "
437                         "what this means, have a look at the VLC Streaming HOWTO." )];
438                         [NSApp beginSheet: o_wizardhelp_window
439                                 modalForWindow: o_wizard_window
440                                 modalDelegate: o_wizardhelp_window
441                                 didEndSelector: nil
442                                 contextInfo: nil];
443                 } else {
444                         [o_userSelections setObject:[o_t3_fld_address stringValue] forKey:@"stmgDest"];
445                         /* let's go to the encap-tab */
446                         [o_tab_pageHolder selectTabViewItemAtIndex:4];
447                 }
448         }
449         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 1"])
450         {
451                 /* check whether the user wants to transcode the video-track and store the related options */
452                 if ([o_t4_ckb_video state] == NSOnState)
453                 {
454                         NSNumber * theNum;
455                         theNum = [NSNumber numberWithInt:[o_t4_pop_videoCodec indexOfSelectedItem]];
456                         [o_userSelections setObject:@"YES" forKey:@"trnscdVideo"];
457                         [o_userSelections setObject:[o_t4_pop_videoBitrate titleOfSelectedItem] forKey:@"trnscdVideoBitrate"];
458                         [o_userSelections setObject:theNum forKey:@"trnscdVideoCodec"];
459                 } else {
460                         [o_userSelections setObject:@"NO" forKey:@"trnscdVideo"];
461                 }
462                 
463                 /* check whether the user wants to transcode the audio-track and store the related options */
464                 if ([o_t4_ckb_audio state] == NSOnState)
465                 {
466                         NSNumber * theNum;
467                         theNum = [NSNumber numberWithInt:[o_t4_pop_audioCodec indexOfSelectedItem]];
468                         [o_userSelections setObject:@"YES" forKey:@"trnscdAudio"];
469                         [o_userSelections setObject:[o_t4_pop_audioBitrate titleOfSelectedItem] forKey:@"trnscdAudioBitrate"];
470                         [o_userSelections setObject:theNum forKey:@"trnscdAudioCodec"];
471                 } else {
472                         [o_userSelections setObject:@"NO" forKey:@"trnscdAudio"];
473                 }
474                 
475                 /* disable all encap-formats */
476                 [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
477                 [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:NO];
478                 [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
479                 [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
480                 [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
481                 [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
482                 [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
483                 [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
484                 [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
485                 [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
486                 
487                 /* re-enable the encap-formats supported by the chosen codecs */
488                 /* FIXME: the following is a really bad coding-style. feel free to write 
489                         me ideas how to make this nicer, if you want to -- FK, 7/11/05 */
490                 
491                 if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualTo: @"YES"])
492                 {
493                         if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualTo: @"YES"])
494                         {
495                                 /* we are transcoding both audio and video, so we need to check both deps */
496                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_PS"])
497                                 {
498                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_PS"])
499                                         {
500                                                 [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
501                                                 [o_t5_matrix_encap selectCellAtRow:0 column:0];
502                                         }
503                                 }
504                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_TS"])
505                                 {
506                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_TS"])
507                                         {
508                                                 [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
509                                                 [o_t5_matrix_encap selectCellAtRow:1 column:0];
510                                         }
511                                 }
512                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MPEG"])
513                                 {
514                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MPEG"])
515                                         {
516                                                 [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
517                                                 [o_t5_matrix_encap selectCellAtRow:2 column:0];
518                                         }
519                                 }
520                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_OGG"])
521                                 {
522                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_OGG"])
523                                         {
524                                                 [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
525                                                 [o_t5_matrix_encap selectCellAtRow:3 column:0];
526                                         }
527                                 }
528                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_RAW"])
529                                 {
530                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_RAW"])
531                                         {
532                                                 [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
533                                                 [o_t5_matrix_encap selectCellAtRow:4 column:0];
534                                         }
535                                 }
536                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_ASF"])
537                                 {
538                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_ASF"])
539                                         {
540                                                 [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
541                                                 [o_t5_matrix_encap selectCellAtRow:5 column:0];
542                                         }
543                                 }
544                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_AVI"])
545                                 {
546                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_AVI"])
547                                         {
548                                                 [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
549                                                 [o_t5_matrix_encap selectCellAtRow:6 column:0];
550                                         }
551                                 }
552                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MP4"])
553                                 {
554                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MP4"])
555                                         {
556                                                 [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
557                                                 [o_t5_matrix_encap selectCellAtRow:7 column:0];
558                                         }
559                                 }
560                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MOV"])
561                                 {
562                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MOV"])
563                                         {
564                                                 [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
565                                                 [o_t5_matrix_encap selectCellAtRow:8 column:0];
566                                         }
567                                 }
568                                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_WAV"])
569                                 {
570                                         if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_WAV"])
571                                         {
572                                                 [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
573                                                 [o_t5_matrix_encap selectCellAtRow:9 column:0];
574                                         }
575                                 }
576                                 
577                         } else {
578                                 
579                                 /* we just transcoding the audio */
580                                 
581                                 /* select formats supported by the audio codec */
582                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_PS"])
583                                 {
584                                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
585                                         [o_t5_matrix_encap selectCellAtRow:0 column:0];
586                                 }
587                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_TS"])
588                                 {
589                                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
590                                         [o_t5_matrix_encap selectCellAtRow:1 column:0];
591                                 }
592                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MPEG"])
593                                 {
594                                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
595                                         [o_t5_matrix_encap selectCellAtRow:2 column:0];
596                                 }
597                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_OGG"])
598                                 {
599                                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
600                                         [o_t5_matrix_encap selectCellAtRow:3 column:0];
601                                 }
602                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_RAW"])
603                                 {
604                                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
605                                         [o_t5_matrix_encap selectCellAtRow:4 column:0];
606                                 }
607                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_ASF"])
608                                 {
609                                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
610                                         [o_t5_matrix_encap selectCellAtRow:5 column:0];
611                                 }
612                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_AVI"])
613                                 {
614                                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
615                                         [o_t5_matrix_encap selectCellAtRow:6 column:0];
616                                 }
617                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MP4"])
618                                 {
619                                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
620                                         [o_t5_matrix_encap selectCellAtRow:7 column:0];
621                                 }
622                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MOV"])
623                                 {
624                                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
625                                         [o_t5_matrix_encap selectCellAtRow:8 column:0];
626                                 }
627                                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_WAV"])
628                                 {
629                                         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
630                                         [o_t5_matrix_encap selectCellAtRow:9 column:0];
631                                 }
632                         }
633                 }
634                 else if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualTo: @"YES"])
635                 {
636                         /* we are just transcoding the video */
637                         
638                         /* select formats supported by the video-codec */ 
639                 
640                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_PS"])
641                         {
642                                 [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
643                                 [o_t5_matrix_encap selectCellAtRow:0 column:0];
644                         }
645                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_TS"])
646                         {
647                                 [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
648                                 [o_t5_matrix_encap selectCellAtRow:1 column:0];
649                         }
650                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MPEG"])
651                         {
652                                 [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
653                                 [o_t5_matrix_encap selectCellAtRow:2 column:0];
654                         }
655                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_OGG"])
656                         {
657                                 [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
658                                 [o_t5_matrix_encap selectCellAtRow:3 column:0];
659                         }
660                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_RAW"])
661                         {
662                                 [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
663                                 [o_t5_matrix_encap selectCellAtRow:4 column:0];
664                         }
665                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_ASF"])
666                         {
667                                 [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
668                                 [o_t5_matrix_encap selectCellAtRow:5 column:0];
669                         }
670                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_AVI"])
671                         {
672                                 [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
673                                 [o_t5_matrix_encap selectCellAtRow:6 column:0];
674                         }
675                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MP4"])
676                         {
677                                 [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
678                                 [o_t5_matrix_encap selectCellAtRow:7 column:0];
679                         }
680                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MOV"])
681                         {
682                                 [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
683                                 [o_t5_matrix_encap selectCellAtRow:8 column:0];
684                         }
685                         if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_WAV"])
686                         {
687                                 [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
688                                 [o_t5_matrix_encap selectCellAtRow:9 column:0];
689                         }
690                 } else {
691                         /* we don't do any transcoding 
692                          * -> enabled the encap-formats allowed when streaming content via http
693                          * since this should work fine in most cases */
694                         /* FIXME: choose a selection of encap-formats based upon the actually used codecs */
695                                                 
696                         /* enable MPEG PS, MPEG TS, MPEG 1, OGG, RAW and ASF; select MPEG PS */
697                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
698                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
699                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
700                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
701                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
702                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
703                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
704                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
705                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
706                         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
707                         [o_t5_matrix_encap selectCellAtRow:0 column:0];
708                 }
709                 int x;
710                 BOOL anythingEnabled;
711                 x = 0;
712                 anythingEnabled = NO;
713                 while (x != [o_t5_matrix_encap numberOfRows])
714                 {
715                         if ([[o_t5_matrix_encap cellAtRow:x column:0] isEnabled])
716                         {       
717                                 anythingEnabled = YES;
718                         }       
719                         x = (x + 1);
720                 }
721                 if (anythingEnabled == YES)
722                 {
723                 [o_tab_pageHolder selectTabViewItemAtIndex:4];
724                 } else {
725                     /* show a sheet that the selected codecs are not compatible */
726                         [o_wh_txt_title setStringValue: _NS("Invalid selection")];
727                         [o_wh_txt_text setStringValue: _NS("Your chosen codecs are " \
728                                 "not compatible with each other. For example: you cannot " \
729                                 "mix uncompressed audio with any video codec.\n\n" \
730                                 "Correct your selection and try again.")];
731                         [NSApp beginSheet: o_wizardhelp_window
732                                 modalForWindow: o_wizard_window
733                                 modalDelegate: o_wizardhelp_window
734                                 didEndSelector: nil
735                                 contextInfo: nil];
736                 }
737                 
738         }
739         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Encap"])
740         {
741                 /* get the chosen encap format and store it */
742                 [o_userSelections setObject:[[o_t5_matrix_encap selectedCell] title] forKey:@"encapFormat"];
743                 
744                 /* show either "Streaming 2" or "Transcode 2" to the user */
745                 if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
746                 {
747                         /* we are streaming */
748                         [o_tab_pageHolder selectTabViewItemAtIndex:5];
749                 }else{
750                         /* we are just transcoding */
751                         [o_tab_pageHolder selectTabViewItemAtIndex:6];
752                 }
753         }
754         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 2"])
755         {
756                 /* store the chosen TTL */
757                 [o_userSelections setObject:[o_t6_fld_ttl stringValue] forKey:@"ttl"];
758                 
759                 /* check whether SAP is enabled and store the announce, if needed */
760                 if ([o_t6_ckb_sap state] == NSOnState)
761                 {
762                         [o_userSelections setObject:@"YES" forKey:@"sap"];
763                         [o_userSelections setObject:[o_t6_fld_sap stringValue] forKey:@"sapText"];
764                 } else {
765                         [o_userSelections setObject:@"NO" forKey:@"sap"];
766                 }
767                 
768                 /* go to "Summary" */
769                 [self showSummary];
770         }
771         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 2"])
772         {
773                 /* check whether the path != "" and store it */
774                 if( [[o_t7_fld_filePath stringValue] isEqualToString: @""] )
775                 {       /* complain to the user that "" is no valid path */
776                         [o_wh_txt_title setStringValue: _NS("No file selected")];
777                         [o_wh_txt_text setStringValue: _NS("You you need to select " \
778                         "a file, you want to save to. \n\n Enter either a valid path or " \
779                         "choose a location through the button's dialog-box.")];
780                         [NSApp beginSheet: o_wizardhelp_window
781                                 modalForWindow: o_wizard_window
782                                 modalDelegate: o_wizardhelp_window
783                                 didEndSelector: nil
784                                 contextInfo: nil];
785                 } else {
786                         [o_userSelections setObject:[o_t7_fld_filePath stringValue] forKey:@"trnscdFilePath"];
787                         
788                         /* go to "Summary" */
789                         [self showSummary];
790                 }
791         }
792 }
793
794 - (void)showSummary
795 {
796         [o_btn_forward setTitle: _NS("Finish")];
797         if ([[o_userSelections objectForKey:@"newStrm"] isEqualToString: @"YES"])
798         {
799                 [o_t8_fld_inptStream setStringValue:[o_userSelections objectForKey:@"pathToNewStrm"]];
800         } else {
801                 [o_t8_fld_inptStream setStringValue:[[o_userSelections objectForKey:@"plItemIndex"] stringValue]];
802         }
803         if ([[o_userSelections objectForKey:@"partExtract"] isEqualToString: @"YES"])
804         {
805                 [o_t8_fld_partExtract setStringValue: [[[[[_NS("yes") stringByAppendingString:@" - "] stringByAppendingString: _NS("from ")] stringByAppendingString: [o_userSelections objectForKey:@"partExtractFrom"]] stringByAppendingString: _NS(" to ")] stringByAppendingString: [o_userSelections objectForKey:@"partExtractTo"]]];
806         } else {
807                 [o_t8_fld_partExtract setStringValue: _NS("no")];
808         }
809         
810         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
811         {
812                 /* we are streaming; no transcoding allowed atm */
813                 [o_t8_fld_saveFileTo setStringValue: @"-"];
814                 [o_t8_fld_trnscdAudio setStringValue: @"-"];
815                 [o_t8_fld_trnscdVideo setStringValue: @"-"];
816                 [o_t8_fld_strmgMthd setStringValue: [o_userSelections objectForKey:@"stmgMhd"]];
817                 [o_t8_fld_destination setStringValue: [o_userSelections objectForKey:@"stmgDest"]];
818                 [o_t8_fld_ttl setStringValue: [o_userSelections objectForKey:@"ttl"]];
819                 if ([[o_userSelections objectForKey:@"sap"] isEqualToString: @"YES"])
820                 {
821                         [o_t8_fld_sap setStringValue: [[_NS("yes") stringByAppendingString:@": "] stringByAppendingString:[o_userSelections objectForKey:@"sapText"]]];
822                 }else{
823                         [o_t8_fld_sap setStringValue: _NS("no")];
824                 }
825         } else {
826                 /* we are transcoding */
827                 [o_t8_fld_strmgMthd setStringValue: @"-"];
828                 [o_t8_fld_destination setStringValue: @"-"];
829                 [o_t8_fld_ttl setStringValue: @"-"];
830                 [o_t8_fld_sap setStringValue: @"-"];
831                 if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"YES"])
832                 {
833                         [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"]];
834                 }else{
835                         [o_t8_fld_trnscdVideo setStringValue: _NS("no")];
836                 }
837                 if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
838                 {
839                         [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"]];
840                 }else{
841                         [o_t8_fld_trnscdAudio setStringValue: _NS("no")];
842                 }
843                 [o_t8_fld_saveFileTo setStringValue: [o_userSelections objectForKey:@"trnscdFilePath"]];
844         }
845         [o_t8_fld_encapFormat setStringValue: [o_userSelections objectForKey:@"encapFormat"]];
846         [o_tab_pageHolder selectTabViewItemAtIndex:7];
847 }
848
849 - (IBAction)prevTab:(id)sender
850 {
851     if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Summary"])
852         {       
853                 /* check whether we are streaming or transcoding and go back */
854                 if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
855                 {
856                         /* show "Streaming 2" */
857                         [o_tab_pageHolder selectTabViewItemAtIndex:5];
858                 }else{
859                         /* show "Transcode 2" */
860                         [o_tab_pageHolder selectTabViewItemAtIndex:6];
861                 }
862                 /* rename the forward-button */
863                 [o_btn_forward setTitle: [_NS("Next") stringByAppendingString:@" >"]];
864         }
865         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 2"])
866         {
867                 /* show "Encap" */
868                 [o_tab_pageHolder selectTabViewItemAtIndex:4];
869         }
870         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 2"])
871         {
872                 /* show "Encap" */
873                 [o_tab_pageHolder selectTabViewItemAtIndex:4];
874         }
875         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Encap"])
876         {
877                 /* check whether we are streaming or transcoding and go back */
878                 if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
879                 {
880                         /* show "Streaming 1" */
881                         [o_tab_pageHolder selectTabViewItemAtIndex:2];
882                 }else{
883                         /* show "Transcode 2" */
884                         [o_tab_pageHolder selectTabViewItemAtIndex:3];
885                 }
886         }
887         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Streaming 1"])
888         {
889                 /* show "Input" */
890                 [o_tab_pageHolder selectTabViewItemAtIndex:1];
891         }
892         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Transcode 1"])
893         {
894                 /* show "Input" */
895                 [o_tab_pageHolder selectTabViewItemAtIndex:1];
896         }
897         else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Input"])
898         {
899                 /* show "Hello" */
900                 [o_tab_pageHolder selectTabViewItemAtIndex:0];
901                 /* disable backwards-btn */
902                 [o_btn_backward setEnabled:NO];
903         }
904 }
905
906 - (IBAction)t1_mrInfo_streaming:(id)sender
907 {
908     /* show a sheet for the help */
909         /* since NSAlert does not exist on OSX < 10.3, we use our own implementation */
910         [o_wh_txt_title setStringValue: _NS("Stream to network")];
911         [o_wh_txt_text setStringValue: _NS("Use this to stream on a network.")];
912         [NSApp beginSheet: o_wizardhelp_window
913             modalForWindow: o_wizard_window
914             modalDelegate: o_wizardhelp_window
915             didEndSelector: nil
916             contextInfo: nil];
917 }
918
919 - (IBAction)t1_mrInfo_transcode:(id)sender
920 {
921     /* show a sheet for the help */
922         [o_wh_txt_title setStringValue: _NS("Transcode/Save to file")];
923         [o_wh_txt_text setStringValue: _NS("Use this to save a stream to a file. You "\
924                 "have the possibility to reencode the stream. You can save whatever "\
925                 "VLC can read.\nPlease notice that VLC is not very suited " \
926                 "for file to file transcoding. You should use its transcoding " \
927         "features to save network streams, for example.")];
928         [NSApp beginSheet: o_wizardhelp_window
929             modalForWindow: o_wizard_window
930             modalDelegate: o_wizardhelp_window
931             didEndSelector: nil
932             contextInfo: nil];
933 }
934
935 - (IBAction)t2_addNewStream:(id)sender
936 {
937     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
938     SEL sel = @selector(t2_getNewStreamFromDialog:returnCode:contextInfo:);
939     [openPanel beginSheetForDirectory:nil file:nil types:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
940 }
941
942 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
943 {
944     if (returnCode == NSOKButton)
945     {
946         [o_t2_fld_pathToNewStrm setStringValue:[sheet filename]];
947     }
948 }
949
950 - (IBAction)t2_chooseStreamOrPlst:(id)sender
951 {
952     /* enable and disable the respective items depending on user's choice */
953     NSString *o_mode;
954     o_mode = [[o_t2_matrix_inputSourceType selectedCell] title];
955         
956         if( [o_mode isEqualToString: _NS("Select a stream")] )
957     {
958                 [o_t2_btn_chooseFile setEnabled:YES];
959                 [o_t2_fld_pathToNewStrm setEnabled:YES];
960                 [o_t2_tbl_plst setEnabled:NO];
961         } else {
962                 [o_t2_btn_chooseFile setEnabled:NO];
963                 [o_t2_fld_pathToNewStrm setEnabled:NO];
964                 [o_t2_tbl_plst setEnabled:YES];
965         }
966 }
967
968 - (IBAction)t2_enableExtract:(id)sender
969 {
970     /* enable/disable the respective items */
971     if([o_t2_ckb_enblPartExtrct state] == NSOnState)
972     {
973         [o_t2_fld_prtExtrctFrom setEnabled:YES];
974         [o_t2_fld_prtExtrctTo setEnabled:YES];
975     } else {
976         [o_t2_fld_prtExtrctFrom setEnabled:NO];
977         [o_t2_fld_prtExtrctTo setEnabled:NO];
978                 [o_t2_fld_prtExtrctFrom setStringValue:@""];
979                 [o_t2_fld_prtExtrctTo setStringValue:@""];
980     }
981 }
982
983 - (IBAction)t3_addressEntered:(id)sender
984 {
985     /* check whether the entered address is valid */
986 }
987
988 - (IBAction)t4_AudCdcChanged:(id)sender
989 {
990     /* update codec info */
991         [o_t4_txt_hintAudio setStringValue:[[o_audioCodecs objectAtIndex:[o_t4_pop_audioCodec indexOfSelectedItem]] objectAtIndex:2]];
992 }
993
994 - (IBAction)t4_enblAudTrnscd:(id)sender
995 {
996     /* enable/disable the respective items */
997     if([o_t4_ckb_audio state] == NSOnState)
998     {
999         [o_t4_pop_audioCodec setEnabled:YES];
1000         [o_t4_pop_audioBitrate setEnabled:YES];
1001                 [o_t4_txt_hintAudio setStringValue: _NS("Select your audio codec. "\
1002                 "Click one to get more information.")];
1003     } else {
1004         [o_t4_pop_audioCodec setEnabled:NO];
1005         [o_t4_pop_audioBitrate setEnabled:NO];
1006                 [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio " \
1007                 "and you want to transcode it, enable this.")];
1008     }
1009 }
1010
1011 - (IBAction)t4_enblVidTrnscd:(id)sender
1012 {
1013     /* enable/disable the respective items */
1014     if([o_t4_ckb_video state] == NSOnState)
1015     {
1016         [o_t4_pop_videoCodec setEnabled:YES];
1017         [o_t4_pop_videoBitrate setEnabled:YES];
1018                 [o_t4_txt_hintVideo setStringValue: _NS("Select your video codec. "\
1019                 "Click one to get more information.")];
1020     } else {
1021         [o_t4_pop_videoCodec setEnabled:NO];
1022         [o_t4_pop_videoBitrate setEnabled:NO];
1023                 [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video " \
1024                 "and you want to transcode it, enable this.")];
1025     }
1026 }
1027
1028 - (IBAction)t4_VidCdcChanged:(id)sender
1029 {
1030     /* update codec info */
1031         [o_t4_txt_hintVideo setStringValue:[[o_videoCodecs objectAtIndex:[o_t4_pop_videoCodec indexOfSelectedItem]] objectAtIndex:2]];
1032 }
1033
1034 - (IBAction)t6_enblSapAnnce:(id)sender
1035 {
1036     /* enable/disable input fld */
1037     if([o_t6_ckb_sap state] == NSOnState)
1038     {
1039         [o_t6_fld_sap setEnabled:YES];
1040     } else {
1041         [o_t6_fld_sap setEnabled:NO];
1042         [o_t6_fld_sap setStringValue:@""];
1043     }
1044 }
1045
1046 - (IBAction)t6_mrInfo_ttl:(id)sender
1047 {
1048     /* show a sheet for the help */
1049         [o_wh_txt_title setStringValue: _NS("Time-To-Live (TTL)")];
1050         [o_wh_txt_text setStringValue: _NS("Define the TTL (Time-To-Live) of the stream. "\
1051                         "This parameter is the maximum number of routers your stream can go "
1052                         "through. If you don't know what it means, or if you want to stream on " \
1053                         "your local network only, leave this setting to 1.")];
1054         [NSApp beginSheet: o_wizardhelp_window
1055             modalForWindow: o_wizard_window
1056             modalDelegate: o_wizardhelp_window
1057             didEndSelector: nil
1058             contextInfo: nil];
1059 }
1060
1061 - (IBAction)t6_mrInfo_sap:(id)sender
1062 {
1063     /* show a sheet for the help */
1064         [o_wh_txt_title setStringValue: _NS("SAP Announce")];
1065         [o_wh_txt_text setStringValue: _NS("When streaming using UDP, you can " \
1066                 "announce your streams using the SAP/SDP announcing protocol. This " \
1067                 "way, the clients won't have to type in the multicast address, it " \
1068                 "will appear in their playlist if they enable the SAP extra interface.\n" \
1069                 "If you want to give a name to your stream, enter it here, " \
1070                 "else, a default name will be used.")];
1071         [NSApp beginSheet: o_wizardhelp_window
1072             modalForWindow: o_wizard_window
1073             modalDelegate: o_wizardhelp_window
1074             didEndSelector: nil
1075             contextInfo: nil];
1076 }
1077
1078 - (IBAction)t7_selectTrnscdDestFile:(id)sender
1079 {
1080     /* provide a save-to-dialogue, so the user can choose a location for his/her new file */
1081     NSSavePanel * savePanel = [NSSavePanel savePanel];
1082     SEL sel = @selector(t7_getTrnscdDestFile:returnCode:contextInfo:);
1083     [savePanel beginSheetForDirectory:nil file:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
1084     /* FIXME: insert a suffix in file depending on the chosen encap-format instead of providing file:nil */
1085 }
1086
1087 - (void)t7_getTrnscdDestFile: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
1088 {
1089     if (returnCode == NSOKButton)
1090     {
1091         [o_t7_fld_filePath setStringValue:[sheet filename]];
1092         /* FIXME: add a suffix depending on the chosen encap-format, if needed */
1093     }
1094 }
1095
1096 - (IBAction)wh_closeSheet:(id)sender
1097 {
1098         /* close the help sheet */
1099         [NSApp endSheet:o_wizardhelp_window];
1100         [o_wizardhelp_window close];
1101 }
1102
1103 - (void)dealloc
1104 {
1105         [o_userSelections release];
1106         [o_videoCodecs release];
1107         [o_audioCodecs release];
1108         [super dealloc];
1109 }
1110
1111 @end