1 /*****************************************************************************
2 * open.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: open.m,v 1.23 2003/02/16 01:29:40 massiot 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];
141 NSRect s_rect = [o_panel frame];
142 s_rect.size.height = OPEN_PANEL_FULL_HEIGHT + WINDOW_TITLE_HEIGHT;
143 [o_panel setFrame: s_rect display: NO];
148 [[o_panel contentView] setBoundsOrigin: s_point];
152 [o_sout_cbox setState: NO];
154 NSRect s_rect = [o_panel frame];
155 s_rect.size.height = OPEN_PANEL_SHORT_HEIGHT + WINDOW_TITLE_HEIGHT;
156 [o_panel setFrame: s_rect display: NO];
160 s_point.y = OPEN_PANEL_FULL_HEIGHT - OPEN_PANEL_SHORT_HEIGHT;
161 [[o_panel contentView] setBoundsOrigin: s_point];
165 [o_panel setTitle: _NS("Open Source")];
166 [o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
167 [o_ckbox_enqueue setTitle: _NS("Only enqueue in playlist, do not play")];
169 [o_btn_ok setTitle: _NS("OK")];
170 [o_btn_cancel setTitle: _NS("Cancel")];
172 [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
173 [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
174 [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
176 [o_file_btn_browse setTitle: _NS("Browse...")];
177 [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
179 [o_file_sub_btn_browse setTitle: _NS("Browse...")];
180 [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
182 [o_disc_device_lbl setStringValue: _NS("Device name")];
183 [o_disc_title_lbl setStringValue: _NS("Title")];
184 [o_disc_chapter_lbl setStringValue: _NS("Chapter")];
185 [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
186 [o_disc_dvd_menus setTitle: _NS("Use DVD menus (EXPERIMENTAL)")];
188 [[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
189 [[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
190 [[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")];
192 [o_net_udp_port_lbl setStringValue: _NS("Port")];
193 [o_net_udpm_addr_lbl setStringValue: _NS("Address")];
194 [o_net_udpm_port_lbl setStringValue: _NS("Port")];
195 [o_net_http_url_lbl setStringValue: _NS("URL")];
197 [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("UDP/RTP")];
198 [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("UDP/RTP Multicast")];
199 [[o_net_mode cellAtRow:2 column:0] setTitle: _NS("HTTP/FTP/MMS")];
201 [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
202 [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
204 [o_sout_cbox setTitle: _NS("Stream output")];
205 [o_sout_mrl_lbl setTitle: _NS("Stream output MRL")];
206 [[o_sout_access cellAtRow:0 column:0] setTitle: _NS("File")];
207 [[o_sout_access cellAtRow:1 column:0] setTitle: _NS("UDP")];
208 [[o_sout_access cellAtRow:2 column:0] setTitle: _NS("RTP")];
210 [o_sout_file_btn_browse setTitle: _NS("Browse...")];
211 [o_sout_udp_addr_lbl setStringValue: _NS("Address")];
212 [o_sout_udp_port_lbl setStringValue: _NS("Port")];
214 [[o_sout_mux cellAtRow:0 column:0] setTitle: _NS("AVI")];
215 [[o_sout_mux cellAtRow:0 column:1] setTitle: _NS("PS")];
216 [[o_sout_mux cellAtRow:0 column:2] setTitle: _NS("TS")];
218 [[NSNotificationCenter defaultCenter] addObserver: self
219 selector: @selector(openFilePathChanged:)
220 name: NSControlTextDidChangeNotification
221 object: o_file_path];
223 [[NSNotificationCenter defaultCenter] addObserver: self
224 selector: @selector(openDiscInfoChanged:)
225 name: NSControlTextDidChangeNotification
226 object: o_disc_device];
227 [[NSNotificationCenter defaultCenter] addObserver: self
228 selector: @selector(openDiscInfoChanged:)
229 name: NSControlTextDidChangeNotification
230 object: o_disc_title];
231 [[NSNotificationCenter defaultCenter] addObserver: self
232 selector: @selector(openDiscInfoChanged:)
233 name: NSControlTextDidChangeNotification
234 object: o_disc_chapter];
235 [[NSNotificationCenter defaultCenter] addObserver: self
236 selector: @selector(openDiscInfoChanged:)
237 name: NSControlTextDidChangeNotification
238 object: o_disc_videots_folder];
240 [[NSNotificationCenter defaultCenter] addObserver: self
241 selector: @selector(openNetInfoChanged:)
242 name: NSControlTextDidChangeNotification
243 object: o_net_udp_port];
244 [[NSNotificationCenter defaultCenter] addObserver: self
245 selector: @selector(openNetInfoChanged:)
246 name: NSControlTextDidChangeNotification
247 object: o_net_udpm_addr];
248 [[NSNotificationCenter defaultCenter] addObserver: self
249 selector: @selector(openNetInfoChanged:)
250 name: NSControlTextDidChangeNotification
251 object: o_net_udpm_port];
252 [[NSNotificationCenter defaultCenter] addObserver: self
253 selector: @selector(openNetInfoChanged:)
254 name: NSControlTextDidChangeNotification
255 object: o_net_http_url];
257 [[NSNotificationCenter defaultCenter] addObserver: self
258 selector: @selector(soutInfoChanged:)
259 name: NSControlTextDidChangeNotification
260 object: o_sout_file_path];
261 [[NSNotificationCenter defaultCenter] addObserver: self
262 selector: @selector(soutInfoChanged:)
263 name: NSControlTextDidChangeNotification
264 object: o_sout_udp_addr];
265 [[NSNotificationCenter defaultCenter] addObserver: self
266 selector: @selector(soutInfoChanged:)
267 name: NSControlTextDidChangeNotification
268 object: o_sout_udp_port];
271 - (void)openTarget:(int)i_type
275 [o_tabview selectTabViewItemAtIndex: i_type];
276 [o_ckbox_enqueue setState: NSOnState];
277 [o_file_sub_path setStringValue: @""];
278 [o_file_sub_ckbox setState: NSOffState];
279 [o_file_sub_path setEnabled: NO];
280 [o_file_sub_btn_browse setEnabled: NO];
282 i_result = [NSApp runModalForWindow: o_panel];
287 NSString *o_sout = [o_sout_mrl stringValue];
288 intf_thread_t * p_intf = [NSApp getIntf];
290 if ( [o_sout_cbox state] )
292 config_PutPsz( p_intf, "sout", [o_sout lossyCString] );
295 NSString *o_source = [o_mrl stringValue];
296 BOOL b_enq = [o_ckbox_enqueue state] == NSOnState ? YES : NO;
297 NSString *subPath = [o_file_sub_path stringValue];
299 [o_playlist appendArray:
300 [NSArray arrayWithObject: o_source] atPos: -1 enqueue:b_enq];
302 if (([o_file_sub_ckbox state] == NSOnState) && !([subPath isEqualTo: @""]))
303 config_PutPsz( p_intf, "sub-file", strdup( [subPath cString] ) );
306 [self soutModeChanged: nil];
309 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
311 NSString *o_label = [o_tvi label];
313 if( [o_label isEqualToString: _NS("File")] )
315 [self openFilePathChanged: nil];
317 else if( [o_label isEqualToString: _NS("Disc")] )
319 [self openDiscTypeChanged: nil];
321 else if( [o_label isEqualToString: _NS("Network")] )
323 [self openNetModeChanged: nil];
327 - (IBAction)openFileGeneric:(id)sender
329 [self openFilePathChanged: nil];
330 [self openTarget: 0];
333 - (IBAction)openDisc:(id)sender
335 [self openDiscTypeChanged: nil];
336 [self openTarget: 1];
339 - (IBAction)openNet:(id)sender
341 [self openNetModeChanged: nil];
342 [self openTarget: 2];
345 - (void)openFilePathChanged:(NSNotification *)o_notification
347 NSString *o_mrl_string;
348 NSString *o_filename = [o_file_path stringValue];
349 NSString *o_ext = [o_filename pathExtension];
350 vlc_bool_t b_stream = [o_file_stream state];
352 if ([o_ext isEqualToString: @"bin"] ||
353 [o_ext isEqualToString: @"cue"] ||
354 [o_ext isEqualToString: @"vob"] ||
355 [o_ext isEqualToString: @"iso"])
357 o_mrl_string = o_filename;
361 o_mrl_string = [NSString stringWithFormat: @"%s://%@",
362 b_stream ? "stream" : "file",
365 [o_mrl setStringValue: o_mrl_string];
368 - (IBAction)openFileBrowse:(id)sender
370 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
372 [o_open_panel setAllowsMultipleSelection: NO];
373 [o_open_panel setTitle: _NS("Open File")];
374 [o_open_panel setPrompt: _NS("Open")];
376 if( [o_open_panel runModalForDirectory: nil
377 file: nil types: nil] == NSOKButton )
379 NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
380 [o_file_path setStringValue: o_filename];
381 [self openFilePathChanged: nil];
385 - (IBAction)openFileStreamChanged:(id)sender
387 [self openFilePathChanged: nil];
390 - (IBAction)loadSubsChanged:(id)sender
392 if ([o_file_sub_ckbox state] == NSOnState)
394 [o_file_sub_path setEnabled:YES];
395 [o_file_sub_btn_browse setEnabled:YES];
399 [o_file_sub_path setEnabled:NO];
400 [o_file_sub_btn_browse setEnabled:NO];
404 - (IBAction)openSubBrowse:(id)sender
406 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
408 [o_open_panel setAllowsMultipleSelection: NO];
409 [o_open_panel setTitle: _NS("Open File")];
410 [o_open_panel setPrompt: _NS("Open")];
412 if( [o_open_panel runModalForDirectory: nil
413 file: nil types: nil] == NSOKButton )
415 NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
416 [o_file_sub_path setStringValue: o_filename];
420 - (IBAction)openDiscTypeChanged:(id)sender
423 vlc_bool_t b_device, b_menus, b_title_chapter;
425 [o_disc_device removeAllItems];
426 b_title_chapter = ![o_disc_dvd_menus state];
428 o_type = [[o_disc_type selectedCell] title];
430 if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
432 b_device = 0; b_menus = 1;
438 const char *psz_class = NULL;
441 if ( [o_type isEqualToString: _NS("VCD")] )
443 psz_class = kIOCDMediaClass;
445 b_menus = 0; b_title_chapter = 1;
446 [o_disc_dvd_menus setState: FALSE];
450 psz_class = kIODVDMediaClass;
455 o_devices = GetEjectableMediaOfClass( psz_class );
456 if ( o_devices != nil )
458 int i_devices = [o_devices count];
464 for( i = 0; i < i_devices; i++ )
467 addItemWithObjectValue: [o_devices objectAtIndex: i]];
470 [o_disc_device selectItemAtIndex: 0];
474 [o_disc_device setStringValue:
475 [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
480 [o_disc_device setEnabled: b_device];
481 [o_disc_title setEnabled: b_title_chapter];
482 [o_disc_title_stp setEnabled: b_title_chapter];
483 [o_disc_chapter setEnabled: b_title_chapter];
484 [o_disc_chapter_stp setEnabled: b_title_chapter];
485 [o_disc_videots_folder setEnabled: !b_device];
486 [o_disc_videots_btn_browse setEnabled: !b_device];
487 [o_disc_dvd_menus setEnabled: b_menus];
489 [self openDiscInfoChanged: nil];
492 - (IBAction)openDiscStepperChanged:(id)sender
494 int i_tag = [sender tag];
498 [o_disc_title setIntValue: [o_disc_title_stp intValue]];
500 else if( i_tag == 1 )
502 [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
505 [self openDiscInfoChanged: nil];
508 - (void)openDiscInfoChanged:(NSNotification *)o_notification
513 NSString *o_mrl_string;
514 int i_title, i_chapter;
517 o_type = [[o_disc_type selectedCell] title];
518 o_device = [o_disc_device stringValue];
519 i_title = [o_disc_title intValue];
520 i_chapter = [o_disc_chapter intValue];
521 o_videots = [o_disc_videots_folder stringValue];
522 b_menus = [o_disc_dvd_menus state];
524 if ( [o_type isEqualToString: _NS("VCD")] )
526 if ( [o_device isEqualToString:
527 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
529 o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i,%i",
530 o_device, i_title, i_chapter];
532 else if ( [o_type isEqualToString: _NS("DVD")] )
534 if ( [o_device isEqualToString:
535 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
538 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
541 o_mrl_string = [NSString stringWithFormat: @"dvdold://%@@%i,%i",
542 o_device, i_title, i_chapter];
544 else /* VIDEO_TS folder */
547 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
550 o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i,%i",
551 o_videots, i_title, i_chapter];
554 [o_mrl setStringValue: o_mrl_string];
557 - (IBAction)openDiscMenusChanged:(id)sender
559 [self openDiscInfoChanged: nil];
560 [self openDiscTypeChanged: nil];
563 - (IBAction)openVTSBrowse:(id)sender
565 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
567 [o_open_panel setAllowsMultipleSelection: NO];
568 [o_open_panel setCanChooseFiles: NO];
569 [o_open_panel setCanChooseDirectories: YES];
570 [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
571 [o_open_panel setPrompt: _NS("Open")];
573 if( [o_open_panel runModalForDirectory: nil
574 file: nil types: nil] == NSOKButton )
576 NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
577 [o_disc_videots_folder setStringValue: o_dirname];
578 [self openDiscInfoChanged: nil];
582 - (IBAction)openNetModeChanged:(id)sender
589 o_mode = [[o_net_mode selectedCell] title];
591 if( [o_mode isEqualToString: _NS("UDP/RTP")] ) b_udp = TRUE;
592 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) b_udpm = TRUE;
593 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] ) b_http = TRUE;
595 [o_net_udp_port setEnabled: b_udp];
596 [o_net_udp_port_stp setEnabled: b_udp];
597 [o_net_udpm_addr setEnabled: b_udpm];
598 [o_net_udpm_port setEnabled: b_udpm];
599 [o_net_udpm_port_stp setEnabled: b_udpm];
600 [o_net_http_url setEnabled: b_http];
602 [self openNetInfoChanged: nil];
605 - (IBAction)openNetStepperChanged:(id)sender
607 int i_tag = [sender tag];
611 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
613 else if( i_tag == 1 )
615 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
618 [self openNetInfoChanged: nil];
621 - (void)openNetInfoChanged:(NSNotification *)o_notification
624 NSString *o_mrl_string = [NSString string];
625 intf_thread_t * p_intf = [NSApp getIntf];
627 o_mode = [[o_net_mode selectedCell] title];
629 if( [o_mode isEqualToString: _NS("UDP/RTP")] )
631 int i_port = [o_net_udp_port intValue];
633 o_mrl_string = [NSString stringWithString: @"udp://"];
635 if( i_port != config_GetInt( p_intf, "server-port" ) )
638 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
641 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] )
643 NSString *o_addr = [o_net_udpm_addr stringValue];
644 int i_port = [o_net_udpm_port intValue];
646 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
648 if( i_port != config_GetInt( p_intf, "server-port" ) )
651 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
654 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] )
656 NSString *o_url = [o_net_http_url stringValue];
658 if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
659 && ![o_url hasPrefix:@"mms"] )
660 o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
662 o_mrl_string = o_url;
665 [o_mrl setStringValue: o_mrl_string];
668 - (IBAction)soutChanged:(id)sender;
670 [self soutModeChanged: nil];
672 if ( [o_sout_cbox state] )
677 [[o_panel contentView] setBoundsOrigin: s_point];
678 [[o_panel contentView] setNeedsDisplay: YES];
680 NSRect s_rect = [o_panel frame];
681 s_rect.size.height = OPEN_PANEL_FULL_HEIGHT + WINDOW_TITLE_HEIGHT;
682 s_rect.origin.y -= OPEN_PANEL_FULL_HEIGHT - OPEN_PANEL_SHORT_HEIGHT;
683 [o_panel setFrame: s_rect display: YES animate: NO];
689 s_point.y = OPEN_PANEL_FULL_HEIGHT - OPEN_PANEL_SHORT_HEIGHT;
690 [[o_panel contentView] setBoundsOrigin: s_point];
691 [[o_panel contentView] setNeedsDisplay: YES];
693 NSRect s_rect = [o_panel frame];
694 s_rect.size.height = OPEN_PANEL_SHORT_HEIGHT + WINDOW_TITLE_HEIGHT;
695 s_rect.origin.y += OPEN_PANEL_FULL_HEIGHT - OPEN_PANEL_SHORT_HEIGHT;
696 [o_panel setFrame: s_rect display: YES animate:NO];
700 - (IBAction)soutFileBrowse:(id)sender
702 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
703 NSString *o_mux_string;
704 if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("PS")] )
705 o_mux_string = @"vob";
707 o_mux_string = @"ts";
709 NSString * o_name = [NSString stringWithFormat: @"vlc-output.%@",
712 [o_save_panel setTitle: _NS("Save File")];
713 [o_save_panel setPrompt: _NS("Save")];
715 if( [o_save_panel runModalForDirectory: nil
716 file: o_name] == NSOKButton )
718 NSString *o_filename = [o_save_panel filename];
719 [o_sout_file_path setStringValue: o_filename];
720 [self soutInfoChanged: nil];
724 - (void)soutModeChanged:(NSNotification *)o_notification
730 o_mode = [[o_sout_access selectedCell] title];
732 if( [o_mode isEqualToString: _NS("File")] ) b_file = TRUE;
733 else if( [o_mode isEqualToString: _NS("UDP")] ) b_net = TRUE;
734 else if( [o_mode isEqualToString: _NS("RTP")] ) b_net = TRUE;
736 [o_sout_file_path setEnabled: b_file];
737 [o_sout_file_btn_browse setEnabled: b_file];
738 [o_sout_udp_addr setEnabled: b_net];
739 [o_sout_udp_port setEnabled: b_net];
740 [o_sout_udp_port_stp setEnabled: b_net];
741 [[o_sout_mux cellAtRow:0 column: 0] setEnabled: !b_net];
742 [[o_sout_mux cellAtRow:0 column: 1] setEnabled: !b_net];
746 [[o_sout_mux cellAtRow: 0 column:2] setState: YES];
749 [self soutInfoChanged: nil];
752 - (void)soutInfoChanged:(NSNotification *)o_notification
756 NSString *o_mrl_string;
757 NSString *o_mux_string;
759 o_mode = [[o_sout_access selectedCell] title];
760 o_mux = [[o_sout_mux selectedCell] title];
762 if ( [o_mux isEqualToString: _NS("AVI")] ) o_mux_string = @"avi";
763 else if ( [o_mux isEqualToString: _NS("PS")] ) o_mux_string = @"ps";
764 else o_mux_string = @"ts";
766 if ( [o_mode isEqualToString: _NS("File")] )
768 o_mrl_string = [NSString stringWithFormat: @"file/%@://%@",
769 o_mux_string, [o_sout_file_path stringValue]];
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_net_udp_port_stp intValue]];
792 [self soutInfoChanged: nil];
795 - (IBAction)openFile:(id)sender
797 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
799 [o_open_panel setAllowsMultipleSelection: YES];
800 [o_open_panel setTitle: _NS("Open File")];
801 [o_open_panel setPrompt: _NS("Open")];
803 if( [o_open_panel runModalForDirectory: nil
804 file: nil types: nil] == NSOKButton )
806 intf_thread_t * p_intf = [NSApp getIntf];
807 config_PutPsz( p_intf, "sout", NULL );
808 [o_playlist appendArray: [o_open_panel filenames] atPos: -1 enqueue:NO];
812 - (IBAction)panelCancel:(id)sender
814 [NSApp stopModalWithCode: 0];
817 - (IBAction)panelOk:(id)sender
819 if( [[o_mrl stringValue] length] )
821 [NSApp stopModalWithCode: 1];
831 @implementation VLGetURLScriptCommand
833 - (id)performDefaultImplementation {
834 NSString *o_command = [[self commandDescription] commandName];
835 NSString *o_urlString = [self directParameter];
838 if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] )
840 intf_thread_t * p_intf = [NSApp getIntf];
842 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
844 if( p_playlist == NULL )
853 int i_mode = PLAYLIST_INSERT | PLAYLIST_GO;
855 playlist_Add( p_playlist, [o_urlString fileSystemRepresentation],
856 i_mode, PLAYLIST_END );
857 NSLog( o_urlString );
858 o_url = [NSURL fileURLWithPath: o_urlString];
861 [[NSDocumentController sharedDocumentController]
862 noteNewRecentDocumentURL: o_url];
865 vlc_object_release( p_playlist );