Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

wizard.m

00001 /*****************************************************************************
00002  * wizard.m: MacOS X Streaming Wizard
00003  *****************************************************************************
00004  * Copyright (C) 2005 the VideoLAN team
00005  * $Id: wizard.m 13451 2005-11-29 14:08:47Z fkuehne $
00006  *
00007  * Authors: Felix Kühne <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 
00025 /*****************************************************************************
00026  * Note: this code is partially based upon ../wxwidgets/wizard.cpp and
00027  *         ../wxwidgets/streamdata.h; both written by Clément Stenac.
00028  *****************************************************************************/
00029 
00030 
00031 /*****************************************************************************
00032  * Preamble
00033  *****************************************************************************/
00034 #import "wizard.h"
00035 #import "intf.h"
00036 #import "network.h"
00037 #import "playlist.h"
00038 
00039 /*****************************************************************************
00040  * VLCWizard implementation
00041  *****************************************************************************/
00042 
00043 @implementation VLCWizard
00044 
00045 static VLCWizard *_o_sharedInstance = nil;
00046 
00047 + (VLCWizard *)sharedInstance
00048 {
00049     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
00050 }
00051 
00052 - (id)init
00053 {
00054     if (_o_sharedInstance) {
00055         [self dealloc];
00056     } else {
00057         _o_sharedInstance = [super init];
00058     }
00059 
00060     return _o_sharedInstance;
00061 }
00062 
00063 - (void)dealloc
00064 {
00065     [o_userSelections release];
00066     [o_videoCodecs release];
00067     [o_audioCodecs release];
00068     [o_encapFormats release];
00069     [super dealloc];
00070 }
00071 
00072 - (void)awakeFromNib
00073 {
00074     /* some minor cleanup */
00075     [o_t2_tbl_plst setEnabled:NO];
00076     [o_wizardhelp_window setExcludedFromWindowsMenu:YES];
00077     o_userSelections = [[NSMutableDictionary alloc] init];
00078     [o_btn_backward setEnabled:NO];
00079 
00080     /* add audio-bitrates for transcoding */
00081     NSArray * audioBitratesArray;
00082     audioBitratesArray = [NSArray arrayWithObjects: @"512", @"256", @"192", \
00083         @"128", @"64", @"32", @"16", nil ];
00084     [o_t4_pop_audioBitrate removeAllItems];
00085     [o_t4_pop_audioBitrate addItemsWithTitles: audioBitratesArray];
00086     [o_t4_pop_audioBitrate selectItemWithTitle: @"192"];
00087 
00088     /* add video-bitrates for transcoding */
00089     NSArray * videoBitratesArray;
00090     videoBitratesArray = [NSArray arrayWithObjects: @"3072", @"2048", @"1024", \
00091         @"768", @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
00092     [o_t4_pop_videoBitrate removeAllItems];
00093     [o_t4_pop_videoBitrate addItemsWithTitles: videoBitratesArray];
00094     [o_t4_pop_videoBitrate selectItemWithTitle: @"1024"];
00095 
00096     /* fill 2 global arrays with arrays containing all codec-related information
00097      * - one array per codec named by its short name to define the encap-compability,
00098      *     cmd-names, real names, more info in the order: realName, shortName,
00099      *     moreInfo, encaps */
00100     NSArray * o_mp1v;
00101     NSArray * o_mp2v;
00102     NSArray * o_mp4v;
00103     NSArray * o_div1;
00104     NSArray * o_div2;
00105     NSArray * o_div3;
00106     NSArray * o_h263;
00107     NSArray * o_h264;
00108     NSArray * o_wmv1;
00109     NSArray * o_wmv2;
00110     NSArray * o_mjpg;
00111     NSArray * o_theo;
00112     NSArray * o_dummyVid;
00113     o_mp1v = [NSArray arrayWithObjects: @"MPEG-1 Video", @"mp1v", \
00114         _NS("MPEG-1 Video codec (usable with MPEG PS, MPEG TS, MPEG1, OGG " \
00115         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_OGG", @"MUX_RAW", \
00116         @"NO", @"NO", @"NO", @"NO", nil];
00117     o_mp2v = [NSArray arrayWithObjects: @"MPEG-2 Video", @"mp2v", \
00118         _NS("MPEG-2 Video codec (usable with MPEG PS, MPEG TS, MPEG1, OGG " \
00119         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_OGG", @"MUX_RAW", \
00120         @"NO", @"NO", @"NO", @"NO", nil];
00121     o_mp4v = [NSArray arrayWithObjects: @"MPEG-4 Video", @"mp4v", \
00122         _NS("MPEG-4 Video codec (useable with MPEG PS, MPEG TS, MPEG1, ASF, " \
00123         "MP4, OGG and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", \
00124         @"MUX_MP4", @"MUX_OGG", @"MUX_RAW", @"NO", @"NO", nil];
00125     o_div1 = [NSArray arrayWithObjects: @"DIVX 1", @"DIV1", \
00126         _NS("DivX first version (useable with MPEG TS, MPEG1, ASF and OGG)"), \
00127         @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", \
00128         @"NO", @"NO", nil];
00129     o_div2 = [NSArray arrayWithObjects: @"DIVX 2", @"DIV2", \
00130         _NS("DivX second version (useable with MPEG TS, MPEG1, ASF and OGG)"), \
00131         @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", \
00132         @"NO", @"NO", nil];
00133     o_div3 = [NSArray arrayWithObjects: @"DIVX 3", @"DIV3", \
00134         _NS("DivX third version (useable with MPEG TS, MPEG1, ASF and OGG)"), \
00135         @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", @"NO", \
00136         @"NO", @"NO", nil];
00137     o_h263 = [NSArray arrayWithObjects: @"H.263", @"h263", \
00138         _NS("H263 is a video codec optimized for videoconference " \
00139         "(low rates, useable with MPEG TS)"), @"MUX_TS", @"NO", @"NO", @"NO", \
00140         @"NO", @"NO", @"NO", @"NO", @"NO", nil];
00141     o_h264 = [NSArray arrayWithObjects: @"H.264", @"h264", \
00142         _NS("H264 is a new video codec (useable with MPEG TS and MP4)"), \
00143         @"MUX_TS", @"MUX_MP4", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", \
00144         @"NO", nil];
00145     o_wmv1 = [NSArray arrayWithObjects: @"WMV 1", @"WMV1", \
00146         _NS("WMV (Windows Media Video) 1 (useable with MPEG TS, MPEG1, ASF and " \
00147         "OGG)"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", \
00148         @"NO", @"NO", @"NO", nil];
00149     o_wmv2 = [NSArray arrayWithObjects: @"WMV 2", @"WMV2", \
00150         _NS("WMV (Windows Media Video) 2 (useable with MPEG TS, MPEG1, ASF and " \
00151         "OGG)"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", @"NO", @"NO", \
00152         @"NO", @"NO", @"NO", nil];
00153     o_mjpg = [NSArray arrayWithObjects: @"MJPEG", @"MJPG", \
00154         _NS("MJPEG consists of a series of JPEG pictures (useable with MPEG TS," \
00155         " MPEG1, ASF and OGG)"), @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", \
00156         @"NO", @"NO", @"NO", @"NO", @"NO", nil];
00157     o_theo = [NSArray arrayWithObjects: @"Theora", @"theo", \
00158         _NS("Theora is a free general-purpose codec (useable with MPEG TS)"), \
00159         @"MUX_TS", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", @"NO", nil];
00160     o_dummyVid = [NSArray arrayWithObjects: @"Dummy", @"dummy", \
00161         _NS("Dummy codec (do not transcode, useable with all encapsulation " \
00162         "formats)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4", \
00163         @"MUX_OGG", @"MUX_WAV", @"MUX_RAW", @"MUX_MOV", nil];
00164     o_videoCodecs = [[NSArray alloc] initWithObjects: o_mp1v, o_mp2v, o_mp4v, \
00165         o_div1, o_div2, o_div3, o_h263, o_h264, o_wmv1, o_wmv2, o_mjpg, o_theo, \
00166         o_dummyVid, nil];
00167     
00168 
00169     NSArray * o_mpga;
00170     NSArray * o_mp3;
00171     NSArray * o_mp4a;
00172     NSArray * o_a52;
00173     NSArray * o_vorb;
00174     NSArray * o_flac;
00175     NSArray * o_spx;
00176     NSArray * o_s16l;
00177     NSArray * o_fl32;
00178     NSArray * o_dummyAud;
00179     o_mpga = [NSArray arrayWithObjects: @"MPEG Audio", @"mpga", \
00180         _NS("The standard MPEG audio (1/2) format (useable with MPEG PS, MPEG TS, " \
00181         "MPEG1, ASF, OGG and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", \
00182         @"MUX_ASF", @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", nil];
00183     o_mp3 = [NSArray arrayWithObjects: @"MP3", @"mp3", \
00184         _NS("MPEG Audio Layer 3 (useable with MPEG PS, MPEG TS, MPEG1, ASF, OGG " \
00185         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", \
00186         @"MUX_RAW", @"-1", @"-1", @"-1", nil];
00187     o_mp4a = [NSArray arrayWithObjects: @"MPEG 4 Audio", @"mp4a", \
00188         _NS("Audio format for MPEG4 (useable with MPEG TS and MPEG4)"), @"MUX_TS", \
00189         @"MUX_MP4", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
00190     o_a52 = [NSArray arrayWithObjects: @"A/52", @"a52", 
00191         _NS("DVD audio format (useable with MPEG PS, MPEG TS, MPEG1, ASF, OGG " \
00192         "and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG", \
00193         @"MUX_RAW", @"-1", @"-1", @"-1", nil];
00194     o_vorb = [NSArray arrayWithObjects: @"Vorbis", @"vorb", \
00195         _NS("Vorbis is a free audio codec (useable with OGG)"), @"MUX_OGG", \
00196         @"-1",  @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
00197     o_flac = [NSArray arrayWithObjects: @"FLAC", @"flac", \
00198         _NS("FLAC is a lossless audio codec (useable with OGG and RAW)"), \
00199         @"MUX_OGG", @"MUX_RAW", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", \
00200         @"-1", nil];
00201     o_spx = [NSArray arrayWithObjects: @"Speex", @"spx", \
00202         _NS("A free audio codec dedicated to compression of voice (useable " \
00203         "with OGG"), @"MUX_OGG", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", \
00204         @"-1", @"-1", nil];
00205     o_s16l = [NSArray arrayWithObjects: @"Uncompressed, integer", @"s16l", \
00206         _NS("Uncompressed audio samples (useable with WAV)"), @"MUX_WAV", \
00207         @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
00208     o_fl32 = [NSArray arrayWithObjects: @"Uncompressed, floating", @"fl32", \
00209         _NS("Uncompressed audio samples (useable with WAV)"), @"MUX_WAV", \
00210         @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
00211     o_dummyAud = [NSArray arrayWithObjects: @"Dummy", @"dummy", \
00212         _NS("Dummy codec (do not transcode, useable with all encapsulation " \
00213         "formats)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4", \
00214         @"MUX_OGG", @"MUX_RAW", @"MUX_MOV", @"MUX_WAV", nil];
00215     o_audioCodecs = [[NSArray alloc] initWithObjects: o_mpga, o_mp3, o_mp4a, \
00216         o_a52, o_vorb, o_flac, o_spx, o_s16l, o_fl32, o_dummyAud, nil];
00217 
00218 
00219     /* fill another global array with all information about the encap-formats
00220      * note that the order of the formats inside the g. array is the same as on
00221      * the encap-tab */
00222     NSArray * o_ps;
00223     NSArray * o_ts;
00224     NSArray * o_mpeg;
00225     NSArray * o_ogg;
00226     NSArray * o_raw;
00227     NSArray * o_asf;
00228     NSArray * o_avi;
00229     NSArray * o_mp4;
00230     NSArray * o_mov;
00231     NSArray * o_wav;
00232     NSArray * o_asfh;
00233     o_ps = [NSArray arrayWithObjects: @"ps", @"MPEG PS", \
00234         _NS("MPEG Program Stream"), @"mpg", nil];
00235     o_ts = [NSArray arrayWithObjects: @"ts", @"MPEG TS", \
00236         _NS("MPEG Transport Stream"), nil];
00237     o_mpeg = [NSArray arrayWithObjects: @"ps", @"MPEG 1", \
00238         _NS("MPEG 1 Format"), @"mpg", nil];
00239     o_ogg = [NSArray arrayWithObjects: @"ogg", @"OGG", @"OGG", nil];
00240     o_raw = [NSArray arrayWithObjects: @"raw", @"RAW", @"RAW", nil];
00241     o_asf = [NSArray arrayWithObjects: @"asf", @"ASF", @"ASF", nil];
00242     o_avi = [NSArray arrayWithObjects: @"avi", @"AVI", @"AVI", nil];
00243     o_mp4 = [NSArray arrayWithObjects: @"mp4", @"MP4", @"MPEG4", nil];
00244     o_mov = [NSArray arrayWithObjects: @"mov", @"MOV", @"MOV", nil];
00245     o_wav = [NSArray arrayWithObjects: @"wav", @"WAV", @"WAV", nil];
00246     o_asfh = [NSArray arrayWithObjects: @"asfh", @"ASFH", @"ASFH", nil];
00247     o_encapFormats = [[NSArray alloc] initWithObjects: o_ps, o_ts, o_mpeg, \
00248         o_ogg, o_raw, o_asf, o_avi, o_mp4, o_mov, o_wav, o_asfh, nil];
00249 
00250     /* yet another array on streaming methods including help texts */
00251     NSArray * o_http;
00252     NSArray * o_mms;
00253     NSArray * o_udp_uni;
00254     NSArray * o_udp_multi;
00255     o_http = [NSArray arrayWithObjects: @"http", @"HTTP", _NS("Enter the local " \
00256         "addresses you want to listen to. Do not enter anything if you want to " \
00257         "listen to all adresses or if you don't understand. This is generally " \
00258         "the best thing to do. Other computers can then access the stream at " \
00259         "http://yourip:8080 by default.") , _NS("Use this to stream to several " \
00260         "computers. This method is less efficient, as the server needs to send " \
00261         "the stream several times."), nil];
00262     o_mms = [NSArray arrayWithObjects: @"mmsh", @"MMS", _NS("Enter the local " \
00263         "addresses you want to listen to. Do not enter anything if you want to " \
00264         "listen to all adresses or if you don't understand. This is generally " \
00265         "the best thing to do. Other computers can then access the stream at " \
00266         "mms://yourip:8080 by default."), _NS("Use this to stream to several " \
00267         "computers using the Microsoft MMS protocol. This protocol is used as " \
00268         "transport method by many Microsoft's softwares. Note that only a " \
00269         "small part of the MMS protocol is supported (MMS encapsulated in " \
00270         "HTTP)." ), nil];
00271     o_udp_uni = [NSArray arrayWithObjects: @"udp", @"UDP-Unicast", _NS("Enter " \
00272         "the address of the computer to stream to."), _NS("Use this to stream " \
00273         "to a single computer."), nil];
00274     o_udp_multi = [NSArray arrayWithObjects: @"udp", @"UDP-Multicast", _NS("Enter " \
00275         "the multicast address to stream to in this field. This must be an IP " \
00276         "address between 224.0.0.0 and 239.255.255.255. For a private use, " \
00277         "enter an address beginning with 239.255."), _NS("Use this to stream " \
00278         "to a dynamic group of computers on a multicast-enabled network. This " \
00279         "is the most efficient method to stream to several computers, but it " \
00280         "does not work over Internet."), nil];
00281     o_strmgMthds = [[NSArray alloc] initWithObjects: o_http, o_mms, \
00282         o_udp_uni, o_udp_multi, nil];
00283 }
00284 
00285 - (void)showWizard
00286 {
00287     /* just present the window to the user */
00288     [o_tab_pageHolder selectFirstTabViewItem:self];
00289 
00290     [o_wizard_window center];
00291     [o_wizard_window displayIfNeeded];
00292     [o_wizard_window makeKeyAndOrderFront:nil];
00293 }
00294 
00295 - (void)resetWizard
00296 {
00297     /* reset the wizard-window to its default values */
00298 
00299     [o_userSelections removeAllObjects];
00300     [o_t1_matrix_strmgOrTrnscd selectCellAtRow:0 column:0];
00301     [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setState: NSOffState];
00302     [o_btn_forward setTitle: _NS("Next")];
00303 
00304     /* "Input" */
00305     [o_t2_fld_pathToNewStrm setStringValue: @""];
00306     [o_t2_ckb_enblPartExtrct setState: NSOffState];
00307     [self t2_enableExtract:nil];
00308     [o_t2_matrix_inputSourceType selectCellAtRow:0 column:0];
00309     [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setState: NSOffState];
00310     [o_t2_fld_pathToNewStrm setEnabled:YES];
00311     [o_t2_btn_chooseFile setEnabled:YES];
00312     [o_t2_tbl_plst setEnabled:NO];
00313 
00314     /* "Streaming 1" */
00315     [o_t3_fld_address setStringValue: @""];
00316     [o_t3_matrix_stmgMhd selectCellAtRow:0 column:0];
00317     [[o_t3_matrix_stmgMhd cellAtRow:0 column:1] setState: NSOffState];
00318     [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setState: NSOffState];
00319     [[o_t3_matrix_stmgMhd cellAtRow:1 column:2] setState: NSOffState];
00320 
00321     /* "Transcode 1" */
00322     [o_t4_ckb_audio setState: NSOffState];
00323     [o_t4_ckb_video setState: NSOffState];
00324     [self t4_enblVidTrnscd:nil];
00325     [self t4_enblAudTrnscd:nil];
00326 
00327     /* "Streaming 2" */
00328     [o_t6_fld_ttl setStringValue: @"1"];
00329     [o_t6_ckb_sap setState: NSOffState];
00330     [self t6_enblSapAnnce:nil];
00331 
00332     /* "Transcode 2" */
00333     [o_t7_fld_filePath setStringValue: @""];
00334 }
00335 
00336 - (void)initStrings
00337 {
00338     /* localise all strings to the users lang */
00339     /* method is called from intf.m (in method showWizard) */
00340 
00341     /* general items */
00342     [o_btn_backward setTitle: _NS("Back")];
00343     [o_btn_cancel setTitle: _NS("Cancel")];
00344     [o_btn_forward setTitle: _NS("Next")];
00345     [o_wizard_window setTitle: _NS("Streaming/Transcoding Wizard")];
00346 
00347     /* page one ("Hello") */
00348     [o_t1_txt_title setStringValue: _NS("Streaming/Transcoding Wizard")];
00349     [o_t1_txt_text setStringValue: _NS("This wizard helps you to stream, " \
00350         "transcode or save a stream.")];
00351     [o_t1_btn_mrInfo_strmg setTitle: _NS("More Info")];
00352     [o_t1_btn_mrInfo_trnscd setTitle: _NS("More Info")];
00353     [o_t1_txt_notice setStringValue: _NS("This wizard only gives access to " \
00354         "a small subset of VLC's streaming and transcoding capabilities. " \
00355         "Use the Open and Stream Output dialogs to get all of them.")];
00356     [[o_t1_matrix_strmgOrTrnscd cellAtRow:0 column:0] setTitle: _NS("Stream " \
00357         "to network")];
00358     [[o_t1_matrix_strmgOrTrnscd cellAtRow:1 column:0] setTitle: _NS("" \
00359         "Transcode/Save to file")];
00360 
00361     /* page two ("Input") */
00362     [o_t2_title setStringValue: _NS("Choose input")];
00363     [o_t2_text setStringValue: _NS("Choose here your input stream.")];
00364     [[o_t2_matrix_inputSourceType cellAtRow:0 column:0] setTitle:  \
00365         _NS("Select a stream")];
00366     [[o_t2_matrix_inputSourceType cellAtRow:1 column:0] setTitle: \
00367         _NS("Existing playlist item")];
00368     [o_t2_btn_chooseFile setTitle: _NS("Choose...")];
00369     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"1"] headerCell] \
00370         setStringValue: _NS("Title")];
00371     [[[o_t2_tbl_plst tableColumnWithIdentifier:@"2"] headerCell] \
00372         setStringValue: _NS("Author")];
00373     [o_t2_box_prtExtrct setTitle: _NS("Partial Extract")];
00374     [o_t2_ckb_enblPartExtrct setTitle: _NS("Enable")];
00375     [o_t2_ckb_enblPartExtrct setToolTip: _NS("Use this to read only a part of "\
00376         "the stream. You must be able to control the incoming stream " \
00377         "(for example, a file or a disc, but not an UDP network stream.) " \
00378         "Enter the starting and ending times (in seconds).")];
00379     [o_t2_txt_prtExtrctFrom setStringValue: _NS("From")];
00380     [o_t2_txt_prtExtrctTo setStringValue: _NS("To")];
00381 
00382     /* page three ("Streaming 1") */
00383     [o_t3_txt_title setStringValue: _NS("Streaming")];
00384     [o_t3_txt_text setStringValue: _NS("In this page, you will select how " \
00385         "your input stream will be sent.")];
00386     [o_t3_box_dest setTitle: _NS("Destination")];
00387     [o_t3_box_strmgMthd setTitle: _NS("Streaming method")];
00388     [o_t3_txt_destInfo setStringValue: _NS("Enter the address of the computer " \
00389         "to stream to.")];
00390     [[o_t3_matrix_stmgMhd cellAtRow:0 column:0] setTitle: _NS("UDP Unicast")];
00391     [[o_t3_matrix_stmgMhd cellAtRow:0 column:1] setTitle: _NS("UDP Multicast")];
00392     [o_t3_txt_strgMthdInfo setStringValue: _NS("Use this to stream to a single " \
00393         "computer.")];
00394 
00395     /* page four ("Transcode 1") */
00396     [o_t4_title setStringValue: _NS("Transcode")];
00397     [o_t4_text setStringValue: _NS("If you want to change the compression " \
00398         "format of the audio or video tracks, fill in this page. (If you only " \
00399         "want to change the container format, proceed to next page.)")];
00400     [o_t4_box_audio setTitle: _NS("Audio")];
00401     [o_t4_box_video setTitle: _NS("Video")];
00402     [o_t4_ckb_audio setTitle: _NS("Transcode audio")];
00403     [o_t4_ckb_video setTitle: _NS("Transcode video")];
00404     [o_t4_txt_videoBitrate setStringValue: _NS("Bitrate (kb/s)")];
00405     [o_t4_txt_videoCodec setStringValue: _NS("Codec")];
00406     [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio and you " \
00407         "want to transcode it, enable this.")];
00408     [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video and you " \
00409         "want to transcode it, enable this.")];
00410 
00411     /* page five ("Encap") */
00412     [o_t5_title setStringValue: _NS("Encapsulation format")];
00413     [o_t5_text setStringValue: _NS("In this page, you will select how the " \
00414         "stream will be encapsulated. Depending on the choices you made, all " \
00415                      "formats won't be available.")];
00416 
00417     /* page six ("Streaming 2") */
00418     [o_t6_title setStringValue: _NS("Additional streaming options")];
00419     [o_t6_text setStringValue: _NS("In this page, you will define a few " \
00420                               "additional parameters for your stream.")];
00421     [o_t6_txt_ttl setStringValue: _NS("Time-To-Live (TTL)")];
00422     [o_t6_btn_mrInfo_ttl setTitle: _NS("More Info")];
00423     [o_t6_ckb_sap setTitle: _NS("SAP Announce")];
00424     [o_t6_btn_mrInfo_sap setTitle: _NS("More Info")];
00425     [o_t6_ckb_local setTitle: _NS("Local playback")];
00426     [o_t6_btn_mrInfo_local setTitle: _NS("More Info")];
00427 
00428     /* page seven ("Transcode 2") */
00429     [o_t7_title setStringValue: _NS("Additional transcode options")];
00430     [o_t7_text setStringValue: _NS("In this page, you will define a few " \
00431                               "additional parameters for your transcoding.")];
00432     [o_t7_txt_saveFileTo setStringValue: _NS("Select the file to save to")];
00433     [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
00434     [o_t7_ckb_local setTitle: _NS("Local playback")];
00435     [o_t7_btn_mrInfo_local setTitle: _NS("More Info")];
00436 
00437     /* page eight ("Summary") */
00438     [o_t8_txt_text setStringValue: _NS("This page lists all your selections. " \
00439         "Click \"Finish\" to start your streaming or transcoding.")];
00440     [o_t8_txt_title setStringValue: _NS("Summary")];
00441     [o_t8_txt_destination setStringValue: [_NS("Destination") \
00442         stringByAppendingString: @":"]];
00443     [o_t8_txt_encapFormat setStringValue: [_NS("Encap. format") \
00444         stringByAppendingString: @":"]];
00445     [o_t8_txt_inputStream setStringValue: [_NS("Input stream") \
00446         stringByAppendingString: @":"]];
00447     [o_t8_txt_partExtract setStringValue: [_NS("Partial Extract") \
00448         stringByAppendingString: @":"]];
00449     [o_t8_txt_sap setStringValue: [_NS("SAP Announce") \
00450         stringByAppendingString: @":"]];
00451     [o_t8_txt_saveFileTo setStringValue: [_NS("Save file to") \
00452         stringByAppendingString: @":"]];
00453     [o_t8_txt_strmgMthd setStringValue: [_NS("Streaming method") \
00454         stringByAppendingString: @":"]];
00455     [o_t8_txt_trnscdAudio setStringValue: [_NS("Transcode audio") \
00456         stringByAppendingString: @":"]];
00457     [o_t8_txt_trnscdVideo setStringValue: [_NS("Transcode video") \
00458         stringByAppendingString: @":"]];
00459     [o_t8_txt_local setStringValue: [_NS("Local playback") \
00460         stringByAppendingString: @":"]];
00461 
00462     /* wizard help window */
00463     [o_wh_btn_okay setTitle: _NS("OK")];
00464 }
00465 
00466 - (void)initWithExtractValuesFrom: (NSString *)from to: (NSString *)to \
00467     ofItem: (NSString *)item
00468 {
00469     [self resetWizard];
00470     msg_Dbg(VLCIntf, "wizard was reseted");
00471     [o_userSelections setObject:@"trnscd" forKey:@"trnscdOrStrmg"];
00472     [o_btn_backward setEnabled:YES];
00473     [o_tab_pageHolder selectTabViewItemAtIndex:1];
00474     [o_t2_fld_prtExtrctFrom setStringValue: from];
00475     [o_t2_fld_prtExtrctTo setStringValue: to];
00476     [o_t2_fld_pathToNewStrm setStringValue: item];
00477     [o_t1_matrix_strmgOrTrnscd selectCellAtRow:1 column:0];
00478     [[o_t1_matrix_strmgOrTrnscd cellAtRow:0 column:0] setState: NSOffState];
00479     [o_t2_ckb_enblPartExtrct setState: NSOnState];
00480     [self t2_enableExtract: nil];
00481     msg_Dbg(VLCIntf, "wizard interface is set");
00482     
00483     [o_wizard_window center];
00484     [o_wizard_window display];
00485     [o_wizard_window makeKeyAndOrderFront:nil];
00486     msg_Dbg(VLCIntf, "wizard window displayed");
00487 }
00488 
00489 - (IBAction)cancelRun:(id)sender
00490 {
00491     [o_wizard_window close];
00492 }
00493 
00494 - (id)getPlaylistWizard
00495 {
00496     return o_playlist_wizard;
00497 }
00498 
00499 - (IBAction)nextTab:(id)sender
00500 {
00501     if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Hello"])
00502     {
00503         /* check whether the user wants to stream or just to transcode;
00504          * store information for later usage */
00505         NSString *o_mode;
00506         o_mode = [[o_t1_matrix_strmgOrTrnscd selectedCell] title];
00507         if( [o_mode isEqualToString: _NS("Stream to network")] )
00508         {
00509             [o_userSelections setObject:@"strmg" forKey:@"trnscdOrStrmg"];
00510         }else{
00511             [o_userSelections setObject:@"trnscd" forKey:@"trnscdOrStrmg"];
00512         }
00513         [o_btn_backward setEnabled:YES];
00514         [o_tab_pageHolder selectTabViewItemAtIndex:1];
00515 
00516         /* Fill the playlist with current playlist items */
00517         [o_playlist_wizard reloadOutlineView];
00518 
00519     }
00520     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Input"])
00521     {
00522         /* check whether partialExtract is enabled and store the values, if needed */
00523         if ([o_t2_ckb_enblPartExtrct state] == NSOnState)
00524         {
00525             [o_userSelections setObject:@"YES" forKey:@"partExtract"];
00526             [o_userSelections setObject:[o_t2_fld_prtExtrctFrom stringValue] \
00527                 forKey:@"partExtractFrom"];
00528             [o_userSelections setObject:[o_t2_fld_prtExtrctTo stringValue] \
00529                 forKey:@"partExtractTo"];
00530         }else{
00531             [o_userSelections setObject:@"NO" forKey:@"partExtract"];
00532         }
00533 
00534         /* check whether we use an existing pl-item or add an new one;
00535          * store the path or the index and set a flag.
00536          * complain to the user if s/he didn't provide a path */
00537         NSString *o_mode;
00538         BOOL stop;
00539         stop = NO;
00540         o_mode = [[o_t2_matrix_inputSourceType selectedCell] title];
00541         if( [o_mode isEqualToString: _NS("Select a stream")] )
00542         {
00543             [o_userSelections setObject:@"YES" forKey:@"newStrm"];
00544             if ([[o_t2_fld_pathToNewStrm stringValue] isEqualToString: @""])
00545             {
00546                 /* set a flag that no file is selected */
00547                 stop = YES;
00548             }
00549             else
00550             {
00551                 [o_userSelections setObject:[o_t2_fld_pathToNewStrm stringValue] \
00552                     forKey:@"pathToStrm"];
00553             }
00554         }
00555         else
00556         {
00557             if ([o_t2_tbl_plst selectedRow] != -1)
00558             {
00559                 playlist_item_t *p_item =
00560                                     [o_playlist_wizard selectedPlaylistItem];
00561                 if( p_item->i_children <= 0 )
00562                 {
00563                     [o_userSelections setObject: [NSString stringWithFormat:
00564                         @"%s", p_item->input.psz_uri] forKey:@"pathToStrm"];
00565                 }
00566                 else
00567                 stop = YES;
00568             } else {
00569                 /* set a flag that no item is selected */
00570                 stop = YES;
00571             }
00572         }
00573 
00574         /* show either "Streaming 1" or "Transcode 1" to the user */
00575         if (stop == NO)
00576         {
00577             if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] \
00578                 isEqualToString:@"strmg"])
00579             {
00580                 /* we are streaming */
00581                 [o_tab_pageHolder selectTabViewItemAtIndex:2];
00582             }else{
00583                 /* we are just transcoding */
00584 
00585                 /* rebuild the menues for the codec-selections */
00586                 [self rebuildCodecMenus];
00587 
00588                 [o_tab_pageHolder selectTabViewItemAtIndex:3];
00589             }
00590         } else {
00591             /* show a sheet that the user didn't select a file */
00592             NSBeginInformationalAlertSheet(_NS("No input selected"), \
00593                 _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
00594                 _NS("You have selected neither a new stream nor a valid " \
00595                 "playlist item. VLC is unable to guess, which input you " \
00596                 "want use.\n\n Choose one before going to the next page."));
00597         }
00598     }
00599     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
00600         @"Streaming 1"])
00601     {
00602         /* rebuild the menues for the codec-selections */
00603         [self rebuildCodecMenus];
00604         
00605         /* check which streaming method is selected and store it */
00606         NSString *o_mode;
00607         o_mode = [[o_t3_matrix_stmgMhd selectedCell] title];
00608         if( [o_mode isEqualToString: @"HTTP"] )
00609         {
00610             [o_userSelections setObject:@"0" forKey:@"stmgMhd"];
00611 
00612             /* disable all codecs which don't support MPEG PS, MPEG TS, MPEG 1,
00613              * OGG, RAW or ASF */
00614             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
00615             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating"];
00616             
00617         } else if ([o_mode isEqualToString: @"MMS"])
00618         {
00619             [o_userSelections setObject:@"1" forKey:@"stmgMhd"];
00620             
00621             /* disable all codecs which don't support ASF / ASFH */
00622             [o_t4_pop_audioCodec removeItemWithTitle:@"MPEG 4 Audio"];
00623             [o_t4_pop_audioCodec removeItemWithTitle:@"Vorbis"];
00624             [o_t4_pop_audioCodec removeItemWithTitle:@"FLAC"];
00625             [o_t4_pop_audioCodec removeItemWithTitle:@"Speex"];
00626             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
00627             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating"];
00628             
00629             [o_t4_pop_videoCodec removeItemWithTitle:@"MPEG-1 Video"];
00630             [o_t4_pop_videoCodec removeItemWithTitle:@"MPEG-2 Video"];
00631             [o_t4_pop_videoCodec removeItemWithTitle:@"H.263"];
00632             [o_t4_pop_videoCodec removeItemWithTitle:@"H.264"];
00633             [o_t4_pop_videoCodec removeItemWithTitle:@"MJPEG"];
00634             [o_t4_pop_videoCodec removeItemWithTitle:@"Theora"];
00635         } else {
00636             if( [o_mode isEqualToString: _NS("UDP Unicast")] )
00637             {
00638                 [o_userSelections setObject:@"2" forKey:@"stmgMhd"];
00639             } else {
00640                 [o_userSelections setObject:@"3" forKey:@"stmgMhd"];
00641             }
00642             
00643             /* disable all codecs which don't support MPEG-TS */
00644             [o_t4_pop_audioCodec removeItemWithTitle:@"Vorbis"];
00645             [o_t4_pop_audioCodec removeItemWithTitle:@"FLAC"];
00646             [o_t4_pop_audioCodec removeItemWithTitle:@"Speex"];
00647             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, integer"];
00648             [o_t4_pop_audioCodec removeItemWithTitle:@"Uncompressed, floating"];
00649         }
00650 
00651         /* store the destination and check whether is it empty */
00652         if([[o_userSelections objectForKey:@"stmgMhd"] intValue] >=2 )
00653         {
00654            /* empty field is valid for HTTP and MMS */
00655             if( [[o_t3_fld_address stringValue] isEqualToString: @""] )
00656             {
00657                 /* complain to the user that "" is no valid dest. */
00658                 NSBeginInformationalAlertSheet(_NS("No valid destination"), \
00659                     _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
00660                     _NS("You need to enter a valid destination you want to "\
00661                     "stream to. Enter either a Unicast-IP or a Multicast-IP." \
00662                     "\n\n If you don't know what this means, have a look at " \
00663                     "the VLC Streaming HOWTO and the help texts in this " \
00664                     "window."));
00665             } else {
00666                 /* FIXME: check whether the entered IP is really valid */
00667                 [o_userSelections setObject:[o_t3_fld_address stringValue] \
00668                     forKey:@"stmgDest"];
00669                 /* let's go to the transcode-1-tab */
00670                 [o_tab_pageHolder selectTabViewItemAtIndex:3];
00671             }
00672         } else {
00673             [o_userSelections setObject:[o_t3_fld_address stringValue] \
00674                 forKey:@"stmgDest"];
00675             /* let's go to the transcode-1-tab */
00676             [o_tab_pageHolder selectTabViewItemAtIndex:3];
00677         }
00678     }
00679     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
00680         @"Transcode 1"])
00681     {
00682         /* check whether the user wants to transcode the video-track and store 
00683          * the related options */
00684         if ([o_t4_ckb_video state] == NSOnState)
00685         {
00686             NSNumber * theNum;
00687             theNum = [NSNumber numberWithInt:[o_t4_pop_videoCodec indexOfSelectedItem]];
00688             [o_userSelections setObject:@"YES" forKey:@"trnscdVideo"];
00689             [o_userSelections setObject:[o_t4_pop_videoBitrate titleOfSelectedItem] \
00690                 forKey:@"trnscdVideoBitrate"];
00691             [o_userSelections setObject:theNum forKey:@"trnscdVideoCodec"];
00692         } else {
00693             [o_userSelections setObject:@"NO" forKey:@"trnscdVideo"];
00694         }
00695 
00696         /* check whether the user wants to transcode the audio-track and store 
00697          * the related options */
00698         if ([o_t4_ckb_audio state] == NSOnState)
00699         {
00700             NSNumber * theNum;
00701             theNum = [NSNumber numberWithInt:[o_t4_pop_audioCodec indexOfSelectedItem]];
00702             [o_userSelections setObject:@"YES" forKey:@"trnscdAudio"];
00703             [o_userSelections setObject:[o_t4_pop_audioBitrate titleOfSelectedItem] \
00704                 forKey:@"trnscdAudioBitrate"];
00705             [o_userSelections setObject:theNum forKey:@"trnscdAudioCodec"];
00706         } else {
00707             [o_userSelections setObject:@"NO" forKey:@"trnscdAudio"];
00708         }
00709 
00710         /* disable all encap-formats */
00711         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
00712         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:NO];
00713         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
00714         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
00715         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
00716         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
00717         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
00718         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
00719         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
00720         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
00721         [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
00722 
00723         /* re-enable the encap-formats supported by the chosen codecs */
00724         /* FIXME: the following is a really bad coding-style. feel free to mail
00725             me ideas how to make this nicer, if you want to -- FK, 7/11/05 */
00726 
00727         if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualTo: @"YES"])
00728         {
00729             if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualTo: @"YES"])
00730             {
00731                 /* we are transcoding both audio and video, so we need to check both deps */
00732                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00733                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_PS"])
00734                 {
00735                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections \
00736                         objectForKey:@"trnscdAudioCodec"] intValue]] \
00737                         containsObject: @"MUX_PS"])
00738                     {
00739                         [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
00740                         [o_t5_matrix_encap selectCellAtRow:0 column:0];
00741                     }
00742                 }
00743                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections \
00744                     objectForKey:@"trnscdVideoCodec"] intValue]] containsObject: @"MUX_TS"])
00745                 {
00746                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00747                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_TS"])
00748                     {
00749                         [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
00750                         [o_t5_matrix_encap selectCellAtRow:1 column:0];
00751                     }
00752                 }
00753                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00754                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MPEG"])
00755                 {
00756                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00757                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MPEG"])
00758                     {
00759                         [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
00760                         [o_t5_matrix_encap selectCellAtRow:2 column:0];
00761                     }
00762                 }
00763                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00764                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_OGG"])
00765                 {
00766                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections \
00767                         objectForKey:@"trnscdAudioCodec"] intValue]] containsObject: @"MUX_OGG"])
00768                     {
00769                         [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
00770                         [o_t5_matrix_encap selectCellAtRow:3 column:0];
00771                     }
00772                 }
00773                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00774                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_RAW"])
00775                 {
00776                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00777                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_RAW"])
00778                     {
00779                         [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
00780                         [o_t5_matrix_encap selectCellAtRow:4 column:0];
00781                     }
00782                 }
00783                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00784                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_ASF"])
00785                 {
00786                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00787                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_ASF"])
00788                     {
00789                         [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
00790                         [o_t5_matrix_encap selectCellAtRow:5 column:0];
00791                     }
00792                 }
00793                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00794                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_AVI"])
00795                 {
00796                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00797                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_AVI"])
00798                     {
00799                         [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
00800                         [o_t5_matrix_encap selectCellAtRow:6 column:0];
00801                     }
00802                 }
00803                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00804                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MP4"])
00805                 {
00806                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00807                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MP4"])
00808                     {
00809                         [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
00810                         [o_t5_matrix_encap selectCellAtRow:7 column:0];
00811                     }
00812                 }
00813                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00814                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MOV"])
00815                 {
00816                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00817                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MOV"])
00818                     {
00819                         [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
00820                         [o_t5_matrix_encap selectCellAtRow:8 column:0];
00821                     }
00822                 }
00823                 if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00824                     @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_WAV"])
00825                 {
00826                     if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00827                         @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_WAV"])
00828                     {
00829                         [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
00830                         [o_t5_matrix_encap selectCellAtRow:9 column:0];
00831                     }
00832                 }
00833 
00834             } else {
00835 
00836                 /* we just transcoding the audio */
00837 
00838                 /* select formats supported by the audio codec */
00839                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00840                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_PS"])
00841                 {
00842                     [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
00843                     [o_t5_matrix_encap selectCellAtRow:0 column:0];
00844                 }
00845                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00846                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_TS"])
00847                 {
00848                     [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
00849                     [o_t5_matrix_encap selectCellAtRow:1 column:0];
00850                 }
00851                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00852                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MPEG"])
00853                 {
00854                     [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
00855                     [o_t5_matrix_encap selectCellAtRow:2 column:0];
00856                 }
00857                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00858                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_OGG"])
00859                 {
00860                     [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
00861                     [o_t5_matrix_encap selectCellAtRow:3 column:0];
00862                 }
00863                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00864                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_RAW"])
00865                 {
00866                     [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
00867                     [o_t5_matrix_encap selectCellAtRow:4 column:0];
00868                 }
00869                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00870                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_ASF"])
00871                 {
00872                     [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
00873                     [o_t5_matrix_encap selectCellAtRow:5 column:0];
00874                 }
00875                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00876                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_AVI"])
00877                 {
00878                     [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
00879                     [o_t5_matrix_encap selectCellAtRow:6 column:0];
00880                 }
00881                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00882                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MP4"])
00883                 {
00884                     [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
00885                     [o_t5_matrix_encap selectCellAtRow:7 column:0];
00886                 }
00887                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00888                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_MOV"])
00889                 {
00890                     [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
00891                     [o_t5_matrix_encap selectCellAtRow:8 column:0];
00892                 }
00893                 if ([[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
00894                     @"trnscdAudioCodec"] intValue]] containsObject: @"MUX_WAV"])
00895                 {
00896                     [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
00897                     [o_t5_matrix_encap selectCellAtRow:9 column:0];
00898                 }
00899             }
00900         }
00901         else if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualTo: @"YES"])
00902         {
00903             /* we are just transcoding the video */
00904 
00905             /* select formats supported by the video-codec */
00906 
00907             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00908                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_PS"])
00909             {
00910                 [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
00911                 [o_t5_matrix_encap selectCellAtRow:0 column:0];
00912             }
00913             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00914                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_TS"])
00915             {
00916                 [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
00917                 [o_t5_matrix_encap selectCellAtRow:1 column:0];
00918             }
00919             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00920                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MPEG"])
00921             {
00922                 [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
00923                 [o_t5_matrix_encap selectCellAtRow:2 column:0];
00924             }
00925             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00926                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_OGG"])
00927             {
00928                 [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
00929                 [o_t5_matrix_encap selectCellAtRow:3 column:0];
00930             }
00931             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00932                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_RAW"])
00933             {
00934                 [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
00935                 [o_t5_matrix_encap selectCellAtRow:4 column:0];
00936             }
00937             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00938                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_ASF"])
00939             {
00940                 [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
00941                 [o_t5_matrix_encap selectCellAtRow:5 column:0];
00942             }
00943             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00944                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_AVI"])
00945             {
00946                 [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:YES];
00947                 [o_t5_matrix_encap selectCellAtRow:6 column:0];
00948             }
00949             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00950                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MP4"])
00951             {
00952                 [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
00953                 [o_t5_matrix_encap selectCellAtRow:7 column:0];
00954             }
00955             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00956                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_MOV"])
00957             {
00958                 [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
00959                 [o_t5_matrix_encap selectCellAtRow:8 column:0];
00960             }
00961             if ([[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
00962                 @"trnscdVideoCodec"] intValue]] containsObject: @"MUX_WAV"])
00963             {
00964                 [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:YES];
00965                 [o_t5_matrix_encap selectCellAtRow:9 column:0];
00966             }
00967         } else {
00968             /* we don't do any transcoding
00969              * -> enabled the encap-formats allowed when streaming content via
00970              * http plus MP4 since this should work fine in most cases */
00971 
00972             /* FIXME: choose a selection of encap-formats based upon the 
00973              * actually used codecs */
00974 
00975             /* enable MPEG PS, MPEG TS, MPEG 1, OGG, RAW, ASF, MP4 and MOV
00976              * select MPEG PS */
00977             [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:YES];
00978             [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
00979             [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:YES];
00980             [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:YES];
00981             [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:YES];
00982             [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:YES];
00983             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
00984             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:YES];
00985             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:YES];
00986             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
00987             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
00988             [o_t5_matrix_encap selectCellAtRow:0 column:0];
00989         }
00990         if ([o_userSelections objectForKey:@"stmgMhd"] == @"1")
00991         {
00992             /* if MMS is the streaming protocol, only ASFH is available */
00993             [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
00994             [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:NO];
00995             [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
00996             [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
00997             [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
00998             [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
00999             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
01000             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
01001             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
01002             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
01003             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:YES];
01004             [o_t5_matrix_encap selectCellAtRow:10 column:0];
01005         }
01006         else if ([o_userSelections objectForKey:@"stmgMhd"] == @"0")
01007         {
01008             /* if HTTP is the streaming protocol, disable all unsupported
01009              * encap-formats, but don't touch the other ones selected above */
01010             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
01011             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
01012             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
01013             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
01014             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
01015         }
01016         else if ([o_userSelections objectForKey:@"stmgMhd"] >= @"2")
01017         {
01018             /* if UDP is the streaming protocol, only MPEG-TS is available */
01019             [[o_t5_matrix_encap cellAtRow:0 column:0] setEnabled:NO];
01020             [[o_t5_matrix_encap cellAtRow:2 column:0] setEnabled:NO];
01021             [[o_t5_matrix_encap cellAtRow:3 column:0] setEnabled:NO];
01022             [[o_t5_matrix_encap cellAtRow:4 column:0] setEnabled:NO];
01023             [[o_t5_matrix_encap cellAtRow:5 column:0] setEnabled:NO];
01024             [[o_t5_matrix_encap cellAtRow:6 column:0] setEnabled:NO];
01025             [[o_t5_matrix_encap cellAtRow:7 column:0] setEnabled:NO];
01026             [[o_t5_matrix_encap cellAtRow:8 column:0] setEnabled:NO];
01027             [[o_t5_matrix_encap cellAtRow:9 column:0] setEnabled:NO];
01028             [[o_t5_matrix_encap cellAtRow:10 column:0] setEnabled:NO];
01029             [[o_t5_matrix_encap cellAtRow:1 column:0] setEnabled:YES];
01030             [o_t5_matrix_encap selectCellAtRow:1 column:0];
01031         }
01032         int x;
01033         BOOL anythingEnabled;
01034         x = 0;
01035         anythingEnabled = NO;
01036         while (x != [o_t5_matrix_encap numberOfRows])
01037         {
01038             if ([[o_t5_matrix_encap cellAtRow:x column:0] isEnabled])
01039             {
01040                 anythingEnabled = YES;
01041             }
01042             x = (x + 1);
01043         }
01044         if (anythingEnabled == YES)
01045         {
01046             /* go the encap-tab */
01047             [o_tab_pageHolder selectTabViewItemAtIndex:4];
01048         } else {
01049             /* show a sheet that the selected codecs are not compatible */
01050             NSBeginInformationalAlertSheet(_NS("Invalid selection"), _NS("OK"), \
01051                 @"", @"", o_wizard_window, nil, nil, nil, nil, _NS("Your " \
01052                 "chosen codecs are not compatible with each other. For example: " \
01053                 "you cannot mix uncompressed audio with any video codec.\n\n" \
01054                 "Correct your selection and try again."));
01055         }
01056 
01057     }
01058     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Encap"])
01059     {
01060         /* get the chosen encap format and store it */
01061         NSNumber * theNum;
01062         theNum = [NSNumber numberWithInt:[[o_t5_matrix_encap selectedCell] tag]];
01063         [o_userSelections setObject:[theNum stringValue] forKey:@"encapFormat"];
01064 
01065         /* show either "Streaming 2" or "Transcode 2" to the user */
01066         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
01067         {
01068             /* we are streaming */
01069             [o_tab_pageHolder selectTabViewItemAtIndex:5];
01070         }else{
01071             /* we are just transcoding */
01072             [o_tab_pageHolder selectTabViewItemAtIndex:6];
01073         }
01074     }
01075     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01076         @"Streaming 2"])
01077     {
01078         /* store the chosen TTL */
01079         [o_userSelections setObject:[o_t6_fld_ttl stringValue] forKey:@"ttl"];
01080 
01081         /* check whether SAP is enabled and store the announce, if needed */
01082         if ([o_t6_ckb_sap state] == NSOnState)
01083         {
01084             [o_userSelections setObject:@"YES" forKey:@"sap"];
01085             [o_userSelections setObject:[o_t6_fld_sap stringValue] forKey:@"sapText"];
01086         } else {
01087             [o_userSelections setObject:@"NO" forKey:@"sap"];
01088         }
01089         
01090         /* local playback? */
01091         if ([o_t6_ckb_local state] == NSOnState)
01092         {
01093             [o_userSelections setObject:@"YES" forKey:@"localPb"];
01094         } else {
01095             [o_userSelections setObject:@"NO" forKey:@"localPb"];
01096         }
01097         
01098         /* go to "Summary" */
01099         [self showSummary];
01100     }
01101     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01102         @"Transcode 2"])
01103     {
01104         /* local playback? */
01105         if ([o_t7_ckb_local state] == NSOnState)
01106         {
01107             [o_userSelections setObject:@"YES" forKey:@"localPb"];
01108         } else {
01109             [o_userSelections setObject:@"NO" forKey:@"localPb"];
01110         }
01111 
01112         /* check whether the path != "" and store it */
01113         if( [[o_t7_fld_filePath stringValue] isEqualToString: @""] )
01114         {
01115             /* complain to the user that "" is no valid path */
01116             NSBeginInformationalAlertSheet(_NS("No file selected"), _NS("OK"), \
01117                 @"", @"", o_wizard_window, nil, nil, nil, nil, _NS("You you " \
01118                 "need to select a file, you want to save to.\n\n Enter either " \
01119                 "a valid path or choose a location through the button's " \
01120                 "dialog-box."));
01121         } else {
01122             [o_userSelections setObject:[o_t7_fld_filePath stringValue] forKey: \
01123                 @"trnscdFilePath"];
01124 
01125             /* go to "Summary" */
01126             [self showSummary];
01127         }
01128     }
01129     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01130         @"Summary"])
01131     {
01132         intf_thread_t * p_intf = VLCIntf;
01133 
01134         playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_intf,
01135                             VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
01136         if( p_playlist )
01137         {
01138             playlist_item_t *p_item = playlist_ItemNew( p_playlist, [[o_userSelections \
01139                 objectForKey:@"pathToStrm"] UTF8String], _("Streaming/Transcoding Wizard") );
01140             playlist_ItemAddOption( p_item, [[o_userSelections objectForKey:@"opts"] UTF8String]);
01141 
01142             if(! [[o_userSelections objectForKey:@"partExtractFrom"] isEqualToString:@""] )
01143             {
01144                 playlist_ItemAddOption( p_item, [[@"start-time=" \
01145                     stringByAppendingString: [o_userSelections \
01146                     objectForKey:@"partExtractFrom"]] UTF8String] );
01147             }
01148 
01149             if(! [[o_userSelections objectForKey:@"partExtractTo"] isEqualToString:@""] )
01150             {
01151                 playlist_ItemAddOption( p_item, [[@"stop-time=" \
01152                     stringByAppendingString: [o_userSelections objectForKey: \
01153                     @"partExtractTo"]] UTF8String] );
01154             }
01155 
01156             playlist_ItemAddOption( p_item, [[@"ttl=" stringByAppendingString: \
01157                 [o_userSelections objectForKey:@"ttl"]] UTF8String] );
01158 
01159             playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END );
01160             
01161             playlist_ViewUpdate( p_playlist, VIEW_CATEGORY );
01162 
01163             vlc_object_release(p_playlist);
01164         } else {
01165             msg_Err( p_intf, "Uh Oh! Unable to find playlist!" );
01166         }
01167 
01168         /* close the window, since we are done */
01169         [o_wizard_window close];
01170     }
01171 }
01172 
01173 - (void)rebuildCodecMenus
01174 {
01175     [o_t4_pop_videoCodec removeAllItems];
01176     unsigned int x;
01177     x = 0;
01178     while (x != [o_videoCodecs count])
01179     {
01180         [o_t4_pop_videoCodec addItemWithTitle:[[o_videoCodecs objectAtIndex:x] \
01181             objectAtIndex:0]];
01182         x = (x + 1);
01183     }
01184     [o_t4_pop_audioCodec removeAllItems];
01185     x = 0;
01186     while (x != [o_audioCodecs count])
01187     {
01188         [o_t4_pop_audioCodec addItemWithTitle:[[o_audioCodecs objectAtIndex:x] \
01189             objectAtIndex:0]];
01190         x = (x + 1);
01191     }
01192 }
01193 
01194 - (void)showSummary
01195 {
01196     [o_btn_forward setTitle: _NS("Finish")];
01197     [o_t8_fld_inptStream setStringValue:[o_userSelections objectForKey:@"pathToStrm"]];
01198     
01199     if ([[o_userSelections objectForKey:@"localPb"] isEqualToString: @"YES"])
01200     {
01201         [o_t8_fld_local setStringValue: _NS("yes")];
01202     } else {
01203         [o_t8_fld_local setStringValue: _NS("no")];
01204     }
01205 
01206     if ([[o_userSelections objectForKey:@"partExtract"] isEqualToString: @"YES"])
01207     {
01208         [o_t8_fld_partExtract setStringValue: [[[[[_NS("yes") \
01209             stringByAppendingString:@" - "] stringByAppendingString: \
01210             _NS("from ")] stringByAppendingString: [o_userSelections \
01211             objectForKey:@"partExtractFrom"]] stringByAppendingString: \
01212             _NS(" to ")] stringByAppendingString: [o_userSelections \
01213             objectForKey:@"partExtractTo"]]];
01214     } else {
01215         [o_t8_fld_partExtract setStringValue: _NS("no")];
01216     }
01217 
01218     if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
01219     {
01220         /* we are streaming; no transcoding allowed atm */
01221         [o_t8_fld_saveFileTo setStringValue: @"-"];
01222         [o_t8_fld_trnscdAudio setStringValue: @"-"];
01223         [o_t8_fld_trnscdVideo setStringValue: @"-"];
01224         [o_t8_fld_strmgMthd setStringValue: [[o_strmgMthds objectAtIndex: \
01225             [[o_userSelections objectForKey:@"stmgMhd"] intValue]] \
01226             objectAtIndex:1]];
01227         [o_t8_fld_destination setStringValue: [o_userSelections objectForKey: \
01228             @"stmgDest"]];
01229         [o_t8_fld_ttl setStringValue: [o_userSelections objectForKey:@"ttl"]];
01230         if ([[o_userSelections objectForKey:@"sap"] isEqualToString: @"YES"])
01231         {
01232             [o_t8_fld_sap setStringValue: [[_NS("yes") stringByAppendingString:@": "] stringByAppendingString:[o_userSelections objectForKey:@"sapText"]]];
01233         }else{
01234             [o_t8_fld_sap setStringValue: _NS("no")];
01235         }
01236     } else {
01237         /* we are transcoding */
01238         [o_t8_fld_strmgMthd setStringValue: @"-"];
01239         [o_t8_fld_destination setStringValue: @"-"];
01240         [o_t8_fld_ttl setStringValue: @"-"];
01241         [o_t8_fld_sap setStringValue: @"-"];
01242         if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"YES"])
01243         {
01244             [o_t8_fld_trnscdVideo setStringValue: [[[[[_NS("yes") \
01245                 stringByAppendingString:@": "] stringByAppendingString: \
01246                 [[o_videoCodecs objectAtIndex:[[o_userSelections objectForKey: \
01247                 @"trnscdVideoCodec"] intValue]] objectAtIndex:0]] \
01248                 stringByAppendingString:@" @ "] stringByAppendingString: \
01249                 [o_userSelections objectForKey:@"trnscdVideoBitrate"]] \
01250                 stringByAppendingString:@" kb/s"]];
01251         }else{
01252             [o_t8_fld_trnscdVideo setStringValue: _NS("no")];
01253         }
01254         if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
01255         {
01256             [o_t8_fld_trnscdAudio setStringValue: [[[[[_NS("yes") \
01257             stringByAppendingString:@": "] stringByAppendingString: \
01258             [[o_audioCodecs objectAtIndex:[[o_userSelections objectForKey: \
01259             @"trnscdAudioCodec"] intValue]] objectAtIndex:0]] \
01260             stringByAppendingString:@" @ "] stringByAppendingString: \
01261             [o_userSelections objectForKey:@"trnscdAudioBitrate"]] \
01262             stringByAppendingString:@" kb/s"]];
01263         }else{
01264             [o_t8_fld_trnscdAudio setStringValue: _NS("no")];
01265         }
01266         [o_t8_fld_saveFileTo setStringValue: [o_userSelections objectForKey: \
01267             @"trnscdFilePath"]];
01268     }
01269     [o_t8_fld_encapFormat setStringValue: [[o_encapFormats objectAtIndex: \
01270         [[o_userSelections objectForKey:@"encapFormat"] intValue]] objectAtIndex:1]];
01271 
01272     [self createOpts];
01273     [o_t8_fld_mrl setStringValue: [o_userSelections objectForKey:@"opts"]];
01274 
01275     [o_tab_pageHolder selectTabViewItemAtIndex:7];
01276 }
01277 
01278 - (void) createOpts
01279 {
01280     NSMutableString * o_opts_string = [NSMutableString stringWithString:@""];
01281     NSMutableString *o_trnscdCmd = [NSMutableString stringWithString:@""];
01282     NSMutableString *o_duplicateCmd = [NSMutableString stringWithString:@""];
01283     
01284     /* check whether we transcode the audio and/or the video and compose a
01285      * string reflecting the settings, if needed */
01286     if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"YES"])
01287     {
01288         [o_trnscdCmd appendString: @"transcode{"];
01289         [o_trnscdCmd appendFormat: @"vcodec=%s,vb=%i", [[[o_videoCodecs \
01290             objectAtIndex:[[o_userSelections objectForKey:@"trnscdVideoCodec"] \
01291             intValue]] objectAtIndex:1] UTF8String],  [[o_userSelections \
01292             objectForKey:@"trnscdVideoBitrate"] intValue]];
01293         if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
01294         {
01295             [o_trnscdCmd appendString: @","];
01296         } 
01297         else
01298         {
01299             [o_trnscdCmd appendString: @"}:"];
01300         }
01301     }
01302     
01303     /* check whether the user requested local playback. if yes, prepare the
01304      * string, if not, let it empty */
01305     if ([[o_userSelections objectForKey:@"localPb"] isEqualToString:@"YES"])
01306     {
01307         [o_duplicateCmd appendString: @"duplicate{dst=display,dst=\""];
01308     }
01309     
01310     if ([[o_userSelections objectForKey:@"trnscdAudio"] isEqualToString:@"YES"])
01311     {
01312         if ([[o_userSelections objectForKey:@"trnscdVideo"] isEqualToString:@"NO"])
01313         {
01314             /* in case we transcode the audio only, add this */
01315             [o_trnscdCmd appendString: @"transcode{"];
01316         }
01317         [o_trnscdCmd appendFormat: @"acodec=%s,ab=%i}:", [[[o_audioCodecs \
01318             objectAtIndex:[[o_userSelections objectForKey:@"trnscdAudioCodec"] \
01319             intValue]] objectAtIndex:1] UTF8String],  [[o_userSelections \
01320             objectForKey:@"trnscdAudioBitrate"] intValue]];
01321     }
01322     
01323     if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"trnscd"])
01324     {
01325         /* we are just transcoding and dumping the stuff to a file */
01326         [o_opts_string appendFormat: \
01327             @":sout=#%s%sstandard{mux=%s,url=%s,access=file}", [o_duplicateCmd \
01328             UTF8String], [o_trnscdCmd UTF8String], [[[o_encapFormats \
01329             objectAtIndex: [[o_userSelections objectForKey:@"encapFormat"] \
01330             intValue]] objectAtIndex:0] UTF8String], [[o_userSelections \
01331             objectForKey: @"trnscdFilePath"] UTF8String]];
01332 
01333     } else {
01334 
01335         /* we are streaming */
01336         if ([[o_userSelections objectForKey:@"sap"] isEqualToString:@"YES"])
01337         {
01338             /* SAP-Announcement is requested */
01339             NSMutableString *o_sap_option = [NSMutableString stringWithString:@""];
01340             if([[o_userSelections objectForKey:@"sapText"] isEqualToString:@""])
01341             {
01342                 [o_sap_option appendString: @"sap"];
01343             } else {
01344                 [o_sap_option appendFormat: @"sap,name=\"%s\"",[[o_userSelections \
01345                     objectForKey:@"sapText"] UTF8String]];
01346             }
01347             [o_opts_string appendFormat: \
01348                 @":sout=#%s%sstandard{mux=%s,url=%s,access=%s,%s}", \
01349                 [o_duplicateCmd UTF8String], [o_trnscdCmd UTF8String], \
01350                 [[[o_encapFormats objectAtIndex: [[o_userSelections \
01351                 objectForKey: @"encapFormat"] intValue]] objectAtIndex:0] \
01352                 UTF8String], [[o_userSelections objectForKey: @"stmgDest"] \
01353                 UTF8String], [[[o_strmgMthds objectAtIndex: [[o_userSelections \
01354                 objectForKey: @"stmgMhd"] intValue]] objectAtIndex:0] \
01355                 UTF8String], [o_sap_option UTF8String]];
01356         } else {
01357             /* no SAP, just streaming */
01358             [o_opts_string appendFormat: \
01359                 @":sout=#%s%sstandard{mux=%s,url=%s,access=%s}", \
01360                 [o_duplicateCmd UTF8String], [o_trnscdCmd UTF8String], \
01361                 [[[o_encapFormats objectAtIndex: [[o_userSelections \
01362                 objectForKey: @"encapFormat"] intValue]] objectAtIndex:0] \
01363                 UTF8String], [[o_userSelections objectForKey: \
01364                 @"stmgDest"] UTF8String], [[[o_strmgMthds objectAtIndex: \
01365                 [[o_userSelections objectForKey: @"stmgMhd"] intValue]] \
01366                 objectAtIndex:0] UTF8String]];
01367         }
01368     }
01369 
01370     /* check whether the user requested local playback. if yes, close the
01371      * string with an additional bracket */
01372     if ([[o_userSelections objectForKey:@"localPb"] isEqualToString:@"YES"])
01373     {
01374         [o_opts_string appendString: @"\"}"];
01375     }
01376 
01377     [o_userSelections setObject:o_opts_string forKey:@"opts"];
01378 }
01379 
01380 - (IBAction)prevTab:(id)sender
01381 {
01382     if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: @"Summary"])
01383     {
01384         /* check whether we are streaming or transcoding and go back */
01385         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
01386         {
01387             /* show "Streaming 2" */
01388             [o_tab_pageHolder selectTabViewItemAtIndex:5];
01389         }else{
01390             /* show "Transcode 2" */
01391             [o_tab_pageHolder selectTabViewItemAtIndex:6];
01392         }
01393         /* rename the forward-button */
01394         [o_btn_forward setTitle: _NS("Next")];
01395     }
01396     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01397         @"Transcode 2"])
01398     {
01399         /* show "Encap" */
01400         [o_tab_pageHolder selectTabViewItemAtIndex:4];
01401     }
01402     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01403         @"Streaming 2"])
01404     {
01405         /* show "Encap" */
01406         [o_tab_pageHolder selectTabViewItemAtIndex:4];
01407     }
01408     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01409         @"Encap"])
01410     {
01411         /* show "Transcode 1" */
01412         [o_tab_pageHolder selectTabViewItemAtIndex:3];
01413     }
01414     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01415         @"Streaming 1"])
01416     {
01417         /* show "Input" */
01418         [o_tab_pageHolder selectTabViewItemAtIndex:1];
01419     }
01420     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01421         @"Transcode 1"])
01422     {
01423         if ([[o_userSelections objectForKey:@"trnscdOrStrmg"] isEqualToString:@"strmg"])
01424         {
01425             /* show "Streaming 1" */
01426             [o_tab_pageHolder selectTabViewItemAtIndex:2];
01427         }else{
01428             /* show "Input" */
01429             [o_tab_pageHolder selectTabViewItemAtIndex:1];
01430         }
01431     }
01432     else if ([[[o_tab_pageHolder selectedTabViewItem] label] isEqualToString: \
01433         @"Input"])
01434     {
01435         /* reset the wizard before going backwards. Otherwise, we might get
01436          * unwanted behaviours in the Encap-Selection */
01437         [self resetWizard];
01438         /* show "Hello" */
01439         [o_tab_pageHolder selectTabViewItemAtIndex:0];
01440         /* disable backwards-btn */
01441         [o_btn_backward setEnabled:NO];
01442     }
01443 }
01444 
01445 - (IBAction)t1_mrInfo_streaming:(id)sender
01446 {
01447     /* show a sheet for the help */
01448     /* since NSAlert does not exist on OSX < 10.3, we use our own implementation */
01449     [o_wh_txt_title setStringValue: _NS("Stream to network")];
01450     [o_wh_txt_text setStringValue: _NS("Use this to stream on a network.")];
01451     [NSApp beginSheet: o_wizardhelp_window
01452             modalForWindow: o_wizard_window
01453             modalDelegate: o_wizardhelp_window
01454             didEndSelector: nil
01455             contextInfo: nil];
01456 }
01457 
01458 - (IBAction)t1_mrInfo_transcode:(id)sender
01459 {
01460     /* show a sheet for the help */
01461     [o_wh_txt_title setStringValue: _NS("Transcode/Save to file")];
01462     [o_wh_txt_text setStringValue: _NS("Use this to save a stream to a file. You "\
01463         "have the possibility to reencode the stream. You can save whatever "\
01464         "VLC can read.\nPlease notice that VLC is not very suited " \
01465         "for file to file transcoding. You should use its transcoding " \
01466         "features to save network streams, for example.")];
01467     [NSApp beginSheet: o_wizardhelp_window
01468             modalForWindow: o_wizard_window
01469             modalDelegate: o_wizardhelp_window
01470             didEndSelector: nil
01471             contextInfo: nil];
01472 }
01473 
01474 - (IBAction)t2_addNewStream:(id)sender
01475 {
01476     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
01477     SEL sel = @selector(t2_getNewStreamFromDialog:returnCode:contextInfo:);
01478     [openPanel beginSheetForDirectory:nil file:nil types:nil modalForWindow: \
01479         o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
01480 }
01481 
01482 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: \
01483     (int)returnCode contextInfo: (void *)contextInfo
01484 {
01485     if (returnCode == NSOKButton)
01486     {
01487         [o_t2_fld_pathToNewStrm setStringValue: [@"file://" \
01488             stringByAppendingString: [sheet filename]]];
01489     }
01490 }
01491 
01492 - (IBAction)t2_chooseStreamOrPlst:(id)sender
01493 {
01494     /* enable and disable the respective items depending on user's choice */
01495     NSString *o_mode;
01496     o_mode = [[o_t2_matrix_inputSourceType selectedCell] title];
01497 
01498     if( [o_mode isEqualToString: _NS("Select a stream")] )
01499     {
01500         [o_t2_btn_chooseFile setEnabled:YES];
01501         [o_t2_fld_pathToNewStrm setEnabled:YES];
01502         [o_t2_tbl_plst setEnabled:NO];
01503     } else {
01504         [o_t2_btn_chooseFile setEnabled:NO];
01505         [o_t2_fld_pathToNewStrm setEnabled:NO];
01506         [o_t2_tbl_plst setEnabled:YES];
01507     }
01508 }
01509 
01510 - (IBAction)t2_enableExtract:(id)sender
01511 {
01512     /* enable/disable the respective items */
01513     if([o_t2_ckb_enblPartExtrct state] == NSOnState)
01514     {
01515         [o_t2_fld_prtExtrctFrom setEnabled:YES];
01516         [o_t2_fld_prtExtrctTo setEnabled:YES];
01517     } else {
01518         [o_t2_fld_prtExtrctFrom setEnabled:NO];
01519         [o_t2_fld_prtExtrctTo setEnabled:NO];
01520         [o_t2_fld_prtExtrctFrom setStringValue:@""];
01521         [o_t2_fld_prtExtrctTo setStringValue:@""];
01522     }
01523 }
01524 
01525 - (IBAction)t3_strmMthdChanged:(id)sender
01526 {
01527     /* change the captions of o_t3_txt_destInfo according to the chosen
01528      * streaming method */
01529     NSNumber * o_mode;
01530     o_mode = [[NSNumber alloc] initWithInt:[[o_t3_matrix_stmgMhd selectedCell] tag]];
01531     if( [o_mode intValue] == 0 )
01532     {
01533         /* UDP-Unicast */
01534         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:2] \
01535             objectAtIndex:2]];
01536         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:2] \
01537         objectAtIndex:3]];
01538     }
01539     else if ( [o_mode intValue] == 1 )
01540     {
01541         /* UDP-Multicast */
01542         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:3] \
01543             objectAtIndex:2]];
01544         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:3] \
01545         objectAtIndex:3]];
01546     }
01547     else if( [o_mode intValue] == 2 )
01548     {
01549         /* HTTP */
01550         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:0] \
01551             objectAtIndex:2]];
01552         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:0] \
01553             objectAtIndex:3]];
01554     }
01555     else if( [o_mode intValue] == 3 )
01556     {
01557         /* MMS */
01558         [o_t3_txt_destInfo setStringValue: [[o_strmgMthds objectAtIndex:1] \
01559             objectAtIndex:2]];
01560         [o_t3_txt_strgMthdInfo setStringValue: [[o_strmgMthds objectAtIndex:1] \
01561             objectAtIndex:3]];
01562     }
01563     [o_mode release];
01564 }
01565 
01566 - (IBAction)t4_AudCdcChanged:(id)sender
01567 {
01568     /* update codec info */
01569     [o_t4_txt_hintAudio setStringValue:[[o_audioCodecs objectAtIndex: \
01570         [o_t4_pop_audioCodec indexOfSelectedItem]] objectAtIndex:2]];
01571 }
01572 
01573 - (IBAction)t4_enblAudTrnscd:(id)sender
01574 {
01575     /* enable/disable the respective items */
01576     if([o_t4_ckb_audio state] == NSOnState)
01577     {
01578         [o_t4_pop_audioCodec setEnabled:YES];
01579         [o_t4_pop_audioBitrate setEnabled:YES];
01580         [o_t4_txt_hintAudio setStringValue: _NS("Select your audio codec. "\
01581         "Click one to get more information.")];
01582     } else {
01583         [o_t4_pop_audioCodec setEnabled:NO];
01584         [o_t4_pop_audioBitrate setEnabled:NO];
01585         [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio " \
01586         "and you want to transcode it, enable this.")];
01587     }
01588 }
01589 
01590 - (IBAction)t4_enblVidTrnscd:(id)sender
01591 {
01592     /* enable/disable the respective items */
01593     if([o_t4_ckb_video state] == NSOnState)
01594     {
01595         [o_t4_pop_videoCodec setEnabled:YES];
01596         [o_t4_pop_videoBitrate setEnabled:YES];
01597         [o_t4_txt_hintVideo setStringValue: _NS("Select your video codec. "\
01598         "Click one to get more information.")];
01599     } else {
01600         [o_t4_pop_videoCodec setEnabled:NO];
01601         [o_t4_pop_videoBitrate setEnabled:NO];
01602         [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video " \
01603         "and you want to transcode it, enable this.")];
01604     }
01605 }
01606 
01607 - (IBAction)t4_VidCdcChanged:(id)sender
01608 {
01609     /* update codec info */
01610     [o_t4_txt_hintVideo setStringValue:[[o_videoCodecs objectAtIndex: \
01611         [o_t4_pop_videoCodec indexOfSelectedItem]] objectAtIndex:2]];
01612 }
01613 
01614 - (IBAction)t6_enblSapAnnce:(id)sender
01615 {
01616     /* enable/disable input fld */
01617     if([o_t6_ckb_sap state] == NSOnState)
01618     {
01619         [o_t6_fld_sap setEnabled:YES];
01620     } else {
01621         [o_t6_fld_sap setEnabled:NO];
01622         [o_t6_fld_sap setStringValue:@""];
01623     }
01624 }
01625 
01626 - (IBAction)t6_mrInfo_ttl:(id)sender
01627 {
01628     /* show a sheet for the help */
01629     [o_wh_txt_title setStringValue: _NS("Time-To-Live (TTL)")];
01630     [o_wh_txt_text setStringValue: _NS("Define the TTL (Time-To-Live) of the stream. "\
01631             "This parameter is the maximum number of routers your stream can go " \
01632             "through. If you don't know what it means, or if you want to stream on " \
01633             "your local network only, leave this setting to 1.")];
01634     [NSApp beginSheet: o_wizardhelp_window
01635             modalForWindow: o_wizard_window
01636             modalDelegate: o_wizardhelp_window
01637             didEndSelector: nil
01638             contextInfo: nil];
01639 }
01640 
01641 - (IBAction)t6_mrInfo_sap:(id)sender
01642 {
01643     /* show a sheet for the help */
01644     [o_wh_txt_title setStringValue: _NS("SAP Announce")];
01645     [o_wh_txt_text setStringValue: _NS("When streaming using UDP, you can " \
01646         "announce your streams using the SAP/SDP announcing protocol. This " \
01647         "way, the clients won't have to type in the multicast address, it " \
01648         "will appear in their playlist if they enable the SAP extra interface.\n" \
01649         "If you want to give a name to your stream, enter it here, " \
01650         "else, a default name will be used.")];
01651     [NSApp beginSheet: o_wizardhelp_window
01652             modalForWindow: o_wizard_window
01653             modalDelegate: o_wizardhelp_window
01654             didEndSelector: nil
01655             contextInfo: nil];
01656 }
01657 
01658 - (IBAction)t67_mrInfo_local:(id)sender
01659 {
01660     /* show a sheet for the help */
01661     NSBeginInformationalAlertSheet(_NS("Local playback"), \
01662             _NS("OK"), @"", @"", o_wizard_window, nil, nil, nil, nil, \
01663             _NS("When this option is enabled, the stream will be both played " \
01664             "and transcoded/streamed.\n\nNote that this requires much more " \
01665             "CPU power than simple transcoding or streaming."));
01666 }
01667 
01668 - (IBAction)t7_selectTrnscdDestFile:(id)sender
01669 {
01670     /* provide a save-to-dialogue, so the user can choose a location for his/her new file */
01671     NSSavePanel * savePanel = [NSSavePanel savePanel];
01672     SEL sel = @selector(t7_getTrnscdDestFile:returnCode:contextInfo:);
01673     NSString * theEncapFormat = [[o_encapFormats objectAtIndex: \
01674         [[o_userSelections objectForKey:@"encapFormat"] intValue]] \
01675         objectAtIndex:0];
01676     
01677     /* don't use ".ps" as suffix, since the OSX Finder confuses our creations 
01678      * with PostScript-files and wants to open them with Preview.app */
01679     if (theEncapFormat != @"ps")
01680     {
01681         [savePanel setRequiredFileType: theEncapFormat];
01682     } else {
01683         [savePanel setRequiredFileType: @"mpg"];
01684     }
01685     
01686     [savePanel setCanSelectHiddenExtension:YES];
01687     [savePanel beginSheetForDirectory:nil file:nil modalForWindow: \
01688         o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
01689 }
01690 
01691 - (void)t7_getTrnscdDestFile: (NSSavePanel *)sheet returnCode: \
01692     (int)returnCode contextInfo: (void *)contextInfo
01693 {
01694     if (returnCode == NSOKButton)
01695     {
01696         /* output returned path to text-field */
01697         [o_t7_fld_filePath setStringValue:[sheet filename]];
01698     }
01699 }
01700 
01701 - (IBAction)wh_closeSheet:(id)sender
01702 {
01703     /* close the help sheet */
01704     [NSApp endSheet:o_wizardhelp_window];
01705     [o_wizardhelp_window close];
01706 }
01707 
01708 @end

Generated on Tue Dec 20 10:14:39 2005 for vlc-0.8.4a by  doxygen 1.4.2