1 /*****************************************************************************
2 * open.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
5 * $Id: open.m,v 1.25 2003/03/24 15:20:26 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];
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];
353 [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
357 o_mrl_string = [NSString stringWithFormat: @"dir:%@", o_filename];
359 else if( [o_ext isEqualToString: @"bin"] ||
360 [o_ext isEqualToString: @"cue"] ||
361 [o_ext isEqualToString: @"vob"] ||
362 [o_ext isEqualToString: @"iso"] )
364 o_mrl_string = o_filename;
368 o_mrl_string = [NSString stringWithFormat: @"%s://%@",
369 b_stream ? "stream" : "file",
372 [o_mrl setStringValue: o_mrl_string];
375 - (IBAction)openFileBrowse:(id)sender
377 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
379 [o_open_panel setAllowsMultipleSelection: NO];
380 [o_open_panel setCanChooseDirectories: YES];
381 [o_open_panel setTitle: _NS("Open File")];
382 [o_open_panel setPrompt: _NS("Open")];
384 if( [o_open_panel runModalForDirectory: nil
385 file: nil types: nil] == NSOKButton )
387 NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
388 [o_file_path setStringValue: o_filename];
389 [self openFilePathChanged: nil];
393 - (IBAction)openFileStreamChanged:(id)sender
395 [self openFilePathChanged: nil];
398 - (IBAction)loadSubsChanged:(id)sender
400 if ([o_file_sub_ckbox state] == NSOnState)
402 [o_file_sub_path setEnabled:YES];
403 [o_file_sub_btn_browse setEnabled:YES];
407 [o_file_sub_path setEnabled:NO];
408 [o_file_sub_btn_browse setEnabled:NO];
412 - (IBAction)openSubBrowse:(id)sender
414 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
416 [o_open_panel setAllowsMultipleSelection: NO];
417 [o_open_panel setTitle: _NS("Open File")];
418 [o_open_panel setPrompt: _NS("Open")];
420 if( [o_open_panel runModalForDirectory: nil
421 file: nil types: nil] == NSOKButton )
423 NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
424 [o_file_sub_path setStringValue: o_filename];
428 - (IBAction)openDiscTypeChanged:(id)sender
431 vlc_bool_t b_device, b_menus, b_title_chapter;
433 [o_disc_device removeAllItems];
434 b_title_chapter = ![o_disc_dvd_menus state];
436 o_type = [[o_disc_type selectedCell] title];
438 if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
440 b_device = 0; b_menus = 1;
446 const char *psz_class = NULL;
449 if ( [o_type isEqualToString: _NS("VCD")] )
451 psz_class = kIOCDMediaClass;
453 b_menus = 0; b_title_chapter = 1;
454 [o_disc_dvd_menus setState: FALSE];
458 psz_class = kIODVDMediaClass;
463 o_devices = GetEjectableMediaOfClass( psz_class );
464 if ( o_devices != nil )
466 int i_devices = [o_devices count];
472 for( i = 0; i < i_devices; i++ )
475 addItemWithObjectValue: [o_devices objectAtIndex: i]];
478 [o_disc_device selectItemAtIndex: 0];
482 [o_disc_device setStringValue:
483 [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
488 [o_disc_device setEnabled: b_device];
489 [o_disc_title setEnabled: b_title_chapter];
490 [o_disc_title_stp setEnabled: b_title_chapter];
491 [o_disc_chapter setEnabled: b_title_chapter];
492 [o_disc_chapter_stp setEnabled: b_title_chapter];
493 [o_disc_videots_folder setEnabled: !b_device];
494 [o_disc_videots_btn_browse setEnabled: !b_device];
495 [o_disc_dvd_menus setEnabled: b_menus];
497 [self openDiscInfoChanged: nil];
500 - (IBAction)openDiscStepperChanged:(id)sender
502 int i_tag = [sender tag];
506 [o_disc_title setIntValue: [o_disc_title_stp intValue]];
508 else if( i_tag == 1 )
510 [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
513 [self openDiscInfoChanged: nil];
516 - (void)openDiscInfoChanged:(NSNotification *)o_notification
521 NSString *o_mrl_string;
522 int i_title, i_chapter;
525 o_type = [[o_disc_type selectedCell] title];
526 o_device = [o_disc_device stringValue];
527 i_title = [o_disc_title intValue];
528 i_chapter = [o_disc_chapter intValue];
529 o_videots = [o_disc_videots_folder stringValue];
530 b_menus = [o_disc_dvd_menus state];
532 if ( [o_type isEqualToString: _NS("VCD")] )
534 if ( [o_device isEqualToString:
535 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
537 o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i,%i",
538 o_device, i_title, i_chapter];
540 else if ( [o_type isEqualToString: _NS("DVD")] )
542 if ( [o_device isEqualToString:
543 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
546 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
549 o_mrl_string = [NSString stringWithFormat: @"dvdold://%@@%i,%i",
550 o_device, i_title, i_chapter];
552 else /* VIDEO_TS folder */
555 o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
558 o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i,%i",
559 o_videots, i_title, i_chapter];
562 [o_mrl setStringValue: o_mrl_string];
565 - (IBAction)openDiscMenusChanged:(id)sender
567 [self openDiscInfoChanged: nil];
568 [self openDiscTypeChanged: nil];
571 - (IBAction)openVTSBrowse:(id)sender
573 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
575 [o_open_panel setAllowsMultipleSelection: NO];
576 [o_open_panel setCanChooseFiles: NO];
577 [o_open_panel setCanChooseDirectories: YES];
578 [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
579 [o_open_panel setPrompt: _NS("Open")];
581 if( [o_open_panel runModalForDirectory: nil
582 file: nil types: nil] == NSOKButton )
584 NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
585 [o_disc_videots_folder setStringValue: o_dirname];
586 [self openDiscInfoChanged: nil];
590 - (IBAction)openNetModeChanged:(id)sender
597 o_mode = [[o_net_mode selectedCell] title];
599 if( [o_mode isEqualToString: _NS("UDP/RTP")] ) b_udp = TRUE;
600 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) b_udpm = TRUE;
601 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] ) b_http = TRUE;
603 [o_net_udp_port setEnabled: b_udp];
604 [o_net_udp_port_stp setEnabled: b_udp];
605 [o_net_udpm_addr setEnabled: b_udpm];
606 [o_net_udpm_port setEnabled: b_udpm];
607 [o_net_udpm_port_stp setEnabled: b_udpm];
608 [o_net_http_url setEnabled: b_http];
610 [self openNetInfoChanged: nil];
613 - (IBAction)openNetStepperChanged:(id)sender
615 int i_tag = [sender tag];
619 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
621 else if( i_tag == 1 )
623 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
626 [self openNetInfoChanged: nil];
629 - (void)openNetInfoChanged:(NSNotification *)o_notification
632 NSString *o_mrl_string = [NSString string];
633 intf_thread_t * p_intf = [NSApp getIntf];
635 o_mode = [[o_net_mode selectedCell] title];
637 if( [o_mode isEqualToString: _NS("UDP/RTP")] )
639 int i_port = [o_net_udp_port intValue];
641 o_mrl_string = [NSString stringWithString: @"udp://"];
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("UDP/RTP Multicast")] )
651 NSString *o_addr = [o_net_udpm_addr stringValue];
652 int i_port = [o_net_udpm_port intValue];
654 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
656 if( i_port != config_GetInt( p_intf, "server-port" ) )
659 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
662 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] )
664 NSString *o_url = [o_net_http_url stringValue];
666 if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
667 && ![o_url hasPrefix:@"mms"] )
668 o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
670 o_mrl_string = o_url;
673 [o_mrl setStringValue: o_mrl_string];
676 - (IBAction)soutChanged:(id)sender;
678 [self soutModeChanged: nil];
680 if ( [o_sout_cbox state] )
685 [[o_panel contentView] setBoundsOrigin: s_point];
686 [[o_panel contentView] setNeedsDisplay: YES];
688 NSRect s_rect = [o_panel frame];
689 s_rect.size.height = OPEN_PANEL_FULL_HEIGHT + WINDOW_TITLE_HEIGHT;
690 s_rect.origin.y -= OPEN_PANEL_FULL_HEIGHT - OPEN_PANEL_SHORT_HEIGHT;
691 [o_panel setFrame: s_rect display: YES animate: NO];
697 s_point.y = OPEN_PANEL_FULL_HEIGHT - OPEN_PANEL_SHORT_HEIGHT;
698 [[o_panel contentView] setBoundsOrigin: s_point];
699 [[o_panel contentView] setNeedsDisplay: YES];
701 NSRect s_rect = [o_panel frame];
702 s_rect.size.height = OPEN_PANEL_SHORT_HEIGHT + WINDOW_TITLE_HEIGHT;
703 s_rect.origin.y += OPEN_PANEL_FULL_HEIGHT - OPEN_PANEL_SHORT_HEIGHT;
704 [o_panel setFrame: s_rect display: YES animate:NO];
708 - (IBAction)soutFileBrowse:(id)sender
710 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
711 NSString *o_mux_string;
712 if ( [[[o_sout_mux selectedCell] title] isEqualToString: _NS("PS")] )
713 o_mux_string = @"vob";
715 o_mux_string = @"ts";
717 NSString * o_name = [NSString stringWithFormat: @"vlc-output.%@",
720 [o_save_panel setTitle: _NS("Save File")];
721 [o_save_panel setPrompt: _NS("Save")];
723 if( [o_save_panel runModalForDirectory: nil
724 file: o_name] == NSOKButton )
726 NSString *o_filename = [o_save_panel filename];
727 [o_sout_file_path setStringValue: o_filename];
728 [self soutInfoChanged: nil];
732 - (void)soutModeChanged:(NSNotification *)o_notification
738 o_mode = [[o_sout_access selectedCell] title];
740 if( [o_mode isEqualToString: _NS("File")] ) b_file = TRUE;
741 else if( [o_mode isEqualToString: _NS("UDP")] ) b_net = TRUE;
742 else if( [o_mode isEqualToString: _NS("RTP")] ) b_net = TRUE;
744 [o_sout_file_path setEnabled: b_file];
745 [o_sout_file_btn_browse setEnabled: b_file];
746 [o_sout_udp_addr setEnabled: b_net];
747 [o_sout_udp_port setEnabled: b_net];
748 [o_sout_udp_port_stp setEnabled: b_net];
749 [[o_sout_mux cellAtRow:0 column: 0] setEnabled: !b_net];
750 [[o_sout_mux cellAtRow:0 column: 1] setEnabled: !b_net];
754 [[o_sout_mux cellAtRow: 0 column:2] setState: YES];
757 [self soutInfoChanged: nil];
760 - (void)soutInfoChanged:(NSNotification *)o_notification
764 NSString *o_mrl_string;
765 NSString *o_mux_string;
767 o_mode = [[o_sout_access selectedCell] title];
768 o_mux = [[o_sout_mux selectedCell] title];
770 if ( [o_mux isEqualToString: _NS("AVI")] ) o_mux_string = @"avi";
771 else if ( [o_mux isEqualToString: _NS("PS")] ) o_mux_string = @"ps";
772 else o_mux_string = @"ts";
774 if ( [o_mode isEqualToString: _NS("File")] )
776 o_mrl_string = [NSString stringWithFormat: @"file/%@://%@",
777 o_mux_string, [o_sout_file_path stringValue]];
779 else if ( [o_mode isEqualToString: _NS("UDP")] )
781 o_mrl_string = [NSString stringWithFormat: @"udp/%@://%@:%i",
782 o_mux_string, [o_sout_udp_addr stringValue],
783 [o_sout_udp_port intValue]];
787 o_mrl_string = [NSString stringWithFormat: @"rtp/%@://%@:%i",
788 o_mux_string, [o_sout_udp_addr stringValue],
789 [o_sout_udp_port intValue]];
793 [o_sout_mrl setStringValue: o_mrl_string];
796 - (IBAction)soutStepperChanged:(id)sender
798 [o_sout_udp_port setIntValue: [o_net_udp_port_stp intValue]];
800 [self soutInfoChanged: nil];
803 - (IBAction)openFile:(id)sender
805 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
807 [o_open_panel setAllowsMultipleSelection: YES];
808 [o_open_panel setCanChooseDirectories: YES];
809 [o_open_panel setTitle: _NS("Open File")];
810 [o_open_panel setPrompt: _NS("Open")];
812 if( [o_open_panel runModalForDirectory: nil
813 file: nil types: nil] == NSOKButton )
815 intf_thread_t * p_intf = [NSApp getIntf];
816 config_PutPsz( p_intf, "sout", NULL );
817 [o_playlist appendArray: [o_open_panel filenames] atPos: -1 enqueue:NO];
821 - (IBAction)panelCancel:(id)sender
823 [NSApp stopModalWithCode: 0];
826 - (IBAction)panelOk:(id)sender
828 if( [[o_mrl stringValue] length] )
830 [NSApp stopModalWithCode: 1];