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: _NS("Capture Device")];
180 [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
181 [o_capture_mode_pop addItemWithTitle: @"EyeTV"];
182 [o_screen_long_lbl setStringValue: _NS("This input allows you to save, stream or display your current screen contents.")];
183 [o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
184 [o_screen_left_lbl setStringValue: _NS("Subscreen left:")];
185 [o_screen_top_lbl setStringValue: _NS("Subscreen top:")];
186 [o_screen_width_lbl setStringValue: _NS("Subscreen width:")];
187 [o_screen_height_lbl setStringValue: _NS("Subscreen height:")];
188 [o_screen_follow_mouse_ckb setTitle: _NS("Follow the mouse")];
189 [o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
190 [o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
191 [o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
192 [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
193 [o_eyetv_noInstance_lbl setStringValue: _NS("EyeTV is not launched")];
194 [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
195 [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
196 [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
197 [o_qtk_long_lbl setStringValue: _NS("This input allows you to process input signals from QuickTime-compatible video devices.\nLive Audio input is not supported.")];
198 [o_capture_width_lbl setStringValue: _NS("Image width:")];
199 [o_capture_height_lbl setStringValue: _NS("Image height:")];
201 [self qtkvideoDevices];
202 [o_qtk_device_pop removeAllItems];
203 msg_Dbg( VLCIntf, "Found %lu capture devices", [qtkvideoDevices count] );
204 if([qtkvideoDevices count] == 0){
205 [o_qtk_device_pop addItemWithTitle: _NS("None")];
206 [qtk_currdevice_uid release];
208 if (!qtk_currdevice_uid) {
209 qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID]
210 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
212 for(int ivideo = 0; ivideo < [qtkvideoDevices count]; ivideo++){
213 QTCaptureDevice *qtk_device;
214 qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
215 [o_qtk_device_pop addItemWithTitle: [qtk_device localizedDisplayName]];
216 if([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid]){
217 [o_qtk_device_pop selectItemAtIndex:ivideo];
224 [[NSNotificationCenter defaultCenter] addObserver: self
225 selector: @selector(openNetInfoChanged:)
226 name: NSControlTextDidChangeNotification
227 object: o_net_udp_port];
228 [[NSNotificationCenter defaultCenter] addObserver: self
229 selector: @selector(openNetInfoChanged:)
230 name: NSControlTextDidChangeNotification
231 object: o_net_udpm_addr];
232 [[NSNotificationCenter defaultCenter] addObserver: self
233 selector: @selector(openNetInfoChanged:)
234 name: NSControlTextDidChangeNotification
235 object: o_net_udpm_port];
236 [[NSNotificationCenter defaultCenter] addObserver: self
237 selector: @selector(openNetInfoChanged:)
238 name: NSControlTextDidChangeNotification
239 object: o_net_http_url];
241 [[NSDistributedNotificationCenter defaultCenter] addObserver: self
242 selector: @selector(eyetvChanged:)
244 object: @"VLCEyeTVSupport"
245 suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
247 [[NSNotificationCenter defaultCenter] addObserver: self
248 selector: @selector(screenFPSfieldChanged:)
249 name: NSControlTextDidChangeNotification
250 object: o_screen_fps_fld];
252 /* register clicks on text fields */
253 [[NSNotificationCenter defaultCenter] addObserver: self
254 selector: @selector(textFieldWasClicked:)
255 name: @"VLCOpenTextFieldWasClicked"
258 /* we want to be notified about removed or added media */
259 o_specialMediaFolders = [[NSMutableArray alloc] init];
260 o_opticalDevices = [[NSMutableArray alloc] init];
261 NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
262 [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
263 [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
264 [self scanOpticalMedia:nil];
269 - (void)setMRL:(NSString *)newMRL
274 [o_mrl_fld setStringValue: newMRL];
275 if ([o_mrl length] > 0)
276 [o_btn_ok setEnabled: YES];
278 [o_btn_ok setEnabled: NO];
289 module_config_t * p_item;
291 [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
292 [o_file_sub_btn_settings setTitle: _NS("Settings...")];
293 [o_file_sub_btn_browse setTitle: _NS("Browse...")];
294 [o_file_sub_override setTitle: _NS("Override parametters")];
295 [o_file_sub_delay_lbl setStringValue: _NS("Delay")];
296 [o_file_sub_delay_stp setEnabled: NO];
297 [o_file_sub_fps_lbl setStringValue: _NS("FPS")];
298 [o_file_sub_fps_stp setEnabled: NO];
299 [o_file_sub_encoding_lbl setStringValue: _NS("Subtitles encoding")];
300 [o_file_sub_encoding_pop removeAllItems];
301 [o_file_sub_size_lbl setStringValue: _NS("Font size")];
302 [o_file_sub_size_pop removeAllItems];
303 [o_file_sub_align_lbl setStringValue: _NS("Subtitles alignment")];
304 [o_file_sub_align_pop removeAllItems];
305 [o_file_sub_ok_btn setStringValue: _NS("OK")];
306 [o_file_sub_font_box setTitle: _NS("Font Properties")];
307 [o_file_sub_file_box setTitle: _NS("Subtitle File")];
309 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
313 for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
316 [o_file_sub_encoding_pop addItemWithTitle:
317 [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
319 [o_file_sub_encoding_pop selectItemWithTitle:
320 [NSString stringWithUTF8String: p_item->value.psz]];
323 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
327 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
329 [o_file_sub_align_pop addItemWithTitle:
330 [NSString stringWithUTF8String:
331 p_item->ppsz_list_text[i_index]]];
333 [o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
336 p_item = config_FindConfig( VLC_OBJECT(p_intf), "freetype-rel-fontsize" );
340 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
342 [o_file_sub_size_pop addItemWithTitle:
343 [NSString stringWithUTF8String:
344 p_item->ppsz_list_text[i_index]]];
345 if ( p_item->value.i == p_item->pi_list[i_index] )
347 [o_file_sub_size_pop selectItemAtIndex: i_index];
353 - (void)openTarget:(int)i_type
357 b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
359 [o_tabview selectTabViewItemAtIndex: i_type];
360 [o_file_sub_ckbox setState: NSOffState];
362 i_result = [NSApp runModalForWindow: o_panel];
367 NSMutableDictionary *o_dic;
368 NSMutableArray *o_options = [NSMutableArray array];
371 o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"];
372 if( [o_file_sub_ckbox state] == NSOnState )
374 module_config_t * p_item;
376 [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", [o_file_sub_path stringValue]]];
377 if( [o_file_sub_override state] == NSOnState )
379 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
380 [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
382 [o_options addObject: [NSString stringWithFormat:
383 @"subsdec-encoding=%@",
384 [o_file_sub_encoding_pop titleOfSelectedItem]]];
385 [o_options addObject: [NSString stringWithFormat:
387 [o_file_sub_align_pop indexOfSelectedItem]]];
389 p_item = config_FindConfig( VLC_OBJECT(p_intf),
390 "freetype-rel-fontsize" );
394 [o_options addObject: [NSString stringWithFormat:
395 @"freetype-rel-fontsize=%i",
396 p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
399 if( [o_output_ckbox state] == NSOnState )
401 for (i = 0 ; i < [[o_sout_options mrl] count] ; i++)
403 [o_options addObject: [NSString stringWithString:
404 [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
407 if( [o_file_slave_ckbox state] && o_file_slave_path )
408 [o_options addObject: [NSString stringWithFormat: @"input-slave=%@", o_file_slave_path]];
409 if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
411 if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
413 [o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
414 [o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
415 [o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
416 [o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
417 [o_options addObject: [NSString stringWithFormat: @"screen-height=%i", [o_screen_height_fld intValue]]];
418 if( [o_screen_follow_mouse_ckb intValue] == YES )
419 [o_options addObject: @"screen-follow-mouse"];
421 [o_options addObject: @"no-screen-follow-mouse"];
423 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Capture Device")] )
425 [o_options addObject: [NSString stringWithFormat: @"qtcapture-width=%i", [o_capture_width_fld intValue]]];
426 [o_options addObject: [NSString stringWithFormat: @"qtcapture-height=%i", [o_capture_height_fld intValue]]];
430 /* apply the options to our item(s) */
431 [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
433 [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
435 [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
439 - (IBAction)qtkChanged:(id)sender
441 NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:[o_qtk_device_pop indexOfSelectedItem]] formatDescriptions] objectAtIndex: 0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
443 [o_capture_width_fld setIntValue: [sizes sizeValue].width];
444 [o_capture_height_fld setIntValue: [sizes sizeValue].height];
445 [o_capture_width_stp setIntValue: [o_capture_width_fld intValue]];
446 [o_capture_height_stp setIntValue: [o_capture_height_fld intValue]];
447 qtk_currdevice_uid = [[[qtkvideoDevices objectAtIndex:[o_qtk_device_pop indexOfSelectedItem]] uniqueID]
448 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
449 [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
452 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
454 NSString *o_label = [o_tvi label];
456 if( [o_label isEqualToString: _NS("File")] )
458 [self openFilePathChanged: nil];
460 else if( [o_label isEqualToString: _NS("Disc")] )
462 [self scanOpticalMedia: nil];
464 else if( [o_label isEqualToString: _NS("Network")] )
466 [self openNetInfoChanged: nil];
468 else if( [o_label isEqualToString: _NS("Capture")] )
470 [self openCaptureModeChanged: nil];
474 - (IBAction)expandMRLfieldAction:(id)sender
476 NSRect o_win_rect, o_view_rect;
477 o_win_rect = [o_panel frame];
478 o_view_rect = [o_mrl_view frame];
480 if( [o_mrl_btn state] == NSOffState )
482 /* we need to collaps, restore the panel size */
483 o_win_rect.size.height = o_win_rect.size.height - o_view_rect.size.height;
484 o_win_rect.origin.y = ( o_win_rect.origin.y + o_view_rect.size.height ) - o_view_rect.size.height;
486 /* remove the MRL view */
487 [o_mrl_view removeFromSuperview];
489 /* we need to expand */
490 [o_mrl_view setFrame: NSMakeRect( 0,
491 [o_mrl_btn frame].origin.y,
492 o_view_rect.size.width,
493 o_view_rect.size.height )];
494 [o_mrl_view setNeedsDisplay: NO];
495 [o_mrl_view setAutoresizesSubviews: YES];
497 /* enlarge panel size for MRL view */
498 o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
501 [o_panel setFrame: o_win_rect display:YES animate: YES];
502 [o_panel displayIfNeeded];
503 if( [o_mrl_btn state] == NSOnState )
504 [[o_panel contentView] addSubview: o_mrl_view];
507 - (IBAction)inputSlaveAction:(id)sender
509 if( sender == o_file_slave_ckbox )
510 [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
513 NSOpenPanel *o_open_panel;
514 o_open_panel = [NSOpenPanel openPanel];
515 [o_open_panel setCanChooseFiles: YES];
516 [o_open_panel setCanChooseDirectories: NO];
517 if( [o_open_panel runModal] == NSOKButton )
519 if( o_file_slave_path )
520 [o_file_slave_path release];
521 o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
522 [o_file_slave_path retain];
525 if( o_file_slave_path && [o_file_slave_ckbox state] == NSOnState)
527 [o_file_slave_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_slave_path]];
528 [o_file_slave_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_slave_path]];
532 [o_file_slave_filename_lbl setStringValue: @""];
533 [o_file_slave_icon_well setImage: NULL];
537 - (void)openFileGeneric
539 [self openFilePathChanged: nil];
540 [self openTarget: 0];
545 [o_specialMediaFolders removeAllObjects];
546 [o_opticalDevices removeAllObjects];
547 [self scanOpticalMedia: nil];
548 [self openTarget: 1];
553 [self openNetInfoChanged: nil];
554 [self openTarget: 2];
559 [self openCaptureModeChanged: nil];
560 [self openTarget: 3];
563 - (void)openFilePathChanged:(NSNotification *)o_notification
565 if ( o_file_path && [o_file_path length] > 0 )
567 bool b_stream = [o_file_stream state];
570 [[NSFileManager defaultManager] fileExistsAtPath:o_file_path isDirectory:&b_dir];
572 char *psz_uri = make_URI([o_file_path UTF8String], "file");
573 if( !psz_uri ) return;
575 NSMutableString *o_mrl_string = [NSMutableString stringWithUTF8String: psz_uri ];
576 NSRange offile = [o_mrl_string rangeOfString:@"file"];
580 [o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
582 [o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
584 [o_file_name setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_path]];
585 [o_file_name_stub setHidden: YES];
586 [o_file_stream setHidden: NO];
587 [o_file_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_path]];
588 [o_file_icon_well setHidden: NO];
589 [self setMRL: o_mrl_string];
593 [o_file_name setStringValue: @""];
594 [o_file_name_stub setHidden: NO];
595 [o_file_stream setHidden: YES];
596 [o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
601 - (IBAction)openFileBrowse:(id)sender
603 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
605 [o_open_panel setAllowsMultipleSelection: NO];
606 [o_open_panel setCanChooseDirectories: YES];
607 [o_open_panel setTitle: _NS("Open File")];
608 [o_open_panel setPrompt: _NS("Open")];
610 [o_open_panel beginSheetForDirectory:nil
613 modalForWindow:[sender window]
615 didEndSelector: @selector(pathChosenInPanel:
621 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void *)contextInfo
623 if (returnCode == NSFileHandlingPanelOKButton)
626 [o_file_path release];
627 o_file_path = [[[sheet URLs] objectAtIndex: 0] path];
628 [o_file_path retain];
629 [self openFilePathChanged: nil];
633 - (IBAction)openFileStreamChanged:(id)sender
635 [self openFilePathChanged: nil];
638 - (void)showOpticalMediaView: theView
641 o_view_rect = [theView frame];
642 if( o_currentOpticalMediaView )
644 [o_currentOpticalMediaView removeFromSuperviewWithoutNeedingDisplay];
645 [o_currentOpticalMediaView release];
647 [theView setFrame: NSMakeRect( 233, 0, o_view_rect.size.width, o_view_rect.size.height)];
648 [theView setNeedsDisplay: YES];
649 [theView setAutoresizesSubviews: YES];
650 [[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] addSubview: theView];
651 [theView displayIfNeeded];
652 o_currentOpticalMediaView = theView;
653 [o_currentOpticalMediaView retain];
656 - (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
660 FSVolumeRefNum actualVolume;
661 err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
663 // get a FSVolumeRefNum from mountPath
664 if ( noErr == err ) {
665 FSCatalogInfo catalogInfo;
666 err = FSGetCatalogInfo ( &ref,
673 if ( noErr == err ) {
674 actualVolume = catalogInfo.volume;
678 GetVolParmsInfoBuffer volumeParms;
679 err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
680 if ( noErr != err ) {
681 msg_Err( p_intf, "error retrieving volume params, bailing out" );
685 NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
686 return [NSString stringWithFormat:@"/dev/r%@", bsdName];
689 - (char *)getVolumeTypeFromMountPath:(NSString *)mountPath
693 FSVolumeRefNum actualVolume;
694 err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
696 // get a FSVolumeRefNum from mountPath
697 if ( noErr == err ) {
698 FSCatalogInfo catalogInfo;
699 err = FSGetCatalogInfo ( &ref,
706 if ( noErr == err ) {
707 actualVolume = catalogInfo.volume;
711 GetVolParmsInfoBuffer volumeParms;
712 err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
714 CFMutableDictionaryRef matchingDict;
715 io_service_t service;
717 matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
718 service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
721 if (IO_OBJECT_NULL != service) {
722 if (IOObjectConformsTo(service, kIOCDMediaClass)) {
723 returnValue = kVLCMediaAudioCD;
725 else if(IOObjectConformsTo(service, kIODVDMediaClass))
726 returnValue = kVLCMediaDVD;
727 else if(IOObjectConformsTo(service, kIOBDMediaClass))
728 returnValue = kVLCMediaBD;
731 if ([mountPath rangeOfString:@"VIDEO_TS"].location != NSNotFound)
732 returnValue = kVLCMediaVideoTSFolder;
733 else if ([mountPath rangeOfString:@"BDMV"].location != NSNotFound)
734 returnValue = kVLCMediaBDMVFolder;
737 NSArray * topLevelItems;
738 topLevelItems = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath: mountPath error: NULL];
739 for (int i = 0; i < [topLevelItems count]; i++) {
740 if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
741 returnValue = kVLCMediaSVCD;
744 if([[topLevelItems objectAtIndex:i] rangeOfString:@"VCD"].location != NSNotFound) {
745 returnValue = kVLCMediaVCD;
750 returnValue = kVLCMediaUnknown;
754 IOObjectRelease(service);
759 - (void)showOpticalAtIndex: (NSNumber *)n_index
761 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
763 unsigned int index = [n_index intValue];
764 char *diskType = [self getVolumeTypeFromMountPath:[o_opticalDevices objectAtIndex: index]];
766 if (diskType == kVLCMediaDVD || diskType == kVLCMediaVideoTSFolder)
768 [o_disc_dvd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
769 [o_disc_dvdwomenus_lbl setStringValue: [o_disc_dvd_lbl stringValue]];
770 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
771 NSString *pathToOpen;
772 if (diskType == kVLCMediaVideoTSFolder)
773 pathToOpen = [o_opticalDevices objectAtIndex: index];
775 pathToOpen = [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]];
777 [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", pathToOpen]];
778 [self showOpticalMediaView: o_disc_dvd_view];
780 [self setMRL: [NSString stringWithFormat: @"dvdread://%@@%i:%i-", pathToOpen, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
781 [self showOpticalMediaView: o_disc_dvdwomenus_view];
784 else if (diskType == kVLCMediaAudioCD)
786 [o_disc_audiocd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
787 [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
788 [self showOpticalMediaView: o_disc_audiocd_view];
789 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
790 [self setMRL: [NSString stringWithFormat: @"cdda://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
792 else if (diskType == kVLCMediaVCD || diskType == kVLCMediaSVCD)
794 [o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
795 [self showOpticalMediaView: o_disc_vcd_view];
796 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
797 [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
799 else if (diskType == kVLCMediaBD || diskType == kVLCMediaBDMVFolder)
801 [o_disc_bd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
802 [self showOpticalMediaView: o_disc_bd_view];
803 [o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
804 if (diskType == kVLCMediaBD)
805 [self setMRL: [NSString stringWithFormat: @"bluray://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
807 [self setMRL: [NSString stringWithFormat: @"bluray://%@", [o_opticalDevices objectAtIndex: index]]];
811 msg_Warn( VLCIntf, "unknown disk type, no idea what to display" );
812 [o_disc_icon_well setImage: [NSImage imageNamed:@"NSApplicationIcon"]];
813 [self showOpticalMediaView: o_disc_nodisc_view];
816 [[o_disc_icon_well image] setSize: NSMakeSize(128,128)];
820 - (void)scanOpticalMedia:(NSNotification *)o_notification
822 [o_opticalDevices removeAllObjects];
823 [o_disc_selector_pop removeAllItems];
824 [o_opticalDevices addObjectsFromArray: [[NSWorkspace sharedWorkspace] mountedRemovableMedia]];
825 if ([o_specialMediaFolders count] > 0)
826 [o_opticalDevices addObjectsFromArray: o_specialMediaFolders];
827 if ([o_opticalDevices count] > 0) {
828 for (int i = 0; i < [o_opticalDevices count] ; i++)
829 [o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: i]]];
831 if ([o_disc_selector_pop numberOfItems] <= 1)
832 [o_disc_selector_pop setHidden: YES];
834 [o_disc_selector_pop setHidden: NO];
836 [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
840 msg_Dbg( VLCIntf, "no optical media found" );
841 [o_disc_selector_pop setHidden: YES];
842 [o_disc_icon_well setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
843 [self showOpticalMediaView: o_disc_nodisc_view];
847 - (IBAction)discSelectorChanged:(id)sender
849 [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
852 - (IBAction)openSpecialMediaFolder:(id)sender
854 /* this is currently for VIDEO_TS and BDMV folders */
855 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
857 [o_open_panel setAllowsMultipleSelection: NO];
858 [o_open_panel setCanChooseFiles: NO];
859 [o_open_panel setCanChooseDirectories: YES];
860 [o_open_panel setTitle: [sender title]];
861 [o_open_panel setPrompt: _NS("Open")];
863 if ([o_open_panel runModal] == NSOKButton)
865 NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
866 if ([o_path length] > 0 )
868 if ([o_path rangeOfString:@"VIDEO_TS"].location != NSNotFound || [o_path rangeOfString:@"BDMV"].location != NSNotFound)
870 [o_specialMediaFolders addObject: o_path];
871 [self scanOpticalMedia: nil];
874 msg_Dbg( VLCIntf, "chosen directory is no suitable special media folder" );
879 - (IBAction)dvdreadOptionChanged:(id)sender
881 if (sender == o_disc_dvdwomenus_enablemenus_btn) {
883 [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]]]];
884 [self showOpticalMediaView: o_disc_dvd_view];
887 if (sender == o_disc_dvd_disablemenus_btn) {
889 [self showOpticalMediaView: o_disc_dvdwomenus_view];
892 if (sender == o_disc_dvdwomenus_title)
893 [o_disc_dvdwomenus_title_stp setIntValue: [o_disc_dvdwomenus_title intValue]];
894 if (sender == o_disc_dvdwomenus_title_stp)
895 [o_disc_dvdwomenus_title setIntValue: [o_disc_dvdwomenus_title_stp intValue]];
896 if (sender == o_disc_dvdwomenus_chapter)
897 [o_disc_dvdwomenus_chapter_stp setIntValue: [o_disc_dvdwomenus_chapter intValue]];
898 if (sender == o_disc_dvdwomenus_chapter_stp)
899 [o_disc_dvdwomenus_chapter setIntValue: [o_disc_dvdwomenus_chapter_stp intValue]];
901 [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]]];
904 - (IBAction)vcdOptionChanged:(id)sender
906 if (sender == o_disc_vcd_title)
907 [o_disc_vcd_title_stp setIntValue: [o_disc_vcd_title intValue]];
908 if (sender == o_disc_vcd_title_stp)
909 [o_disc_vcd_title setIntValue: [o_disc_vcd_title_stp intValue]];
910 if (sender == o_disc_vcd_chapter)
911 [o_disc_vcd_chapter_stp setIntValue: [o_disc_vcd_chapter intValue]];
912 if (sender == o_disc_vcd_chapter_stp)
913 [o_disc_vcd_chapter setIntValue: [o_disc_vcd_chapter_stp intValue]];
915 [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]]];
918 - (void)textFieldWasClicked:(NSNotification *)o_notification
920 if( [o_notification object] == o_net_udp_port )
921 [o_net_mode selectCellAtRow: 0 column: 0];
922 else if( [o_notification object] == o_net_udpm_addr ||
923 [o_notification object] == o_net_udpm_port )
924 [o_net_mode selectCellAtRow: 1 column: 0];
926 [o_net_mode selectCellAtRow: 2 column: 0];
928 [self openNetInfoChanged: nil];
931 - (IBAction)openNetModeChanged:(id)sender
933 if( sender == o_net_mode )
935 if( [[sender selectedCell] tag] == 0 )
936 [o_panel makeFirstResponder: o_net_udp_port];
937 else if ( [[sender selectedCell] tag] == 1 )
938 [o_panel makeFirstResponder: o_net_udpm_addr];
940 msg_Warn( p_intf, "Unknown sender tried to change UDP/RTP mode" );
943 [self openNetInfoChanged: nil];
946 - (IBAction)openNetStepperChanged:(id)sender
948 int i_tag = [sender tag];
952 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
953 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
954 object: o_net_udp_port];
955 [o_panel makeFirstResponder: o_net_udp_port];
957 else if( i_tag == 1 )
959 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
960 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
961 object: o_net_udpm_port];
962 [o_panel makeFirstResponder: o_net_udpm_port];
965 [self openNetInfoChanged: nil];
968 - (void)openNetInfoChanged:(NSNotification *)o_notification
970 NSString *o_mrl_string = [NSString string];
972 if( [o_net_udp_panel isVisible] )
975 o_mode = [[o_net_mode selectedCell] title];
977 if( [o_mode isEqualToString: _NS("Unicast")] )
979 int i_port = [o_net_udp_port intValue];
981 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
982 o_mrl_string = [NSString stringWithString: @"udp://"];
984 o_mrl_string = [NSString stringWithString: @"rtp://"];
986 if( i_port != config_GetInt( p_intf, "server-port" ) )
989 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
992 else if( [o_mode isEqualToString: _NS("Multicast")] )
994 NSString *o_addr = [o_net_udpm_addr stringValue];
995 int i_port = [o_net_udpm_port intValue];
997 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
998 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
1000 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
1002 if( i_port != config_GetInt( p_intf, "server-port" ) )
1005 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
1011 o_mrl_string = [o_net_http_url stringValue];
1013 [self setMRL: o_mrl_string];
1016 - (IBAction)openNetUDPButtonAction:(id)sender
1018 if( sender == o_net_openUDP_btn )
1020 [NSApp beginSheet: o_net_udp_panel
1021 modalForWindow: o_panel
1023 didEndSelector: NULL
1025 [self openNetInfoChanged: nil];
1027 else if( sender == o_net_udp_cancel_btn )
1029 [o_net_udp_panel orderOut: sender];
1030 [NSApp endSheet: o_net_udp_panel];
1032 else if( sender == o_net_udp_ok_btn )
1034 NSString *o_mrl_string = [NSString string];
1035 if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
1037 int i_port = [o_net_udp_port intValue];
1039 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
1040 o_mrl_string = [NSString stringWithString: @"udp://"];
1042 o_mrl_string = [NSString stringWithString: @"rtp://"];
1044 if( i_port != config_GetInt( p_intf, "server-port" ) )
1047 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
1050 else if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Multicast")] )
1052 NSString *o_addr = [o_net_udpm_addr stringValue];
1053 int i_port = [o_net_udpm_port intValue];
1055 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
1056 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
1058 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
1060 if( i_port != config_GetInt( p_intf, "server-port" ) )
1063 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
1066 [self setMRL: o_mrl_string];
1067 [o_net_http_url setStringValue: o_mrl_string];
1068 [o_net_udp_panel orderOut: sender];
1069 [NSApp endSheet: o_net_udp_panel];
1075 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1077 b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
1079 [o_open_panel setAllowsMultipleSelection: YES];
1080 [o_open_panel setCanChooseDirectories: YES];
1081 [o_open_panel setTitle: _NS("Open File")];
1082 [o_open_panel setPrompt: _NS("Open")];
1084 if( [o_open_panel runModal] == NSOKButton )
1086 NSArray *o_array = [NSArray array];
1087 NSArray *o_values = [[o_open_panel URLs]
1088 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
1090 for( i = 0; i < (int)[o_values count]; i++)
1092 NSDictionary *o_dic;
1093 char *psz_uri = make_URI([[[o_values objectAtIndex:i] path] UTF8String], "file");
1097 o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
1101 o_array = [o_array arrayByAddingObject: o_dic];
1104 [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
1106 [o_playlist appendArray: o_array atPos: -1 enqueue:YES];
1110 - (void)showCaptureView: theView
1113 o_view_rect = [theView frame];
1114 if( o_currentCaptureView )
1116 [o_currentCaptureView removeFromSuperviewWithoutNeedingDisplay];
1117 [o_currentCaptureView release];
1119 [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
1120 [theView setNeedsDisplay: YES];
1121 [theView setAutoresizesSubviews: YES];
1122 [[[o_tabview tabViewItemAtIndex: 3] view] addSubview: theView];
1123 [theView displayIfNeeded];
1124 o_currentCaptureView = theView;
1125 [o_currentCaptureView retain];
1128 - (IBAction)openCaptureModeChanged:(id)sender
1130 if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
1132 if( [[[VLCMain sharedInstance] eyeTVController] isEyeTVrunning] == YES )
1134 if( [[[VLCMain sharedInstance] eyeTVController] isDeviceConnected] == YES )
1136 [self showCaptureView: o_eyetv_running_view];
1137 [self setupChannelInfo];
1141 setEyeTVUnconnected;
1145 [self showCaptureView: o_eyetv_notLaunched_view];
1148 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
1150 [self showCaptureView: o_screen_view];
1151 [self setMRL: @"screen://"];
1152 [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
1153 [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
1154 [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
1155 [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
1156 [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
1157 [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
1159 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Capture Device")] )
1161 [self showCaptureView: o_qtk_view];
1162 if ([o_capture_width_fld intValue] <= 0)
1163 [self qtkChanged:nil];
1165 if(!qtk_currdevice_uid)
1168 [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
1172 - (IBAction)screenStepperChanged:(id)sender
1174 [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
1175 [o_panel makeFirstResponder: o_screen_fps_fld];
1176 [self setMRL: @"screen://"];
1179 - (void)screenFPSfieldChanged:(NSNotification *)o_notification
1181 [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
1182 if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
1183 [o_screen_fps_fld setFloatValue: 1.0];
1184 [self setMRL: @"screen://"];
1187 - (IBAction)eyetvSwitchChannel:(id)sender
1189 if( sender == o_eyetv_nextProgram_btn )
1191 int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
1192 [o_eyetv_channels_pop selectItemWithTag:chanNum];
1193 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1195 else if( sender == o_eyetv_previousProgram_btn )
1197 int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
1198 [o_eyetv_channels_pop selectItemWithTag:chanNum];
1199 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1201 else if( sender == o_eyetv_channels_pop )
1203 int chanNum = [[sender selectedItem] tag];
1204 [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
1205 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1208 msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
1211 - (IBAction)eyetvLaunch:(id)sender
1213 [[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
1216 - (IBAction)eyetvGetPlugin:(id)sender
1218 [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
1221 - (void)eyetvChanged:(NSNotification *)o_notification
1223 if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
1225 msg_Dbg( VLCIntf, "eyetv device was added" );
1226 [self showCaptureView: o_eyetv_running_view];
1227 [self setupChannelInfo];
1229 else if( [[o_notification name] isEqualToString: @"DeviceRemoved"] )
1231 /* leave the channel selection like that,
1232 * switch to our "no device" tab */
1233 msg_Dbg( VLCIntf, "eyetv device was removed" );
1234 setEyeTVUnconnected;
1236 else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
1238 /* switch to the "launch eyetv" tab */
1239 msg_Dbg( VLCIntf, "eyetv was terminated" );
1240 [self showCaptureView: o_eyetv_notLaunched_view];
1242 else if( [[o_notification name] isEqualToString: @"PluginInit"] )
1244 /* we got no device yet */
1245 msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
1246 setEyeTVUnconnected;
1250 /* little helper method, since this code needs to be run by multiple objects */
1251 - (void)setupChannelInfo
1253 /* set up channel selection */
1254 [o_eyetv_channels_pop removeAllItems];
1255 [o_eyetv_chn_bgbar setHidden: NO];
1256 [o_eyetv_chn_bgbar animate: self];
1257 [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
1258 [o_eyetv_chn_status_txt setHidden: NO];
1261 NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
1263 [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
1265 keyEquivalent: @""] setTag:x++];
1266 [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
1268 keyEquivalent: @""] setTag:x++];
1272 [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
1273 while( channel = [channels nextObject] )
1275 /* we have to add items this way, because we accept duplicates
1276 * additionally, we save a bit of time */
1277 [[[o_eyetv_channels_pop menu] addItemWithTitle: channel
1279 keyEquivalent: @""] setTag:++x];
1281 /* make Tuner the default */
1282 [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] currentChannel]];
1286 [o_eyetv_chn_bgbar setHidden: YES];
1287 [o_eyetv_chn_status_txt setHidden: YES];
1290 - (IBAction)subsChanged:(id)sender
1292 if ([o_file_sub_ckbox state] == NSOnState)
1294 [o_file_sub_btn_settings setEnabled:YES];
1295 if ([[o_file_sub_path stringValue] length] > 0) {
1296 [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_file_sub_path stringValue]]];
1297 [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_file_sub_path stringValue]]];
1302 [o_file_sub_btn_settings setEnabled:NO];
1303 [o_file_subtitles_filename_lbl setStringValue: @""];
1304 [o_file_subtitles_icon_well setImage: NULL];
1308 - (IBAction)subSettings:(id)sender
1310 [NSApp beginSheet: o_file_sub_sheet
1311 modalForWindow: [sender window]
1313 didEndSelector: NULL
1317 - (IBAction)subCloseSheet:(id)sender
1319 [self subsChanged: nil];
1320 [o_file_sub_sheet orderOut:sender];
1321 [NSApp endSheet: o_file_sub_sheet];
1324 - (IBAction)subFileBrowse:(id)sender
1326 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1328 [o_open_panel setAllowsMultipleSelection: NO];
1329 [o_open_panel setTitle: _NS("Open File")];
1330 [o_open_panel setPrompt: _NS("Open")];
1332 if( [o_open_panel runModal] == NSOKButton )
1334 NSString *o_filename = [[[o_open_panel URLs] objectAtIndex: 0] path];
1335 [o_file_sub_path setStringValue: o_filename];
1336 [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_filename]];
1337 [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_filename]];
1341 - (IBAction)subOverride:(id)sender
1343 BOOL b_state = [o_file_sub_override state];
1344 [o_file_sub_delay setEnabled: b_state];
1345 [o_file_sub_delay_stp setEnabled: b_state];
1346 [o_file_sub_fps setEnabled: b_state];
1347 [o_file_sub_fps_stp setEnabled: b_state];
1350 - (IBAction)subDelayStepperChanged:(id)sender
1352 [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
1355 - (IBAction)subFpsStepperChanged:(id)sender;
1357 [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
1360 - (IBAction)panelCancel:(id)sender
1362 [NSApp stopModalWithCode: 0];
1365 - (IBAction)panelOk:(id)sender
1367 if( [[self MRL] length] )
1368 [NSApp stopModalWithCode: 1];
1373 - (NSArray *)qtkvideoDevices
1375 if (!qtkvideoDevices)
1376 [self qtkrefreshDevices];
1377 return qtkvideoDevices;
1380 - (void)qtkrefreshDevices
1382 [qtkvideoDevices release];
1383 qtkvideoDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
1388 @implementation VLCOpenTextField
1390 - (void)mouseDown:(NSEvent *)theEvent
1392 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
1394 [super mouseDown: theEvent];