1 /*****************************************************************************
2 * open.m: Open dialogues for VLC's MacOS X port
3 *****************************************************************************
4 * Copyright (C) 2002-2011 the VideoLAN team
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * Derk-Jan Hartman <thedj@users.sourceforge.net>
10 * Benjamin Pracht <bigben at videolan dot org>
11 * Felix Paul Kühne <fkuehne at videolan dot org>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
28 /*****************************************************************************
30 *****************************************************************************/
31 #import <stdlib.h> /* malloc(), free() */
32 #import <sys/param.h> /* for MAXPATHLEN */
35 #import <IOKit/IOBSD.h>
36 #import <IOKit/storage/IOMedia.h>
37 #import <IOKit/storage/IOCDMedia.h>
38 #import <IOKit/storage/IODVDMedia.h>
39 #import <IOKit/storage/IOBDMedia.h>
40 #import <Cocoa/Cocoa.h>
41 #import <QTKit/QTKit.h>
51 NSArray *qtkvideoDevices;
52 #define setEyeTVUnconnected \
53 [o_capture_lbl setStringValue: _NS("No device is selected")]; \
54 [o_capture_long_lbl setStringValue: _NS("Any device is not selected.\n\nChose abailable device in above pull-down menu\n.")]; \
55 [o_capture_lbl displayIfNeeded]; \
56 [o_capture_long_lbl displayIfNeeded]; \
57 [self showCaptureView: o_capture_label_view]
59 #define kVLCMediaAudioCD "AudioCD"
60 #define kVLCMediaDVD "DVD"
61 #define kVLCMediaVCD "VCD"
62 #define kVLCMediaSVCD "SVCD"
63 #define kVLCMediaBD "Bluray"
64 #define kVLCMediaVideoTSFolder "VIDEO_TS"
65 #define kVLCMediaBDMVFolder "BDMV"
66 #define kVLCMediaUnknown "Unknown"
69 /*****************************************************************************
70 * VLCOpen implementation
71 *****************************************************************************/
72 @implementation VLCOpen
74 static VLCOpen *_o_sharedMainInstance = nil;
76 + (VLCOpen *)sharedInstance
78 return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init];
83 if( _o_sharedMainInstance) {
86 _o_sharedMainInstance = [super init];
90 return _o_sharedMainInstance;
95 [o_specialMediaFolders release];
96 [o_opticalDevices release];
97 if( o_file_slave_path )
98 [o_file_slave_path release];
105 [o_panel setTitle: _NS("Open Source")];
106 [o_mrl_lbl setStringValue: _NS("Media Resource Locator (MRL)")];
108 [o_btn_ok setTitle: _NS("Open")];
109 [o_btn_cancel setTitle: _NS("Cancel")];
111 [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
112 [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
113 [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
114 [[o_tabview tabViewItemAtIndex: 3] setLabel: _NS("Capture")];
116 [o_file_name setStringValue: @""];
117 [o_file_name_stub setStringValue: _NS("Choose a file")];
118 [o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
119 [o_file_btn_browse setTitle: _NS("Browse...")];
120 [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
121 [o_file_stream setHidden: NO];
122 [o_file_slave_ckbox setTitle: _NS("Play another media synchronously")];
123 [o_file_slave_select_btn setTitle: _NS("Choose...")];
124 [o_file_slave_filename_lbl setStringValue: @""];
125 [o_file_slave_icon_well setImage: NULL];
126 [o_file_subtitles_filename_lbl setStringValue: @""];
127 [o_file_subtitles_icon_well setImage: NULL];
129 [o_disc_selector_pop removeAllItems];
130 [o_disc_selector_pop setHidden: NO];
131 NSString *o_videots = _NS("Open VIDEO_TS folder");
132 NSString *o_bdmv = _NS("Open BDMV folder");
133 [o_disc_nodisc_lbl setStringValue: _NS("Insert Disc")];
134 [o_disc_nodisc_videots_btn setTitle: o_videots];
135 [o_disc_nodisc_bdmv_btn setTitle: o_bdmv];
136 [o_disc_audiocd_lbl setStringValue: _NS("Audio CD")];
137 [o_disc_audiocd_trackcount_lbl setStringValue: @""];
138 [o_disc_audiocd_videots_btn setTitle: o_videots];
139 [o_disc_audiocd_bdmv_btn setTitle: o_bdmv];
140 [o_disc_dvd_lbl setStringValue: @""];
141 [o_disc_dvd_disablemenus_btn setTitle: _NS("Disable DVD menus")];
142 [o_disc_dvd_videots_btn setTitle: o_videots];
143 [o_disc_dvd_bdmv_btn setTitle: o_bdmv];
144 [o_disc_dvdwomenus_lbl setStringValue: @""];
145 [o_disc_dvdwomenus_enablemenus_btn setTitle: _NS("Enable DVD menus")];
146 [o_disc_dvdwomenus_videots_btn setTitle: o_videots];
147 [o_disc_dvdwomenus_bdmv_btn setTitle: o_bdmv];
148 [o_disc_dvdwomenus_title_lbl setStringValue: _NS("Title")];
149 [o_disc_dvdwomenus_chapter_lbl setStringValue: _NS("Chapter")];
150 [o_disc_vcd_title_lbl setStringValue: _NS("Title")];
151 [o_disc_vcd_chapter_lbl setStringValue: _NS("Chapter")];
152 [o_disc_vcd_videots_btn setTitle: o_videots];
153 [o_disc_vcd_bdmv_btn setTitle: o_bdmv];
154 [o_disc_bd_videots_btn setTitle: o_videots];
155 [o_disc_bd_bdmv_btn setTitle: o_bdmv];
157 [o_net_udp_port_lbl setStringValue: _NS("Port")];
158 [o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
159 [o_net_udpm_port_lbl setStringValue: _NS("Port")];
160 [o_net_http_url_lbl setStringValue: _NS("URL")];
161 [o_net_help_lbl setStringValue: _NS("To Open a usual network stream (HTTP, RTSP, RTMP, MMS, FTP, etc.), just enter the URL in the field above. If you want to open a RTP or UDP stream, press the button below.")];
162 [o_net_help_udp_lbl setStringValue: _NS("If you want to open a multicast stream, enter the respective IP address given by the stream provider. In unicast mode, VLC will use your machine's IP automatically.\n\nTo open a stream using a different protocol, just press Cancel to close this sheet.")];
163 [o_net_udp_cancel_btn setTitle: _NS("Cancel")];
164 [o_net_udp_ok_btn setTitle: _NS("Open")];
165 [o_net_openUDP_btn setTitle: _NS("Open RTP/UDP Stream")];
166 [o_net_udp_mode_lbl setStringValue: _NS("Mode")];
167 [o_net_udp_protocol_lbl setStringValue: _NS("Protocol")];
168 [o_net_udp_address_lbl setStringValue: _NS("Address")];
170 [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("Unicast")];
171 [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("Multicast")];
173 [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
174 [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
176 [o_eyetv_chn_bgbar setUsesThreadedAnimation: YES];
178 [o_capture_mode_pop removeAllItems];
179 [o_capture_mode_pop addItemWithTitle: @"iSight"];
180 [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
181 [o_capture_mode_pop addItemWithTitle: @"EyeTV"];
182 [o_screen_lbl setStringValue: _NS("Screen Capture Input")];
183 [o_screen_long_lbl setStringValue: _NS("This facility allows you to process your screen's output.")];
184 [o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
185 [o_screen_left_lbl setStringValue: _NS("Subscreen left:")];
186 [o_screen_top_lbl setStringValue: _NS("Subscreen top:")];
187 [o_screen_width_lbl setStringValue: _NS("Subscreen width:")];
188 [o_screen_height_lbl setStringValue: _NS("Subscreen height:")];
189 [o_screen_follow_mouse_ckb setTitle: _NS("Follow the mouse")];
190 [o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
191 [o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
192 [o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
193 [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
194 [o_eyetv_noInstance_lbl setStringValue: _NS("EyeTV is not launched")];
195 [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
196 [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
197 [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
199 [self qtkvideoDevices];
200 [o_qtk_device_pop removeAllItems];
201 msg_Dbg( VLCIntf, "Found %lu capture devices", [qtkvideoDevices count] );
202 if([qtkvideoDevices count] == 0){
203 [o_qtk_device_pop addItemWithTitle: _NS("None")];
204 [qtk_currdevice_uid release];
206 if (!qtk_currdevice_uid) {
207 qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID]
208 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
210 for(int ivideo = 0; ivideo < [qtkvideoDevices count]; ivideo++){
211 QTCaptureDevice *qtk_device;
212 qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
213 [o_qtk_device_pop addItemWithTitle: [qtk_device localizedDisplayName]];
214 if([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid]){
215 [o_qtk_device_pop selectItemAtIndex:ivideo];
222 [[NSNotificationCenter defaultCenter] addObserver: self
223 selector: @selector(openNetInfoChanged:)
224 name: NSControlTextDidChangeNotification
225 object: o_net_udp_port];
226 [[NSNotificationCenter defaultCenter] addObserver: self
227 selector: @selector(openNetInfoChanged:)
228 name: NSControlTextDidChangeNotification
229 object: o_net_udpm_addr];
230 [[NSNotificationCenter defaultCenter] addObserver: self
231 selector: @selector(openNetInfoChanged:)
232 name: NSControlTextDidChangeNotification
233 object: o_net_udpm_port];
234 [[NSNotificationCenter defaultCenter] addObserver: self
235 selector: @selector(openNetInfoChanged:)
236 name: NSControlTextDidChangeNotification
237 object: o_net_http_url];
239 [[NSDistributedNotificationCenter defaultCenter] addObserver: self
240 selector: @selector(eyetvChanged:)
242 object: @"VLCEyeTVSupport"
243 suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
245 [[NSNotificationCenter defaultCenter] addObserver: self
246 selector: @selector(screenFPSfieldChanged:)
247 name: NSControlTextDidChangeNotification
248 object: o_screen_fps_fld];
250 /* register clicks on text fields */
251 [[NSNotificationCenter defaultCenter] addObserver: self
252 selector: @selector(textFieldWasClicked:)
253 name: @"VLCOpenTextFieldWasClicked"
256 /* we want to be notified about removed or added media */
257 o_specialMediaFolders = [[NSMutableArray alloc] init];
258 o_opticalDevices = [[NSMutableArray alloc] init];
259 NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
260 [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
261 [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
262 [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidRenameVolumeNotification object:nil];
263 [self scanOpticalMedia:nil];
268 - (void)setMRL:(NSString *)newMRL
273 [o_mrl_fld setStringValue: newMRL];
274 if ([o_mrl length] > 0)
275 [o_btn_ok setEnabled: YES];
277 [o_btn_ok setEnabled: NO];
288 module_config_t * p_item;
290 [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
291 [o_file_sub_btn_settings setTitle: _NS("Settings...")];
292 [o_file_sub_btn_browse setTitle: _NS("Browse...")];
293 [o_file_sub_override setTitle: _NS("Override parametters")];
294 [o_file_sub_delay_lbl setStringValue: _NS("Delay")];
295 [o_file_sub_delay_stp setEnabled: NO];
296 [o_file_sub_fps_lbl setStringValue: _NS("FPS")];
297 [o_file_sub_fps_stp setEnabled: NO];
298 [o_file_sub_encoding_lbl setStringValue: _NS("Subtitles encoding")];
299 [o_file_sub_encoding_pop removeAllItems];
300 [o_file_sub_size_lbl setStringValue: _NS("Font size")];
301 [o_file_sub_size_pop removeAllItems];
302 [o_file_sub_align_lbl setStringValue: _NS("Subtitles alignment")];
303 [o_file_sub_align_pop removeAllItems];
304 [o_file_sub_ok_btn setStringValue: _NS("OK")];
305 [o_file_sub_font_box setTitle: _NS("Font Properties")];
306 [o_file_sub_file_box setTitle: _NS("Subtitle File")];
308 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
312 for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
315 [o_file_sub_encoding_pop addItemWithTitle:
316 [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
318 [o_file_sub_encoding_pop selectItemWithTitle:
319 [NSString stringWithUTF8String: p_item->value.psz]];
322 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
326 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
328 [o_file_sub_align_pop addItemWithTitle:
329 [NSString stringWithUTF8String:
330 p_item->ppsz_list_text[i_index]]];
332 [o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
335 p_item = config_FindConfig( VLC_OBJECT(p_intf), "freetype-rel-fontsize" );
339 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
341 [o_file_sub_size_pop addItemWithTitle:
342 [NSString stringWithUTF8String:
343 p_item->ppsz_list_text[i_index]]];
344 if ( p_item->value.i == p_item->pi_list[i_index] )
346 [o_file_sub_size_pop selectItemAtIndex: i_index];
352 - (void)openTarget:(int)i_type
356 b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
358 [o_tabview selectTabViewItemAtIndex: i_type];
359 [o_file_sub_ckbox setState: NSOffState];
361 i_result = [NSApp runModalForWindow: o_panel];
366 NSMutableDictionary *o_dic;
367 NSMutableArray *o_options = [NSMutableArray array];
370 o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"];
371 if( [o_file_sub_ckbox state] == NSOnState )
373 module_config_t * p_item;
375 [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", [o_file_sub_path stringValue]]];
376 if( [o_file_sub_override state] == NSOnState )
378 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
379 [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
381 [o_options addObject: [NSString stringWithFormat:
382 @"subsdec-encoding=%@",
383 [o_file_sub_encoding_pop titleOfSelectedItem]]];
384 [o_options addObject: [NSString stringWithFormat:
386 [o_file_sub_align_pop indexOfSelectedItem]]];
388 p_item = config_FindConfig( VLC_OBJECT(p_intf),
389 "freetype-rel-fontsize" );
393 [o_options addObject: [NSString stringWithFormat:
394 @"freetype-rel-fontsize=%i",
395 p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
398 if( [o_output_ckbox state] == NSOnState )
400 for (i = 0 ; i < [[o_sout_options mrl] count] ; i++)
402 [o_options addObject: [NSString stringWithString:
403 [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
406 if( [o_file_slave_ckbox state] && o_file_slave_path )
407 [o_options addObject: [NSString stringWithFormat: @"input-slave=%@", o_file_slave_path]];
408 if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
410 if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
411 [o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
412 [o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
413 [o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
414 [o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
415 [o_options addObject: [NSString stringWithFormat: @"screen-height=%i", [o_screen_height_fld intValue]]];
416 if( [o_screen_follow_mouse_ckb intValue] == YES )
417 [o_options addObject: @"screen-follow-mouse"];
419 [o_options addObject: @"no-screen-follow-mouse"];
422 /* apply the options to our item(s) */
423 [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
425 [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
427 [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
431 - (IBAction)qtkChanged:(id)sender
433 msg_Dbg( VLCIntf, "Changed UID: old %s", [qtk_currdevice_uid UTF8String] );
434 qtk_currdevice_uid = [[[qtkvideoDevices objectAtIndex:[o_qtk_device_pop indexOfSelectedItem]] uniqueID]
435 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
436 msg_Dbg( VLCIntf, "Changed UID: new %s", [qtk_currdevice_uid UTF8String] );
437 [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
440 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
442 NSString *o_label = [o_tvi label];
444 if( [o_label isEqualToString: _NS("File")] )
446 [self openFilePathChanged: nil];
448 else if( [o_label isEqualToString: _NS("Disc")] )
450 [self scanOpticalMedia: nil];
452 else if( [o_label isEqualToString: _NS("Network")] )
454 [self openNetInfoChanged: nil];
456 else if( [o_label isEqualToString: _NS("Capture")] )
458 [self openCaptureModeChanged: nil];
462 - (IBAction)expandMRLfieldAction:(id)sender
464 NSRect o_win_rect, o_view_rect;
465 o_win_rect = [o_panel frame];
466 o_view_rect = [o_mrl_view frame];
468 if( [o_mrl_btn state] == NSOffState )
470 /* we need to collaps, restore the panel size */
471 o_win_rect.size.height = o_win_rect.size.height - o_view_rect.size.height;
472 o_win_rect.origin.y = ( o_win_rect.origin.y + o_view_rect.size.height ) - o_view_rect.size.height;
474 /* remove the MRL view */
475 [o_mrl_view removeFromSuperview];
477 /* we need to expand */
478 [o_mrl_view setFrame: NSMakeRect( 0,
479 [o_mrl_btn frame].origin.y,
480 o_view_rect.size.width,
481 o_view_rect.size.height )];
482 [o_mrl_view setNeedsDisplay: NO];
483 [o_mrl_view setAutoresizesSubviews: YES];
485 /* enlarge panel size for MRL view */
486 o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
489 [o_panel setFrame: o_win_rect display:YES animate: YES];
490 [o_panel displayIfNeeded];
491 if( [o_mrl_btn state] == NSOnState )
492 [[o_panel contentView] addSubview: o_mrl_view];
495 - (IBAction)inputSlaveAction:(id)sender
497 if( sender == o_file_slave_ckbox )
498 [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
501 NSOpenPanel *o_open_panel;
502 o_open_panel = [NSOpenPanel openPanel];
503 [o_open_panel setCanChooseFiles: YES];
504 [o_open_panel setCanChooseDirectories: NO];
505 if( [o_open_panel runModal] == NSOKButton )
507 if( o_file_slave_path )
508 [o_file_slave_path release];
509 o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
510 [o_file_slave_path retain];
513 if( o_file_slave_path && [o_file_slave_ckbox state] == NSOnState)
515 [o_file_slave_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_slave_path]];
516 [o_file_slave_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_slave_path]];
520 [o_file_slave_filename_lbl setStringValue: @""];
521 [o_file_slave_icon_well setImage: NULL];
525 - (void)openFileGeneric
527 [self openFilePathChanged: nil];
528 [self openTarget: 0];
533 [o_specialMediaFolders removeAllObjects];
534 [o_opticalDevices removeAllObjects];
535 [self scanOpticalMedia: nil];
536 [self openTarget: 1];
541 [self openNetInfoChanged: nil];
542 [self openTarget: 2];
547 [self openCaptureModeChanged: nil];
548 [self openTarget: 3];
551 - (void)openFilePathChanged:(NSNotification *)o_notification
553 if ( o_file_path && [o_file_path length] > 0 )
555 bool b_stream = [o_file_stream state];
558 [[NSFileManager defaultManager] fileExistsAtPath:o_file_path isDirectory:&b_dir];
560 char *psz_uri = make_URI([o_file_path UTF8String], "file");
561 if( !psz_uri ) return;
563 NSMutableString *o_mrl_string = [NSMutableString stringWithUTF8String: psz_uri ];
564 NSRange offile = [o_mrl_string rangeOfString:@"file"];
568 [o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
570 [o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
572 [o_file_name setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_path]];
573 [o_file_name_stub setHidden: YES];
574 [o_file_stream setHidden: NO];
575 [o_file_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_path]];
576 [o_file_icon_well setHidden: NO];
577 [self setMRL: o_mrl_string];
581 [o_file_name setStringValue: @""];
582 [o_file_name_stub setHidden: NO];
583 [o_file_stream setHidden: YES];
584 [o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
589 - (IBAction)openFileBrowse:(id)sender
591 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
593 [o_open_panel setAllowsMultipleSelection: NO];
594 [o_open_panel setCanChooseDirectories: YES];
595 [o_open_panel setTitle: _NS("Open File")];
596 [o_open_panel setPrompt: _NS("Open")];
598 [o_open_panel beginSheetForDirectory:nil
601 modalForWindow:[sender window]
603 didEndSelector: @selector(pathChosenInPanel:
609 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void *)contextInfo
611 if (returnCode == NSFileHandlingPanelOKButton)
614 [o_file_path release];
615 o_file_path = [[[sheet URLs] objectAtIndex: 0] path];
616 [o_file_path retain];
617 [self openFilePathChanged: nil];
621 - (IBAction)openFileStreamChanged:(id)sender
623 [self openFilePathChanged: nil];
626 - (void)showOpticalMediaView: theView
629 o_view_rect = [theView frame];
630 if( o_currentOpticalMediaView )
632 [o_currentOpticalMediaView removeFromSuperviewWithoutNeedingDisplay];
633 [o_currentOpticalMediaView release];
635 [theView setFrame: NSMakeRect( 233, 0, o_view_rect.size.width, o_view_rect.size.height)];
636 [theView setNeedsDisplay: YES];
637 [theView setAutoresizesSubviews: YES];
638 [[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] addSubview: theView];
639 [theView displayIfNeeded];
640 o_currentOpticalMediaView = theView;
641 [o_currentOpticalMediaView retain];
644 - (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
648 FSVolumeRefNum actualVolume;
649 err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
651 // get a FSVolumeRefNum from mountPath
652 if ( noErr == err ) {
653 FSCatalogInfo catalogInfo;
654 err = FSGetCatalogInfo ( &ref,
661 if ( noErr == err ) {
662 actualVolume = catalogInfo.volume;
666 GetVolParmsInfoBuffer volumeParms;
667 err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
668 if ( noErr != err ) {
669 msg_Err( p_intf, "error retrieving volume params, bailing out" );
673 NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
674 return [NSString stringWithFormat:@"/dev/r%@", bsdName];
677 - (char *)getVolumeTypeFromMountPath:(NSString *)mountPath
681 FSVolumeRefNum actualVolume;
682 err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
684 // get a FSVolumeRefNum from mountPath
685 if ( noErr == err ) {
686 FSCatalogInfo catalogInfo;
687 err = FSGetCatalogInfo ( &ref,
694 if ( noErr == err ) {
695 actualVolume = catalogInfo.volume;
699 GetVolParmsInfoBuffer volumeParms;
700 err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
702 CFMutableDictionaryRef matchingDict;
703 io_service_t service;
705 matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
706 service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
709 if (IO_OBJECT_NULL != service) {
710 if (IOObjectConformsTo(service, kIOCDMediaClass)) {
711 returnValue = kVLCMediaAudioCD;
713 else if(IOObjectConformsTo(service, kIODVDMediaClass))
714 returnValue = kVLCMediaDVD;
715 else if(IOObjectConformsTo(service, kIOBDMediaClass))
716 returnValue = kVLCMediaBD;
719 if ([mountPath rangeOfString:@"VIDEO_TS"].location != NSNotFound)
720 returnValue = kVLCMediaVideoTSFolder;
721 else if ([mountPath rangeOfString:@"BDMV"].location != NSNotFound)
722 returnValue = kVLCMediaBDMVFolder;
725 NSArray * topLevelItems;
726 topLevelItems = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath: mountPath error: NULL];
727 for (int i = 0; i < [topLevelItems count]; i++) {
728 if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
729 returnValue = kVLCMediaSVCD;
732 if([[topLevelItems objectAtIndex:i] rangeOfString:@"VCD"].location != NSNotFound) {
733 returnValue = kVLCMediaVCD;
738 returnValue = kVLCMediaUnknown;
742 IOObjectRelease(service);
747 - (void)showOpticalAtIndex: (NSNumber *)n_index
749 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
751 unsigned int index = [n_index intValue];
752 char *diskType = [self getVolumeTypeFromMountPath:[o_opticalDevices objectAtIndex: index]];
754 if (diskType == kVLCMediaDVD || diskType == kVLCMediaVideoTSFolder)
756 [o_disc_dvd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
757 [o_disc_dvdwomenus_lbl setStringValue: [o_disc_dvd_lbl stringValue]];
758 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
759 NSString *pathToOpen;
760 if (diskType == kVLCMediaVideoTSFolder)
761 pathToOpen = [o_opticalDevices objectAtIndex: index];
763 pathToOpen = [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]];
765 [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", pathToOpen]];
766 [self showOpticalMediaView: o_disc_dvd_view];
768 [self setMRL: [NSString stringWithFormat: @"dvdread://%@@%i:%i-", pathToOpen, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
769 [self showOpticalMediaView: o_disc_dvdwomenus_view];
772 else if (diskType == kVLCMediaAudioCD)
774 [o_disc_audiocd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
775 [o_disc_audiocd_trackcount_lbl setStringValue: [NSString stringWithFormat:_NS("%i tracks"), [[[NSFileManager defaultManager] subpathsOfDirectoryAtPath: [o_opticalDevices objectAtIndex: index] error:NULL] count] - 1]]; // minus .TOC.plist
776 [self showOpticalMediaView: o_disc_audiocd_view];
777 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
778 [self setMRL: [NSString stringWithFormat: @"cdda://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
780 else if (diskType == kVLCMediaVCD || diskType == kVLCMediaSVCD)
782 [o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
783 [self showOpticalMediaView: o_disc_vcd_view];
784 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
785 [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
787 else if (diskType == kVLCMediaBD || diskType == kVLCMediaBDMVFolder)
789 [o_disc_bd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
790 [self showOpticalMediaView: o_disc_bd_view];
791 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
792 if (diskType == kVLCMediaBD)
793 [self setMRL: [NSString stringWithFormat: @"bluray://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
795 [self setMRL: [NSString stringWithFormat: @"bluray://%@", [o_opticalDevices objectAtIndex: index]]];
799 msg_Warn( VLCIntf, "unknown disk type, no idea what to display" );
800 [o_disc_icon_well setImage: [NSImage imageNamed:@"NSApplicationIcon"]];
801 [self showOpticalMediaView: o_disc_nodisc_view];
804 [[o_disc_icon_well image] setSize: NSMakeSize(128,128)];
808 - (void)scanOpticalMedia:(NSNotification *)o_notification
810 [o_opticalDevices removeAllObjects];
811 [o_disc_selector_pop removeAllItems];
812 [o_opticalDevices addObjectsFromArray: [[NSWorkspace sharedWorkspace] mountedRemovableMedia]];
813 if ([o_specialMediaFolders count] > 0)
814 [o_opticalDevices addObjectsFromArray: o_specialMediaFolders];
815 if ([o_opticalDevices count] > 0) {
816 for (int i = 0; i < [o_opticalDevices count] ; i++)
817 [o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: i]]];
819 if ([o_disc_selector_pop numberOfItems] <= 1)
820 [o_disc_selector_pop setHidden: YES];
822 [o_disc_selector_pop setHidden: NO];
824 [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
828 msg_Dbg( VLCIntf, "no optical media found" );
829 [o_disc_selector_pop setHidden: YES];
830 [o_disc_icon_well setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
831 [self showOpticalMediaView: o_disc_nodisc_view];
835 - (IBAction)discSelectorChanged:(id)sender
837 [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
840 - (IBAction)openSpecialMediaFolder:(id)sender
842 /* this is currently for VIDEO_TS and BDMV folders */
843 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
845 [o_open_panel setAllowsMultipleSelection: NO];
846 [o_open_panel setCanChooseFiles: NO];
847 [o_open_panel setCanChooseDirectories: YES];
848 [o_open_panel setTitle: [sender title]];
849 [o_open_panel setPrompt: _NS("Open")];
851 if ([o_open_panel runModal] == NSOKButton)
853 NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
854 if ([o_path length] > 0 )
856 if ([o_path rangeOfString:@"VIDEO_TS"].location != NSNotFound || [o_path rangeOfString:@"BDMV"].location != NSNotFound)
858 [o_specialMediaFolders addObject: o_path];
859 [self scanOpticalMedia: nil];
862 msg_Dbg( VLCIntf, "chosen directory is no suitable special media folder" );
867 - (IBAction)dvdreadOptionChanged:(id)sender
869 if (sender == o_disc_dvdwomenus_enablemenus_btn) {
871 [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]]]];
872 [self showOpticalMediaView: o_disc_dvd_view];
875 if (sender == o_disc_dvd_disablemenus_btn) {
877 [self showOpticalMediaView: o_disc_dvdwomenus_view];
880 if (sender == o_disc_dvdwomenus_title)
881 [o_disc_dvdwomenus_title_stp setIntValue: [o_disc_dvdwomenus_title intValue]];
882 if (sender == o_disc_dvdwomenus_title_stp)
883 [o_disc_dvdwomenus_title setIntValue: [o_disc_dvdwomenus_title_stp intValue]];
884 if (sender == o_disc_dvdwomenus_chapter)
885 [o_disc_dvdwomenus_chapter_stp setIntValue: [o_disc_dvdwomenus_chapter intValue]];
886 if (sender == o_disc_dvdwomenus_chapter_stp)
887 [o_disc_dvdwomenus_chapter setIntValue: [o_disc_dvdwomenus_chapter_stp intValue]];
889 [self setMRL: [NSString stringWithFormat: @"dvdread://%@@%i:%i-", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]], [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
892 - (IBAction)vcdOptionChanged:(id)sender
894 if (sender == o_disc_vcd_title)
895 [o_disc_vcd_title_stp setIntValue: [o_disc_vcd_title intValue]];
896 if (sender == o_disc_vcd_title_stp)
897 [o_disc_vcd_title setIntValue: [o_disc_vcd_title_stp intValue]];
898 if (sender == o_disc_vcd_chapter)
899 [o_disc_vcd_chapter_stp setIntValue: [o_disc_vcd_chapter intValue]];
900 if (sender == o_disc_vcd_chapter_stp)
901 [o_disc_vcd_chapter setIntValue: [o_disc_vcd_chapter_stp intValue]];
903 [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
906 - (void)textFieldWasClicked:(NSNotification *)o_notification
908 if( [o_notification object] == o_net_udp_port )
909 [o_net_mode selectCellAtRow: 0 column: 0];
910 else if( [o_notification object] == o_net_udpm_addr ||
911 [o_notification object] == o_net_udpm_port )
912 [o_net_mode selectCellAtRow: 1 column: 0];
914 [o_net_mode selectCellAtRow: 2 column: 0];
916 [self openNetInfoChanged: nil];
919 - (IBAction)openNetModeChanged:(id)sender
921 if( sender == o_net_mode )
923 if( [[sender selectedCell] tag] == 0 )
924 [o_panel makeFirstResponder: o_net_udp_port];
925 else if ( [[sender selectedCell] tag] == 1 )
926 [o_panel makeFirstResponder: o_net_udpm_addr];
928 msg_Warn( p_intf, "Unknown sender tried to change UDP/RTP mode" );
931 [self openNetInfoChanged: nil];
934 - (IBAction)openNetStepperChanged:(id)sender
936 int i_tag = [sender tag];
940 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
941 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
942 object: o_net_udp_port];
943 [o_panel makeFirstResponder: o_net_udp_port];
945 else if( i_tag == 1 )
947 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
948 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
949 object: o_net_udpm_port];
950 [o_panel makeFirstResponder: o_net_udpm_port];
953 [self openNetInfoChanged: nil];
956 - (void)openNetInfoChanged:(NSNotification *)o_notification
958 NSString *o_mrl_string = [NSString string];
960 if( [o_net_udp_panel isVisible] )
963 o_mode = [[o_net_mode selectedCell] title];
965 if( [o_mode isEqualToString: _NS("Unicast")] )
967 int i_port = [o_net_udp_port intValue];
969 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
970 o_mrl_string = [NSString stringWithString: @"udp://"];
972 o_mrl_string = [NSString stringWithString: @"rtp://"];
974 if( i_port != config_GetInt( p_intf, "server-port" ) )
977 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
980 else if( [o_mode isEqualToString: _NS("Multicast")] )
982 NSString *o_addr = [o_net_udpm_addr stringValue];
983 int i_port = [o_net_udpm_port intValue];
985 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
986 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
988 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
990 if( i_port != config_GetInt( p_intf, "server-port" ) )
993 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
999 o_mrl_string = [o_net_http_url stringValue];
1001 [self setMRL: o_mrl_string];
1004 - (IBAction)openNetUDPButtonAction:(id)sender
1006 if( sender == o_net_openUDP_btn )
1008 [NSApp beginSheet: o_net_udp_panel
1009 modalForWindow: o_panel
1011 didEndSelector: NULL
1013 [self openNetInfoChanged: nil];
1015 else if( sender == o_net_udp_cancel_btn )
1017 [o_net_udp_panel orderOut: sender];
1018 [NSApp endSheet: o_net_udp_panel];
1020 else if( sender == o_net_udp_ok_btn )
1022 NSString *o_mrl_string = [NSString string];
1023 if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
1025 int i_port = [o_net_udp_port intValue];
1027 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
1028 o_mrl_string = [NSString stringWithString: @"udp://"];
1030 o_mrl_string = [NSString stringWithString: @"rtp://"];
1032 if( i_port != config_GetInt( p_intf, "server-port" ) )
1035 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
1038 else if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Multicast")] )
1040 NSString *o_addr = [o_net_udpm_addr stringValue];
1041 int i_port = [o_net_udpm_port intValue];
1043 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
1044 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
1046 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
1048 if( i_port != config_GetInt( p_intf, "server-port" ) )
1051 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
1054 [self setMRL: o_mrl_string];
1055 [o_net_http_url setStringValue: o_mrl_string];
1056 [o_net_udp_panel orderOut: sender];
1057 [NSApp endSheet: o_net_udp_panel];
1063 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1065 b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
1067 [o_open_panel setAllowsMultipleSelection: YES];
1068 [o_open_panel setCanChooseDirectories: YES];
1069 [o_open_panel setTitle: _NS("Open File")];
1070 [o_open_panel setPrompt: _NS("Open")];
1072 if( [o_open_panel runModal] == NSOKButton )
1074 NSArray *o_array = [NSArray array];
1075 NSArray *o_values = [[o_open_panel URLs]
1076 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
1078 for( i = 0; i < (int)[o_values count]; i++)
1080 NSDictionary *o_dic;
1081 char *psz_uri = make_URI([[[o_values objectAtIndex:i] path] UTF8String], "file");
1085 o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
1089 o_array = [o_array arrayByAddingObject: o_dic];
1092 [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
1094 [o_playlist appendArray: o_array atPos: -1 enqueue:YES];
1098 - (void)showCaptureView: theView
1101 o_view_rect = [theView frame];
1102 if( o_currentCaptureView )
1104 [o_currentCaptureView removeFromSuperviewWithoutNeedingDisplay];
1105 [o_currentCaptureView release];
1107 [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
1108 [theView setNeedsDisplay: YES];
1109 [theView setAutoresizesSubviews: YES];
1110 [[[o_tabview tabViewItemAtIndex: 3] view] addSubview: theView];
1111 [theView displayIfNeeded];
1112 o_currentCaptureView = theView;
1113 [o_currentCaptureView retain];
1116 - (IBAction)openCaptureModeChanged:(id)sender
1118 if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
1120 if( [[[VLCMain sharedInstance] eyeTVController] isEyeTVrunning] == YES )
1122 if( [[[VLCMain sharedInstance] eyeTVController] isDeviceConnected] == YES )
1124 [self showCaptureView: o_eyetv_running_view];
1125 [self setupChannelInfo];
1129 setEyeTVUnconnected;
1133 [self showCaptureView: o_eyetv_notLaunched_view];
1136 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
1138 [self showCaptureView: o_screen_view];
1139 [self setMRL: @"screen://"];
1140 [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
1141 [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
1142 [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
1143 [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
1144 [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
1145 [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
1147 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"iSight"] )
1149 [self showCaptureView: o_qtk_view];
1150 [o_qtk_lbl setStringValue: _NS("iSight Capture Input")];
1151 [o_qtk_long_lbl setStringValue: _NS("This facility allows you to process your iSight's input signal.\n\nNo settings are available in this version, so you will be provided a 640px*480px raw video stream.\n\nLive Audio input is not supported.")];
1152 [o_qtk_lbl displayIfNeeded];
1153 [o_qtk_long_lbl displayIfNeeded];
1155 if(!qtk_currdevice_uid)
1161 [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
1166 - (IBAction)screenStepperChanged:(id)sender
1168 [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
1169 [o_panel makeFirstResponder: o_screen_fps_fld];
1170 [self setMRL: @"screen://"];
1173 - (void)screenFPSfieldChanged:(NSNotification *)o_notification
1175 [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
1176 if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
1177 [o_screen_fps_fld setFloatValue: 1.0];
1178 [self setMRL: @"screen://"];
1181 - (IBAction)eyetvSwitchChannel:(id)sender
1183 if( sender == o_eyetv_nextProgram_btn )
1185 int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
1186 [o_eyetv_channels_pop selectItemWithTag:chanNum];
1187 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1189 else if( sender == o_eyetv_previousProgram_btn )
1191 int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
1192 [o_eyetv_channels_pop selectItemWithTag:chanNum];
1193 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1195 else if( sender == o_eyetv_channels_pop )
1197 int chanNum = [[sender selectedItem] tag];
1198 [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
1199 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1202 msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
1205 - (IBAction)eyetvLaunch:(id)sender
1207 [[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
1210 - (IBAction)eyetvGetPlugin:(id)sender
1212 [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
1215 - (void)eyetvChanged:(NSNotification *)o_notification
1217 if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
1219 msg_Dbg( VLCIntf, "eyetv device was added" );
1220 [self showCaptureView: o_eyetv_running_view];
1221 [self setupChannelInfo];
1223 else if( [[o_notification name] isEqualToString: @"DeviceRemoved"] )
1225 /* leave the channel selection like that,
1226 * switch to our "no device" tab */
1227 msg_Dbg( VLCIntf, "eyetv device was removed" );
1228 setEyeTVUnconnected;
1230 else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
1232 /* switch to the "launch eyetv" tab */
1233 msg_Dbg( VLCIntf, "eyetv was terminated" );
1234 [self showCaptureView: o_eyetv_notLaunched_view];
1236 else if( [[o_notification name] isEqualToString: @"PluginInit"] )
1238 /* we got no device yet */
1239 msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
1240 setEyeTVUnconnected;
1243 msg_Warn( VLCIntf, "unknown external notify '%s' received", [[o_notification name] UTF8String] );
1246 /* little helper method, since this code needs to be run by multiple objects */
1247 - (void)setupChannelInfo
1249 /* set up channel selection */
1250 [o_eyetv_channels_pop removeAllItems];
1251 [o_eyetv_chn_bgbar setHidden: NO];
1252 [o_eyetv_chn_bgbar animate: self];
1253 [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
1254 [o_eyetv_chn_status_txt setHidden: NO];
1257 NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
1259 [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
1261 keyEquivalent: @""] setTag:x++];
1262 [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
1264 keyEquivalent: @""] setTag:x++];
1268 [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
1269 while( channel = [channels nextObject] )
1271 /* we have to add items this way, because we accept duplicates
1272 * additionally, we save a bit of time */
1273 [[[o_eyetv_channels_pop menu] addItemWithTitle: channel
1275 keyEquivalent: @""] setTag:++x];
1277 /* make Tuner the default */
1278 [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] currentChannel]];
1282 [o_eyetv_chn_bgbar setHidden: YES];
1283 [o_eyetv_chn_status_txt setHidden: YES];
1286 - (IBAction)subsChanged:(id)sender
1288 if ([o_file_sub_ckbox state] == NSOnState)
1290 [o_file_sub_btn_settings setEnabled:YES];
1291 if ([[o_file_sub_path stringValue] length] > 0) {
1292 [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_file_sub_path stringValue]]];
1293 [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_file_sub_path stringValue]]];
1298 [o_file_sub_btn_settings setEnabled:NO];
1299 [o_file_subtitles_filename_lbl setStringValue: @""];
1300 [o_file_subtitles_icon_well setImage: NULL];
1304 - (IBAction)subSettings:(id)sender
1306 [NSApp beginSheet: o_file_sub_sheet
1307 modalForWindow: [sender window]
1309 didEndSelector: NULL
1313 - (IBAction)subCloseSheet:(id)sender
1315 [self subsChanged: nil];
1316 [o_file_sub_sheet orderOut:sender];
1317 [NSApp endSheet: o_file_sub_sheet];
1320 - (IBAction)subFileBrowse:(id)sender
1322 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1324 [o_open_panel setAllowsMultipleSelection: NO];
1325 [o_open_panel setTitle: _NS("Open File")];
1326 [o_open_panel setPrompt: _NS("Open")];
1328 if( [o_open_panel runModal] == NSOKButton )
1330 NSString *o_filename = [[[o_open_panel URLs] objectAtIndex: 0] path];
1331 [o_file_sub_path setStringValue: o_filename];
1332 [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_filename]];
1333 [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_filename]];
1337 - (IBAction)subOverride:(id)sender
1339 BOOL b_state = [o_file_sub_override state];
1340 [o_file_sub_delay setEnabled: b_state];
1341 [o_file_sub_delay_stp setEnabled: b_state];
1342 [o_file_sub_fps setEnabled: b_state];
1343 [o_file_sub_fps_stp setEnabled: b_state];
1346 - (IBAction)subDelayStepperChanged:(id)sender
1348 [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
1351 - (IBAction)subFpsStepperChanged:(id)sender;
1353 [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
1356 - (IBAction)panelCancel:(id)sender
1358 [NSApp stopModalWithCode: 0];
1361 - (IBAction)panelOk:(id)sender
1363 if( [[self MRL] length] )
1364 [NSApp stopModalWithCode: 1];
1369 - (NSArray *)qtkvideoDevices
1371 if (!qtkvideoDevices)
1372 [self qtkrefreshDevices];
1373 return qtkvideoDevices;
1376 - (void)qtkrefreshDevices
1378 [qtkvideoDevices release];
1379 qtkvideoDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
1384 @implementation VLCOpenTextField
1386 - (void)mouseDown:(NSEvent *)theEvent
1388 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
1390 [super mouseDown: theEvent];