]> git.sesse.net Git - vlc/blob - modules/gui/macosx/wizard.m
Fix playlist crasher and simplify a few things
[vlc] / modules / gui / macosx / wizard.m
1 /*****************************************************************************
2  * wizard.m: MacOS X Streaming Wizard
3  *****************************************************************************
4  * Copyright (C) 2005-2006 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24
25 /*****************************************************************************
26  * Note: this code is partially based upon ../wxwidgets/wizard.cpp and
27  *         ../wxwidgets/streamdata.h; both written by Clément Stenac.
28  *****************************************************************************/
29
30
31 /*****************************************************************************
32  * Preamble
33  *****************************************************************************/
34 #import "wizard.h"
35 #import "intf.h"
36 #import "network.h"
37 #import "playlist.h"
38 #import <vlc/intf.h>
39
40 /*****************************************************************************
41  * VLCWizard implementation
42  *****************************************************************************/
43
44 @implementation VLCWizard
45
46 static VLCWizard *_o_sharedInstance = nil;
47
48 + (VLCWizard *)sharedInstance
49 {
50     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
51 }
52
53 - (id)init
54 {
55     if (_o_sharedInstance) {
56         [self dealloc];
57     } else {
58         _o_sharedInstance = [super init];
59     }
60
61     return _o_sharedInstance;
62 }
63
64 - (void)dealloc
65 {
66     [o_userSelections release];
67     [o_videoCodecs release];
68     [o_audioCodecs release];
69     [o_encapFormats release];
70     [super dealloc];
71 }
72
73 - (void)awakeFromNib
74 {
75     /* some minor cleanup */
76     [o_t2_tbl_plst setEnabled:NO];
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", \
83         @"128", @"64", @"32", @"16", nil ];
84     [o_t4_pop_audioBitrate removeAllItems];
85     [o_t4_pop_audioBitrate addItemsWithTitles: audioBitratesArray];
86     [o_t4_pop_audioBitrate selectItemWithTitle: @"192"];
87
88     /* add video-bitrates for transcoding */
89     NSArray * videoBitratesArray;
90     videoBitratesArray = [NSArray arrayWithObjects: @"3072", @"2048", @"1024", \
91         @"768", @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
92     [o_t4_pop_videoBitrate removeAllItems];
93     [o_t4_pop_videoBitrate addItemsWithTitles: videoBitratesArray];
94     [o_t4_pop_videoBitrate selectItemWithTitle: @"1024"];
95
96     /* fill 2 global arrays with arrays containing all codec-related information
97      * - one array per codec named by its short name to define the encap-compability,
98      *     cmd-names, real names, more info in the order: realName, shortName,
99      *     moreInfo, encaps */
100     NSArray * o_mp1v;
101     NSArray * o_mp2v;
102     NSArray * o_mp4v;
103     NSArray * o_div1;
104     NSArray * o_div2;
105     NSArray * o_div3;
106     NSArray * o_h263;
107     NSArray * o_h264;
108     NSArray * o_wmv1;
109     NSArray * o_wmv2;
110     NSArray * o_mjpg;
111     NSArray * o_theo;
112     NSArray * o_dummyVid;
113     o_mp1v = [NSArray arrayWithObjects: @"MPEG-1 Video", @"mp1v", \
114         _NS("MPEG-1 Video codec (usable with MPEG PS, MPEG TS, MPEG1, OGG " \
115         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_OGG", @"MUX_RAW", \
116         @"NO", @"NO", @"NO", @"NO", nil];
117     o_mp2v = [NSArray arrayWithObjects: @"MPEG-2 Video", @"mp2v", \
118         _NS("MPEG-2 Video codec (usable with MPEG PS, MPEG TS, MPEG1, OGG " \
119         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_OGG", @"MUX_RAW", \
120         @"NO", @"NO", @"NO", @"NO", nil];
121     o_mp4v = [NSArray arrayWithObjects: @"MPEG-4 Video", @"mp4v", \
122         _NS("MPEG-4 Video codec (useable with MPEG PS, MPEG TS, MPEG1, ASF, " \
123         "MP4, OGG and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", \
124         @"MUX_MP4", @"MUX_OGG", @"MUX_RAW", @"NO", @"NO", nil];
125     o_div1 = [NSArray arrayWithObjects: @"DIVX 1", @"DIV1", \
126         _NS("DivX first version (useable with MPEG TS, MPEG1, ASF and OGG)"), \
127         @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", \
128         @"NO", @"NO", nil];
129     o_div2 = [NSArray arrayWithObjects: @"DIVX 2", @"DIV2", \
130         _NS("DivX second version (useable with MPEG TS, MPEG1, ASF and OGG)"), \
131         @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", \
132         @"NO", @"NO", nil];
133     o_div3 = [NSArray arrayWithObjects: @"DIVX 3", @"DIV3", \
134         _NS("DivX third version (useable with MPEG TS, MPEG1, ASF and OGG)"), \
135         @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", \
136         @"NO", @"NO", nil];
137     o_h263 = [NSArray arrayWithObjects: @"H.263", @"h263", \
138         _NS("H263 is a video codec optimized for videoconference " \
139         "(low rates, useable with MPEG TS)"), @"MUX_TS", @"NO", @"NO", @"NO", \
140         @"NO", @"NO", @"NO", @"NO", @"NO", nil];
141     o_h264 = [NSArray arrayWithObjects: @"H.264", @"h264", \
142         _NS("H264 is a new video codec (useable with MPEG TS and MP4)"), \
143         @"MUX_TS", @"MUX_MP4", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", \
144         @"NO", nil];
145     o_wmv1 = [NSArray arrayWithObjects: @"WMV 1", @"WMV1", \
146         _NS("WMV (Windows Media Video) 1 (useable with MPEG TS, MPEG1, ASF and " \
147         "OGG)"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", \
148         @"NO", @"NO", @"NO", nil];
149     o_wmv2 = [NSArray arrayWithObjects: @"WMV 2", @"WMV2", \
150         _NS("WMV (Windows Media Video) 2 (useable with MPEG TS, MPEG1, ASF and " \
151         "OGG)"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", \
152         @"NO", @"NO", @"NO", nil];
153     o_mjpg = [NSArray arrayWithObjects: @"MJPEG", @"MJPG", \
154         _NS("MJPEG consists of a series of JPEG pictures (useable with MPEG TS," \
155         " MPEG1, ASF and OGG)"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", \
156         @"NO", @"NO", @"NO", @"NO", @"NO", nil];
157     o_theo = [NSArray arrayWithObjects: @"Theora", @"theo", \
158         _NS("Theora is a free general-purpose codec (useable with MPEG TS " \
159         "and OGG)"), @"MUX_TS", @"MUX_OGG", @"NO", @"NO", @"NO", @"NO", @"NO", \
160         @"NO", @"NO", nil];
161     o_dummyVid = [NSArray arrayWithObjects: @"Dummy", @"dummy", \
162         _NS("Dummy codec (do not transcode, useable with all encapsulation " \
163         "formats)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4", \
164         @"MUX_OGG", @"MUX_WAV", @"MUX_RAW", @"MUX_MOV", nil];
165     o_videoCodecs = [[NSArray alloc] initWithObjects: o_mp1v, o_mp2v, o_mp4v, \
166         o_div1, o_div2, o_div3, o_h263, o_h264, o_wmv1, o_wmv2, o_mjpg, o_theo, \
167         o_dummyVid, nil];
168     
169
170     NSArray * o_mpga;
171     NSArray * o_mp3;
172     NSArray * o_mp4a;
173     NSArray * o_a52;
174     NSArray * o_vorb;
175     NSArray * o_flac;
176     NSArray * o_spx;
177     NSArray * o_s16l;
178     NSArray * o_fl32;
179     NSArray * o_dummyAud;
180     o_mpga = [NSArray arrayWithObjects: @"MPEG Audio", @"mpga", \
181         _NS("The standard MPEG audio (1/2) format (useable with MPEG PS, MPEG TS, " \
182         "MPEG1, ASF, OGG and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", \
183         @"MUX_ASF", @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", nil];
184     o_mp3 = [NSArray arrayWithObjects: @"MP3", @"mp3", \
185         _NS("MPEG Audio Layer 3 (useable with MPEG PS, MPEG TS, MPEG1, ASF, OGG " \
186         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", \
187         @"MUX_RAW", @"-1", @"-1", @"-1", nil];
188     o_mp4a = [NSArray arrayWithObjects: @"MPEG 4 Audio", @"mp4a", \
189         _NS("Audio format for MPEG4 (useable with MPEG TS and MPEG4)"), @"MUX_TS", \
190         @"MUX_MP4", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
191     o_a52 = [NSArray arrayWithObjects: @"A/52", @"a52", 
192         _NS("DVD audio format (useable with MPEG PS, MPEG TS, MPEG1, ASF, OGG " \
193         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", \
194         @"MUX_RAW", @"-1", @"-1", @"-1", nil];
195     o_vorb = [NSArray arrayWithObjects: @"Vorbis", @"vorb", \
196         _NS("Vorbis is a free audio codec (useable with OGG)"), @"MUX_OGG", \
197         @"-1",  @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
198     o_flac = [NSArray arrayWithObjects: @"FLAC", @"flac", \
199         _NS("FLAC is a lossless audio codec (useable with OGG and RAW)"), \
200         @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", \
201         @"-1", nil];
202     o_spx = [NSArray arrayWithObjects: @"Speex", @"spx", \
203         _NS("A free audio codec dedicated to compression of voice (useable " \
204         "with OGG)"), @"MUX_OGG", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", \
205         @"-1", @"-1", nil];
206     o_s16l = [NSArray arrayWithObjects: @"Uncompressed, integer", @"s16l", \
207         _NS("Uncompressed audio samples (useable with WAV)"), @"MUX_WAV", \
208         @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
209     o_fl32 = [NSArray arrayWithObjects: @"Uncompressed, floating point", @"fl32", \
210         _NS("Uncompressed audio samples (useable with WAV)"), @"MUX_WAV", \
211         @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
212     o_dummyAud = [NSArray arrayWithObjects: @"Dummy", @"dummy", \
213         _NS("Dummy codec (do not transcode, useable with all encapsulation " \
214         "formats)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4", \
215         @"MUX_OGG", @"MUX_RAW", @"MUX_MOV", @"MUX_WAV", nil];
216     o_audioCodecs = [[NSArray alloc] initWithObjects: o_mpga, o_mp3, o_mp4a, \
217         o_a52, o_vorb, o_flac, o_spx, o_s16l, o_fl32, o_dummyAud, nil];
218
219
220     /* fill another global array with all information about the encap-formats
221      * note that the order of the formats inside the g. array is the same as on
222      * the encap-tab */
223     NSArray * o_ps;
224     NSArray * o_ts;
225     NSArray * o_mpeg;
226     NSArray * o_ogg;
227     NSArray * o_raw;
228     NSArray * o_asf;
229     NSArray * o_avi;
230     NSArray * o_mp4;
231     NSArray * o_mov;
232     NSArray * o_wav;
233     NSArray * o_asfh;
234     o_ps = [NSArray arrayWithObjects: @"ps", @"MPEG PS", \
235         _NS("MPEG Program Stream"), @"mpg", nil];
236     o_ts = [NSArray arrayWithObjects: @"ts", @"MPEG TS", \
237         _NS("MPEG Transport Stream"), nil];
238     o_mpeg = [NSArray arrayWithObjects: @"ps", @"MPEG 1", \
239         _NS("MPEG 1 Format"), @"mpg", nil];
240     o_ogg = [NSArray arrayWithObjects: @"ogg", @"OGG", @"OGG", nil];
241     o_raw = [NSArray arrayWithObjects: @"raw", @"RAW", @"RAW", nil];
242     o_asf = [NSArray arrayWithObjects: @"asf", @"ASF", @"ASF", nil];
243     o_avi = [NSArray arrayWithObjects: @"avi", @"AVI", @"AVI", nil];
244     o_mp4 = [NSArray arrayWithObjects: @"mp4", @"MP4", @"MPEG4", nil];
245     o_mov = [NSArray arrayWithObjects: @"mov", @"MOV", @"MOV", nil];
246     o_wav = [NSArray arrayWithObjects: @"wav", @"WAV", @"WAV", nil];
247     o_asfh = [NSArray arrayWithObjects: @"asfh", @"ASFH", @"ASFH", nil];
248     o_encapFormats = [[NSArray alloc] initWithObjects: o_ps, o_ts, o_mpeg, \
249         o_ogg, o_raw, o_asf, o_avi, o_mp4, o_mov, o_wav, o_asfh, nil];
250
251     /* yet another array on streaming methods including help texts */
252     NSArray * o_http;
253     NSArray * o_mms;
254     NSArray * o_udp_uni;
255     NSArray * o_udp_multi;
256     NSArray * o_rtp_uni;
257     NSArray * o_rtp_multi;
258     o_http = [NSArray arrayWithObjects: @"http", @"HTTP", _NS("Enter the local " \
259         "addresses you want to listen requests on. Do not enter anything if " \
260         "you want to listen on all the network interfaces. This is generally " \
261         "the best thing to do. Other computers can then access the stream at " \
262         "http://yourip:8080 by default.") , _NS("Use this to stream to several " \
263         "computers. This method is not the most efficient, as the server needs "\
264         "to send the stream several times, but generally the most compatible"), nil];
265     o_mms = [NSArray arrayWithObjects: @"mmsh", @"MMS", _NS("Enter the local " \
266         "addresses you want to listen requests on. Do not enter anything if " \
267         "you want to listen on all the network interfaces. This is generally " \
268         "the best thing to do. Other computers can then access the stream at " \
269         "mms://yourip:8080 by default."), _NS("Use this to stream to several " \
270         "computers using the Microsoft MMS protocol. This protocol is used as " \
271         "transport method by many Microsoft's softwares. Note that only a " \
272         "small part of the MMS protocol is supported (MMS encapsulated in " \
273         "HTTP)." ), nil];
274     o_udp_uni = [NSArray arrayWithObjects: @"udp", @"UDP-Unicast", _NS("Enter " \
275         "the address of the computer to stream to."), _NS("Use this to stream " \
276         "to a single computer."), nil];
277     o_udp_multi = [NSArray arrayWithObjects: @"udp", @"UDP-Multicast", _NS("Enter " \
278         "the multicast address to stream to in this field. This must be an IP " \
279         "address between 224.0.0.0 and 239.255.255.255. For a private use, " \
280         "enter an address beginning with 239.255."), _NS("Use this to stream " \
281         "to a dynamic group of computers on a multicast-enabled network. This " \
282         "is the most efficient method to stream to several computers, but it " \
283         "won't work over the Internet."), nil];
284     o_rtp_uni = [NSArray arrayWithObjects: @"rtp", @"RTP-Unicast", _NS("Enter the " \
285         "address of the computer to stream to.") , _NS("Use this to stream " \
286         "to a single computer. RTP headers will be added to the stream"), nil];
287     o_rtp_multi = [NSArray arrayWithObjects: @"rtp", @"RTP-Multicast", _NS("Enter " \
288         "the multicast address to stream to in this field. This must be an IP " \
289         "address between 224.0.0.0 and 239.255.255.255. For a private use, " \
290         "enter an address beginning with 239.255."), _NS("Use this to stream " \
291         "to a dynamic group of computers on a multicast-enabled network. This " \
292         "is the most efficient method to stream to several computers, but it " \
293         "won't work over Internet. RTP headers will be added to the stream"), nil];
294     o_strmgMthds = [[NSArray alloc] initWithObjects: o_http, o_mms, \
295         o_udp_uni, o_udp_multi, o_rtp_uni, o_rtp_multi, nil];
296 }
297
298 - (void)showWizard
299 {
300     /* just present the window to the user */
301     [o_wizard_window center];
302     [o_wizard_window displayIfNeeded];
303     [o_wizard_window makeKeyAndOrderFront:nil];
304 }
305
306 - (void)resetWizard
307 {
308     /* get the current state of our setting to keep the selections or not */
309     keepSettingsOrNot = (BOOL *)config_GetInt( VLCIntf, "macosx-wizard-keep" );
310
311     /* go to the front page and clean up a bit */
312     [o_userSelections removeAllObjects];
313     [o_btn_forward setTitle: _NS("Next")];
314     [o_tab_pageHolder selectFirstTabViewItem:self];
315
316     
317     if( keepSettingsOrNot )
318         return;
319     
320     /* reset the wizard-window to its default values if wanted */
321     [o_t1_matrix_strmgOrTrnscd selectCellAtRow:0 column:0];
322     [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setState: NSOffState];
323
324     /* "Input" */
325     [o_t2_fld_pathToNewStrm setStringValue: @""];
326     [o_t2_ckb_enblPartExtrct setState: NSOffState];
327     [self t2_enableExtract:nil];
328     [o_t2_matrix_inputSourceType selectCellAtRow:0 column:0];
329     [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setState: NSOffState];
330     [o_t2_fld_pathToNewStrm setEnabled:YES];
331     [o_t2_btn_chooseFile setEnabled:YES];
332     [o_t2_tbl_plst setEnabled:NO];
333
334     /* "Streaming 1" */
335     [o_t3_fld_address setStringValue: @""];
336     [o_t3_matrix_stmgMhd selectCellAtRow:0 column:0];
337     [[o_t3_matrix_stmgMhd cellAtRow:0 column:1] setState: NSOffState];
338     [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setState: NSOffState];
339     [[o_t3_matrix_stmgMhd cellAtRow:1 column:2] setState: NSOffState];
340
341     /* "Transcode 1" */
342     [o_t4_ckb_audio setState: NSOffState];
343     [o_t4_ckb_video setState: NSOffState];
344     [self t4_enblVidTrnscd:nil];
345     [self t4_enblAudTrnscd:nil];
346
347     /* "Streaming 2" */
348     [o_t6_fld_ttl setStringValue: @"1"];
349     [o_t6_ckb_sap setState: NSOffState];
350     [self t6_enblSapAnnce:nil];
351
352     /* "Transcode 2" */
353     [o_t7_fld_filePath setStringValue: @""];
354 }
355
356 - (void)initStrings
357 {
358     /* localise all strings to the users lang */
359     /* method is called from intf.m (in method showWizard) */
360
361     /* general items */
362     [o_btn_backward setTitle: _NS("Back")];
363     [o_btn_cancel setTitle: _NS("Cancel")];
364     [o_btn_forward setTitle: _NS("Next")];
365     [o_wizard_window setTitle: _NS("Streaming/Transcoding Wizard")];
366
367     /* page one ("Hello") */
368     [o_t1_txt_title setStringValue: _NS("Streaming/Transcoding Wizard")];
369     [o_t1_txt_text setStringValue: _NS("This wizard allows to configure " \
370         "simple streaming or transcoding setups.")];
371     [o_t1_btn_mrInfo_strmg setTitle: _NS("More Info")];
372     [o_t1_btn_mrInfo_trnscd setTitle: _NS("More Info")];
373     [o_t1_txt_notice setStringValue: _NS("This wizard only gives access to " \
374         "a small subset of VLC's streaming and transcoding capabilities. " \
375         "The Open and 'Saving/Streaming' dialogs will give access to more " \
376         "features.")];
377     [[o_t1_matrix_strmgOrTrnscd cellAtRow:0 column:0] setTitle: _NS("Stream " \
378         "to network")];
379     [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setTitle: _NS("" \
380         "Transcode/Save to file")];
381
382     /* page two ("Input") */
383     [o_t2_title setStringValue: _NS("Choose input")];
384     [o_t2_text setStringValue: _NS("Choose here your input stream.")];
385     [[o_t2_matrix_inputSourceType cellAtRow:0 column:0] setTitle:  \
386         _NS("Select a stream")];
387     [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setTitle: \
388         _NS("Existing playlist item")];
389     [o_t2_btn_chooseFile setTitle: _NS("Choose...")];
390     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"1"] headerCell] \
391         setStringValue: _NS("Title")];
392     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"2"] headerCell] \
393         setStringValue: _NS("Author")];
394     [o_t2_box_prtExtrct setTitle: _NS("Partial Extract")];
395     [o_t2_ckb_enblPartExtrct setTitle: _NS("Enable")];
396     [o_t2_ckb_enblPartExtrct setToolTip: _NS("This can be used to read only a "\
397         "part of the stream. It must be possible to control the incoming "\
398         "stream (for example, a file or a disc, but not an UDP network stream.) " \
399         "The starting and ending times can be given in seconds.")];
400     [o_t2_txt_prtExtrctFrom setStringValue: _NS("From")];
401     [o_t2_txt_prtExtrctTo setStringValue: _NS("To")];
402
403     /* page three ("Streaming 1") */
404     [o_t3_txt_title setStringValue: _NS("Streaming")];
405     [o_t3_txt_text setStringValue: _NS("This page allows to select how " \
406         "the input stream will be sent.")];
407     [o_t3_box_dest setTitle: _NS("Destination")];
408     [o_t3_box_strmgMthd setTitle: _NS("Streaming method")];
409     [o_t3_txt_destInfo setStringValue: _NS("Address of the computer " \
410         "to stream to.")];
411     [[o_t3_matrix_stmgMhd cellAtRow:0 column:0] setTitle: _NS("UDP Unicast")];
412     [[o_t3_matrix_stmgMhd cellAtRow:0 column:1] setTitle: _NS("UDP Multicast")];
413     [o_t3_txt_strgMthdInfo setStringValue: _NS("Use this to stream to a single " \
414         "computer.")];
415
416     /* page four ("Transcode 1") */
417     [o_t4_title setStringValue: _NS("Transcode")];
418     [o_t4_text setStringValue: _NS("This page allows to change the compression " \
419         "format of the audio or video tracks. To change only " \
420         "the container format, proceed to next page.")];
421     [o_t4_box_audio setTitle: _NS("Audio")];
422     [o_t4_box_video setTitle: _NS("Video")];
423     [o_t4_ckb_audio setTitle: _NS("Transcode audio")];
424     [o_t4_ckb_video setTitle: _NS("Transcode video")];
425     [o_t4_txt_videoBitrate setStringValue: _NS("Bitrate (kb/s)")];
426     [o_t4_txt_videoCodec setStringValue: _NS("Codec")];
427     [o_t4_txt_hintAudio setStringValue: _NS("Enabling this allows to transcode "\
428     "the audio track if one is present in the stream.")];
429     [o_t4_txt_hintVideo setStringValue: _NS("Enabling this allows to transcode "\
430     "the video track if one is present in the stream.")];
431
432     /* page five ("Encap") */
433     [o_t5_title setStringValue: _NS("Encapsulation format")];
434     [o_t5_text setStringValue: _NS("This page allows to select how the " \
435         "stream will be encapsulated. Depending on previously chosen settings "
436         "all formats won't be available.")];
437
438     /* page six ("Streaming 2") */
439     [o_t6_title setStringValue: _NS("Additional streaming options")];
440     [o_t6_text setStringValue: _NS("In this page, a few " \
441                               "additional streaming parameters can be set.")];
442     [o_t6_txt_ttl setStringValue: _NS("Time-To-Live (TTL)")];
443     [o_t6_btn_mrInfo_ttl setTitle: _NS("More Info")];
444     [o_t6_ckb_sap setTitle: _NS("SAP Announce")];
445     [o_t6_btn_mrInfo_sap setTitle: _NS("More Info")];
446     [o_t6_ckb_local setTitle: _NS("Local playback")];
447     [o_t6_btn_mrInfo_local setTitle: _NS("More Info")];
448
449     /* page seven ("Transcode 2") */
450     [o_t7_title setStringValue: _NS("Additional transcode options")];
451     [o_t7_text setStringValue: _NS("In this page, a few " \
452                               "additional transcoding parameters can be set.")];
453     [o_t7_txt_saveFileTo setStringValue: _NS("Select the file to save to")];
454     [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
455     [o_t7_ckb_local setTitle: _NS("Local playback")];
456     [o_t7_btn_mrInfo_local setTitle: _NS("More Info")];
457
458     /* page eight ("Summary") */
459     [o_t8_txt_text setStringValue: _NS("This page lists all the settings." \
460         "Click \"Finish\" to start streaming or transcoding.")];
461     [o_t8_txt_title setStringValue: _NS("Summary")];
462     [o_t8_txt_destination setStringValue: [_NS("Destination") \
463         stringByAppendingString: @":"]];
464     [o_t8_txt_encapFormat setStringValue: [_NS("Encap. format") \
465         stringByAppendingString: @":"]];
466     [o_t8_txt_inputStream setStringValue: [_NS("Input stream") \
467         stringByAppendingString: @":"]];
468     [o_t8_txt_partExtract setStringValue: [_NS("Partial Extract") \
469         stringByAppendingString: @":"]];
470     [o_t8_txt_sap setStringValue: [_NS("SAP Announce") \
471         stringByAppendingString: @":"]];
472     [o_t8_txt_saveFileTo setStringValue: [_NS("Save file to") \
473         stringByAppendingString: @":"]];
474     [o_t8_txt_strmgMthd setStringValue: [_NS("Streaming method") \
475         stringByAppendingString: @":"]];
476     [o_t8_txt_trnscdAudio setStringValue: [_NS("Transcode audio") \
477         stringByAppendingString: @":"]];
478     [o_t8_txt_trnscdVideo setStringValue: [_NS("Transcode video") \
479         stringByAppendingString: @":"]];
480     [o_t8_txt_local setStringValue: [_NS("Local playback") \
481         stringByAppendingString: @":"]];
482 }
483
484 - (void)initWithExtractValuesFrom: (NSString *)from to: (NSString *)to \
485     ofItem: (NSString *)item
486 {
487     [self resetWizard];
488     msg_Dbg(VLCIntf, "wizard was reseted");
489     [o_userSelections setObject:@"trnscd" forKey:@"trnscdOrStrmg"];
490     [o_btn_backward setEnabled:YES];
491     [o_tab_pageHolder selectTabViewItemAtIndex:1];
492     [o_t2_fld_prtExtrctFrom setStringValue: from];
493     [o_t2_fld_prtExtrctTo setStringValue: to];
494     [o_t2_fld_pathToNewStrm setStringValue: item];
495     [o_t1_matrix_strmgOrTrnscd selectCellAtRow:1 column:0];
496     [[o_t1_matrix_strmgOrTrnscd cellAtRow:0 column:0] setState: NSOffState];
497     [o_t2_ckb_enblPartExtrct setState: NSOnState];
498     [self t2_enableExtract: nil];
499     msg_Dbg(VLCIntf, "wizard interface is set");
500     
501     [o_wizard_window center];
502     [o_wizard_window display];
503     [o_wizard_window makeKeyAndOrderFront:nil];
504     msg_Dbg(VLCIntf, "wizard window displayed");
505 }
506
507 - (IBAction)cancelRun:(id)sender
508 {
509     [o_wizard_window close];
510 }
511
512 - (id)getPlaylistWizard
513 {
514     return o_playlist_wizard;
515 }
516
517 - (IBAction)nextTab:(id)sender
518 {
519     if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Hello"])
520     {
521         /* check whether the user wants to stream or just to transcode;
522          * store information for later usage */
523         NSString *o_mode;
524         o_mode = [[o_t1_matrix_strmgOrTrnscd selectedCell] title];
525         if( [o_mode isEqualToString: _NS("Stream to network")] )
526         {
527             /* we will be streaming */
528             [o_userSelections setObject:@"strmg" forKey:@"trnscdOrStrmg"];
529         }
530         else
531         {
532             /* we will just do some transcoding */
533             [o_userSelections setObject:@"trnscd" forKey:@"trnscdOrStrmg"];
534         }
535         [o_btn_backward setEnabled:YES];
536         [o_tab_pageHolder selectTabViewItemAtIndex:1];
537
538         /* Fill the playlist with current playlist items */
539         [o_playlist_wizard reloadOutlineView];
540
541     }
542     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Input"])
543     {
544         /* check whether partialExtract is enabled and store the values, if needed */
545         if ([o_t2_ckb_enblPartExtrct state] == NSOnState)
546         {
547             [o_userSelections setObject:@"YES" forKey:@"partExtract"];
548             [o_userSelections setObject:[o_t2_fld_prtExtrctFrom stringValue] \
549                 forKey:@"partExtractFrom"];
550             [o_userSelections setObject:[o_t2_fld_prtExtrctTo stringValue] \
551                 forKey:@"partExtractTo"];
552         }else{
553             [o_userSelections setObject:@"NO" forKey:@"partExtract"];
554         }
555
556         /* check whether we use an existing pl-item or add an new one;
557          * store the path or the index and set a flag.
558          * complain to the user if s/he didn't provide a path */
559         NSString *o_mode;
560         BOOL stop;
561         stop = NO;
562         o_mode = [[o_t2_matrix_inputSourceType selectedCell] title];
563         if( [o_mode isEqualToString: _NS("Select a stream")] )
564         {
565             [o_userSelections setObject:@"YES" forKey:@"newStrm"];
566             if ([[o_t2_fld_pathToNewStrm stringValue] isEqualToString: @""])
567             {
568                 /* set a flag that no file is selected */
569                 stop = YES;
570             }
571             else
572             {
573                 [o_userSelections setObject:[NSArray arrayWithObject:
574                     [o_t2_fld_pathToNewStrm stringValue]] forKey:@"pathToStrm"];
575             }
576         }
577         else
578         {
579             if ([o_t2_tbl_plst numberOfSelectedRows] > 0)
580             {
581                 int x = 0;
582                 int y = [[o_t2_tbl_plst selectedRowIndexes] count];
583                 NSMutableArray * tempArray = [[NSMutableArray alloc] init];
584                 while( x != y )
585                 {
586                     playlist_item_t *p_item =
587                         [[o_t2_tbl_plst itemAtRow: 
588                             [[o_t2_tbl_plst selectedRowIndexes] 
589                             indexGreaterThanOrEqualToIndex: x]] pointerValue];
590
591                     if( p_item->i_children <= 0 )
592                     {
593                         [tempArray addObject: [NSString stringWithUTF8String:
594                         p_item->p_input->psz_uri]];
595                         stop = NO;
596                     }
597                     else
598                         stop = YES;
599                     x += 1;
600                 }
601                 [o_userSelections setObject:[NSArray arrayWithArray: tempArray]
602                     forKey:@"pathToStrm"];
603                 [tempArray release];
604             }
605             else
606             {
607                 /* set a flag that no item is selected */
608                 stop = YES;
609             }
610         }
611
612         /* show either "Streaming 1" or "Transcode 1" to the user */
613         if (stop == NO)
614         {
615             if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] \
616                 isEqualToString:@"strmg"])
617             {
618                 /* we are streaming */
619                 [o_tab_pageHolder selectTabViewItemAtIndex:2];
620             }else{
621                 /* we are just transcoding */
622
623                 /* rebuild the menues for the codec-selections */
624                 [self rebuildCodecMenus];
625
626                 [o_tab_pageHolder selectTabViewItemAtIndex:3];
627             }
628         } else {
629             /* show a sheet that the user didn't select a file */
630             NSBeginInformationalAlertSheet(_NS("No input selected"), \
631                 _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
632                 _NS("No new stream or valid playlist item has been selected.\n\n" \
633                 "Choose one before going to the next page."));
634         }
635     }
636     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
637         @"Streaming 1"])
638     {
639         /* rebuild the menues for the codec-selections */
640         [self rebuildCodecMenus];
641         
642         /* check which streaming method is selected and store it */
643         int mode;
644         mode = [[o_t3_matrix_stmgMhd selectedCell] tag];
645         if( mode == 0 )
646         {
647             /* HTTP Streaming */
648             [o_userSelections setObject:@"0" forKey:@"stmgMhd"];
649
650             /* disable all codecs which don't support MPEG PS, MPEG TS, MPEG 1,
651              * OGG, RAW or ASF */
652             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
653             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating point"];
654             
655         } else if ( mode == 1 )
656         {
657             /* MMS Streaming */
658             [o_userSelections setObject:@"1" forKey:@"stmgMhd"];
659             
660             /* disable all codecs which don't support ASF / ASFH */
661             [o_t4_pop_audioCodec removeItemWithTitle:@"MPEG 4 Audio"];
662             [o_t4_pop_audioCodec removeItemWithTitle:@"Vorbis"];
663             [o_t4_pop_audioCodec removeItemWithTitle:@"FLAC"];
664             [o_t4_pop_audioCodec removeItemWithTitle:@"Speex"];
665             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
666             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating point"];
667             
668             [o_t4_pop_videoCodec removeItemWithTitle:@"MPEG-1 Video"];
669             [o_t4_pop_videoCodec removeItemWithTitle:@"MPEG-2 Video"];
670             [o_t4_pop_videoCodec removeItemWithTitle:@"H.263"];
671             [o_t4_pop_videoCodec removeItemWithTitle:@"H.264"];
672             [o_t4_pop_videoCodec removeItemWithTitle:@"MJPEG"];
673             [o_t4_pop_videoCodec removeItemWithTitle:@"Theora"];
674         } else {
675             /* RTP/UDP Unicast/Multicast Streaming */
676             [o_userSelections setObject: [[NSNumber numberWithInt: mode] \
677                 stringValue] forKey:@"stmgMhd"];
678             
679             /* disable all codecs which don't support MPEG-TS */
680             [o_t4_pop_audioCodec removeItemWithTitle:@"Vorbis"];
681             [o_t4_pop_audioCodec removeItemWithTitle:@"FLAC"];
682             [o_t4_pop_audioCodec removeItemWithTitle:@"Speex"];
683             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
684             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating point"];
685         }
686
687         /* store the destination and check whether is it empty */
688         if([[o_userSelections objectForKey:@"stmgMhd"] intValue] >=2 )
689         {
690            /* empty field is valid for HTTP and MMS */
691             if( [[o_t3_fld_address stringValue] isEqualToString: @""] )
692             {
693                 /* complain to the user that "" is no valid dest. */
694                 NSBeginInformationalAlertSheet(_NS("No valid destination"), \
695                     _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
696                     _NS("A valid destination has to be selected "\
697                     "Enter either a Unicast-IP or a Multicast-IP." \
698                     "\n\nIf you don't know what this means, have a look at " \
699                     "the VLC Streaming HOWTO and the help texts in this " \
700                     "window."));
701             } else {
702                 /* FIXME: check whether the entered IP is really valid */
703                 [o_userSelections setObject:[o_t3_fld_address stringValue] \
704                     forKey:@"stmgDest"];
705                 /* let's go to the transcode-1-tab */
706                 [o_tab_pageHolder selectTabViewItemAtIndex:3];
707             }
708         } else {
709             [o_userSelections setObject:[o_t3_fld_address stringValue] \
710                 forKey:@"stmgDest"];
711             /* let's go to the transcode-1-tab */
712             [o_tab_pageHolder selectTabViewItemAtIndex:3];
713         }
714     }
715     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
716         @"Transcode 1"])
717     {
718         /* check whether the user wants to transcode the video-track and store 
719          * the related options */
720         if ([o_t4_ckb_video state] == NSOnState)
721         {
722             NSNumber * theNum;
723             theNum = [NSNumber numberWithInt:[o_t4_pop_videoCodec indexOfSelectedItem]];
724             [o_userSelections setObject:@"YES" forKey:@"trnscdVideo"];
725             [o_userSelections setObject:[o_t4_pop_videoBitrate titleOfSelectedItem] \
726                 forKey:@"trnscdVideoBitrate"];
727             [o_userSelections setObject:theNum forKey:@"trnscdVideoCodec"];
728         } else {
729             [o_userSelections setObject:@"NO" forKey:@"trnscdVideo"];
730         }
731
732         /* check whether the user wants to transcode the audio-track and store 
733          * the related options */
734         if ([o_t4_ckb_audio state] == NSOnState)
735         {
736             NSNumber * theNum;
737             theNum = [NSNumber numberWithInt:[o_t4_pop_audioCodec indexOfSelectedItem]];
738             [o_userSelections setObject:@"YES" forKey:@"trnscdAudio"];
739             [o_userSelections setObject:[o_t4_pop_audioBitrate titleOfSelectedItem] \
740                 forKey:@"trnscdAudioBitrate"];
741             [o_userSelections setObject:theNum forKey:@"trnscdAudioCodec"];
742         } else {
743             [o_userSelections setObject:@"NO" forKey:@"trnscdAudio"];
744         }
745
746         /* disable all encap-formats */
747         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
748         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:NO];
749         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
750         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
751         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
752         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
753         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
754         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
755         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
756         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
757         [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
758
759         /* re-enable the encap-formats supported by the chosen codecs */
760         /* FIXME: the following is a really bad coding-style. feel free to mail
761             me ideas how to make this nicer, if you want to -- FK, 7/11/05 */
762
763         if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualTo: @"YES"])
764         {
765             if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualTo: @"YES"])
766             {
767                 /* we are transcoding both audio and video, so we need to check both deps */
768                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
769                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_PS"])
770                 {
771                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections \
772                         objectForKey:@"trnscdAudioCodec"] intValue]] \
773                         containsObject: @"MUX_PS"])
774                     {
775                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
776                         [o_t5_matrix_encap selectCellAtRow:0 column:0];
777                     }
778                 }
779                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections \
780                     objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_TS"])
781                 {
782                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
783                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_TS"])
784                     {
785                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
786                         [o_t5_matrix_encap selectCellAtRow:1 column:0];
787                     }
788                 }
789                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
790                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MPEG"])
791                 {
792                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
793                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MPEG"])
794                     {
795                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
796                         [o_t5_matrix_encap selectCellAtRow:2 column:0];
797                     }
798                 }
799                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
800                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_OGG"])
801                 {
802                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections \
803                         objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_OGG"])
804                     {
805                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
806                         [o_t5_matrix_encap selectCellAtRow:3 column:0];
807                     }
808                 }
809                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
810                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_RAW"])
811                 {
812                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
813                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_RAW"])
814                     {
815                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
816                         [o_t5_matrix_encap selectCellAtRow:4 column:0];
817                     }
818                 }
819                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
820                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_ASF"])
821                 {
822                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
823                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_ASF"])
824                     {
825                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
826                         [o_t5_matrix_encap selectCellAtRow:5 column:0];
827                     }
828                 }
829                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
830                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_AVI"])
831                 {
832                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
833                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_AVI"])
834                     {
835                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
836                         [o_t5_matrix_encap selectCellAtRow:6 column:0];
837                     }
838                 }
839                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
840                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MP4"])
841                 {
842                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
843                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MP4"])
844                     {
845                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
846                         [o_t5_matrix_encap selectCellAtRow:7 column:0];
847                     }
848                 }
849                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
850                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MOV"])
851                 {
852                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
853                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MOV"])
854                     {
855                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
856                         [o_t5_matrix_encap selectCellAtRow:8 column:0];
857                     }
858                 }
859                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
860                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_WAV"])
861                 {
862                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
863                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_WAV"])
864                     {
865                         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
866                         [o_t5_matrix_encap selectCellAtRow:9 column:0];
867                     }
868                 }
869
870             } else {
871
872                 /* we just transcoding the audio */
873
874                 /* select formats supported by the audio codec */
875                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
876                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_PS"])
877                 {
878                     [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
879                     [o_t5_matrix_encap selectCellAtRow:0 column:0];
880                 }
881                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
882                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_TS"])
883                 {
884                     [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
885                     [o_t5_matrix_encap selectCellAtRow:1 column:0];
886                 }
887                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
888                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MPEG"])
889                 {
890                     [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
891                     [o_t5_matrix_encap selectCellAtRow:2 column:0];
892                 }
893                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
894                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_OGG"])
895                 {
896                     [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
897                     [o_t5_matrix_encap selectCellAtRow:3 column:0];
898                 }
899                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
900                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_RAW"])
901                 {
902                     [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
903                     [o_t5_matrix_encap selectCellAtRow:4 column:0];
904                 }
905                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
906                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_ASF"])
907                 {
908                     [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
909                     [o_t5_matrix_encap selectCellAtRow:5 column:0];
910                 }
911                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
912                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_AVI"])
913                 {
914                     [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
915                     [o_t5_matrix_encap selectCellAtRow:6 column:0];
916                 }
917                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
918                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MP4"])
919                 {
920                     [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
921                     [o_t5_matrix_encap selectCellAtRow:7 column:0];
922                 }
923                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
924                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MOV"])
925                 {
926                     [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
927                     [o_t5_matrix_encap selectCellAtRow:8 column:0];
928                 }
929                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
930                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_WAV"])
931                 {
932                     [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
933                     [o_t5_matrix_encap selectCellAtRow:9 column:0];
934                 }
935             }
936         }
937         else if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualTo: @"YES"])
938         {
939             /* we are just transcoding the video */
940
941             /* select formats supported by the video-codec */
942
943             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
944                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_PS"])
945             {
946                 [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
947                 [o_t5_matrix_encap selectCellAtRow:0 column:0];
948             }
949             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
950                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_TS"])
951             {
952                 [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
953                 [o_t5_matrix_encap selectCellAtRow:1 column:0];
954             }
955             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
956                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MPEG"])
957             {
958                 [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
959                 [o_t5_matrix_encap selectCellAtRow:2 column:0];
960             }
961             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
962                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_OGG"])
963             {
964                 [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
965                 [o_t5_matrix_encap selectCellAtRow:3 column:0];
966             }
967             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
968                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_RAW"])
969             {
970                 [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
971                 [o_t5_matrix_encap selectCellAtRow:4 column:0];
972             }
973             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
974                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_ASF"])
975             {
976                 [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
977                 [o_t5_matrix_encap selectCellAtRow:5 column:0];
978             }
979             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
980                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_AVI"])
981             {
982                 [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
983                 [o_t5_matrix_encap selectCellAtRow:6 column:0];
984             }
985             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
986                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MP4"])
987             {
988                 [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
989                 [o_t5_matrix_encap selectCellAtRow:7 column:0];
990             }
991             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
992                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MOV"])
993             {
994                 [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
995                 [o_t5_matrix_encap selectCellAtRow:8 column:0];
996             }
997             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
998                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_WAV"])
999             {
1000                 [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
1001                 [o_t5_matrix_encap selectCellAtRow:9 column:0];
1002             }
1003         } else {
1004             /* we don't do any transcoding
1005              * -> enabled the encap-formats allowed when streaming content via
1006              * http plus MP4 since this should work fine in most cases */
1007
1008             /* FIXME: choose a selection of encap-formats based upon the 
1009              * actually used codecs */
1010
1011             /* enable MPEG PS, MPEG TS, MPEG 1, OGG, RAW, ASF, MP4 and MOV
1012              * select MPEG PS */
1013             [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
1014             [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
1015             [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
1016             [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
1017             [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
1018             [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
1019             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
1020             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
1021             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
1022             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
1023             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
1024             [o_t5_matrix_encap selectCellAtRow:0 column:0];
1025         }
1026
1027         if ( [o_userSelections objectForKey:@"stmgMhd"] == @"1" )
1028         {
1029             /* if MMS is the streaming protocol, only ASFH is available */
1030             [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
1031             [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:NO];
1032             [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
1033             [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
1034             [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
1035             [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
1036             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
1037             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
1038             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
1039             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
1040             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:YES];
1041             [o_t5_matrix_encap selectCellAtRow:10 column:0];
1042         }
1043         else if ( [o_userSelections objectForKey:@"stmgMhd"] == @"0" )
1044         {
1045             /* if HTTP is the streaming protocol, disable all unsupported
1046              * encap-formats, but don't touch the other ones selected above */
1047             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
1048             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
1049             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
1050             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
1051             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
1052         }
1053         else if ( [[o_userSelections objectForKey:@"stmgMhd"] intValue] >= 2 )
1054         {
1055             /* if UDP/RTP is the streaming protocol, only MPEG-TS is available */
1056             [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
1057             [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
1058             [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
1059             [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
1060             [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
1061             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
1062             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
1063             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
1064             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
1065             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
1066             [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
1067             [o_t5_matrix_encap selectCellAtRow:1 column:0];
1068         }
1069         int x;
1070         BOOL anythingEnabled;
1071         x = 0;
1072         anythingEnabled = NO;
1073         while (x != [o_t5_matrix_encap numberOfRows])
1074         {
1075             if ([[o_t5_matrix_encap cellAtRow:x column:0] isEnabled])
1076             {
1077                 anythingEnabled = YES;
1078             }
1079             x += 1;
1080         }
1081         if (anythingEnabled == YES)
1082         {
1083             /* go the encap-tab */
1084             [o_tab_pageHolder selectTabViewItemAtIndex:4];
1085         } else {
1086             /* show a sheet that the selected codecs are not compatible */
1087             NSBeginInformationalAlertSheet(_NS("Invalid selection"), _NS("OK"), \
1088                 @"", @"", o_wizard_window, nil, nil, nil, nil, _NS("The " \
1089                 "chosen codecs are not compatible with each other. For example: " \
1090                 "It is impossibleto  mix uncompressed audio with any video codec.\n\n" \
1091                 "Correct your selection and try again."));
1092         }
1093
1094     }
1095     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Encap"])
1096     {
1097         /* get the chosen encap format and store it */
1098         NSNumber * theNum;
1099         theNum = [NSNumber numberWithInt:[[o_t5_matrix_encap selectedCell] tag]];
1100         [o_userSelections setObject:[theNum stringValue] forKey:@"encapFormat"];
1101
1102         /* show either "Streaming 2" or "Transcode 2" to the user */
1103         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
1104         {
1105             /* we are streaming */
1106             [o_tab_pageHolder selectTabViewItemAtIndex:5];
1107         }else{
1108             /* we are just transcoding */
1109             [o_tab_pageHolder selectTabViewItemAtIndex:6];
1110             /* in case that we are processing multiple items, let the user
1111              * select a folder instead of a localtion for a single item */
1112             if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
1113             {
1114                 [o_t7_txt_saveFileTo setStringValue: 
1115                     _NS("Select the directory to save to")];
1116             }
1117             else
1118             {
1119                 [o_t7_txt_saveFileTo setStringValue: 
1120                     _NS("Select the file to save to")];
1121             }
1122         }
1123     }
1124     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1125         @"Streaming 2"])
1126     {
1127         /* store the chosen TTL */
1128         [o_userSelections setObject:[o_t6_fld_ttl stringValue] forKey:@"ttl"];
1129
1130         /* check whether SAP is enabled and store the announce, if needed */
1131         if ([o_t6_ckb_sap state] == NSOnState)
1132         {
1133             [o_userSelections setObject:@"YES" forKey:@"sap"];
1134             [o_userSelections setObject:[o_t6_fld_sap stringValue] forKey:@"sapText"];
1135         } else {
1136             [o_userSelections setObject:@"NO" forKey:@"sap"];
1137         }
1138         
1139         /* local playback? */
1140         if ([o_t6_ckb_local state] == NSOnState)
1141         {
1142             [o_userSelections setObject:@"YES" forKey:@"localPb"];
1143         } else {
1144             [o_userSelections setObject:@"NO" forKey:@"localPb"];
1145         }
1146         
1147         /* go to "Summary" */
1148         [self showSummary];
1149     }
1150     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1151         @"Transcode 2"])
1152     {
1153         /* local playback? */
1154         if ([o_t7_ckb_local state] == NSOnState)
1155         {
1156             [o_userSelections setObject:@"YES" forKey:@"localPb"];
1157         } else {
1158             [o_userSelections setObject:@"NO" forKey:@"localPb"];
1159         }
1160
1161         /* check whether the path != "" and store it */
1162         if( [[o_t7_fld_filePath stringValue] isEqualToString: @""] )
1163         {
1164             /* complain to the user that "" is no valid path for a folder/file */
1165             if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
1166                 NSBeginInformationalAlertSheet(_NS("No folder selected"), \
1167                     _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
1168                     [NSString stringWithFormat: @"%@\n\n%@", _NS("A directory "
1169                     "where to save the files has to be selected."),
1170                     _NS("Enter either a valid path or use the \"Choose...\" " \
1171                     "button to select a location.")]);
1172             else
1173                 NSBeginInformationalAlertSheet(_NS("No file selected"), \
1174                     _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
1175                     [NSString stringWithFormat: @"%@\n\n%@", _NS("A file " \
1176                     "where to save the stream has to be selected."),
1177                     _NS("Enter either a valid path or use the \"Choose\" " \
1178                     "button to select a location.")]);
1179         } else {
1180             /* create a string containing the requested suffix for later usage */
1181             NSString * theEncapFormat = [[o_encapFormats objectAtIndex:
1182                 [[o_userSelections objectForKey:@"encapFormat"] intValue]] \
1183                 objectAtIndex:0];
1184             if( theEncapFormat == @"ps" )
1185                 theEncapFormat = @"mpg";
1186
1187             /* look whether we need to process multiple items or not.
1188              * choose a faster variant if we just want a single item */
1189             if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
1190             {
1191                 NSMutableArray * tempArray = [[NSMutableArray alloc] init];
1192                 int x = 0;
1193                 int y = [[o_userSelections objectForKey:@"pathToStrm"] count];
1194                 NSMutableString * tempString = [[NSMutableString alloc] init];
1195                 while( x != y )
1196                 {
1197                     NSString * fileNameToUse;
1198                     /* check whether the extension is hidden or not. 
1199                      * if not, remove it
1200                      * we need the casting to make GCC4 happy */
1201                     if( (int)[[[NSFileManager defaultManager] fileAttributesAtPath: \
1202                         [[o_userSelections objectForKey:@"pathToStrm"] \
1203                         objectAtIndex: x] traverseLink: NO] objectForKey: \
1204                         NSFileExtensionHidden] == YES )
1205                         fileNameToUse = [NSString stringWithString:
1206                             [[NSFileManager defaultManager] displayNameAtPath:
1207                             [[o_userSelections objectForKey:@"pathToStrm"]
1208                             objectAtIndex: x]]];
1209                     else
1210                     {
1211                         int z = 0;
1212                         int count = [[[[NSFileManager defaultManager] \
1213                             displayNameAtPath: \
1214                             [[o_userSelections objectForKey:@"pathToStrm"] \
1215                             objectAtIndex: x]] \
1216                             componentsSeparatedByString: @"."] count];
1217                         fileNameToUse = @"";
1218                         while( z < (count - 1) )
1219                         {
1220                             fileNameToUse = [fileNameToUse stringByAppendingString:
1221                                 [[[[NSFileManager defaultManager] \
1222                                 displayNameAtPath: \
1223                                 [[o_userSelections objectForKey:@"pathToStrm"] \
1224                                 objectAtIndex: x]] \
1225                                 componentsSeparatedByString: @"."] \
1226                                 objectAtIndex: z]];
1227                             z += 1;
1228                         }
1229                     }
1230                     tempString = [NSString stringWithFormat: @"%@%@.%@",
1231                         [o_t7_fld_filePath stringValue],
1232                         fileNameToUse, theEncapFormat];
1233                     if( [[NSFileManager defaultManager] fileExistsAtPath: \
1234                         tempString] )
1235                     {
1236                         /* we don't wanna overwrite existing files, so add an
1237                          * int to the file-name */
1238                         int additionalInt = 1;
1239                         while( additionalInt < 100 )
1240                         {
1241                             tempString = [NSString stringWithFormat:@"%@%@ %i.%@",
1242                                 [o_t7_fld_filePath stringValue],
1243                                 fileNameToUse, additionalInt, theEncapFormat];
1244                             if(! [[NSFileManager defaultManager] \
1245                                 fileExistsAtPath: tempString] )
1246                                 break;
1247                             additionalInt += 1;
1248                         }
1249                         if( additionalInt >= 100 )
1250                             msg_Err( VLCIntf, "Files with the same name are " \
1251                                 "already present in the destination directory. " \
1252                                 "Delete these files or choose a different directory." );
1253                     }
1254                     [tempArray addObject: [tempString retain]];
1255                     x += 1;
1256                 }
1257                 [o_userSelections setObject: [NSArray arrayWithArray:tempArray]
1258                     forKey: @"trnscdFilePath"];
1259                 [tempArray release];
1260                 [tempString release];
1261             }
1262             else
1263             {
1264                 /* we don't need to check for existing items because Cocoa
1265                  * does that already when we are asking the user for a location
1266                  * to save her file */
1267                 [o_userSelections setObject: [NSArray arrayWithObject: \
1268                     [o_t7_fld_filePath stringValue]] forKey: @"trnscdFilePath"];
1269             }
1270
1271             /* go to "Summary" */
1272             [self showSummary];
1273         }
1274     }
1275     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1276         @"Summary"])
1277     {
1278         intf_thread_t * p_intf = VLCIntf;
1279
1280         playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_intf,
1281                             VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
1282         if( p_playlist )
1283         {
1284             int x = 0;
1285             int y = [[o_userSelections objectForKey:@"pathToStrm"] count];
1286             while( x != y )
1287             {
1288                 /* we need a temp. variable here to work-around a GCC4-bug */
1289                 NSString *tempString = [NSString stringWithFormat: \
1290                     @"%@ (%i/%i)", _NS("Streaming/Transcoding Wizard"), \
1291                     ( x + 1 ), y];
1292                 input_item_t *p_input = input_ItemNew( p_playlist, \
1293                     [[[o_userSelections objectForKey:@"pathToStrm"] \
1294                     objectAtIndex:x] UTF8String], \
1295                     [tempString UTF8String] );
1296                 vlc_input_item_AddOption( p_input, [[[o_userSelections \
1297                     objectForKey:@"opts"] objectAtIndex: x] UTF8String]);
1298
1299                 if(! [[o_userSelections objectForKey:@"partExtractFrom"] \
1300                     isEqualToString:@""] )
1301                 {
1302                     vlc_input_item_AddOption( p_input, [[NSString \
1303                         stringWithFormat: @"start-time=%@", [o_userSelections \
1304                         objectForKey: @"partExtractFrom"]] UTF8String] );
1305                 }
1306
1307                 if(! [[o_userSelections objectForKey:@"partExtractTo"] \
1308                     isEqualToString:@""] )
1309                 {
1310                     vlc_input_item_AddOption( p_input, [[NSString \
1311                         stringWithFormat: @"stop-time=%@", [o_userSelections \
1312                         objectForKey: @"partExtractTo"]] UTF8String] );
1313                 }
1314
1315                 vlc_input_item_AddOption( p_input, [[NSString stringWithFormat: \
1316                     @"ttl=%@", [o_userSelections objectForKey:@"ttl"]] \
1317                     UTF8String] );
1318
1319                 playlist_PlaylistAddInput( p_playlist, p_input, PLAYLIST_STOP, PLAYLIST_END );
1320
1321                 if( x == 0 )
1322                 {
1323                     /* play the first item and add the others afterwards */
1324                     playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input );
1325                     playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL,
1326                                       p_item );
1327                 }
1328
1329                 x += 1;
1330             }
1331
1332             vlc_object_release(p_playlist);
1333         } else {
1334             msg_Err( p_intf, "unable to find playlist" );
1335         }
1336
1337         /* close the window, since we are done */
1338         [o_wizard_window close];
1339     }
1340 }
1341
1342 - (void)rebuildCodecMenus
1343 {
1344     int savePreviousSel = 0;
1345     savePreviousSel = [o_t4_pop_videoCodec indexOfSelectedItem];
1346     [o_t4_pop_videoCodec removeAllItems];
1347     unsigned int x;
1348     x = 0;
1349     while (x != [o_videoCodecs count])
1350     {
1351         [o_t4_pop_videoCodec addItemWithTitle:[[o_videoCodecs objectAtIndex:x] \
1352             objectAtIndex:0]];
1353         x += 1;
1354     }
1355     if( keepSettingsOrNot && savePreviousSel >= 0 )
1356         [o_t4_pop_videoCodec selectItemAtIndex: savePreviousSel];
1357
1358     savePreviousSel = [o_t4_pop_audioCodec indexOfSelectedItem];
1359     [o_t4_pop_audioCodec removeAllItems];
1360     x = 0;
1361     while (x != [o_audioCodecs count])
1362     {
1363         [o_t4_pop_audioCodec addItemWithTitle:[[o_audioCodecs objectAtIndex:x] \
1364             objectAtIndex:0]];
1365         x += 1;
1366     }
1367     if( keepSettingsOrNot && savePreviousSel >= 0 )
1368         [o_t4_pop_audioCodec selectItemAtIndex: savePreviousSel];
1369 }
1370
1371 - (void)showSummary
1372 {
1373     [o_btn_forward setTitle: _NS("Finish")];
1374     /* if we will transcode multiple items, just give their number; otherwise
1375      * print the URI of the single item */
1376     if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
1377         [o_t8_fld_inptStream setStringValue: [NSString stringWithFormat:
1378             _NS("%i items"), 
1379             [[o_userSelections objectForKey:@"pathToStrm"] count]]];
1380     else
1381         [o_t8_fld_inptStream setStringValue: 
1382             [[o_userSelections objectForKey:@"pathToStrm"] objectAtIndex: 0]];
1383     
1384     if ([[o_userSelections objectForKey:@"localPb"] isEqualToString: @"YES"])
1385     {
1386         [o_t8_fld_local setStringValue: _NS("yes")];
1387     } else {
1388         [o_t8_fld_local setStringValue: _NS("no")];
1389     }
1390
1391     if ([[o_userSelections objectForKey:@"partExtract"] isEqualToString: @"YES"])
1392     {
1393         [o_t8_fld_partExtract setStringValue: [NSString stringWithFormat: 
1394             _NS("yes: from %@ to %@ secs"), 
1395             [o_userSelections objectForKey:@"partExtractFrom"],
1396             [o_userSelections objectForKey:@"partExtractTo"]]];
1397     } else {
1398         [o_t8_fld_partExtract setStringValue: _NS("no")];
1399     }
1400
1401     if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"YES"])
1402     {
1403         [o_t8_fld_trnscdVideo setStringValue: [NSString stringWithFormat:
1404             _NS("yes: %@ @ %@ kb/s"),
1405             [[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
1406             @"trnscdVideoCodec"] intValue]] objectAtIndex:0],
1407             [o_userSelections objectForKey:@"trnscdVideoBitrate"]]];
1408     }
1409     else
1410     {
1411         [o_t8_fld_trnscdVideo setStringValue: _NS("no")];
1412     }
1413     if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
1414     {
1415         [o_t8_fld_trnscdAudio setStringValue: [NSString stringWithFormat:
1416             _NS("yes: %@ @ %@ kb/s"),
1417             [[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
1418                 @"trnscdAudioCodec"] intValue]] objectAtIndex:0],
1419             [o_userSelections objectForKey:@"trnscdAudioBitrate"]]];
1420     }
1421     else
1422     {
1423         [o_t8_fld_trnscdAudio setStringValue: _NS("no")];
1424     }
1425
1426
1427     if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
1428     {
1429         /* we are streaming and perhaps also transcoding */
1430         [o_t8_fld_saveFileTo setStringValue: @"-"];
1431         [o_t8_fld_strmgMthd setStringValue: [[o_strmgMthds objectAtIndex: \
1432             [[o_userSelections objectForKey:@"stmgMhd"] intValue]] \
1433             objectAtIndex:1]];
1434         [o_t8_fld_destination setStringValue: [o_userSelections objectForKey: \
1435             @"stmgDest"]];
1436         [o_t8_fld_ttl setStringValue: [o_userSelections objectForKey:@"ttl"]];
1437         if ([[o_userSelections objectForKey:@"sap"] isEqualToString: @"YES"])
1438         {
1439             [o_t8_fld_sap setStringValue: 
1440                 [_NS("yes") stringByAppendingFormat: @": \"%@\"",
1441                     [o_userSelections objectForKey:@"sapText"]]];
1442         }else{
1443             [o_t8_fld_sap setStringValue: _NS("no")];
1444         }
1445     } else {
1446         /* we are transcoding */
1447         [o_t8_fld_strmgMthd setStringValue: @"-"];
1448         [o_t8_fld_destination setStringValue: @"-"];
1449         [o_t8_fld_ttl setStringValue: @"-"];
1450         [o_t8_fld_sap setStringValue: @"-"];
1451         /* do only show the destination of the first item and add a counter, if needed */
1452         if( [[o_userSelections objectForKey: @"trnscdFilePath"] count] > 1 )
1453             [o_t8_fld_saveFileTo setStringValue: \
1454                 [NSString stringWithFormat: @"%@ (+%i)", \
1455                 [[o_userSelections objectForKey: @"trnscdFilePath"] objectAtIndex:0], \
1456                 ([[o_userSelections objectForKey: @"trnscdFilePath"] count] - 1)]];
1457         else
1458             [o_t8_fld_saveFileTo setStringValue: \
1459                 [[o_userSelections objectForKey: @"trnscdFilePath"] objectAtIndex:0]];
1460     }
1461     [o_t8_fld_encapFormat setStringValue: [[o_encapFormats objectAtIndex: \
1462         [[o_userSelections objectForKey:@"encapFormat"] intValue]] objectAtIndex:1]];
1463
1464     [self createOpts];
1465     [o_t8_fld_mrl setStringValue: [[o_userSelections objectForKey:@"opts"]
1466         objectAtIndex: 0]];
1467
1468     [o_tab_pageHolder selectTabViewItemAtIndex:7];
1469 }
1470
1471 - (void) createOpts
1472 {
1473     NSMutableString * o_opts_string = [NSMutableString stringWithString:@""];
1474     NSMutableString *o_trnscdCmd = [NSMutableString stringWithString:@""];
1475     NSMutableString *o_duplicateCmd = [NSMutableString stringWithString:@""];
1476     int x = 0;
1477     int y = [[o_userSelections objectForKey:@"pathToStrm"] count];
1478     NSMutableArray * tempArray = [[NSMutableArray alloc] init];
1479     
1480     /* loop to create an opt-string for each item we're processing */
1481     while( x != y )
1482     {
1483         /* check whether we transcode the audio and/or the video and compose a
1484          * string reflecting the settings, if needed */
1485         if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"YES"])
1486         {
1487             [o_trnscdCmd appendString: @"transcode{"];
1488             [o_trnscdCmd appendFormat: @"vcodec=%s,vb=%i", [[[o_videoCodecs \
1489                 objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] \
1490                 intValue]] objectAtIndex:1] UTF8String],  [[o_userSelections \
1491                 objectForKey:@"trnscdVideoBitrate"] intValue]];
1492             if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
1493             {
1494                 [o_trnscdCmd appendString: @","];
1495             }
1496             else
1497             {
1498                 [o_trnscdCmd appendString: @"}:"];
1499             }
1500         }
1501     
1502         /* check whether the user requested local playback. if yes, prepare the
1503          * string, if not, let it empty */
1504         if ([[o_userSelections objectForKey:@"localPb"] isEqualToString:@"YES"])
1505         {
1506             [o_duplicateCmd appendString: @"duplicate{dst=display,dst=\""];
1507         }
1508     
1509         if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
1510         {
1511             if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"NO"])
1512             {
1513                 /* in case we transcode the audio only, add this */
1514                 [o_trnscdCmd appendString: @"transcode{"];
1515             }
1516             [o_trnscdCmd appendFormat: @"acodec=%s,ab=%i}:", [[[o_audioCodecs \
1517                 objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] \
1518                 intValue]] objectAtIndex:1] UTF8String],  [[o_userSelections \
1519                 objectForKey:@"trnscdAudioBitrate"] intValue]];
1520         }
1521     
1522         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"trnscd"])
1523         {
1524             /* we are just transcoding and dumping the stuff to a file */
1525             [o_opts_string appendFormat: \
1526                 @":sout=#%s%sstandard{mux=%s,dst=%s,access=file}", [o_duplicateCmd \
1527                 UTF8String], [o_trnscdCmd UTF8String], [[[o_encapFormats \
1528                 objectAtIndex: [[o_userSelections objectForKey:@"encapFormat"] \
1529                 intValue]] objectAtIndex:0] UTF8String], [[[o_userSelections \
1530                 objectForKey: @"trnscdFilePath"] objectAtIndex: x] UTF8String]];
1531         }
1532         else
1533         {
1534
1535             /* we are streaming */
1536             if ([[o_userSelections objectForKey:@"sap"] isEqualToString:@"YES"])
1537             {
1538                 /* SAP-Announcement is requested */
1539                 NSMutableString *o_sap_option = [NSMutableString stringWithString:@""];
1540                 if([[o_userSelections objectForKey:@"sapText"] isEqualToString:@""])
1541                 {
1542                     [o_sap_option appendString: @"sap"];
1543                 }
1544                 else
1545                 {
1546                     [o_sap_option appendFormat: @"sap,name=\"%s\"", \
1547                         [[o_userSelections objectForKey:@"sapText"] UTF8String]];
1548                 }
1549                 [o_opts_string appendFormat: \
1550                     @":sout=#%s%sstandard{mux=%s,dst=%s,access=%s,%s}", \
1551                     [o_duplicateCmd UTF8String], [o_trnscdCmd UTF8String], \
1552                     [[[o_encapFormats objectAtIndex: [[o_userSelections \
1553                     objectForKey: @"encapFormat"] intValue]] objectAtIndex:0] \
1554                     UTF8String], [[o_userSelections objectForKey: @"stmgDest"] \
1555                     UTF8String], [[[o_strmgMthds objectAtIndex: [[o_userSelections \
1556                     objectForKey: @"stmgMhd"] intValue]] objectAtIndex:0] \
1557                     UTF8String], [o_sap_option UTF8String]];
1558             }
1559             else
1560             {
1561                 /* no SAP, just streaming */
1562                 [o_opts_string appendFormat: \
1563                     @":sout=#%s%sstandard{mux=%s,dst=%s,access=%s}", \
1564                     [o_duplicateCmd UTF8String], [o_trnscdCmd UTF8String], \
1565                     [[[o_encapFormats objectAtIndex: [[o_userSelections \
1566                     objectForKey: @"encapFormat"] intValue]] objectAtIndex:0] \
1567                     UTF8String], [[o_userSelections objectForKey: \
1568                     @"stmgDest"] UTF8String], [[[o_strmgMthds objectAtIndex: \
1569                     [[o_userSelections objectForKey: @"stmgMhd"] intValue]] \
1570                     objectAtIndex:0] UTF8String]];
1571             }
1572         }
1573
1574         /* check whether the user requested local playback. if yes, close the
1575          * string with an additional bracket */
1576         if ([[o_userSelections objectForKey:@"localPb"] isEqualToString:@"YES"])
1577         {
1578             [o_opts_string appendString: @"\"}"];
1579         }
1580
1581         [tempArray addObject: o_opts_string];
1582
1583         o_opts_string = [NSMutableString stringWithString:@""];
1584         o_trnscdCmd = [NSMutableString stringWithString:@""];
1585         o_duplicateCmd = [NSMutableString stringWithString:@""];
1586         x += 1;
1587     }
1588     [o_userSelections setObject:[NSArray arrayWithArray: tempArray] forKey:@"opts"];
1589     [tempArray release];
1590 }
1591
1592 - (IBAction)prevTab:(id)sender
1593 {
1594     if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Summary"])
1595     {
1596         /* check whether we are streaming or transcoding and go back */
1597         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
1598         {
1599             /* show "Streaming 2" */
1600             [o_tab_pageHolder selectTabViewItemAtIndex:5];
1601         }else{
1602             /* show "Transcode 2" */
1603             [o_tab_pageHolder selectTabViewItemAtIndex:6];
1604         }
1605         /* rename the forward-button */
1606         [o_btn_forward setTitle: _NS("Next")];
1607     }
1608     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1609         @"Transcode 2"])
1610     {
1611         /* show "Encap" */
1612         [o_tab_pageHolder selectTabViewItemAtIndex:4];
1613     }
1614     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1615         @"Streaming 2"])
1616     {
1617         /* show "Encap" */
1618         [o_tab_pageHolder selectTabViewItemAtIndex:4];
1619     }
1620     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1621         @"Encap"])
1622     {
1623         /* show "Transcode 1" */
1624         [o_tab_pageHolder selectTabViewItemAtIndex:3];
1625     }
1626     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1627         @"Streaming 1"])
1628     {
1629         /* show "Input" */
1630         [o_tab_pageHolder selectTabViewItemAtIndex:1];
1631     }
1632     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1633         @"Transcode 1"])
1634     {
1635         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
1636         {
1637             /* show "Streaming 1" */
1638             [o_tab_pageHolder selectTabViewItemAtIndex:2];
1639         }else{
1640             /* show "Input" */
1641             [o_tab_pageHolder selectTabViewItemAtIndex:1];
1642         }
1643     }
1644     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
1645         @"Input"])
1646     {
1647         /* reset the wizard before going backwards. Otherwise, we might get
1648          * unwanted behaviours in the Encap-Selection */
1649         [self resetWizard];
1650         /* show "Hello" */
1651         [o_tab_pageHolder selectTabViewItemAtIndex:0];
1652         /* disable backwards-btn */
1653         [o_btn_backward setEnabled:NO];
1654     }
1655 }
1656
1657 - (IBAction)t1_mrInfo_streaming:(id)sender
1658 {
1659     /* show a sheet for the help */
1660     NSBeginInformationalAlertSheet(_NS("Stream to network"), \
1661         _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
1662         _NS("This allows to stream on a network."));
1663 }
1664
1665 - (IBAction)t1_mrInfo_transcode:(id)sender
1666 {
1667     /* show a sheet for the help */
1668     NSBeginInformationalAlertSheet(_NS("Transcode/Save to file"), \
1669         _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
1670         _NS("This allows to save a stream to a file. The "\
1671         "can be reencoded on the fly. Whatever "\
1672         "VLC can read can be saved.\nPlease note that VLC is not very suited " \
1673         "for file to file transcoding. Its transcoding " \
1674         "features are however useful to save network streams, for example."));
1675 }
1676
1677 - (IBAction)t2_addNewStream:(id)sender
1678 {
1679     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
1680     SEL sel = @selector(t2_getNewStreamFromDialog:returnCode:contextInfo:);
1681     [openPanel beginSheetForDirectory:nil file:nil types:nil modalForWindow: \
1682         o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
1683 }
1684
1685 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: \
1686     (int)returnCode contextInfo: (void *)contextInfo
1687 {
1688     if (returnCode == NSOKButton)
1689     {
1690         [o_t2_fld_pathToNewStrm setStringValue: [@"file://" \
1691             stringByAppendingString: [sheet filename]]];
1692     }
1693 }
1694
1695 - (IBAction)t2_chooseStreamOrPlst:(id)sender
1696 {
1697     /* enable and disable the respective items depending on user's choice */
1698     NSString *o_mode;
1699     o_mode = [[o_t2_matrix_inputSourceType selectedCell] title];
1700
1701     if( [o_mode isEqualToString: _NS("Select a stream")] )
1702     {
1703         [o_t2_btn_chooseFile setEnabled:YES];
1704         [o_t2_fld_pathToNewStrm setEnabled:YES];
1705         [o_t2_tbl_plst setEnabled:NO];
1706     } else {
1707         [o_t2_btn_chooseFile setEnabled:NO];
1708         [o_t2_fld_pathToNewStrm setEnabled:NO];
1709         [o_t2_tbl_plst setEnabled:YES];
1710     }
1711 }
1712
1713 - (IBAction)t2_enableExtract:(id)sender
1714 {
1715     /* enable/disable the respective items */
1716     if([o_t2_ckb_enblPartExtrct state] == NSOnState)
1717     {
1718         [o_t2_fld_prtExtrctFrom setEnabled:YES];
1719         [o_t2_fld_prtExtrctTo setEnabled:YES];
1720     } else {
1721         [o_t2_fld_prtExtrctFrom setEnabled:NO];
1722         [o_t2_fld_prtExtrctTo setEnabled:NO];
1723         [o_t2_fld_prtExtrctFrom setStringValue:@""];
1724         [o_t2_fld_prtExtrctTo setStringValue:@""];
1725     }
1726 }
1727
1728 - (IBAction)t3_strmMthdChanged:(id)sender
1729 {
1730     /* change the captions of o_t3_txt_destInfo according to the chosen
1731      * streaming method */
1732     int mode;
1733     mode = [[o_t3_matrix_stmgMhd selectedCell] tag];
1734     if( mode == 0 )
1735     {
1736         /* HTTP */
1737         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:0] \
1738             objectAtIndex:2]];
1739         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:0] \
1740             objectAtIndex:3]];
1741     }
1742     else if( mode == 1 )
1743     {
1744         /* MMS */
1745         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:1] \
1746             objectAtIndex:2]];
1747         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:1] \
1748             objectAtIndex:3]];
1749     }
1750     else if( mode == 2 )
1751     {
1752         /* UDP-Unicast */
1753         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:2] \
1754             objectAtIndex:2]];
1755         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:2] \
1756         objectAtIndex:3]];
1757     }
1758     else if( mode == 3 )
1759     {
1760         /* UDP-Multicast */
1761         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:3] \
1762             objectAtIndex:2]];
1763         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:3] \
1764         objectAtIndex:3]];
1765     }
1766     else if( mode == 4 )
1767     {
1768         /* RTP-Unicast */
1769         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:4] \
1770             objectAtIndex:2]];
1771         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:4] \
1772             objectAtIndex:3]];
1773     }
1774     else if( mode == 5 )
1775     {
1776         /* RTP-Multicast */
1777         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:5] \
1778             objectAtIndex:2]];
1779         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:5] \
1780         objectAtIndex:3]];
1781     }
1782 }
1783
1784 - (IBAction)t4_AudCdcChanged:(id)sender
1785 {
1786     /* update codec info */
1787     [o_t4_txt_hintAudio setStringValue:[[o_audioCodecs objectAtIndex: \
1788         [o_t4_pop_audioCodec indexOfSelectedItem]] objectAtIndex:2]];
1789 }
1790
1791 - (IBAction)t4_enblAudTrnscd:(id)sender
1792 {
1793     /* enable/disable the respective items */
1794     if([o_t4_ckb_audio state] == NSOnState)
1795     {
1796         [o_t4_pop_audioCodec setEnabled:YES];
1797         [o_t4_pop_audioBitrate setEnabled:YES];
1798         [o_t4_txt_hintAudio setStringValue: _NS("Select your audio codec. " \
1799         "Click one to get more information.")];
1800     } else {
1801         [o_t4_pop_audioCodec setEnabled:NO];
1802         [o_t4_pop_audioBitrate setEnabled:NO];
1803         [o_t4_txt_hintAudio setStringValue: _NS("Enabling this allows to transcode " \
1804         "the audio track if one is present in the stream.")];
1805     }
1806 }
1807
1808 - (IBAction)t4_enblVidTrnscd:(id)sender
1809 {
1810     /* enable/disable the respective items */
1811     if([o_t4_ckb_video state] == NSOnState)
1812     {
1813         [o_t4_pop_videoCodec setEnabled:YES];
1814         [o_t4_pop_videoBitrate setEnabled:YES];
1815         [o_t4_txt_hintVideo setStringValue: _NS("Select your video codec. "\
1816         "Click one to get more information.")];
1817     } else {
1818         [o_t4_pop_videoCodec setEnabled:NO];
1819         [o_t4_pop_videoBitrate setEnabled:NO];
1820         [o_t4_txt_hintVideo setStringValue: _NS("Enabling this allows to transcode " \
1821         "the video track if one is present in the stream.")];
1822
1823     }
1824 }
1825
1826 - (IBAction)t4_VidCdcChanged:(id)sender
1827 {
1828     /* update codec info */
1829     [o_t4_txt_hintVideo setStringValue:[[o_videoCodecs objectAtIndex: \
1830         [o_t4_pop_videoCodec indexOfSelectedItem]] objectAtIndex:2]];
1831 }
1832
1833 - (IBAction)t6_enblSapAnnce:(id)sender
1834 {
1835     /* enable/disable input fld */
1836     if([o_t6_ckb_sap state] == NSOnState)
1837     {
1838         [o_t6_fld_sap setEnabled:YES];
1839     } else {
1840         [o_t6_fld_sap setEnabled:NO];
1841         [o_t6_fld_sap setStringValue:@""];
1842     }
1843 }
1844
1845 - (IBAction)t6_mrInfo_ttl:(id)sender
1846 {
1847     /* show a sheet for the help */
1848     NSBeginInformationalAlertSheet(_NS("Time-To-Live (TTL)"), \
1849         _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
1850         _NS("This allows to define the TTL (Time-To-Live) of the stream. "\
1851             "This parameter is the maximum number of routers your stream can " \
1852             "go through. If you don't know what it means, or if you want to " \
1853             "stream on your local network only, leave this setting to 1."));
1854 }
1855
1856 - (IBAction)t6_mrInfo_sap:(id)sender
1857 {
1858     /* show a sheet for the help */
1859     NSBeginInformationalAlertSheet(_NS("SAP Announce"), \
1860         _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
1861         _NS("When streaming using UDP, the streams can be " \
1862         "announced using the SAP/SDP announcing protocol. This " \
1863         "way, the clients won't have to type in the multicast address, it " \
1864         "will appear in their playlist if they enable the SAP extra " \
1865         "interface.\nIf you want to give a name to your stream, enter it " \
1866         "here, else, a default name will be used."));
1867 }
1868
1869 - (IBAction)t67_mrInfo_local:(id)sender
1870 {
1871     /* show a sheet for the help */
1872     NSBeginInformationalAlertSheet(_NS("Local playback"), \
1873             _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
1874             _NS("When this option is enabled, the stream will be both played " \
1875             "and transcoded/streamed.\n\nNote that this requires much more " \
1876             "CPU power than simple transcoding or streaming."));
1877 }
1878
1879 - (IBAction)t7_selectTrnscdDestFile:(id)sender
1880 {
1881     /* provide a save-to-dialogue, so the user can choose a location for 
1882      * his/her new file. We take a modified NSOpenPanel to select a folder
1883      * and a plain NSSavePanel to save a single file. */
1884
1885     SEL sel = @selector(t7_getTrnscdDestFile:returnCode:contextInfo:);
1886     
1887     if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
1888     {
1889         NSOpenPanel * saveFolderPanel = [[NSOpenPanel alloc] init];
1890         
1891         [saveFolderPanel setCanChooseDirectories: YES];
1892         [saveFolderPanel setCanChooseFiles: NO];
1893         [saveFolderPanel setCanSelectHiddenExtension: NO];
1894         [saveFolderPanel setCanCreateDirectories: YES];
1895         [saveFolderPanel beginSheetForDirectory:nil file:nil modalForWindow: \
1896         o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
1897     }
1898     else
1899     {
1900         NSSavePanel * saveFilePanel = [[NSSavePanel alloc] init];
1901
1902         /* don't use ".ps" as suffix, since the OSX Finder confuses our 
1903          * creations with PostScript-files and wants to open them with 
1904          * Preview.app */
1905         NSString * theEncapFormat = [[o_encapFormats objectAtIndex: \
1906         [[o_userSelections objectForKey:@"encapFormat"] intValue]] \
1907         objectAtIndex:0];
1908         if( theEncapFormat != @"ps" )
1909             [saveFilePanel setRequiredFileType: theEncapFormat];
1910         else
1911             [saveFilePanel setRequiredFileType: @"mpg"];
1912
1913         [saveFilePanel setCanSelectHiddenExtension: YES];
1914         [saveFilePanel setCanCreateDirectories: YES];
1915         [saveFilePanel beginSheetForDirectory:nil file:nil modalForWindow: \
1916         o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
1917     }
1918 }
1919
1920 - (void)t7_getTrnscdDestFile: (NSOpenPanel *)sheet returnCode: \
1921     (int)returnCode contextInfo: (void *)contextInfo
1922 {
1923     if (returnCode == NSOKButton)
1924     {
1925         /* output returned path to text-field, add a / to the end if the user
1926          * selected a folder */
1927         if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
1928             [o_t7_fld_filePath setStringValue: [NSString stringWithFormat: \
1929                 @"%@/", [sheet filename]]];
1930         else
1931             [o_t7_fld_filePath setStringValue:[sheet filename]];
1932     }
1933     [sheet release];
1934 }
1935
1936 @end