wizard.m
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:87k
源码类别:

midi

开发平台:

Unix_Linux

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