1 /*****************************************************************************
2 * open.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
5 * $Id: open.m,v 1.26 2003/03/26 03:13:30 hartman Exp $
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * Derk-Jan Hartman <thedj@users.sourceforge.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
29 #include <stdlib.h> /* malloc(), free() */
30 #include <sys/param.h> /* for MAXPATHLEN */
34 #include <IOKit/IOKitLib.h>
35 #include <IOKit/IOBSD.h>
36 #include <IOKit/storage/IOMedia.h>
37 #include <IOKit/storage/IOCDMedia.h>
38 #include <IOKit/storage/IODVDMedia.h>
46 /*****************************************************************************
47 * GetEjectableMediaOfClass
48 *****************************************************************************/
49 NSArray *GetEjectableMediaOfClass( const char *psz_class )
51 io_object_t next_media;
52 mach_port_t master_port;
53 kern_return_t kern_result;
54 NSArray *o_devices = nil;
55 NSMutableArray *p_list = nil;
56 io_iterator_t media_iterator;
57 CFMutableDictionaryRef classes_to_match;
59 kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
60 if( kern_result != KERN_SUCCESS )
65 classes_to_match = IOServiceMatching( psz_class );
66 if( classes_to_match == NULL )
71 CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectable ),
74 kern_result = IOServiceGetMatchingServices( master_port, classes_to_match,
76 if( kern_result != KERN_SUCCESS )
81 p_list = [NSMutableArray arrayWithCapacity: 1];
83 next_media = IOIteratorNext( media_iterator );
84 if( next_media != NULL )
87 size_t dev_path_length;
88 CFTypeRef str_bsd_path;
92 str_bsd_path = IORegistryEntryCreateCFProperty( next_media,
96 if( str_bsd_path == NULL )
98 IOObjectRelease( next_media );
102 snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
103 dev_path_length = strlen( psz_buf );
105 if( CFStringGetCString( str_bsd_path,
106 (char*)&psz_buf + dev_path_length,
107 sizeof(psz_buf) - dev_path_length,
108 kCFStringEncodingASCII ) )
110 [p_list addObject: [NSString stringWithCString: psz_buf]];
113 CFRelease( str_bsd_path );
115 IOObjectRelease( next_media );
117 } while( ( next_media = IOIteratorNext( media_iterator ) ) != NULL );
120 IOObjectRelease( media_iterator );
122 o_devices = [NSArray arrayWithArray: p_list];
127 /*****************************************************************************
128 * VLCOpen implementation
129 *****************************************************************************/
130 @implementation VLCOpen
134 intf_thread_t * p_intf = [NSApp getIntf];
135 char * psz_sout = config_GetPsz( p_intf, "sout" );
137 if ( psz_sout != NULL && *psz_sout )
139 [o_sout_cbox setState: YES];
143 [o_sout_cbox setState: NO];
147 [o_panel setTitle: _NS("Open Source")];
148 [o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
149 [o_ckbox_enqueue setTitle: _NS("Only enqueue in playlist, do not play")];
151 [o_btn_ok setTitle: _NS("OK")];
152 [o_btn_cancel setTitle: _NS("Cancel")];
154 [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
155 [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
156 [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
158 [o_file_btn_browse setTitle: _NS("Browse...")];
159 [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
161 [o_disc_device_lbl setStringValue: _NS("Device name")];
162 [o_disc_title_lbl setStringValue: _NS("Title")];
163 [o_disc_chapter_lbl setStringValue: _NS("Chapter")];
164 [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
165 [o_disc_dvd_menus setTitle: _NS("Use DVD menus (EXPERIMENTAL)")];
167 [[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
168 [[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
169 [[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")];
171 [o_net_udp_port_lbl setStringValue: _NS("Port")];
172 [o_net_udpm_addr_lbl setStringValue: _NS("Address")];
173 [o_net_udpm_port_lbl setStringValue: _NS("Port")];
174 [o_net_http_url_lbl setStringValue: _NS("URL")];
176 [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("UDP/RTP")];
177 [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("UDP/RTP Multicast")];
178 [[o_net_mode cellAtRow:2 column:0] setTitle: _NS("HTTP/FTP/MMS")];
180 [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
181 [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
183 [o_sout_cbox setTitle: _NS("Stream output:")];
184 [o_sout_btn_ok setTitle: _NS("OK")];
185 [o_sout_settings setTitle: _NS("Settings")];
186 [o_sout_mrl_lbl setTitle: _NS("Stream output MRL")];
188 [o_sout_access_lbl setTitle: _NS("Output Method")];
189 [[o_sout_access cellAtRow:0 column:0] setTitle: _NS("File")];
190 [[o_sout_access cellAtRow:1 column:0] setTitle: _NS("HTTP")];
191 [[o_sout_access cellAtRow:2 column:0] setTitle: _NS("UDP")];
192 [[o_sout_access cellAtRow:3 column:0] setTitle: _NS("RTP")];
194 [o_sout_file_btn_browse setTitle: _NS("Browse...")];
195 [o_sout_udp_addr_lbl setStringValue: _NS("Address")];
196 [o_sout_udp_port_lbl setStringValue: _NS("Port")];
198 [o_sout_mux_lbl setTitle: _NS("Encapsulation Method")];
199 [[o_sout_mux cellAtRow:0 column:0] setTitle: _NS("MPEG TS")];
200 [[o_sout_mux cellAtRow:0 column:1] setTitle: _NS("MPEG PS")];
201 [[o_sout_mux cellAtRow:0 column:2] setTitle: _NS("AVI")];
202 [[o_sout_mux cellAtRow:0 column:3] setTitle: _NS("Ogg")];
204 [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
205 [o_file_sub_btn_settings setTitle: _NS("Settings")];
206 [o_file_sub_btn_browse setTitle: _NS("Browse...")];
207 [o_file_sub_override setTitle: _NS("Override")];
208 [o_file_sub_delay_lbl setStringValue: _NS("delay")];
209 [o_file_sub_delay_stp setEnabled: NO];
210 [o_file_sub_fps_lbl setStringValue: _NS("fps")];
211 [o_file_sub_fps_stp setEnabled: NO];
212 [o_file_sub_ok_btn setStringValue: _NS("OK")];
214 [[NSNotificationCenter defaultCenter] addObserver: self
215 selector: @selector(openFilePathChanged:)
216 name: NSControlTextDidChangeNotification
217 object: o_file_path];
219 [[NSNotificationCenter defaultCenter] addObserver: self
220 selector: @selector(openDiscInfoChanged:)
221 name: NSControlTextDidChangeNotification
222 object: o_disc_device];
223 [[NSNotificationCenter defaultCenter] addObserver: self
224 selector: @selector(openDiscInfoChanged:)
225 name: NSControlTextDidChangeNotification
226 object: o_disc_title];
227 [[NSNotificationCenter defaultCenter] addObserver: self
228 selector: @selector(openDiscInfoChanged:)
229 name: NSControlTextDidChangeNotification
230 object: o_disc_chapter];
231 [[NSNotificationCenter defaultCenter] addObserver: self
232 selector: @selector(openDiscInfoChanged:)
233 name: NSControlTextDidChangeNotification
234 object: o_disc_videots_folder];
236 [[NSNotificationCenter defaultCenter] addObserver: self
237 selector: @selector(openNetInfoChanged:)
238 name: NSControlTextDidChangeNotification
239 object: o_net_udp_port];
240 [[NSNotificationCenter defaultCenter] addObserver: self
241 selector: @selector(openNetInfoChanged:)
242 name: NSControlTextDidChangeNotification
243 object: o_net_udpm_addr];
244 [[NSNotificationCenter defaultCenter] addObserver: self
245 selector: @selector(openNetInfoChanged:)
246 name: NSControlTextDidChangeNotification
247 object: o_net_udpm_port];
248 [[NSNotificationCenter defaultCenter] addObserver: self
249 selector: @selector(openNetInfoChanged:)
250 name: NSControlTextDidChangeNotification
251 object: o_net_http_url];
253 [[NSNotificationCenter defaultCenter] addObserver: self
254 selector: @selector(soutInfoChanged:)
255 name: NSControlTextDidChangeNotification
256 object: o_sout_file_path];
257 [[NSNotificationCenter defaultCenter] addObserver: self
258 selector: @selector(soutInfoChanged:)
259 name: NSControlTextDidChangeNotification
260 object: o_sout_udp_addr];
261 [[NSNotificationCenter defaultCenter] addObserver: self
262 selector: @selector(soutInfoChanged:)
263 name: NSControlTextDidChangeNotification
264 object: o_sout_udp_port];
267 - (void)openTarget:(int)i_type
271 [o_tabview selectTabViewItemAtIndex: i_type];
272 [o_ckbox_enqueue setState: NSOnState];
273 [o_file_sub_ckbox setState: NSOffState];
275 i_result = [NSApp runModalForWindow: o_panel];
280 NSString *o_sout = [o_sout_mrl stringValue];
281 intf_thread_t * p_intf = [NSApp getIntf];
283 if ( [o_sout_cbox state] )
285 config_PutPsz( p_intf, "sout", [o_sout lossyCString] );
288 NSString *o_source = [o_mrl stringValue];
289 BOOL b_enq = [o_ckbox_enqueue state] == NSOnState ? YES : NO;
290 NSString *subPath = [o_file_sub_path stringValue];
292 [o_playlist appendArray:
293 [NSArray arrayWithObject: o_source] atPos: -1 enqueue:b_enq];
295 if (([o_file_sub_ckbox state] == NSOnState) && !([subPath isEqualTo: @""]))
297 config_PutPsz( p_intf, "sub-file", strdup( [subPath cString] ) );
298 if ( [o_file_sub_override state] )
300 config_PutInt( p_intf, "sub-delay", (int)( [o_file_sub_delay intValue] * 10 ) );
301 config_PutFloat( p_intf, "sub-fps", [o_file_sub_fps floatValue] );
306 config_PutPsz( p_intf, "sub-file", "" );
307 config_PutInt( p_intf, "sub-delay", 0 );
308 config_PutFloat( p_intf, "sub-fps", 0.0 );
311 [self soutModeChanged: nil];
314 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
316 NSString *o_label = [o_tvi label];
318 if( [o_label isEqualToString: _NS("File")] )
320 [self openFilePathChanged: nil];
322 else if( [o_label isEqualToString: _NS("Disc")] )
324 [self openDiscTypeChanged: nil];
326 else if( [o_label isEqualToString: _NS("Network")] )
328 [self openNetModeChanged: nil];
332 - (IBAction)openFileGeneric:(id)sender
334 [self openFilePathChanged: nil];
335 [self openTarget: 0];
338 - (IBAction)openDisc:(id)sender
340 [self openDiscTypeChanged: nil];
341 [self openTarget: 1];
344 - (IBAction)openNet:(id)sender
346 [self openNetModeChanged: nil];
347 [self openTarget: 2];
350 - (void)openFilePathChanged:(NSNotification *)o_notification
352 NSString *o_mrl_string;
353 NSString *o_filename = [o_file_path stringValue];
354 NSString *o_ext = [o_filename pathExtension];
355 vlc_bool_t b_stream = [o_file_stream state];
358 [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
362 o_mrl_string = [NSString stringWithFormat: @"dir:%@", o_filename];
364 else if( [o_ext isEqualToString: @"bin"] ||
365 [o_ext isEqualToString: @"cue"] ||
366 [o_ext isEqualToString: @"vob"] ||
367 [o_ext isEqualToString: @"iso"] )
369 o_mrl_string = o_filename;
373 o_mrl_string = [NSString stringWithFormat: @"%s://%@",
374 b_stream ? "stream" : "file",
377 [o_mrl setStringValue: o_mrl_string];
380 - (IBAction)openFileBrowse:(id)sender
382 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
384 [o_open_panel setAllowsMultipleSelection: NO];
385 [o_open_panel setCanChooseDirectories: YES];
386 [o_open_panel setTitle: _NS("Open File")];
387 [o_open_panel setPrompt: _NS("Open")];
389 [o_open_panel beginSheetForDirectory:nil
392 modalForWindow:[sender window]
394 didEndSelector: @selector(pathChosenInPanel:
400 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void *)contextInfo
402 if (returnCode == NSFileHandlingPanelOKButton)
404 NSString *o_filename = [[sheet filenames] objectAtIndex: 0];
405 [o_file_path setStringValue: o_filename];
406 [self openFilePathChanged: nil];
410 - (IBAction)openFileStreamChanged:(id)sender
412 [self openFilePathChanged: nil];
415 - (IBAction)openDiscTypeChanged:(id)sender
418 vlc_bool_t b_device, b_menus, b_title_chapter;
420 [o_disc_device removeAllItems];
421 b_title_chapter = ![o_disc_dvd_menus state];
423 o_type = [[o_disc_type selectedCell] title];
425 if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
427 b_device = 0; b_menus = 1;
433 const char *psz_class = NULL;
436 if ( [o_type isEqualToString: _NS("VCD")] )
438 psz_class = kIOCDMediaClass;
440 b_menus = 0; b_title_chapter = 1;
441 [o_disc_dvd_menus setState: FALSE];
445 psz_class = kIODVDMediaClass;
450 o_devices = GetEjectableMediaOfClass( psz_class );
451 if ( o_devices != nil )
453 int i_devices = [o_devices count];
459 for( i = 0; i < i_devices; i++ )
462 addItemWithObjectValue: [o_devices objectAtIndex: i]];
465 [o_disc_device selectItemAtIndex: 0];
469 [o_disc_device setStringValue:
470 [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
475 [o_disc_device setEnabled: b_device];
476 [o_disc_title setEnabled: b_title_chapter];
477 [o_disc_title_stp setEnabled: b_title_chapter];
478 [o_disc_chapter setEnabled: b_title_chapter];
479 [o_disc_chapter_stp setEnabled: b_title_chapter];
480 [o_disc_videots_folder setEnabled: !b_device];
481 [o_disc_videots_btn_browse setEnabled: !b_device];
482 [o_disc_dvd_menus setEnabled: b_menus];
484 [self openDiscInfoChanged: nil];
487 - (IBAction)openDiscStepperChanged:(id)sender
489 int i_tag = [sender tag];
493 [o_disc_title setIntValue: [o_disc_title_stp intValue]];
495 else if( i_tag == 1 )
497 [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
500 [self openDiscInfoChanged: nil];
503 - (void)openDiscInfoChanged:(NSNotification *)o_notification
508 NSString *o_mrl_string;
509 int i_title, i_chapter;
512 o_type = [[o_disc_type selectedCell] title];
513 o_device = [o_disc_device stringValue];
514 i_title = [o_disc_title intValue];
515 i_chapter = [o_disc_chapter intValue];
516 o_videots = [o_disc_videots_folder stringValue];
517 b_menus = [o_disc_dvd_menus state];
519 if ( [o_type isEqualToString: _NS("VCD")] )
521 if ( [o_device isEqualToString:
522 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
524 o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i,%i",
525 o_device, i_title, i_chapter];
527 else if ( [o_type isEqualToString: _NS("DVD")] )
529 if ( [o_device isEqualToString:
530 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
533 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
536 o_mrl_string = [NSString stringWithFormat: @"dvdold://%@@%i,%i",
537 o_device, i_title, i_chapter];
539 else /* VIDEO_TS folder */
542 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
545 o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i,%i",
546 o_videots, i_title, i_chapter];
549 [o_mrl setStringValue: o_mrl_string];
552 - (IBAction)openDiscMenusChanged:(id)sender
554 [self openDiscInfoChanged: nil];
555 [self openDiscTypeChanged: nil];
558 - (IBAction)openVTSBrowse:(id)sender
560 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
562 [o_open_panel setAllowsMultipleSelection: NO];
563 [o_open_panel setCanChooseFiles: NO];
564 [o_open_panel setCanChooseDirectories: YES];
565 [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
566 [o_open_panel setPrompt: _NS("Open")];
568 if( [o_open_panel runModalForDirectory: nil
569 file: nil types: nil] == NSOKButton )
571 NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
572 [o_disc_videots_folder setStringValue: o_dirname];
573 [self openDiscInfoChanged: nil];
577 - (IBAction)openNetModeChanged:(id)sender
584 o_mode = [[o_net_mode selectedCell] title];
586 if( [o_mode isEqualToString: _NS("UDP/RTP")] ) b_udp = TRUE;
587 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) b_udpm = TRUE;
588 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] ) b_http = TRUE;
590 [o_net_udp_port setEnabled: b_udp];
591 [o_net_udp_port_stp setEnabled: b_udp];
592 [o_net_udpm_addr setEnabled: b_udpm];
593 [o_net_udpm_port setEnabled: b_udpm];
594 [o_net_udpm_port_stp setEnabled: b_udpm];
595 [o_net_http_url setEnabled: b_http];
597 [self openNetInfoChanged: nil];
600 - (IBAction)openNetStepperChanged:(id)sender
602 int i_tag = [sender tag];
606 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
608 else if( i_tag == 1 )
610 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
613 [self openNetInfoChanged: nil];
616 - (void)openNetInfoChanged:(NSNotification *)o_notification
619 NSString *o_mrl_string = [NSString string];
620 intf_thread_t * p_intf = [NSApp getIntf];
622 o_mode = [[o_net_mode selectedCell] title];
624 if( [o_mode isEqualToString: _NS("UDP/RTP")] )
626 int i_port = [o_net_udp_port intValue];
628 o_mrl_string = [NSString stringWithString: @"udp://"];
630 if( i_port != config_GetInt( p_intf, "server-port" ) )
633 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
636 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] )
638 NSString *o_addr = [o_net_udpm_addr stringValue];
639 int i_port = [o_net_udpm_port intValue];
641 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
643 if( i_port != config_GetInt( p_intf, "server-port" ) )
646 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
649 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] )
651 NSString *o_url = [o_net_http_url stringValue];
653 if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
654 && ![o_url hasPrefix:@"mms"] )
655 o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
657 o_mrl_string = o_url;
660 [o_mrl setStringValue: o_mrl_string];
663 - (IBAction)soutChanged:(id)sender;
665 if ([o_sout_cbox state] == NSOnState)
667 [o_sout_settings setEnabled:YES];
671 [o_sout_settings setEnabled:NO];
675 - (IBAction)soutSettings:(id)sender
677 [self soutModeChanged: nil];
678 [NSApp beginSheet: o_sout_sheet
679 modalForWindow: [sender window]
685 - (IBAction)soutFileBrowse:(id)sender
687 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
688 NSString *o_mux_string;
689 if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("MPEG PS")] )
690 o_mux_string = @"vob";
691 else if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("AVI")] )
692 o_mux_string = @"avi";
693 else if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("Ogg")] )
694 o_mux_string = @"ogm";
696 o_mux_string = @"ts";
698 NSString * o_name = [NSString stringWithFormat: @"vlc-output.%@",
701 [o_save_panel setTitle: _NS("Save File")];
702 [o_save_panel setPrompt: _NS("Save")];
704 if( [o_save_panel runModalForDirectory: nil
705 file: o_name] == NSOKButton )
707 NSString *o_filename = [o_save_panel filename];
708 [o_sout_file_path setStringValue: o_filename];
709 [self soutInfoChanged: nil];
713 - (void)soutModeChanged:(NSNotification *)o_notification
719 o_mode = [[o_sout_access selectedCell] title];
721 if( [o_mode isEqualToString: _NS("File")] ) b_file = TRUE;
722 else if( [o_mode isEqualToString: _NS("UDP")] ) b_net = TRUE;
723 else if( [o_mode isEqualToString: _NS("RTP")] ) b_net = TRUE;
725 [o_sout_file_path setEnabled: b_file];
726 [o_sout_file_btn_browse setEnabled: b_file];
727 [o_sout_udp_addr setEnabled: !b_file];
728 [o_sout_udp_port setEnabled: !b_file];
729 [o_sout_udp_port_stp setEnabled: !b_file ];
731 [[o_sout_mux cellAtRow:0 column: 1] setEnabled: !b_net];
732 [[o_sout_mux cellAtRow:0 column: 2] setEnabled: !b_net];
733 [[o_sout_mux cellAtRow:0 column: 3] setEnabled: !b_net];
736 [o_sout_mux selectCellAtRow:0 column: 0];
739 [self soutInfoChanged: nil];
742 - (void)soutInfoChanged:(NSNotification *)o_notification
746 NSString *o_mrl_string;
747 NSString *o_mux_string;
749 o_mode = [[o_sout_access selectedCell] title];
750 o_mux = [[o_sout_mux selectedCell] title];
752 if ( [o_mux isEqualToString: _NS("AVI")] ) o_mux_string = @"avi";
753 else if ( [o_mux isEqualToString: _NS("Ogg")] ) o_mux_string = @"ogg";
754 else if ( [o_mux isEqualToString: _NS("MPEG PS")] ) o_mux_string = @"ps";
755 else o_mux_string = @"ts";
757 if ( [o_mode isEqualToString: _NS("File")] )
759 o_mrl_string = [NSString stringWithFormat: @"file/%@://%@",
760 o_mux_string, [o_sout_file_path stringValue]];
762 else if ( [o_mode isEqualToString: _NS("HTTP")] )
764 o_mrl_string = [NSString stringWithFormat: @"http/%@://%@:%i",
765 o_mux_string, [o_sout_udp_addr stringValue],
766 [o_sout_udp_port intValue]];
768 else if ( [o_mode isEqualToString: _NS("UDP")] )
770 o_mrl_string = [NSString stringWithFormat: @"udp/%@://%@:%i",
771 o_mux_string, [o_sout_udp_addr stringValue],
772 [o_sout_udp_port intValue]];
776 o_mrl_string = [NSString stringWithFormat: @"rtp/%@://%@:%i",
777 o_mux_string, [o_sout_udp_addr stringValue],
778 [o_sout_udp_port intValue]];
782 [o_sout_mrl setStringValue: o_mrl_string];
785 - (IBAction)soutStepperChanged:(id)sender
787 [o_sout_udp_port setIntValue: [o_sout_udp_port_stp intValue]];
788 [self soutInfoChanged: nil];
791 - (IBAction)soutCloseSheet:(id)sender
793 [o_sout_sheet orderOut:sender];
794 [NSApp endSheet: o_sout_sheet];
797 - (IBAction)openFile:(id)sender
799 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
801 [o_open_panel setAllowsMultipleSelection: YES];
802 [o_open_panel setCanChooseDirectories: YES];
803 [o_open_panel setTitle: _NS("Open File")];
804 [o_open_panel setPrompt: _NS("Open")];
806 if( [o_open_panel runModalForDirectory: nil
807 file: nil types: nil] == NSOKButton )
809 intf_thread_t * p_intf = [NSApp getIntf];
810 config_PutPsz( p_intf, "sout", NULL );
811 [o_playlist appendArray: [o_open_panel filenames] atPos: -1 enqueue:NO];
815 - (IBAction)subsChanged:(id)sender
817 if ([o_file_sub_ckbox state] == NSOnState)
819 [o_file_sub_btn_settings setEnabled:YES];
823 [o_file_sub_btn_settings setEnabled:NO];
827 - (IBAction)subSettings:(id)sender
829 [NSApp beginSheet: o_file_sub_sheet
830 modalForWindow: [sender window]
836 - (IBAction)subFileBrowse:(id)sender
838 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
840 [o_open_panel setAllowsMultipleSelection: NO];
841 [o_open_panel setTitle: _NS("Open File")];
842 [o_open_panel setPrompt: _NS("Open")];
844 if( [o_open_panel runModalForDirectory: nil
845 file: nil types: nil] == NSOKButton )
847 NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
848 [o_file_sub_path setStringValue: o_filename];
852 - (IBAction)subOverride:(id)sender
854 BOOL b_state = [o_file_sub_override state];
855 [o_file_sub_delay setEnabled: b_state];
856 [o_file_sub_delay_stp setEnabled: b_state];
857 [o_file_sub_fps setEnabled: b_state];
858 [o_file_sub_fps_stp setEnabled: b_state];
861 - (IBAction)subDelayStepperChanged:(id)sender
863 [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
866 - (IBAction)subFpsStepperChanged:(id)sender;
868 [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
871 - (IBAction)subCloseSheet:(id)sender
873 [o_file_sub_sheet orderOut:sender];
874 [NSApp endSheet: o_file_sub_sheet];
877 - (IBAction)panelCancel:(id)sender
879 [NSApp stopModalWithCode: 0];
882 - (IBAction)panelOk:(id)sender
884 if( [[o_mrl stringValue] length] )
886 [NSApp stopModalWithCode: 1];