1 /*****************************************************************************
2 * wizard.h: MacOS X Streaming Wizard
3 *****************************************************************************
4 * Copyright (C) 2005 VideoLAN
7 * Authors: Felix Kühne <fkuehne@users.sf.net>
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.
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.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 /*****************************************************************************
26 * Note: this code is based upon ../wxwindows/wizard.cpp,
27 * written by Clément Stenac.
28 *****************************************************************************/
31 /*****************************************************************************
33 *****************************************************************************/
38 /*****************************************************************************
39 * VLCWizard implementation
40 *****************************************************************************/
42 @implementation VLCWizard
44 static VLCWizard *_o_sharedInstance = nil;
46 + (VLCWizard *)sharedInstance
48 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
53 if (_o_sharedInstance) {
56 _o_sharedInstance = [super init];
59 return _o_sharedInstance;
64 /* some minor cleanup */
65 [o_t2_tbl_plst setEnabled:NO];
67 /* FIXME: make the both arrays global */
69 /* add audio-codecs for transcoding */
70 NSArray * audioBitratesArray;
71 audioBitratesArray = [NSArray arrayWithObjects: @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
72 [o_t4_pop_audioBitrate removeAllItems];
73 [o_t4_pop_audioBitrate addItemsWithTitles: audioBitratesArray];
74 [o_t4_pop_audioBitrate selectItemWithTitle: @"192"];
76 /* add video-codecs for transcoding */
77 NSArray * videoBitratesArray;
78 videoBitratesArray = [NSArray arrayWithObjects: @"3072", @"2048", @"1024", @"768", @"512", @"256", @"192", @"128", @"64", @"32", @"16", nil ];
79 [o_t4_pop_videoBitrate removeAllItems];
80 [o_t4_pop_videoBitrate addItemsWithTitles: videoBitratesArray];
81 [o_t4_pop_videoBitrate selectItemWithTitle: @"1024"];
83 /* FIXME: fill the codec-popups as well */
88 /* just present the window to the user */
89 /* we might need a method to reset the window first */
90 [o_tab_pageHolder selectFirstTabViewItem:self];
92 [o_wizard_window center];
93 [o_wizard_window displayIfNeeded];
94 [o_wizard_window makeKeyAndOrderFront:nil];
99 /* localise all strings to the users lang */
100 /* method is called from intf.m (in method openWizard) */
103 [o_btn_backward setTitle: _NS("< Back")];
104 [o_btn_cancel setTitle: _NS("Cancel")];
105 [o_btn_forward setTitle: _NS("Next >")];
106 [o_wizard_window setTitle: _NS("Streaming/Transcoding Wizard")];
108 /* page one ("Hello") */
109 [o_t1_txt_title setStringValue: _NS("Streaming/Transcoding Wizard")];
110 [o_t1_txt_text setStringValue: _NS("This wizard helps you to stream, transcode or save a stream")];
111 [o_t1_btn_mrInfo_strmg setTitle: _NS("More Info")];
112 [o_t1_btn_mrInfo_trnscd setTitle: _NS("More Info")];
113 [o_t1_txt_notice setStringValue: _NS("This wizard only gives access to a small subset of VLC's streaming and transcoding capabilities. Use the Open and Stream Output dialogs to get all of them")];
114 [o_t1_rdo_streaming setTitle: _NS("Stream to network")];
115 [o_t1_rdo_transcode setTitle: _NS("Transcode/Save to file")];
117 /* page two ("Input") */
118 [o_t2_title setStringValue: _NS("Choose input")];
119 [o_t2_text setStringValue: _NS("Choose here your input stream")];
120 [o_t2_rdo_newStrm setTitle: _NS("Select a stream")];
121 [o_t2_rdo_exstPlstItm setTitle: _NS("Existing playlist item")];
122 [o_t2_btn_chooseFile setTitle: _NS("Choose...")];
123 [[[o_t2_tbl_plst tableColumnWithIdentifier:@"name"] headerCell] setStringValue: _NS("Name")];
124 [o_t2_box_prtExtrct setTitle: _NS("Partial Extract")];
125 [o_t2_ckb_enblPartExtrct setTitle: _NS("Enable")];
126 [o_t2_txt_prtExtrctFrom setStringValue: _NS("From")];
127 [o_t2_txt_prtExtrctTo setStringValue: _NS("To")];
129 /* page three ("Streaming 1") */
130 [o_t3_txt_title setStringValue: _NS("Streaming")];
131 [o_t3_txt_text setStringValue: _NS("In this page, you will select how your input stream will be sent.")];
132 [o_t3_box_dest setTitle: _NS("Destination")];
133 [o_t3_box_strmgMthd setTitle: _NS("Streaming method")];
134 [o_t3_txt_destInfo setStringValue: _NS("Enter the address of the computer to stream to")];
135 [[o_t3_matrix_stmgMhd cellAtRow:1 column:0] setTitle: _NS("UDP Unicast")];
136 [[o_t3_matrix_stmgMhd cellAtRow:1 column:1] setTitle: _NS("UDP Multicast")];
138 /* page four ("Transcode 1") */
139 [o_t4_title setStringValue: _NS("Transcode")];
140 [o_t4_text setStringValue: _NS("If you want to change the compression format of the audio or video tracks, fill in this page. (If you only want to change the container format, proceed to next page).")];
141 [o_t4_box_audio setTitle: _NS("Audio")];
142 [o_t4_box_video setTitle: _NS("Video")];
143 [o_t4_ckb_audio setTitle: _NS("Transcode audio")];
144 [o_t4_ckb_video setTitle: _NS("Transcode video")];
145 [o_t4_txt_videoBitrate setStringValue: _NS("Bitrate (kb/s)")];
146 [o_t4_txt_videoCodec setStringValue: _NS("Codec")];
147 [o_t4_txt_hintAudio setStringValue: _NS("If your stream has audio and you want to " \
148 "transcode it, enable this")];
149 [o_t4_txt_hintVideo setStringValue: _NS("If your stream has video and you want to " \
150 "transcode it, enable this")];
152 /* page five ("Encap") */
153 [o_t5_title setStringValue: _NS("Encapsulation format")];
154 [o_t5_text setStringValue: _NS("In this page, you will select how the stream will be "\
155 "encapsulated. Depending on the choices you made, all "\
156 "formats won't be available.")];
158 /* page six ("Streaming 2") */
159 [o_t6_title setStringValue: _NS("Additional streaming options")];
160 [o_t6_text setStringValue: _NS("In this page, you will define a few " \
161 "additional parameters for your stream.")];
162 [o_t6_txt_ttl setStringValue: _NS("Time-To-Live (TTL)")];
163 [o_t6_btn_mrInfo_ttl setTitle: _NS("More Info")];
164 [o_t6_ckb_sap setTitle: _NS("SAP Announce")];
165 [o_t6_btn_mrInfo_sap setTitle: _NS("More Info")];
167 /* page seven ("Transcode 2") */
168 [o_t7_title setStringValue: _NS("Additional transcode options")];
169 [o_t7_text setStringValue: _NS("In this page, you will define a few " \
170 "additionnal parameters for your transcoding.")];
171 [o_t7_txt_saveFileTo setStringValue: _NS("Select the file to save to")];
172 [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
175 - (IBAction)cancelRun:(id)sender
177 [o_wizard_window close];
180 - (IBAction)nextTab:(id)sender
182 /* only a stub atm; needs to be implemented correctly later on */
183 [o_tab_pageHolder selectNextTabViewItem:self];
186 - (IBAction)prevTab:(id)sender
188 /* only a stub atm; needs to be implemented correctly later on */
189 [o_tab_pageHolder selectPreviousTabViewItem:self];
192 - (IBAction)t1_mrInfo_streaming:(id)sender
194 /* show a simple notify sheet for the help */
197 - (IBAction)t1_mrInfo_transcode:(id)sender
199 /* show a simple notify sheet for the help */
202 - (IBAction)t2_addNewStream:(id)sender
204 NSOpenPanel * openPanel = [NSOpenPanel openPanel];
205 SEL sel = @selector(t2_getNewStreamFromDialog:returnCode:contextInfo:);
206 [openPanel beginSheetForDirectory:@"~" file:nil types:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
209 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
211 if (returnCode == NSOKButton)
213 [o_t2_fld_pathToNewStrm setStringValue:[sheet filename]];
214 /* FIXME: store path in a global variable */
218 - (IBAction)t2_chooseStreamOrPlst:(id)sender
220 /* enable and disable the respective items depending on user's choice */
224 - (IBAction)t2_enableExtract:(id)sender
226 /* enable/disable the respective items */
227 if([o_t2_ckb_enblPartExtrct state] == NSOnState)
229 [o_t2_fld_prtExtrctFrom setEnabled:YES];
230 [o_t2_fld_prtExtrctTo setEnabled:YES];
232 [o_t2_fld_prtExtrctFrom setEnabled:NO];
233 [o_t2_fld_prtExtrctTo setEnabled:NO];
237 - (IBAction)t3_addressEntered:(id)sender
239 /* check whether the entered address is valid */
242 - (IBAction)t4_AudCdcChanged:(id)sender
244 /* update codec info */
247 - (IBAction)t4_enblAudTrnscd:(id)sender
249 /* enable/disable the respective items */
250 if([o_t4_ckb_audio state] == NSOnState)
252 [o_t4_pop_audioCodec setEnabled:YES];
254 [o_t4_pop_audioBitrate setEnabled:YES];
256 [o_t4_pop_audioCodec setEnabled:NO];
257 [o_t4_pop_audioBitrate setEnabled:NO];
261 - (IBAction)t4_enblVidTrnscd:(id)sender
263 /* enable/disable the respective items */
264 if([o_t4_ckb_video state] == NSOnState)
266 [o_t4_pop_videoCodec setEnabled:YES];
267 [o_t4_pop_videoBitrate setEnabled:YES];
269 [o_t4_pop_videoCodec setEnabled:NO];
270 [o_t4_pop_videoBitrate setEnabled:NO];
274 - (IBAction)t4_VidCdcChanged:(id)sender
276 /* update codec info */
279 - (IBAction)t6_enblSapAnnce:(id)sender
281 /* enable/disable input fld */
282 if([o_t6_ckb_sap state] == NSOnState)
284 [o_t6_fld_sap setEnabled:YES];
286 [o_t6_fld_sap setEnabled:NO];
287 [o_t6_fld_sap setStringValue:@""];
291 - (IBAction)t6_mrInfo_ttl:(id)sender
293 /* show a simple notify sheet for the help */
296 - (IBAction)t6_mrInfo_sap:(id)sender
298 /* show a simple notify sheet for the help */
301 - (IBAction)t7_selectTrnscdDestFile:(id)sender
303 /* provide a save-to-dialogue, so the user can choose a location for his/her new file */
304 NSSavePanel * savePanel = [NSSavePanel savePanel];
305 SEL sel = @selector(t7_getTrnscdDestFile:returnCode:contextInfo:);
306 [savePanel beginSheetForDirectory:@"~" file:nil modalForWindow:o_wizard_window modalDelegate:self didEndSelector:sel contextInfo:nil];
307 /* FIXME: insert a suffix in file depending on the chosen encap-format */
310 - (void)t7_getTrnscdDestFile: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
312 if (returnCode == NSOKButton)
314 [o_t7_fld_filePath setStringValue:[sheet filename]];
315 /* FIXME: store path in a global variable and add a suffix depending on the chosen encap-format, if needed */