]> git.sesse.net Git - vlc/blob - modules/gui/macosx/wizard.m
* ALL: basic skeleton for a streaming-wizard (refs #13)
[vlc] / modules / gui / macosx / wizard.m
1 /*****************************************************************************
2  * wizard.h: MacOS X Streaming Wizard
3  *****************************************************************************
4  * Copyright (C) 2005 VideoLAN
5  * $Id$
6  *
7  * Authors: Felix Kühne <fkuehne@users.sf.net> 
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24  
25 /*****************************************************************************
26  * Note: this code is based upon ../wxwindows/wizard.cpp,
27  *       written by Clément Stenac.
28  *****************************************************************************/ 
29  
30  
31 /*****************************************************************************
32  * Preamble
33  *****************************************************************************/ 
34 #import "wizard.h"
35 #import "intf.h"
36
37
38 /*****************************************************************************
39  * VLCWizard implementation
40  *****************************************************************************/
41
42 @implementation VLCWizard
43
44 static VLCWizard *_o_sharedInstance = nil;
45
46 + (VLCWizard *)sharedInstance
47 {
48     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
49 }
50
51 - (id)init 
52 {
53     if (_o_sharedInstance) {
54         [self dealloc];
55     } else {
56         _o_sharedInstance = [super init];
57     }
58     
59     return _o_sharedInstance;
60 }
61
62 - (void)awakeFromNib
63 {
64     /* some minor cleanup */
65     [o_t2_tbl_plst setEnabled:NO];
66
67     /* FIXME: make the both arrays global */
68
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"];
75     
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"];
82     
83     /* FIXME: fill the codec-popups as well */
84 }
85
86 - (void)showWizard
87 {
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];
91     
92     [o_wizard_window center];
93     [o_wizard_window displayIfNeeded];
94     [o_wizard_window makeKeyAndOrderFront:nil];
95 }
96
97 - (void)initStrings
98 {
99     /* localise all strings to the users lang */
100     /* method is called from intf.m (in method openWizard) */
101     
102     /* general items */
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")];
107     
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")];
116     
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")];
128     
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")];
137     
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")];
151     
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.")];
157     
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")];
166      
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...")];
173 }
174
175 - (IBAction)cancelRun:(id)sender
176 {
177     [o_wizard_window close];
178 }
179
180 - (IBAction)nextTab:(id)sender
181 {
182     /* only a stub atm; needs to be implemented correctly later on */
183     [o_tab_pageHolder selectNextTabViewItem:self];
184 }
185
186 - (IBAction)prevTab:(id)sender
187 {
188     /* only a stub atm; needs to be implemented correctly later on */
189     [o_tab_pageHolder selectPreviousTabViewItem:self];
190 }
191
192 - (IBAction)t1_mrInfo_streaming:(id)sender
193 {
194     /* show a simple notify sheet for the help */
195 }
196
197 - (IBAction)t1_mrInfo_transcode:(id)sender
198 {
199     /* show a simple notify sheet for the help */
200 }
201
202 - (IBAction)t2_addNewStream:(id)sender
203 {
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];
207 }
208
209 - (void)t2_getNewStreamFromDialog: (NSOpenPanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
210 {
211     if (returnCode == NSOKButton)
212     {
213         [o_t2_fld_pathToNewStrm setStringValue:[sheet filename]];
214         /* FIXME: store path in a global variable */
215     }
216 }
217
218 - (IBAction)t2_chooseStreamOrPlst:(id)sender
219 {
220     /* enable and disable the respective items depending on user's choice */
221     /* TODO */
222 }
223
224 - (IBAction)t2_enableExtract:(id)sender
225 {
226     /* enable/disable the respective items */
227     if([o_t2_ckb_enblPartExtrct state] == NSOnState)
228     {
229         [o_t2_fld_prtExtrctFrom setEnabled:YES];
230         [o_t2_fld_prtExtrctTo setEnabled:YES];
231     } else {
232         [o_t2_fld_prtExtrctFrom setEnabled:NO];
233         [o_t2_fld_prtExtrctTo setEnabled:NO];
234     }
235 }
236
237 - (IBAction)t3_addressEntered:(id)sender
238 {
239     /* check whether the entered address is valid */
240 }
241
242 - (IBAction)t4_AudCdcChanged:(id)sender
243 {
244     /* update codec info */
245 }
246
247 - (IBAction)t4_enblAudTrnscd:(id)sender
248 {
249     /* enable/disable the respective items */
250     if([o_t4_ckb_audio state] == NSOnState)
251     {
252         [o_t4_pop_audioCodec setEnabled:YES];
253         
254         [o_t4_pop_audioBitrate setEnabled:YES];
255     } else {
256         [o_t4_pop_audioCodec setEnabled:NO];
257         [o_t4_pop_audioBitrate setEnabled:NO];
258     }
259 }
260
261 - (IBAction)t4_enblVidTrnscd:(id)sender
262 {
263     /* enable/disable the respective items */
264     if([o_t4_ckb_video state] == NSOnState)
265     {
266         [o_t4_pop_videoCodec setEnabled:YES];
267         [o_t4_pop_videoBitrate setEnabled:YES];
268     } else {
269         [o_t4_pop_videoCodec setEnabled:NO];
270         [o_t4_pop_videoBitrate setEnabled:NO];
271     }
272 }
273
274 - (IBAction)t4_VidCdcChanged:(id)sender
275 {
276     /* update codec info */
277 }
278
279 - (IBAction)t6_enblSapAnnce:(id)sender
280 {
281     /* enable/disable input fld */
282     if([o_t6_ckb_sap state] == NSOnState)
283     {
284         [o_t6_fld_sap setEnabled:YES];
285     } else {
286         [o_t6_fld_sap setEnabled:NO];
287         [o_t6_fld_sap setStringValue:@""];
288     }
289 }
290
291 - (IBAction)t6_mrInfo_ttl:(id)sender
292 {
293     /* show a simple notify sheet for the help */
294 }
295
296 - (IBAction)t6_mrInfo_sap:(id)sender
297 {
298     /* show a simple notify sheet for the help */
299 }
300
301 - (IBAction)t7_selectTrnscdDestFile:(id)sender
302 {
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 */
308 }
309
310 - (void)t7_getTrnscdDestFile: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
311 {
312     if (returnCode == NSOKButton)
313     {
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 */
316     }
317 }
318
319 @end