1 /*****************************************************************************
2 * open.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
5 * $Id: open.m,v 1.29 2003/04/15 14:05:13 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_file_sub_ckbox setState: NSOffState];
274 i_result = [NSApp runModalForWindow: o_panel];
279 NSString *o_sout = [o_sout_mrl stringValue];
280 intf_thread_t * p_intf = [NSApp getIntf];
282 if ( [o_sout_cbox state] )
284 config_PutPsz( p_intf, "sout", [o_sout lossyCString] );
288 config_PutPsz( p_intf, "sout", "" );
291 NSString *o_source = [o_mrl stringValue];
292 BOOL b_enq = [o_ckbox_enqueue state] == NSOnState ? YES : NO;
293 NSString *subPath = [o_file_sub_path stringValue];
295 [o_playlist appendArray:
296 [NSArray arrayWithObject: o_source] atPos: -1 enqueue:b_enq];
298 if (([o_file_sub_ckbox state] == NSOnState) && !([subPath isEqualTo: @""]))
300 config_PutPsz( p_intf, "sub-file", strdup( [subPath cString] ) );
301 if ( [o_file_sub_override state] )
303 config_PutInt( p_intf, "sub-delay", (int)( [o_file_sub_delay intValue] * 10 ) );
304 config_PutFloat( p_intf, "sub-fps", [o_file_sub_fps floatValue] );
309 config_PutPsz( p_intf, "sub-file", "" );
310 config_PutInt( p_intf, "sub-delay", 0 );
311 config_PutFloat( p_intf, "sub-fps", 0.0 );
314 [self soutModeChanged: nil];
317 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
319 NSString *o_label = [o_tvi label];
321 if( [o_label isEqualToString: _NS("File")] )
323 [self openFilePathChanged: nil];
325 else if( [o_label isEqualToString: _NS("Disc")] )
327 [self openDiscTypeChanged: nil];
329 else if( [o_label isEqualToString: _NS("Network")] )
331 [self openNetModeChanged: nil];
335 - (IBAction)openFileGeneric:(id)sender
337 [self openFilePathChanged: nil];
338 [self openTarget: 0];
341 - (IBAction)openDisc:(id)sender
343 [self openDiscTypeChanged: nil];
344 [self openTarget: 1];
347 - (IBAction)openNet:(id)sender
349 [self openNetModeChanged: nil];
350 [self openTarget: 2];
353 - (void)openFilePathChanged:(NSNotification *)o_notification
355 NSString *o_mrl_string;
356 NSString *o_filename = [o_file_path stringValue];
357 NSString *o_ext = [o_filename pathExtension];
358 vlc_bool_t b_stream = [o_file_stream state];
361 [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
365 o_mrl_string = [NSString stringWithFormat: @"dir:%@", o_filename];
367 else if( [o_ext isEqualToString: @"bin"] ||
368 [o_ext isEqualToString: @"cue"] ||
369 [o_ext isEqualToString: @"vob"] ||
370 [o_ext isEqualToString: @"iso"] )
372 o_mrl_string = o_filename;
376 o_mrl_string = [NSString stringWithFormat: @"%s://%@",
377 b_stream ? "stream" : "file",
380 [o_mrl setStringValue: o_mrl_string];
383 - (IBAction)openFileBrowse:(id)sender
385 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
387 [o_open_panel setAllowsMultipleSelection: NO];
388 [o_open_panel setCanChooseDirectories: YES];
389 [o_open_panel setTitle: _NS("Open File")];
390 [o_open_panel setPrompt: _NS("Open")];
392 [o_open_panel beginSheetForDirectory:nil
395 modalForWindow:[sender window]
397 didEndSelector: @selector(pathChosenInPanel:
403 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void *)contextInfo
405 if (returnCode == NSFileHandlingPanelOKButton)
407 NSString *o_filename = [[sheet filenames] objectAtIndex: 0];
408 [o_file_path setStringValue: o_filename];
409 [self openFilePathChanged: nil];
413 - (IBAction)openFileStreamChanged:(id)sender
415 [self openFilePathChanged: nil];
418 - (IBAction)openDiscTypeChanged:(id)sender
421 vlc_bool_t b_device, b_menus, b_title_chapter;
423 [o_disc_device removeAllItems];
424 b_title_chapter = ![o_disc_dvd_menus state];
426 o_type = [[o_disc_type selectedCell] title];
428 if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
430 b_device = 0; b_menus = 1;
436 const char *psz_class = NULL;
439 if ( [o_type isEqualToString: _NS("VCD")] )
441 psz_class = kIOCDMediaClass;
443 b_menus = 0; b_title_chapter = 1;
444 [o_disc_dvd_menus setState: FALSE];
448 psz_class = kIODVDMediaClass;
453 o_devices = GetEjectableMediaOfClass( psz_class );
454 if ( o_devices != nil )
456 int i_devices = [o_devices count];
462 for( i = 0; i < i_devices; i++ )
465 addItemWithObjectValue: [o_devices objectAtIndex: i]];
468 [o_disc_device selectItemAtIndex: 0];
472 [o_disc_device setStringValue:
473 [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
478 [o_disc_device setEnabled: b_device];
479 [o_disc_title setEnabled: b_title_chapter];
480 [o_disc_title_stp setEnabled: b_title_chapter];
481 [o_disc_chapter setEnabled: b_title_chapter];
482 [o_disc_chapter_stp setEnabled: b_title_chapter];
483 [o_disc_videots_folder setEnabled: !b_device];
484 [o_disc_videots_btn_browse setEnabled: !b_device];
485 [o_disc_dvd_menus setEnabled: b_menus];
487 [self openDiscInfoChanged: nil];
490 - (IBAction)openDiscStepperChanged:(id)sender
492 int i_tag = [sender tag];
496 [o_disc_title setIntValue: [o_disc_title_stp intValue]];
498 else if( i_tag == 1 )
500 [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
503 [self openDiscInfoChanged: nil];
506 - (void)openDiscInfoChanged:(NSNotification *)o_notification
511 NSString *o_mrl_string;
512 int i_title, i_chapter;
515 o_type = [[o_disc_type selectedCell] title];
516 o_device = [o_disc_device stringValue];
517 i_title = [o_disc_title intValue];
518 i_chapter = [o_disc_chapter intValue];
519 o_videots = [o_disc_videots_folder stringValue];
520 b_menus = [o_disc_dvd_menus state];
522 if ( [o_type isEqualToString: _NS("VCD")] )
524 if ( [o_device isEqualToString:
525 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
527 o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i,%i",
528 o_device, i_title, i_chapter];
530 else if ( [o_type isEqualToString: _NS("DVD")] )
532 if ( [o_device isEqualToString:
533 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
536 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
539 o_mrl_string = [NSString stringWithFormat: @"dvdold://%@@%i,%i",
540 o_device, i_title, i_chapter];
542 else /* VIDEO_TS folder */
545 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
548 o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i,%i",
549 o_videots, i_title, i_chapter];
552 [o_mrl setStringValue: o_mrl_string];
555 - (IBAction)openDiscMenusChanged:(id)sender
557 [self openDiscInfoChanged: nil];
558 [self openDiscTypeChanged: nil];
561 - (IBAction)openVTSBrowse:(id)sender
563 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
565 [o_open_panel setAllowsMultipleSelection: NO];
566 [o_open_panel setCanChooseFiles: NO];
567 [o_open_panel setCanChooseDirectories: YES];
568 [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
569 [o_open_panel setPrompt: _NS("Open")];
571 if( [o_open_panel runModalForDirectory: nil
572 file: nil types: nil] == NSOKButton )
574 NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
575 [o_disc_videots_folder setStringValue: o_dirname];
576 [self openDiscInfoChanged: nil];
580 - (IBAction)openNetModeChanged:(id)sender
587 o_mode = [[o_net_mode selectedCell] title];
589 if( [o_mode isEqualToString: _NS("UDP/RTP")] ) b_udp = TRUE;
590 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) b_udpm = TRUE;
591 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] ) b_http = TRUE;
593 [o_net_udp_port setEnabled: b_udp];
594 [o_net_udp_port_stp setEnabled: b_udp];
595 [o_net_udpm_addr setEnabled: b_udpm];
596 [o_net_udpm_port setEnabled: b_udpm];
597 [o_net_udpm_port_stp setEnabled: b_udpm];
598 [o_net_http_url setEnabled: b_http];
600 [self openNetInfoChanged: nil];
603 - (IBAction)openNetStepperChanged:(id)sender
605 int i_tag = [sender tag];
609 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
611 else if( i_tag == 1 )
613 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
616 [self openNetInfoChanged: nil];
619 - (void)openNetInfoChanged:(NSNotification *)o_notification
622 NSString *o_mrl_string = [NSString string];
623 intf_thread_t * p_intf = [NSApp getIntf];
625 o_mode = [[o_net_mode selectedCell] title];
627 if( [o_mode isEqualToString: _NS("UDP/RTP")] )
629 int i_port = [o_net_udp_port intValue];
631 o_mrl_string = [NSString stringWithString: @"udp://"];
633 if( i_port != config_GetInt( p_intf, "server-port" ) )
636 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
639 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] )
641 NSString *o_addr = [o_net_udpm_addr stringValue];
642 int i_port = [o_net_udpm_port intValue];
644 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
646 if( i_port != config_GetInt( p_intf, "server-port" ) )
649 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
652 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] )
654 NSString *o_url = [o_net_http_url stringValue];
656 if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
657 && ![o_url hasPrefix:@"mms"] )
658 o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
660 o_mrl_string = o_url;
663 [o_mrl setStringValue: o_mrl_string];
666 - (IBAction)soutChanged:(id)sender;
668 if ([o_sout_cbox state] == NSOnState)
670 [o_sout_settings setEnabled:YES];
674 [o_sout_settings setEnabled:NO];
678 - (IBAction)soutSettings:(id)sender
680 [self soutModeChanged: nil];
681 [NSApp beginSheet: o_sout_sheet
682 modalForWindow: [sender window]
688 - (IBAction)soutFileBrowse:(id)sender
690 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
691 NSString *o_mux_string;
692 if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("MPEG PS")] )
693 o_mux_string = @"vob";
694 else if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("AVI")] )
695 o_mux_string = @"avi";
696 else if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("Ogg")] )
697 o_mux_string = @"ogm";
699 o_mux_string = @"ts";
701 NSString * o_name = [NSString stringWithFormat: @"vlc-output.%@",
704 [o_save_panel setTitle: _NS("Save File")];
705 [o_save_panel setPrompt: _NS("Save")];
707 if( [o_save_panel runModalForDirectory: nil
708 file: o_name] == NSOKButton )
710 NSString *o_filename = [o_save_panel filename];
711 [o_sout_file_path setStringValue: o_filename];
712 [self soutInfoChanged: nil];
716 - (void)soutModeChanged:(NSNotification *)o_notification
722 o_mode = [[o_sout_access selectedCell] title];
724 if( [o_mode isEqualToString: _NS("File")] ) b_file = TRUE;
725 else if( [o_mode isEqualToString: _NS("UDP")] ) b_net = TRUE;
726 else if( [o_mode isEqualToString: _NS("RTP")] ) b_net = TRUE;
728 [o_sout_file_path setEnabled: b_file];
729 [o_sout_file_btn_browse setEnabled: b_file];
730 [o_sout_udp_addr setEnabled: !b_file];
731 [o_sout_udp_port setEnabled: !b_file];
732 [o_sout_udp_port_stp setEnabled: !b_file ];
734 [[o_sout_mux cellAtRow:0 column: 1] setEnabled: !b_net];
735 [[o_sout_mux cellAtRow:0 column: 2] setEnabled: !b_net];
736 [[o_sout_mux cellAtRow:0 column: 3] setEnabled: !b_net];
739 [o_sout_mux selectCellAtRow:0 column: 0];
742 [self soutInfoChanged: nil];
745 - (void)soutInfoChanged:(NSNotification *)o_notification
749 NSString *o_mrl_string;
750 NSString *o_mux_string;
752 o_mode = [[o_sout_access selectedCell] title];
753 o_mux = [[o_sout_mux selectedCell] title];
755 if ( [o_mux isEqualToString: _NS("AVI")] ) o_mux_string = @"avi";
756 else if ( [o_mux isEqualToString: _NS("Ogg")] ) o_mux_string = @"ogg";
757 else if ( [o_mux isEqualToString: _NS("MPEG PS")] ) o_mux_string = @"ps";
758 else o_mux_string = @"ts";
760 if ( [o_mode isEqualToString: _NS("File")] )
762 o_mrl_string = [NSString stringWithFormat: @"file/%@://%@",
763 o_mux_string, [o_sout_file_path stringValue]];
765 else if ( [o_mode isEqualToString: _NS("HTTP")] )
767 o_mrl_string = [NSString stringWithFormat: @"http/%@://%@:%i",
768 o_mux_string, [o_sout_udp_addr stringValue],
769 [o_sout_udp_port intValue]];
771 else if ( [o_mode isEqualToString: _NS("UDP")] )
773 o_mrl_string = [NSString stringWithFormat: @"udp/%@://%@:%i",
774 o_mux_string, [o_sout_udp_addr stringValue],
775 [o_sout_udp_port intValue]];
779 o_mrl_string = [NSString stringWithFormat: @"rtp/%@://%@:%i",
780 o_mux_string, [o_sout_udp_addr stringValue],
781 [o_sout_udp_port intValue]];
785 [o_sout_mrl setStringValue: o_mrl_string];
788 - (IBAction)soutStepperChanged:(id)sender
790 [o_sout_udp_port setIntValue: [o_sout_udp_port_stp intValue]];
791 [self soutInfoChanged: nil];
794 - (IBAction)soutCloseSheet:(id)sender
796 [o_sout_sheet orderOut:sender];
797 [NSApp endSheet: o_sout_sheet];
800 - (IBAction)openFile:(id)sender
802 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
804 [o_open_panel setAllowsMultipleSelection: YES];
805 [o_open_panel setCanChooseDirectories: YES];
806 [o_open_panel setTitle: _NS("Open File")];
807 [o_open_panel setPrompt: _NS("Open")];
809 if( [o_open_panel runModalForDirectory: nil
810 file: nil types: nil] == NSOKButton )
812 intf_thread_t * p_intf = [NSApp getIntf];
813 config_PutPsz( p_intf, "sout", NULL );
815 NSArray *o_values = [[o_open_panel filenames]
816 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
818 [o_playlist appendArray: o_values atPos: -1 enqueue:NO];
819 config_PutPsz( p_intf, "sub-file", "" );
820 config_PutInt( p_intf, "sub-delay", 0 );
821 config_PutFloat( p_intf, "sub-fps", 0.0 );
822 config_PutPsz( p_intf, "sout", "" );
826 - (IBAction)subsChanged:(id)sender
828 if ([o_file_sub_ckbox state] == NSOnState)
830 [o_file_sub_btn_settings setEnabled:YES];
834 [o_file_sub_btn_settings setEnabled:NO];
838 - (IBAction)subSettings:(id)sender
840 [NSApp beginSheet: o_file_sub_sheet
841 modalForWindow: [sender window]
847 - (IBAction)subFileBrowse:(id)sender
849 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
851 [o_open_panel setAllowsMultipleSelection: NO];
852 [o_open_panel setTitle: _NS("Open File")];
853 [o_open_panel setPrompt: _NS("Open")];
855 if( [o_open_panel runModalForDirectory: nil
856 file: nil types: nil] == NSOKButton )
858 NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
859 [o_file_sub_path setStringValue: o_filename];
863 - (IBAction)subOverride:(id)sender
865 BOOL b_state = [o_file_sub_override state];
866 [o_file_sub_delay setEnabled: b_state];
867 [o_file_sub_delay_stp setEnabled: b_state];
868 [o_file_sub_fps setEnabled: b_state];
869 [o_file_sub_fps_stp setEnabled: b_state];
872 - (IBAction)subDelayStepperChanged:(id)sender
874 [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
877 - (IBAction)subFpsStepperChanged:(id)sender;
879 [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
882 - (IBAction)subCloseSheet:(id)sender
884 [o_file_sub_sheet orderOut:sender];
885 [NSApp endSheet: o_file_sub_sheet];
888 - (IBAction)panelCancel:(id)sender
890 [NSApp stopModalWithCode: 0];
893 - (IBAction)panelOk:(id)sender
895 if( [[o_mrl stringValue] length] )
897 [NSApp stopModalWithCode: 1];