00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <stdlib.h>
00031 #include <sys/param.h>
00032 #include <string.h>
00033
00034 #include <paths.h>
00035 #include <IOKit/IOKitLib.h>
00036 #include <IOKit/IOBSD.h>
00037 #include <IOKit/storage/IOMedia.h>
00038 #include <IOKit/storage/IOCDMedia.h>
00039 #include <IOKit/storage/IODVDMedia.h>
00040
00041 #include "intf.h"
00042 #include "playlist.h"
00043 #include "open.h"
00044 #include "output.h"
00045
00046
00047
00048
00049 NSArray *GetEjectableMediaOfClass( const char *psz_class )
00050 {
00051 io_object_t next_media;
00052 mach_port_t master_port;
00053 kern_return_t kern_result;
00054 NSArray *o_devices = nil;
00055 NSMutableArray *p_list = nil;
00056 io_iterator_t media_iterator;
00057 CFMutableDictionaryRef classes_to_match;
00058
00059 kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
00060 if( kern_result != KERN_SUCCESS )
00061 {
00062 return( nil );
00063 }
00064
00065 classes_to_match = IOServiceMatching( psz_class );
00066 if( classes_to_match == NULL )
00067 {
00068 return( nil );
00069 }
00070
00071 CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectableKey ),
00072 kCFBooleanTrue );
00073
00074 kern_result = IOServiceGetMatchingServices( master_port, classes_to_match,
00075 &media_iterator );
00076 if( kern_result != KERN_SUCCESS )
00077 {
00078 return( nil );
00079 }
00080
00081 p_list = [NSMutableArray arrayWithCapacity: 1];
00082
00083 next_media = IOIteratorNext( media_iterator );
00084 if( next_media != nil )
00085 {
00086 char psz_buf[0x32];
00087 size_t dev_path_length;
00088 CFTypeRef str_bsd_path;
00089
00090 do
00091 {
00092 str_bsd_path = IORegistryEntryCreateCFProperty( next_media,
00093 CFSTR( kIOBSDNameKey ),
00094 kCFAllocatorDefault,
00095 0 );
00096 if( str_bsd_path == NULL )
00097 {
00098 IOObjectRelease( next_media );
00099 continue;
00100 }
00101
00102 snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
00103 dev_path_length = strlen( psz_buf );
00104
00105 if( CFStringGetCString( str_bsd_path,
00106 (char*)&psz_buf + dev_path_length,
00107 sizeof(psz_buf) - dev_path_length,
00108 kCFStringEncodingASCII ) )
00109 {
00110 [p_list addObject: [NSString stringWithCString: psz_buf]];
00111 }
00112
00113 CFRelease( str_bsd_path );
00114
00115 IOObjectRelease( next_media );
00116
00117 } while( ( next_media = IOIteratorNext( media_iterator ) ) != nil );
00118 }
00119
00120 IOObjectRelease( media_iterator );
00121
00122 o_devices = [NSArray arrayWithArray: p_list];
00123
00124 return( o_devices );
00125 }
00126
00127
00128
00129
00130 @implementation VLCOpen
00131
00132 static VLCOpen *_o_sharedMainInstance = nil;
00133
00134 + (VLCOpen *)sharedInstance
00135 {
00136 return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init];
00137 }
00138
00139 - (id)init
00140 {
00141 if( _o_sharedMainInstance) {
00142 [self dealloc];
00143 } else {
00144 _o_sharedMainInstance = [super init];
00145 }
00146
00147 return _o_sharedMainInstance;
00148 }
00149
00150 - (void)awakeFromNib
00151 {
00152 intf_thread_t * p_intf = VLCIntf;
00153
00154 [o_panel setTitle: _NS("Open Source")];
00155 [o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
00156
00157 [o_btn_ok setTitle: _NS("OK")];
00158 [o_btn_cancel setTitle: _NS("Cancel")];
00159
00160 [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
00161 [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
00162 [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
00163
00164 [o_file_btn_browse setTitle: _NS("Browse...")];
00165 [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
00166
00167 [o_disc_device_lbl setStringValue: _NS("Device name")];
00168 [o_disc_title_lbl setStringValue: _NS("Title")];
00169 [o_disc_chapter_lbl setStringValue: _NS("Chapter")];
00170 [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
00171 [o_disc_dvd_menus setTitle: _NS("Use DVD menus")];
00172
00173 [[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
00174 [[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
00175 [[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")];
00176 [[o_disc_type cellAtRow:3 column:0] setTitle: _NS("Audio CD")];
00177
00178 [o_net_udp_port_lbl setStringValue: _NS("Port")];
00179 [o_net_udpm_addr_lbl setStringValue: _NS("Address")];
00180 [o_net_udpm_port_lbl setStringValue: _NS("Port")];
00181 [o_net_http_url_lbl setStringValue: _NS("URL")];
00182
00183 [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("UDP/RTP")];
00184 [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("UDP/RTP Multicast")];
00185 [[o_net_mode cellAtRow:2 column:0] setTitle: _NS("HTTP/FTP/MMS/RTSP")];
00186 [o_net_timeshift_ckbox setTitle: _NS("Allow timeshifting")];
00187
00188 [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
00189 [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
00190
00191 [self setSubPanel];
00192
00193
00194 [[NSNotificationCenter defaultCenter] addObserver: self
00195 selector: @selector(openFilePathChanged:)
00196 name: NSControlTextDidChangeNotification
00197 object: o_file_path];
00198
00199 [[NSNotificationCenter defaultCenter] addObserver: self
00200 selector: @selector(openDiscInfoChanged:)
00201 name: NSControlTextDidChangeNotification
00202 object: o_disc_device];
00203 [[NSNotificationCenter defaultCenter] addObserver: self
00204 selector: @selector(openDiscInfoChanged:)
00205 name: NSControlTextDidChangeNotification
00206 object: o_disc_title];
00207 [[NSNotificationCenter defaultCenter] addObserver: self
00208 selector: @selector(openDiscInfoChanged:)
00209 name: NSControlTextDidChangeNotification
00210 object: o_disc_chapter];
00211 [[NSNotificationCenter defaultCenter] addObserver: self
00212 selector: @selector(openDiscInfoChanged:)
00213 name: NSControlTextDidChangeNotification
00214 object: o_disc_videots_folder];
00215
00216 [[NSNotificationCenter defaultCenter] addObserver: self
00217 selector: @selector(openNetInfoChanged:)
00218 name: NSControlTextDidChangeNotification
00219 object: o_net_udp_port];
00220 [[NSNotificationCenter defaultCenter] addObserver: self
00221 selector: @selector(openNetInfoChanged:)
00222 name: NSControlTextDidChangeNotification
00223 object: o_net_udpm_addr];
00224 [[NSNotificationCenter defaultCenter] addObserver: self
00225 selector: @selector(openNetInfoChanged:)
00226 name: NSControlTextDidChangeNotification
00227 object: o_net_udpm_port];
00228 [[NSNotificationCenter defaultCenter] addObserver: self
00229 selector: @selector(openNetInfoChanged:)
00230 name: NSControlTextDidChangeNotification
00231 object: o_net_http_url];
00232 }
00233
00234 - (void)setSubPanel
00235 {
00236 intf_thread_t * p_intf = VLCIntf;
00237 int i_index;
00238 module_config_t * p_item;
00239
00240 [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
00241 [o_file_sub_btn_settings setTitle: _NS("Settings...")];
00242 [o_file_sub_btn_browse setTitle: _NS("Browse...")];
00243 [o_file_sub_override setTitle: _NS("Override")];
00244 [o_file_sub_delay_lbl setStringValue: _NS("delay")];
00245 [o_file_sub_delay_stp setEnabled: NO];
00246 [o_file_sub_fps_lbl setStringValue: _NS("fps")];
00247 [o_file_sub_fps_stp setEnabled: NO];
00248 [o_file_sub_encoding_lbl setStringValue: _NS("Subtitles encoding")];
00249 [o_file_sub_encoding_pop removeAllItems];
00250 [o_file_sub_size_lbl setStringValue: _NS("Font size")];
00251 [o_file_sub_size_pop removeAllItems];
00252 [o_file_sub_align_lbl setStringValue: _NS("Subtitles justification")];
00253 [o_file_sub_align_pop removeAllItems];
00254 [o_file_sub_ok_btn setStringValue: _NS("OK")];
00255 [o_file_sub_font_box setTitle: _NS("Font Properties")];
00256 [o_file_sub_file_box setTitle: _NS("Subtitle File")];
00257
00258 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
00259
00260 if( p_item )
00261 {
00262 for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
00263 i_index++ )
00264 {
00265 [o_file_sub_encoding_pop addItemWithTitle:
00266 [NSString stringWithCString:
00267 p_item->ppsz_list[i_index]]];
00268 }
00269 [o_file_sub_encoding_pop selectItemWithTitle:
00270 [NSString stringWithCString:
00271 p_item->psz_value]];
00272 }
00273
00274 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
00275
00276 if ( p_item )
00277 {
00278 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
00279 {
00280 [o_file_sub_align_pop addItemWithTitle:
00281 [NSString stringWithUTF8String:
00282 p_item->ppsz_list_text[i_index]]];
00283 }
00284 [o_file_sub_align_pop selectItemAtIndex: p_item->i_value];
00285 }
00286
00287 p_item = config_FindConfig( VLC_OBJECT(p_intf), "freetype-rel-fontsize" );
00288
00289 if ( p_item )
00290 {
00291 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
00292 {
00293 [o_file_sub_size_pop addItemWithTitle:
00294 [NSString stringWithUTF8String:
00295 p_item->ppsz_list_text[i_index]]];
00296 if ( p_item->i_value == p_item->pi_list[i_index] )
00297 {
00298 [o_file_sub_size_pop selectItemAtIndex: i_index];
00299 }
00300 }
00301 }
00302 }
00303
00304 - (void)openTarget:(int)i_type
00305 {
00306 int i_result;
00307
00308 [o_tabview selectTabViewItemAtIndex: i_type];
00309 [o_file_sub_ckbox setState: NSOffState];
00310
00311 i_result = [NSApp runModalForWindow: o_panel];
00312 [o_panel close];
00313
00314 if( i_result )
00315 {
00316 NSMutableDictionary *o_dic;
00317 NSMutableArray *o_options = [NSMutableArray array];
00318 unsigned int i;
00319
00320 o_dic = [NSMutableDictionary dictionaryWithObject: [o_mrl stringValue] forKey: @"ITEM_URL"];
00321 if( [o_file_sub_ckbox state] == NSOnState )
00322 {
00323 intf_thread_t * p_intf = VLCIntf;
00324 module_config_t * p_item;
00325
00326 [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", [o_file_sub_path stringValue]]];
00327 if( [o_file_sub_override state] == NSOnState )
00328 {
00329 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
00330 [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
00331 }
00332 [o_options addObject: [NSString stringWithFormat:
00333 @"subsdec-encoding=%@",
00334 [o_file_sub_encoding_pop titleOfSelectedItem]]];
00335 [o_options addObject: [NSString stringWithFormat:
00336 @"subsdec-align=%i",
00337 [o_file_sub_align_pop indexOfSelectedItem]]];
00338
00339 p_item = config_FindConfig( VLC_OBJECT(p_intf),
00340 "freetype-rel-fontsize" );
00341
00342 if ( p_item )
00343 {
00344 [o_options addObject: [NSString stringWithFormat:
00345 @"freetype-rel-fontsize=%i",
00346 p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
00347 }
00348 }
00349 if( [o_output_ckbox state] == NSOnState )
00350 {
00351 for (i = 0 ; i < [[o_sout_options getMRL] count] ; i++)
00352 {
00353 [o_options addObject: [NSString stringWithString:
00354 [[(VLCOutput *)o_sout_options getMRL] objectAtIndex: i]]];
00355 }
00356 }
00357 if( [o_net_timeshift_ckbox state] == NSOnState )
00358 {
00359 [o_options addObject: [NSString stringWithString:
00360 @"access-filter=timeshift"]];
00361 }
00362 [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
00363 [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
00364 }
00365 }
00366
00367 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
00368 {
00369 NSString *o_label = [o_tvi label];
00370
00371 if( [o_label isEqualToString: _NS("File")] )
00372 {
00373 [self openFilePathChanged: nil];
00374 }
00375 else if( [o_label isEqualToString: _NS("Disc")] )
00376 {
00377 [self openDiscTypeChanged: nil];
00378 }
00379 else if( [o_label isEqualToString: _NS("Network")] )
00380 {
00381 [self openNetModeChanged: nil];
00382 }
00383 }
00384
00385 - (void)openFileGeneric
00386 {
00387 [self openFilePathChanged: nil];
00388 [self openTarget: 0];
00389 }
00390
00391 - (void)openDisc
00392 {
00393 [self openDiscTypeChanged: nil];
00394 [self openTarget: 1];
00395 }
00396
00397 - (void)openNet
00398 {
00399 [self openNetModeChanged: nil];
00400 [self openTarget: 2];
00401 }
00402
00403 - (void)openFilePathChanged:(NSNotification *)o_notification
00404 {
00405 NSString *o_mrl_string;
00406 NSString *o_filename = [o_file_path stringValue];
00407 NSString *o_ext = [o_filename pathExtension];
00408 vlc_bool_t b_stream = [o_file_stream state];
00409 BOOL b_dir = NO;
00410
00411 [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
00412
00413 if( b_dir )
00414 {
00415 o_mrl_string = [NSString stringWithFormat: @"dir:%@", o_filename];
00416 }
00417 else if( [o_ext isEqualToString: @"bin"] ||
00418 [o_ext isEqualToString: @"cue"] ||
00419 [o_ext isEqualToString: @"vob"] ||
00420 [o_ext isEqualToString: @"iso"] )
00421 {
00422 o_mrl_string = o_filename;
00423 }
00424 else
00425 {
00426 o_mrl_string = [NSString stringWithFormat: @"%s://%@",
00427 b_stream ? "stream" : "file",
00428 o_filename];
00429 }
00430 [o_mrl setStringValue: o_mrl_string];
00431 }
00432
00433 - (IBAction)openFileBrowse:(id)sender
00434 {
00435 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
00436
00437 [o_open_panel setAllowsMultipleSelection: NO];
00438 [o_open_panel setCanChooseDirectories: YES];
00439 [o_open_panel setTitle: _NS("Open File")];
00440 [o_open_panel setPrompt: _NS("Open")];
00441
00442 [o_open_panel beginSheetForDirectory:nil
00443 file:nil
00444 types:nil
00445 modalForWindow:[sender window]
00446 modalDelegate: self
00447 didEndSelector: @selector(pathChosenInPanel:
00448 withReturn:
00449 contextInfo:)
00450 contextInfo: nil];
00451 }
00452
00453 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void *)contextInfo
00454 {
00455 if (returnCode == NSFileHandlingPanelOKButton)
00456 {
00457 NSString *o_filename = [[sheet filenames] objectAtIndex: 0];
00458 [o_file_path setStringValue: o_filename];
00459 [self openFilePathChanged: nil];
00460 }
00461 }
00462
00463 - (IBAction)openFileStreamChanged:(id)sender
00464 {
00465 [self openFilePathChanged: nil];
00466 }
00467
00468 - (IBAction)openDiscTypeChanged:(id)sender
00469 {
00470 NSString *o_type;
00471 vlc_bool_t b_device, b_menus, b_title_chapter;
00472
00473 [o_disc_device removeAllItems];
00474 b_title_chapter = ![o_disc_dvd_menus state];
00475
00476 o_type = [[o_disc_type selectedCell] title];
00477
00478 if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
00479 {
00480 b_device = 0; b_menus = 1;
00481 }
00482 else
00483 {
00484 NSArray *o_devices;
00485 NSString *o_disc;
00486 const char *psz_class = NULL;
00487 b_device = 1;
00488
00489 if ( [o_type isEqualToString: _NS("VCD")] )
00490 {
00491 psz_class = kIOCDMediaClass;
00492 o_disc = o_type;
00493 b_menus = 0; b_title_chapter = 1;
00494 [o_disc_dvd_menus setState: FALSE];
00495 }
00496 else if ( [o_type isEqualToString: _NS("Audio CD")])
00497 {
00498 psz_class = kIOCDMediaClass;
00499 o_disc = o_type;
00500 b_menus = 0; b_title_chapter = 0;
00501 [o_disc_dvd_menus setState: FALSE];
00502 }
00503 else
00504 {
00505 psz_class = kIODVDMediaClass;
00506 o_disc = o_type;
00507 b_menus = 1;
00508 }
00509
00510 o_devices = GetEjectableMediaOfClass( psz_class );
00511 if ( o_devices != nil )
00512 {
00513 int i_devices = [o_devices count];
00514
00515 if ( i_devices )
00516 {
00517 int i;
00518
00519 for( i = 0; i < i_devices; i++ )
00520 {
00521 [o_disc_device
00522 addItemWithObjectValue: [o_devices objectAtIndex: i]];
00523 }
00524
00525 [o_disc_device selectItemAtIndex: 0];
00526 }
00527 else
00528 {
00529 [o_disc_device setStringValue:
00530 [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
00531 }
00532 }
00533 }
00534
00535 [o_disc_device setEnabled: b_device];
00536 [o_disc_title setEnabled: b_title_chapter];
00537 [o_disc_title_stp setEnabled: b_title_chapter];
00538 [o_disc_chapter setEnabled: b_title_chapter];
00539 [o_disc_chapter_stp setEnabled: b_title_chapter];
00540 [o_disc_videots_folder setEnabled: !b_device];
00541 [o_disc_videots_btn_browse setEnabled: !b_device];
00542 [o_disc_dvd_menus setEnabled: b_menus];
00543
00544 [self openDiscInfoChanged: nil];
00545 }
00546
00547 - (IBAction)openDiscStepperChanged:(id)sender
00548 {
00549 int i_tag = [sender tag];
00550
00551 if( i_tag == 0 )
00552 {
00553 [o_disc_title setIntValue: [o_disc_title_stp intValue]];
00554 }
00555 else if( i_tag == 1 )
00556 {
00557 [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
00558 }
00559
00560 [self openDiscInfoChanged: nil];
00561 }
00562
00563 - (void)openDiscInfoChanged:(NSNotification *)o_notification
00564 {
00565 NSString *o_type;
00566 NSString *o_device;
00567 NSString *o_videots;
00568 NSString *o_mrl_string;
00569 int i_title, i_chapter;
00570 vlc_bool_t b_menus;
00571
00572 o_type = [[o_disc_type selectedCell] title];
00573 o_device = [o_disc_device stringValue];
00574 i_title = [o_disc_title intValue];
00575 i_chapter = [o_disc_chapter intValue];
00576 o_videots = [o_disc_videots_folder stringValue];
00577 b_menus = [o_disc_dvd_menus state];
00578
00579 if ( [o_type isEqualToString: _NS("VCD")] )
00580 {
00581 if ( [o_device isEqualToString:
00582 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
00583 o_device = @"";
00584 o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i:%i",
00585 o_device, i_title, i_chapter];
00586 }
00587 else if ( [o_type isEqualToString: _NS("Audio CD")] )
00588 {
00589 if ( [o_device isEqualToString:
00590 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
00591 o_device = @"";
00592 o_mrl_string = [NSString stringWithFormat: @"cdda://%@",
00593 o_device];
00594 }
00595 else if ( [o_type isEqualToString: _NS("DVD")] )
00596 {
00597 if ( [o_device isEqualToString:
00598 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
00599 o_device = @"";
00600 if ( b_menus )
00601 o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
00602 o_device];
00603 else
00604 o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i-",
00605 o_device, i_title, i_chapter];
00606 }
00607 else
00608 {
00609 if ( b_menus )
00610 o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
00611 o_videots];
00612 else
00613 o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i",
00614 o_videots, i_title, i_chapter];
00615 }
00616
00617 [o_mrl setStringValue: o_mrl_string];
00618 }
00619
00620 - (IBAction)openDiscMenusChanged:(id)sender
00621 {
00622 [self openDiscInfoChanged: nil];
00623 [self openDiscTypeChanged: nil];
00624 }
00625
00626 - (IBAction)openVTSBrowse:(id)sender
00627 {
00628 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
00629
00630 [o_open_panel setAllowsMultipleSelection: NO];
00631 [o_open_panel setCanChooseFiles: NO];
00632 [o_open_panel setCanChooseDirectories: YES];
00633 [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
00634 [o_open_panel setPrompt: _NS("Open")];
00635
00636 if( [o_open_panel runModalForDirectory: nil
00637 file: nil types: nil] == NSOKButton )
00638 {
00639 NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
00640 [o_disc_videots_folder setStringValue: o_dirname];
00641 [self openDiscInfoChanged: nil];
00642 }
00643 }
00644
00645 - (IBAction)openNetModeChanged:(id)sender
00646 {
00647 NSString *o_mode;
00648 BOOL b_udp = FALSE;
00649 BOOL b_udpm = FALSE;
00650 BOOL b_http = FALSE;
00651
00652 o_mode = [[o_net_mode selectedCell] title];
00653
00654 if( [o_mode isEqualToString: _NS("UDP/RTP")] ) b_udp = TRUE;
00655 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) b_udpm = TRUE;
00656 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS/RTSP")] ) b_http = TRUE;
00657
00658 [o_net_udp_port setEnabled: b_udp];
00659 [o_net_udp_port_stp setEnabled: b_udp];
00660 [o_net_udpm_addr setEnabled: b_udpm];
00661 [o_net_udpm_port setEnabled: b_udpm];
00662 [o_net_udpm_port_stp setEnabled: b_udpm];
00663 [o_net_http_url setEnabled: b_http];
00664
00665 [self openNetInfoChanged: nil];
00666 }
00667
00668 - (IBAction)openNetStepperChanged:(id)sender
00669 {
00670 int i_tag = [sender tag];
00671
00672 if( i_tag == 0 )
00673 {
00674 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
00675 }
00676 else if( i_tag == 1 )
00677 {
00678 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
00679 }
00680
00681 [self openNetInfoChanged: nil];
00682 }
00683
00684 - (void)openNetInfoChanged:(NSNotification *)o_notification
00685 {
00686 NSString *o_mode;
00687 NSString *o_mrl_string = [NSString string];
00688 intf_thread_t * p_intf = VLCIntf;
00689
00690 o_mode = [[o_net_mode selectedCell] title];
00691
00692 if( [o_mode isEqualToString: _NS("UDP/RTP")] )
00693 {
00694 int i_port = [o_net_udp_port intValue];
00695
00696 o_mrl_string = [NSString stringWithString: @"udp://"];
00697
00698 if( i_port != config_GetInt( p_intf, "server-port" ) )
00699 {
00700 o_mrl_string =
00701 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
00702 }
00703 }
00704 else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] )
00705 {
00706 NSString *o_addr = [o_net_udpm_addr stringValue];
00707 int i_port = [o_net_udpm_port intValue];
00708
00709 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
00710
00711 if( i_port != config_GetInt( p_intf, "server-port" ) )
00712 {
00713 o_mrl_string =
00714 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
00715 }
00716 }
00717 else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS/RTSP")] )
00718 {
00719 NSString *o_url = [o_net_http_url stringValue];
00720
00721 if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
00722 && ![o_url hasPrefix:@"mms"] && ![o_url hasPrefix:@"rtsp"] )
00723 o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
00724 else
00725 o_mrl_string = o_url;
00726 }
00727 [o_mrl setStringValue: o_mrl_string];
00728 }
00729
00730 - (void)openFile
00731 {
00732 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
00733 int i;
00734
00735 [o_open_panel setAllowsMultipleSelection: YES];
00736 [o_open_panel setCanChooseDirectories: YES];
00737 [o_open_panel setTitle: _NS("Open File")];
00738 [o_open_panel setPrompt: _NS("Open")];
00739
00740 if( [o_open_panel runModalForDirectory: nil
00741 file: nil types: nil] == NSOKButton )
00742 {
00743 NSArray *o_array = [NSArray array];
00744 NSArray *o_values = [[o_open_panel filenames]
00745 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
00746
00747 for( i = 0; i < (int)[o_values count]; i++)
00748 {
00749 NSDictionary *o_dic;
00750 o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
00751 o_array = [o_array arrayByAddingObject: o_dic];
00752 }
00753 [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
00754 }
00755 }
00756
00757 - (IBAction)subsChanged:(id)sender
00758 {
00759 if ([o_file_sub_ckbox state] == NSOnState)
00760 {
00761 [o_file_sub_btn_settings setEnabled:YES];
00762 }
00763 else
00764 {
00765 [o_file_sub_btn_settings setEnabled:NO];
00766 }
00767 }
00768
00769 - (IBAction)subSettings:(id)sender
00770 {
00771 [NSApp beginSheet: o_file_sub_sheet
00772 modalForWindow: [sender window]
00773 modalDelegate: self
00774 didEndSelector: NULL
00775 contextInfo: nil];
00776 }
00777
00778 - (IBAction)subFileBrowse:(id)sender
00779 {
00780 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
00781
00782 [o_open_panel setAllowsMultipleSelection: NO];
00783 [o_open_panel setTitle: _NS("Open File")];
00784 [o_open_panel setPrompt: _NS("Open")];
00785
00786 if( [o_open_panel runModalForDirectory: nil
00787 file: nil types: nil] == NSOKButton )
00788 {
00789 NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
00790 [o_file_sub_path setStringValue: o_filename];
00791 }
00792 }
00793
00794 - (IBAction)subOverride:(id)sender
00795 {
00796 BOOL b_state = [o_file_sub_override state];
00797 [o_file_sub_delay setEnabled: b_state];
00798 [o_file_sub_delay_stp setEnabled: b_state];
00799 [o_file_sub_fps setEnabled: b_state];
00800 [o_file_sub_fps_stp setEnabled: b_state];
00801 }
00802
00803 - (IBAction)subDelayStepperChanged:(id)sender
00804 {
00805 [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
00806 }
00807
00808 - (IBAction)subFpsStepperChanged:(id)sender;
00809 {
00810 [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
00811 }
00812
00813 - (IBAction)subCloseSheet:(id)sender
00814 {
00815 [o_file_sub_sheet orderOut:sender];
00816 [NSApp endSheet: o_file_sub_sheet];
00817 }
00818
00819 - (IBAction)panelCancel:(id)sender
00820 {
00821 [NSApp stopModalWithCode: 0];
00822 }
00823
00824 - (IBAction)panelOk:(id)sender
00825 {
00826 if( [[o_mrl stringValue] length] )
00827 {
00828 [NSApp stopModalWithCode: 1];
00829 }
00830 else
00831 {
00832 NSBeep();
00833 }
00834 }
00835
00836 @end