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