]> git.sesse.net Git - vlc/blob - modules/gui/macosx/output.m
Support for UDP-Lite (with full checksum coverage only atm)
[vlc] / modules / gui / macosx / output.m
1 /*****************************************************************************
2  * output.m: MacOS X Output Dialog
3  *****************************************************************************
4  * Copyright (C) 2002-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Christophe Massiot <massiot@via.ecp.fr>
9  *          Derk-Jan Hartman <thedj@users.sourceforge.net>
10  *          Benjamin Pracht <bigben AT videolan DOT org>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include <stdlib.h>                                      /* malloc(), free() */
31 #include <string.h>
32
33 #include "intf.h"
34 #include "output.h"
35
36 /*****************************************************************************
37  * VLCOutput implementation 
38  *****************************************************************************/
39 @implementation VLCOutput
40
41 - (id)init
42 {
43     self = [super init];
44     o_mrl = [[NSArray alloc] init];
45     o_transcode = [[NSString alloc] init];
46     return self;
47 }
48
49 - (void)dealloc
50 {
51     [o_mrl release];
52     [o_transcode release];
53     [super dealloc];
54 }
55
56 - (void)setMRL:(NSArray *)o_mrl_array
57 {
58     [o_mrl autorelease];
59     o_mrl = [o_mrl_array copy];
60 }
61
62 - (NSArray *)getMRL
63 {
64     return [o_mrl copy];
65 }
66
67 - (void)setTranscode:(NSString *)o_transcode_string
68 {
69     [o_transcode autorelease];
70     o_transcode = [o_transcode_string copy];
71 }
72
73 - (void)awakeFromNib
74 {
75     [self initStrings];
76
77     [[NSNotificationCenter defaultCenter] addObserver: self
78         selector: @selector(outputInfoChanged:)
79         name: NSControlTextDidChangeNotification
80         object: o_file_field];
81     [[NSNotificationCenter defaultCenter] addObserver: self
82         selector: @selector(outputInfoChanged:)
83         name: NSControlTextDidChangeNotification
84         object: o_stream_address];
85     [[NSNotificationCenter defaultCenter] addObserver: self
86         selector: @selector(outputInfoChanged:)
87         name: NSControlTextDidChangeNotification
88         object: o_stream_port];
89     [[NSNotificationCenter defaultCenter] addObserver: self
90         selector: @selector(TTLChanged:)
91         name: NSControlTextDidChangeNotification
92         object: o_stream_ttl];
93     [[NSNotificationCenter defaultCenter] addObserver: self
94         selector: @selector(transcodeInfoChanged:)
95         name: NSControlTextDidChangeNotification
96         object: o_transcode_video_bitrate];
97     [[NSNotificationCenter defaultCenter] addObserver: self
98         selector: @selector(transcodeInfoChanged:)
99         name: NSControlTextDidChangeNotification
100         object: o_transcode_video_scale];
101     [[NSNotificationCenter defaultCenter] addObserver: self
102         selector: @selector(transcodeInfoChanged:)
103         name: NSControlTextDidChangeNotification
104         object: o_transcode_audio_bitrate];
105     [[NSNotificationCenter defaultCenter] addObserver: self
106         selector: @selector(transcodeInfoChanged:)
107         name: NSControlTextDidChangeNotification
108         object: o_transcode_audio_channels];
109     [[NSNotificationCenter defaultCenter] addObserver: self
110         selector: @selector(transcodeInfoChanged:)
111         name: NSControlTextDidChangeNotification
112         object: o_channel_name];
113     [[NSNotificationCenter defaultCenter] addObserver: self
114         selector: @selector(transcodeInfoChanged:)
115         name: NSControlTextDidChangeNotification
116         object: o_sdp_url];
117
118     [o_mux_selector setAutoenablesItems: NO];
119     [self transcodeChanged:nil];
120 }
121
122 - (void)initStrings
123 {
124     NSArray *o_muxers = [NSArray arrayWithObjects: @"MPEG TS", @"MPEG PS", @"MPEG 1",
125         @"Ogg", @"AVI", @"ASF", @"MPEG 4", @"Quicktime", @"Raw", nil];
126     NSArray *o_a_channels = [NSArray arrayWithObjects: @"1", @"2", @"4", @"6", nil];
127     NSArray *o_a_bitrates = [NSArray arrayWithObjects: @"16", @"32", @"64", @"96",
128         @"128", @"192", @"256", @"512", nil];
129     NSArray *o_v_bitrates = [NSArray arrayWithObjects: @"16", @"32", @"64", @"96",
130         @"128", @"192", @"256", @"384", @"512", @"768", @"1024", @"2048", @"3072", nil];
131     NSArray *o_v_scales = [NSArray arrayWithObjects: @"0.25",@"0.5",@"0.75",@"1",@"1.25",@"1.5",@"1.75",@"2",nil];
132     NSArray *o_a_codecs = [NSArray arrayWithObjects: @"mpga", @"mp3 ", @"mp4a", @"a52 ", @"vorb", @"flac", @"spx ", nil];
133     NSArray *o_v_codecs = [NSArray arrayWithObjects: @"mp1v", @"mp2v", @"mp4v", @"DIV1",
134         @"DIV2", @"DIV3", @"h263", @"h264", @"WMV1", @"WMV2", @"MJPG", @"theo", nil];
135
136     [o_output_ckbox setTitle: _NS("Streaming/Saving:")];
137     [o_output_settings setTitle: _NS("Settings...")];
138     [o_btn_ok setTitle: _NS("OK")];
139
140     [o_options_lbl setTitle: _NS("Streaming and Transcoding Options")];
141     [o_display setTitle: _NS("Display the stream locally")];
142     [[o_method cellAtRow:0 column:0] setTitle: _NS("File")];
143     [[o_method cellAtRow:1 column:0] setTitle: _NS("Stream")];
144     [o_dump_chkbox setTitle: _NS("Dump raw input")];
145     [o_btn_browse setTitle: _NS("Browse...")]; 
146     [o_stream_address_lbl setStringValue: _NS("Address")];
147     [o_stream_port_lbl setStringValue: _NS("Port")];
148     [o_stream_ttl_lbl setStringValue: @"TTL"];
149     [[o_stream_type itemAtIndex: 0] setTitle: @"HTTP"];
150     [[o_stream_type itemAtIndex: 1] setTitle: @"MMSH"];
151     [[o_stream_type itemAtIndex: 2] setTitle: @"UDP"];
152     [[o_stream_type itemAtIndex: 3] setTitle: @"RTP"];
153     [o_stream_type_lbl setStringValue: _NS("Type")];
154
155     [o_mux_lbl setStringValue: _NS("Encapsulation Method")];
156     [o_mux_selector removeAllItems];
157     [o_mux_selector addItemsWithTitles: o_muxers];
158
159     [o_transcode_lbl setTitle: _NS("Transcoding options")];
160     [o_transcode_video_chkbox setTitle: _NS("Video")];
161     [o_transcode_video_selector removeAllItems];
162     [o_transcode_video_selector addItemsWithTitles: o_v_codecs];
163     [o_transcode_video_bitrate_lbl setStringValue: _NS("Bitrate (kb/s)")];
164     [o_transcode_video_bitrate removeAllItems];
165     [o_transcode_video_bitrate addItemsWithObjectValues: o_v_bitrates];
166     [o_transcode_video_scale_lbl setStringValue: _NS("Scale")];
167     [o_transcode_video_scale removeAllItems];
168     [o_transcode_video_scale addItemsWithObjectValues: o_v_scales];
169     [o_transcode_video_scale selectItemWithObjectValue: @"1"];
170     [o_transcode_audio_chkbox setTitle: _NS("Audio")];
171     [o_transcode_audio_selector removeAllItems];
172     [o_transcode_audio_selector addItemsWithTitles: o_a_codecs];
173     [o_transcode_audio_bitrate_lbl setStringValue: _NS("Bitrate (kb/s)")];
174     [o_transcode_audio_bitrate removeAllItems];
175     [o_transcode_audio_bitrate addItemsWithObjectValues: o_a_bitrates];
176     [o_transcode_audio_channels_lbl setStringValue: _NS("Channels")];
177     [o_transcode_audio_channels removeAllItems];
178     [o_transcode_audio_channels addItemsWithObjectValues: o_a_channels];
179
180     [o_misc_lbl setTitle: _NS("Stream Announcing")];
181     [o_sap_chkbox setTitle: _NS("SAP announce")];
182     [o_rtsp_chkbox setTitle: _NS("RTSP announce")];
183     [o_http_chkbox setTitle:_NS("HTTP announce")];
184     [o_file_chkbox setTitle:_NS("Export SDP as file")];
185
186     [o_channel_name_lbl setStringValue: _NS("Channel Name")];
187     [o_sdp_url_lbl setStringValue: _NS("SDP URL")];
188 }
189
190 - (IBAction)outputChanged:(id)sender;
191 {
192     if ([o_output_ckbox state] == NSOnState)
193     {
194         [o_output_settings setEnabled:YES];
195     }
196     else
197     {
198         [o_output_settings setEnabled:NO];
199     }
200 }
201
202 - (IBAction)outputSettings:(id)sender
203 {
204     [NSApp beginSheet: o_output_sheet
205         modalForWindow: o_open_panel
206         modalDelegate: self
207         didEndSelector: NULL
208         contextInfo: nil];
209 }
210
211 - (IBAction)outputCloseSheet:(id)sender
212 {
213     [o_output_sheet orderOut:sender];
214     [NSApp endSheet: o_output_sheet];
215 }
216
217 - (void)outputMethodChanged:(NSNotification *)o_notification
218 {
219     NSString *o_mode;
220     o_mode = [[o_method selectedCell] title];
221
222     [o_sap_chkbox setEnabled: NO];
223     [o_http_chkbox setEnabled: NO];
224     [o_rtsp_chkbox setEnabled: NO];
225     [o_file_chkbox setEnabled: NO];
226     [o_channel_name setEnabled: NO];
227     [o_sdp_url setEnabled: NO];
228     [[o_mux_selector itemAtIndex: 0] setEnabled: YES];
229
230     if( [o_mode isEqualToString: _NS("File")] )
231     {
232         [o_file_field setEnabled: YES];
233         [o_btn_browse setEnabled: YES];
234         [o_dump_chkbox setEnabled: YES];
235         [o_stream_address setEnabled: NO];
236         [o_stream_port setEnabled: NO];
237         [o_stream_ttl setEnabled: NO];
238         [o_stream_port_stp setEnabled: NO];
239         [o_stream_ttl_stp setEnabled: NO];
240         [o_stream_type setEnabled: NO];
241         [o_mux_selector setEnabled: YES];
242         [[o_mux_selector itemAtIndex: 1] setEnabled: YES]; // MPEG PS
243         [[o_mux_selector itemAtIndex: 2] setEnabled: YES]; // MPEG 1
244         [[o_mux_selector itemAtIndex: 3] setEnabled: YES]; // Ogg
245         [[o_mux_selector itemAtIndex: 4] setEnabled: YES]; // AVI
246         [[o_mux_selector itemAtIndex: 5] setEnabled: YES]; // ASF
247         [[o_mux_selector itemAtIndex: 6] setEnabled: YES]; // MPEG 4
248         [[o_mux_selector itemAtIndex: 7] setEnabled: YES]; // QuickTime
249         [[o_mux_selector itemAtIndex: 8] setEnabled: YES]; // Raw
250     }
251     else if( [o_mode isEqualToString: _NS("Stream")] )
252     {
253         [o_file_field setEnabled: NO];
254         [o_dump_chkbox setEnabled: NO];
255         [o_btn_browse setEnabled: NO];
256         [o_stream_port setEnabled: YES];
257         [o_stream_port_stp setEnabled: YES];
258         [o_stream_type setEnabled: YES];
259         [o_mux_selector setEnabled: YES];
260
261         o_mode = [o_stream_type titleOfSelectedItem];
262
263         if( [o_mode isEqualToString: @"HTTP"] )
264         {
265             [o_stream_address setEnabled: YES];
266             [o_stream_ttl setEnabled: NO];
267             [o_stream_ttl_stp setEnabled: NO];
268             [[o_mux_selector itemAtIndex: 1] setEnabled: YES];
269             [[o_mux_selector itemAtIndex: 2] setEnabled: YES];
270             [[o_mux_selector itemAtIndex: 3] setEnabled: YES];
271             [[o_mux_selector itemAtIndex: 4] setEnabled: NO];
272             [[o_mux_selector itemAtIndex: 5] setEnabled: YES];
273             [[o_mux_selector itemAtIndex: 6] setEnabled: NO];
274             [[o_mux_selector itemAtIndex: 7] setEnabled: NO];
275             [[o_mux_selector itemAtIndex: 8] setEnabled: YES];
276         }
277         else if( [o_mode isEqualToString: @"MMSH"] )
278         {
279             [o_stream_address setEnabled: YES];
280             [o_stream_ttl setEnabled: NO];
281             [o_stream_ttl_stp setEnabled: NO];
282             [[o_mux_selector itemAtIndex: 0] setEnabled: NO];
283             [[o_mux_selector itemAtIndex: 1] setEnabled: NO];
284             [[o_mux_selector itemAtIndex: 2] setEnabled: NO];
285             [[o_mux_selector itemAtIndex: 3] setEnabled: NO];
286             [[o_mux_selector itemAtIndex: 4] setEnabled: NO];
287             [[o_mux_selector itemAtIndex: 5] setEnabled: YES];
288             [[o_mux_selector itemAtIndex: 6] setEnabled: NO];
289             [[o_mux_selector itemAtIndex: 7] setEnabled: NO];
290             [[o_mux_selector itemAtIndex: 8] setEnabled: NO];
291             [o_mux_selector selectItemAtIndex: 5];
292         }
293         else if( [o_mode isEqualToString: @"UDP"] )
294         {
295             [o_stream_address setEnabled: YES];
296             [o_stream_ttl setEnabled: YES];
297             [o_stream_ttl_stp setEnabled: YES];
298             [[o_mux_selector itemAtIndex: 1] setEnabled: NO];
299             [[o_mux_selector itemAtIndex: 2] setEnabled: NO];
300             [[o_mux_selector itemAtIndex: 3] setEnabled: NO];
301             [[o_mux_selector itemAtIndex: 4] setEnabled: NO];
302             [[o_mux_selector itemAtIndex: 5] setEnabled: NO];
303             [[o_mux_selector itemAtIndex: 6] setEnabled: NO];
304             [[o_mux_selector itemAtIndex: 7] setEnabled: NO];
305             [[o_mux_selector itemAtIndex: 8] setEnabled: YES];
306             [o_sap_chkbox setEnabled: YES];
307             [o_channel_name setEnabled: YES];
308         }
309         else if( [o_mode isEqualToString: @"RTP"] )
310         {
311             [o_stream_address setEnabled: YES];
312             [o_stream_ttl setEnabled: YES];
313             [o_stream_ttl_stp setEnabled: YES];
314             [[o_mux_selector itemAtIndex: 0] setEnabled: NO];
315             [[o_mux_selector itemAtIndex: 1] setEnabled: NO];
316             [[o_mux_selector itemAtIndex: 2] setEnabled: NO];
317             [[o_mux_selector itemAtIndex: 3] setEnabled: NO];
318             [[o_mux_selector itemAtIndex: 4] setEnabled: NO];
319             [[o_mux_selector itemAtIndex: 5] setEnabled: NO];
320             [[o_mux_selector itemAtIndex: 6] setEnabled: NO];
321             [[o_mux_selector itemAtIndex: 7] setEnabled: NO];
322             [[o_mux_selector itemAtIndex: 8] setEnabled: YES];
323             [o_mux_selector selectItemAtIndex: 8];
324             [o_sap_chkbox setEnabled: YES];
325             [o_rtsp_chkbox setEnabled: YES];
326             [o_http_chkbox setEnabled: YES];
327             [o_file_chkbox setEnabled: YES];
328             [o_channel_name setEnabled: YES];
329         }
330     }
331
332     if( ![[o_mux_selector selectedItem] isEnabled] && ![o_mode isEqualToString: @"RTP"] )
333     {
334         [o_mux_selector selectItemAtIndex: 0];
335     }
336     else if (![[o_mux_selector selectedItem] isEnabled] && [o_mode isEqualToString: @"RTP"] )
337     {
338         [o_mux_selector selectItemAtIndex: 8];
339     }
340     [self outputInfoChanged: nil];
341 }
342
343 - (void)outputInfoChanged:(NSNotification *)o_notification
344 {
345     NSString *o_mode, *o_mux, *o_mux_string;
346     NSMutableString *o_announce = [NSMutableString stringWithString:@""];
347     NSMutableString *o_mrl_string = [NSMutableString stringWithString:@":sout=#"];
348     NSArray *o_sout_options;
349
350     [o_mrl_string appendString: o_transcode];
351     if( [o_display state] == NSOnState )
352     {
353         [o_mrl_string appendString: @"duplicate{dst=display,dst="];
354     }
355
356     o_mode = [[o_method selectedCell] title];
357     o_mux = [o_mux_selector titleOfSelectedItem];
358
359     if ( [o_mux isEqualToString: @"AVI"] ) o_mux_string = @"avi";
360     else if ( [o_mux isEqualToString: @"Ogg"] ) o_mux_string = @"ogg";
361     else if ( [o_mux isEqualToString: @"MPEG PS"] ) o_mux_string = @"ps";
362     else if ( [o_mux isEqualToString: @"MPEG 4"] ) o_mux_string = @"mp4";
363     else if ( [o_mux isEqualToString: @"MPEG 1"] ) o_mux_string = @"mpeg1";
364     else if ( [o_mux isEqualToString: @"Quicktime"] ) o_mux_string = @"mov";
365     else if ( [o_mux isEqualToString: @"ASF"] ) o_mux_string = @"asf";
366     else if ( [o_mux isEqualToString: @"Raw"] ) o_mux_string = @"raw";
367     else o_mux_string = @"ts";
368
369     if( [o_mode isEqualToString: _NS("File")] )
370     {
371         if( [o_dump_chkbox state] == NSOnState )
372         {
373             NSMutableArray * o_sout_options;
374             o_sout_options = [NSArray arrayWithObjects:
375                                     [NSString stringWithString:
376                                     @":demux=dump"],
377                                     [NSString stringWithFormat:
378                                     @":demuxdump-file=%@",
379                                     [o_file_field stringValue]],
380                                     nil];
381             [self setMRL:o_sout_options];
382             return;
383         }
384         else
385         {
386                 [o_mrl_string appendFormat:
387                         @"std{access=file,mux=%@,dst=\"%@\"}",
388                         o_mux_string, [o_file_field stringValue]];
389         }
390     }
391     else if( [o_mode isEqualToString: _NS("Stream")] )
392     {
393         o_mode = [o_stream_type titleOfSelectedItem];
394
395         if ( [o_mode isEqualToString: @"HTTP"] )
396             o_mode = @"http";
397         else if ( [o_mode isEqualToString: @"MMSH"] )
398         {
399             if ( [o_mux isEqualToString: @"ASF"] ) o_mux_string = @"asfh";
400             o_mode = @"mmsh";
401         }
402         else if ( [o_mode isEqualToString: @"UDP"] )
403         {
404             o_mode = @"udp";
405             if( [o_sap_chkbox state] == NSOnState )
406             {
407                 if ( ![[o_channel_name stringValue] isEqualToString: @""] )
408                     [o_announce appendFormat:
409                         @",sap,name=%@", [o_channel_name stringValue]];
410                 else
411                     [o_announce appendFormat:@",sap"];
412             }
413         }
414         if ( ![o_mode isEqualToString: @"RTP"] )
415         {
416             /* split up the hostname and the following path to paste the
417              * port correctly. Not need, if there isn't any path following the
418              * hostname. */
419             NSArray * o_urlItems = [[o_stream_address stringValue] \
420                 componentsSeparatedByString: @"/"];
421             NSMutableString * o_finalStreamAddress;
422             o_finalStreamAddress = [[NSMutableString alloc] init];
423             
424             if ([o_urlItems count] == 1)
425             {
426                 [o_finalStreamAddress appendFormat: @"\"%@:%@\"", \
427                     [o_stream_address stringValue],[o_stream_port stringValue]];
428             }
429             else
430             {
431                 [o_finalStreamAddress appendFormat: @"\"%@:%@", [o_urlItems \
432                     objectAtIndex: 0], [o_stream_port stringValue]];
433                 unsigned int x;
434                 x = 1;
435                 while (x != [o_urlItems count])
436                 {
437                     [o_finalStreamAddress appendFormat: @"/%@", [o_urlItems \
438                         objectAtIndex: x]];
439                     x = (x + 1);
440                 }
441                 [o_finalStreamAddress appendString: @"\""];
442             }
443             
444             [o_mrl_string appendFormat:
445                         @"std{access=%@,mux=%@,dst=%@%@}",
446                         o_mode, o_mux_string, o_finalStreamAddress, o_announce];
447         }
448         else
449         {
450             NSString * o_stream_name;
451
452             if (![[o_channel_name stringValue] isEqualToString: @""] )
453             {
454                 o_stream_name = [NSString stringWithFormat:@",name=%@",
455                                 [o_channel_name stringValue]];
456             }
457             else
458             {
459                 o_stream_name = @"";
460             }
461
462             if ( [o_sap_chkbox state] == NSOnState )
463             {
464                 [o_announce appendString: @",sdp=sap"];
465             }
466             if ([o_rtsp_chkbox state] == NSOnState )
467             {
468                 [o_announce appendFormat:@",sdp=\"rtsp://%@\"",[o_sdp_url stringValue]];
469
470             }
471             if ([o_http_chkbox state] == NSOnState )
472             {
473                 [o_announce appendFormat:@",sdp=\"http://%@\"",[o_sdp_url stringValue]];
474             }
475             if ([o_file_chkbox state] == NSOnState )
476             {
477                 [o_announce appendFormat:@",sdp=\"file://%@\"",[o_sdp_url stringValue]];
478             }
479             [o_mrl_string appendFormat:
480                         @"rtp{dst=\"%@\",port=%@%@%@}",[o_stream_address stringValue],
481                         [o_stream_port stringValue], o_stream_name, o_announce];
482         }
483
484     }
485     if( [o_display state] == NSOnState )
486     {
487         [o_mrl_string appendString: @"}"];
488     }
489     o_sout_options = [NSArray arrayWithObjects: o_mrl_string,nil];
490     [self setMRL:o_sout_options];
491 }
492
493 - (void)TTLChanged:(NSNotification *)o_notification
494 {
495     intf_thread_t * p_intf = VLCIntf;
496     config_PutInt( p_intf, "ttl", [o_stream_ttl intValue] );
497 }
498
499 - (IBAction)outputFileBrowse:(id)sender
500 {
501     NSSavePanel *o_save_panel = [NSSavePanel savePanel];
502     NSString *o_mux_string;
503     if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"MPEG PS"] )
504         o_mux_string = @"vob";
505     else if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"MPEG 1"] )
506         o_mux_string = @"mpg";
507     else if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"AVI"] )
508         o_mux_string = @"avi";
509     else if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"ASF"] )
510         o_mux_string = @"asf";
511     else if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"Ogg"] )
512         o_mux_string = @"ogm";
513     else if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"MPEG 4"] )
514         o_mux_string = @"mp4";
515     else if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"Quicktime"] )
516         o_mux_string = @"mov";
517     else if ( [[o_mux_selector titleOfSelectedItem] isEqualToString: @"Raw"] )
518         o_mux_string = @"raw";
519     else
520         o_mux_string = @"ts";
521
522     NSString * o_name = [NSString stringWithFormat: @"vlc-output.%@",
523                          o_mux_string];
524
525     [o_save_panel setTitle: _NS("Save File")];
526     [o_save_panel setPrompt: _NS("Save")];
527
528     if( [o_save_panel runModalForDirectory: nil
529             file: o_name] == NSOKButton )
530     {
531         NSString *o_filename = [o_save_panel filename];
532         [o_file_field setStringValue: o_filename];
533         [self outputInfoChanged: nil];
534     }
535 }
536
537 - (IBAction)streamPortStepperChanged:(id)sender
538 {
539     [o_stream_port setIntValue: [o_stream_port_stp intValue]];
540     [self outputInfoChanged: nil];
541 }
542
543 - (IBAction)streamTTLStepperChanged:(id)sender
544 {
545     [o_stream_ttl setIntValue: [o_stream_ttl_stp intValue]];
546     [self TTLChanged:nil];
547 }
548
549 - (void)transcodeChanged:(NSNotification *)o_notification
550 {
551     if( [o_transcode_video_chkbox state] == NSOnState )
552     {
553         [o_transcode_video_selector setEnabled: YES];
554         [o_transcode_video_bitrate setEnabled: YES];
555         [o_transcode_video_scale setEnabled: YES];
556     }
557     else
558     {
559         [o_transcode_video_selector setEnabled: NO];
560         [o_transcode_video_bitrate setEnabled: NO];
561         [o_transcode_video_scale setEnabled: NO];
562     }
563     if( [o_transcode_audio_chkbox state] == NSOnState )
564     {
565         [o_transcode_audio_selector setEnabled: YES];
566         [o_transcode_audio_bitrate setEnabled: YES];
567         [o_transcode_audio_channels setEnabled: YES];
568     }
569     else
570     {
571         [o_transcode_audio_selector setEnabled: NO];
572         [o_transcode_audio_bitrate setEnabled: NO];
573         [o_transcode_audio_channels setEnabled: NO];
574     }
575
576     [self transcodeInfoChanged:nil];
577 }
578
579 - (void)transcodeInfoChanged:(NSNotification *)o_notification
580 {
581     NSMutableString *o_transcode_string;
582
583     if( [o_transcode_video_chkbox state] == NSOnState ||
584         [o_transcode_audio_chkbox state] == NSOnState )
585     {
586         o_transcode_string = [NSMutableString stringWithString:@"transcode{"];
587         if ( [o_transcode_video_chkbox state] == NSOnState )
588         {
589             [o_transcode_string appendFormat: @"vcodec=\"%@\",vb=\"%@\"" \
590                                                             ",scale=\"%@\"",
591                 [o_transcode_video_selector titleOfSelectedItem],
592                 [o_transcode_video_bitrate stringValue],
593                 [o_transcode_video_scale stringValue]];
594             if ( [o_transcode_audio_chkbox state] == NSOnState )
595             {
596                 [o_transcode_string appendString: @","];
597             }
598         }
599         if ( [o_transcode_audio_chkbox state] == NSOnState )
600         {
601             [o_transcode_string appendFormat: @"acodec=\"%@\",ab=\"%@\"",
602                 [o_transcode_audio_selector titleOfSelectedItem],
603                 [o_transcode_audio_bitrate stringValue]];
604             if ( ![[o_transcode_audio_channels stringValue]
605                                             isEqualToString: @""])
606             {
607                 [o_transcode_string appendFormat: @",channels=\"%@\"",
608                                    [o_transcode_audio_channels stringValue]];
609             }
610         }
611         [o_transcode_string appendString:@"}:"];
612     }
613     else
614     {
615         o_transcode_string = [NSString stringWithString:@""];
616     }
617     [self setTranscode: o_transcode_string];
618     [self outputInfoChanged:nil];
619 }
620
621 - (IBAction)announceChanged:(id)sender
622 {
623     NSString *o_mode;
624     o_mode = [[o_stream_type selectedCell] title];
625     [o_channel_name setEnabled: [o_sap_chkbox state] ||
626                 [o_mode isEqualToString: @"RTP"]];
627
628     if ([o_mode isEqualToString: @"RTP"])
629     {
630 /*        if ([[sender title] isEqualToString: _NS("SAP announce")])
631         {
632             [o_rtsp_chkbox setState:NSOffState];
633             [o_http_chkbox setState:NSOffState];
634         }*/
635         if ([[sender title] isEqualToString:_NS("RTSP announce")])
636         {
637 //            [o_sap_chkbox setState:NSOffState];
638             [o_http_chkbox setState:NSOffState];
639             [o_file_chkbox setState:NSOffState];
640         }
641         else if ([[sender title] isEqualToString:_NS("HTTP announce")])
642         {
643 //            [o_sap_chkbox setState:NSOffState];
644             [o_rtsp_chkbox setState:NSOffState];
645             [o_file_chkbox setState:NSOffState];
646         }
647         else if ([[sender title] isEqualToString:_NS("Export SDP as file")])
648         {
649             [o_rtsp_chkbox setState:NSOffState];
650             [o_http_chkbox setState:NSOffState];
651         }
652
653         if ( [o_rtsp_chkbox state] == NSOnState ||
654                             [o_http_chkbox state] == NSOnState ||
655                             [o_file_chkbox state] == NSOnState )
656         {
657             [o_sdp_url setEnabled: YES];
658         }
659         else
660         {
661             [o_sdp_url setEnabled: NO];
662         }
663     }
664     [self outputInfoChanged: nil];
665 }
666
667 @end