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];
100 [o_currentOpticalMediaIconView release];
101 [o_currentOpticalMediaView release];
107 [o_panel setTitle: _NS("Open Source")];
108 [o_mrl_lbl setStringValue: _NS("Media Resource Locator (MRL)")];
110 [o_btn_ok setTitle: _NS("Open")];
111 [o_btn_cancel setTitle: _NS("Cancel")];
113 [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
114 [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
115 [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
116 [[o_tabview tabViewItemAtIndex: 3] setLabel: _NS("Capture")];
118 [o_file_name setStringValue: @""];
119 [o_file_name_stub setStringValue: _NS("Choose a file")];
120 [o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
121 [o_file_btn_browse setTitle: _NS("Browse...")];
122 [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
123 [o_file_stream setHidden: NO];
124 [o_file_slave_ckbox setTitle: _NS("Play another media synchronously")];
125 [o_file_slave_select_btn setTitle: _NS("Choose...")];
126 [o_file_slave_filename_lbl setStringValue: @""];
127 [o_file_slave_icon_well setImage: NULL];
128 [o_file_subtitles_filename_lbl setStringValue: @""];
129 [o_file_subtitles_icon_well setImage: NULL];
131 [o_disc_selector_pop removeAllItems];
132 [o_disc_selector_pop setHidden: NO];
133 NSString *o_videots = _NS("Open VIDEO_TS folder");
134 NSString *o_bdmv = _NS("Open BDMV folder");
135 [o_disc_nodisc_lbl setStringValue: _NS("Insert Disc")];
136 [o_disc_nodisc_videots_btn setTitle: o_videots];
137 [o_disc_nodisc_bdmv_btn setTitle: o_bdmv];
138 [o_disc_audiocd_lbl setStringValue: _NS("Audio CD")];
139 [o_disc_audiocd_trackcount_lbl setStringValue: @""];
140 [o_disc_audiocd_videots_btn setTitle: o_videots];
141 [o_disc_audiocd_bdmv_btn setTitle: o_bdmv];
142 [o_disc_dvd_lbl setStringValue: @""];
143 [o_disc_dvd_disablemenus_btn setTitle: _NS("Disable DVD menus")];
144 [o_disc_dvd_videots_btn setTitle: o_videots];
145 [o_disc_dvd_bdmv_btn setTitle: o_bdmv];
146 [o_disc_dvdwomenus_lbl setStringValue: @""];
147 [o_disc_dvdwomenus_enablemenus_btn setTitle: _NS("Enable DVD menus")];
148 [o_disc_dvdwomenus_videots_btn setTitle: o_videots];
149 [o_disc_dvdwomenus_bdmv_btn setTitle: o_bdmv];
150 [o_disc_dvdwomenus_title_lbl setStringValue: _NS("Title")];
151 [o_disc_dvdwomenus_chapter_lbl setStringValue: _NS("Chapter")];
152 [o_disc_vcd_title_lbl setStringValue: _NS("Title")];
153 [o_disc_vcd_chapter_lbl setStringValue: _NS("Chapter")];
154 [o_disc_vcd_videots_btn setTitle: o_videots];
155 [o_disc_vcd_bdmv_btn setTitle: o_bdmv];
156 [o_disc_bd_videots_btn setTitle: o_videots];
157 [o_disc_bd_bdmv_btn setTitle: o_bdmv];
159 [o_net_udp_port_lbl setStringValue: _NS("Port")];
160 [o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
161 [o_net_udpm_port_lbl setStringValue: _NS("Port")];
162 [o_net_http_url_lbl setStringValue: _NS("URL")];
163 [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.")];
164 [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.")];
165 [o_net_udp_cancel_btn setTitle: _NS("Cancel")];
166 [o_net_udp_ok_btn setTitle: _NS("Open")];
167 [o_net_openUDP_btn setTitle: _NS("Open RTP/UDP Stream")];
168 [o_net_udp_mode_lbl setStringValue: _NS("Mode")];
169 [o_net_udp_protocol_lbl setStringValue: _NS("Protocol")];
170 [o_net_udp_address_lbl setStringValue: _NS("Address")];
172 [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("Unicast")];
173 [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("Multicast")];
175 [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
176 [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
178 [o_eyetv_chn_bgbar setUsesThreadedAnimation: YES];
180 [o_capture_mode_pop removeAllItems];
181 [o_capture_mode_pop addItemWithTitle: _NS("Capture Device")];
182 [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
183 [o_capture_mode_pop addItemWithTitle: @"EyeTV"];
184 [o_screen_long_lbl setStringValue: _NS("This input allows you to save, stream or display your current screen contents.")];
185 [o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
186 [o_screen_left_lbl setStringValue: _NS("Subscreen left:")];
187 [o_screen_top_lbl setStringValue: _NS("Subscreen top:")];
188 [o_screen_width_lbl setStringValue: _NS("Subscreen width:")];
189 [o_screen_height_lbl setStringValue: _NS("Subscreen height:")];
190 [o_screen_follow_mouse_ckb setTitle: _NS("Follow the mouse")];
191 [o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
192 [o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
193 [o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
194 [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
195 [o_eyetv_noInstance_lbl setStringValue: _NS("EyeTV is not launched")];
196 [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
197 [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
198 [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
199 [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.")];
200 [o_capture_width_lbl setStringValue: _NS("Image width:")];
201 [o_capture_height_lbl setStringValue: _NS("Image height:")];
203 [self qtkvideoDevices];
204 [o_qtk_device_pop removeAllItems];
205 msg_Dbg( VLCIntf, "Found %lu capture devices", [qtkvideoDevices count] );
206 if([qtkvideoDevices count] == 0){
207 [o_qtk_device_pop addItemWithTitle: _NS("None")];
208 [qtk_currdevice_uid release];
210 if (!qtk_currdevice_uid) {
211 qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID]
212 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
214 for(int ivideo = 0; ivideo < [qtkvideoDevices count]; ivideo++){
215 QTCaptureDevice *qtk_device;
216 qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
217 [o_qtk_device_pop addItemWithTitle: [qtk_device localizedDisplayName]];
218 if([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid]){
219 [o_qtk_device_pop selectItemAtIndex:ivideo];
226 [[NSNotificationCenter defaultCenter] addObserver: self
227 selector: @selector(openNetInfoChanged:)
228 name: NSControlTextDidChangeNotification
229 object: o_net_udp_port];
230 [[NSNotificationCenter defaultCenter] addObserver: self
231 selector: @selector(openNetInfoChanged:)
232 name: NSControlTextDidChangeNotification
233 object: o_net_udpm_addr];
234 [[NSNotificationCenter defaultCenter] addObserver: self
235 selector: @selector(openNetInfoChanged:)
236 name: NSControlTextDidChangeNotification
237 object: o_net_udpm_port];
238 [[NSNotificationCenter defaultCenter] addObserver: self
239 selector: @selector(openNetInfoChanged:)
240 name: NSControlTextDidChangeNotification
241 object: o_net_http_url];
243 [[NSDistributedNotificationCenter defaultCenter] addObserver: self
244 selector: @selector(eyetvChanged:)
246 object: @"VLCEyeTVSupport"
247 suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
249 [[NSNotificationCenter defaultCenter] addObserver: self
250 selector: @selector(screenFPSfieldChanged:)
251 name: NSControlTextDidChangeNotification
252 object: o_screen_fps_fld];
254 /* register clicks on text fields */
255 [[NSNotificationCenter defaultCenter] addObserver: self
256 selector: @selector(textFieldWasClicked:)
257 name: @"VLCOpenTextFieldWasClicked"
260 /* we want to be notified about removed or added media */
261 o_specialMediaFolders = [[NSMutableArray alloc] init];
262 o_opticalDevices = [[NSMutableArray alloc] init];
263 NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
264 [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
265 [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
266 [self scanOpticalMedia:nil];
271 - (void)setMRL:(NSString *)newMRL
276 [o_mrl_fld setStringValue: newMRL];
277 if ([o_mrl length] > 0)
278 [o_btn_ok setEnabled: YES];
280 [o_btn_ok setEnabled: NO];
291 module_config_t * p_item;
293 [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
294 [o_file_sub_btn_settings setTitle: _NS("Settings...")];
295 [o_file_sub_btn_browse setTitle: _NS("Browse...")];
296 [o_file_sub_override setTitle: _NS("Override parametters")];
297 [o_file_sub_delay_lbl setStringValue: _NS("Delay")];
298 [o_file_sub_delay_stp setEnabled: NO];
299 [o_file_sub_fps_lbl setStringValue: _NS("FPS")];
300 [o_file_sub_fps_stp setEnabled: NO];
301 [o_file_sub_encoding_lbl setStringValue: _NS("Subtitles encoding")];
302 [o_file_sub_encoding_pop removeAllItems];
303 [o_file_sub_size_lbl setStringValue: _NS("Font size")];
304 [o_file_sub_size_pop removeAllItems];
305 [o_file_sub_align_lbl setStringValue: _NS("Subtitles alignment")];
306 [o_file_sub_align_pop removeAllItems];
307 [o_file_sub_ok_btn setStringValue: _NS("OK")];
308 [o_file_sub_font_box setTitle: _NS("Font Properties")];
309 [o_file_sub_file_box setTitle: _NS("Subtitle File")];
311 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
315 for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
318 [o_file_sub_encoding_pop addItemWithTitle:
319 [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
321 [o_file_sub_encoding_pop selectItemWithTitle:
322 [NSString stringWithUTF8String: p_item->value.psz]];
325 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
329 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
331 [o_file_sub_align_pop addItemWithTitle:
332 [NSString stringWithUTF8String:
333 p_item->ppsz_list_text[i_index]]];
335 [o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
338 p_item = config_FindConfig( VLC_OBJECT(p_intf), "freetype-rel-fontsize" );
342 for ( i_index = 0; i_index < p_item->i_list; i_index++ )
344 [o_file_sub_size_pop addItemWithTitle:
345 [NSString stringWithUTF8String:
346 p_item->ppsz_list_text[i_index]]];
347 if ( p_item->value.i == p_item->pi_list[i_index] )
349 [o_file_sub_size_pop selectItemAtIndex: i_index];
355 - (void)openTarget:(int)i_type
359 b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
361 [o_tabview selectTabViewItemAtIndex: i_type];
362 [o_file_sub_ckbox setState: NSOffState];
364 i_result = [NSApp runModalForWindow: o_panel];
369 NSMutableDictionary *o_dic;
370 NSMutableArray *o_options = [NSMutableArray array];
373 o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"];
374 if( [o_file_sub_ckbox state] == NSOnState )
376 module_config_t * p_item;
378 [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", [o_file_sub_path stringValue]]];
379 if( [o_file_sub_override state] == NSOnState )
381 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
382 [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
384 [o_options addObject: [NSString stringWithFormat:
385 @"subsdec-encoding=%@",
386 [o_file_sub_encoding_pop titleOfSelectedItem]]];
387 [o_options addObject: [NSString stringWithFormat:
389 [o_file_sub_align_pop indexOfSelectedItem]]];
391 p_item = config_FindConfig( VLC_OBJECT(p_intf),
392 "freetype-rel-fontsize" );
396 [o_options addObject: [NSString stringWithFormat:
397 @"freetype-rel-fontsize=%i",
398 p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
401 if( [o_output_ckbox state] == NSOnState )
403 for (i = 0 ; i < [[o_sout_options mrl] count] ; i++)
405 [o_options addObject: [NSString stringWithString:
406 [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
409 if( [o_file_slave_ckbox state] && o_file_slave_path )
410 [o_options addObject: [NSString stringWithFormat: @"input-slave=%@", o_file_slave_path]];
411 if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
413 if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
415 [o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
416 [o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
417 [o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
418 [o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
419 [o_options addObject: [NSString stringWithFormat: @"screen-height=%i", [o_screen_height_fld intValue]]];
420 if( [o_screen_follow_mouse_ckb intValue] == YES )
421 [o_options addObject: @"screen-follow-mouse"];
423 [o_options addObject: @"no-screen-follow-mouse"];
425 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Capture Device")] )
427 [o_options addObject: [NSString stringWithFormat: @"qtcapture-width=%i", [o_capture_width_fld intValue]]];
428 [o_options addObject: [NSString stringWithFormat: @"qtcapture-height=%i", [o_capture_height_fld intValue]]];
432 /* apply the options to our item(s) */
433 [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
435 [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
437 [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
441 - (IBAction)qtkChanged:(id)sender
443 NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:[o_qtk_device_pop indexOfSelectedItem]] formatDescriptions] objectAtIndex: 0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
445 [o_capture_width_fld setIntValue: [sizes sizeValue].width];
446 [o_capture_height_fld setIntValue: [sizes sizeValue].height];
447 [o_capture_width_stp setIntValue: [o_capture_width_fld intValue]];
448 [o_capture_height_stp setIntValue: [o_capture_height_fld intValue]];
449 qtk_currdevice_uid = [[[qtkvideoDevices objectAtIndex:[o_qtk_device_pop indexOfSelectedItem]] uniqueID]
450 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
451 [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
454 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
456 NSString *o_label = [o_tvi label];
458 if( [o_label isEqualToString: _NS("File")] )
460 [self openFilePathChanged: nil];
462 else if( [o_label isEqualToString: _NS("Disc")] )
464 [self scanOpticalMedia: nil];
466 else if( [o_label isEqualToString: _NS("Network")] )
468 [self openNetInfoChanged: nil];
470 else if( [o_label isEqualToString: _NS("Capture")] )
472 [self openCaptureModeChanged: nil];
476 - (IBAction)expandMRLfieldAction:(id)sender
478 NSRect o_win_rect, o_view_rect;
479 o_win_rect = [o_panel frame];
480 o_view_rect = [o_mrl_view frame];
482 if( [o_mrl_btn state] == NSOffState )
484 /* we need to collaps, restore the panel size */
485 o_win_rect.size.height = o_win_rect.size.height - o_view_rect.size.height;
486 o_win_rect.origin.y = ( o_win_rect.origin.y + o_view_rect.size.height ) - o_view_rect.size.height;
488 /* remove the MRL view */
489 [o_mrl_view removeFromSuperview];
491 /* we need to expand */
492 [o_mrl_view setFrame: NSMakeRect( 0,
493 [o_mrl_btn frame].origin.y,
494 o_view_rect.size.width,
495 o_view_rect.size.height )];
496 [o_mrl_view setNeedsDisplay: NO];
497 [o_mrl_view setAutoresizesSubviews: YES];
499 /* enlarge panel size for MRL view */
500 o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
503 [[o_panel animator] setFrame: o_win_rect display:YES];
504 // [o_panel displayIfNeeded];
505 if( [o_mrl_btn state] == NSOnState )
506 [[o_panel contentView] addSubview: o_mrl_view];
509 - (IBAction)inputSlaveAction:(id)sender
511 if( sender == o_file_slave_ckbox )
512 [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
515 NSOpenPanel *o_open_panel;
516 o_open_panel = [NSOpenPanel openPanel];
517 [o_open_panel setCanChooseFiles: YES];
518 [o_open_panel setCanChooseDirectories: NO];
519 if( [o_open_panel runModal] == NSOKButton )
521 if( o_file_slave_path )
522 [o_file_slave_path release];
523 o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
524 [o_file_slave_path retain];
527 if( o_file_slave_path && [o_file_slave_ckbox state] == NSOnState)
529 [o_file_slave_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_slave_path]];
530 [o_file_slave_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_slave_path]];
534 [o_file_slave_filename_lbl setStringValue: @""];
535 [o_file_slave_icon_well setImage: NULL];
539 - (void)openFileGeneric
541 [self openFilePathChanged: nil];
542 [self openTarget: 0];
547 [o_specialMediaFolders removeAllObjects];
548 [o_opticalDevices removeAllObjects];
549 [self scanOpticalMedia: nil];
550 [self openTarget: 1];
555 [self openNetInfoChanged: nil];
556 [self openTarget: 2];
561 [self openCaptureModeChanged: nil];
562 [self openTarget: 3];
565 - (void)openFilePathChanged:(NSNotification *)o_notification
567 if ( o_file_path && [o_file_path length] > 0 )
569 bool b_stream = [o_file_stream state];
572 [[NSFileManager defaultManager] fileExistsAtPath:o_file_path isDirectory:&b_dir];
574 char *psz_uri = make_URI([o_file_path UTF8String], "file");
575 if( !psz_uri ) return;
577 NSMutableString *o_mrl_string = [NSMutableString stringWithUTF8String: psz_uri ];
578 NSRange offile = [o_mrl_string rangeOfString:@"file"];
582 [o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
584 [o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
586 [o_file_name setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_path]];
587 [o_file_name_stub setHidden: YES];
588 [o_file_stream setHidden: NO];
589 [o_file_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_path]];
590 [o_file_icon_well setHidden: NO];
591 [self setMRL: o_mrl_string];
595 [o_file_name setStringValue: @""];
596 [o_file_name_stub setHidden: NO];
597 [o_file_stream setHidden: YES];
598 [o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
603 - (IBAction)openFileBrowse:(id)sender
605 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
607 [o_open_panel setAllowsMultipleSelection: NO];
608 [o_open_panel setCanChooseDirectories: YES];
609 [o_open_panel setTitle: _NS("Open File")];
610 [o_open_panel setPrompt: _NS("Open")];
612 [o_open_panel beginSheetForDirectory:nil
615 modalForWindow:[sender window]
617 didEndSelector: @selector(pathChosenInPanel:
623 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void *)contextInfo
625 if (returnCode == NSFileHandlingPanelOKButton)
628 [o_file_path release];
629 o_file_path = [[[sheet URLs] objectAtIndex: 0] path];
630 [o_file_path retain];
631 [self openFilePathChanged: nil];
635 - (IBAction)openFileStreamChanged:(id)sender
637 [self openFilePathChanged: nil];
640 - (void)showOpticalMediaView: theView withIcon:(NSImage *)icon
643 o_view_rect = [theView frame];
644 [theView setFrame: NSMakeRect( 233, 0, o_view_rect.size.width, o_view_rect.size.height)];
645 [theView setAutoresizesSubviews: YES];
646 if (o_currentOpticalMediaView)
648 [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] replaceSubview: o_currentOpticalMediaView with: theView];
649 [o_currentOpticalMediaView release];
652 [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] addSubview: theView];
653 o_currentOpticalMediaView = theView;
654 [o_currentOpticalMediaView retain];
656 NSImageView *imageView;
657 imageView = [[NSImageView alloc] init];
658 [imageView setFrame: NSMakeRect( 53, 61, 128, 128 )];
659 [icon setSize: NSMakeSize(128,128)];
660 [imageView setImage: icon];
661 if (o_currentOpticalMediaIconView)
663 [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] replaceSubview: o_currentOpticalMediaIconView with: imageView];
664 [o_currentOpticalMediaIconView release];
667 [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] addSubview: imageView];
668 o_currentOpticalMediaIconView = imageView;
669 [o_currentOpticalMediaIconView retain];
672 - (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
676 FSVolumeRefNum actualVolume;
677 err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
679 // get a FSVolumeRefNum from mountPath
680 if ( noErr == err ) {
681 FSCatalogInfo catalogInfo;
682 err = FSGetCatalogInfo ( &ref,
689 if ( noErr == err ) {
690 actualVolume = catalogInfo.volume;
694 GetVolParmsInfoBuffer volumeParms;
695 err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
696 if ( noErr != err ) {
697 msg_Err( p_intf, "error retrieving volume params, bailing out" );
701 NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
702 return [NSString stringWithFormat:@"/dev/r%@", bsdName];
705 - (char *)getVolumeTypeFromMountPath:(NSString *)mountPath
709 FSVolumeRefNum actualVolume;
710 err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
712 // get a FSVolumeRefNum from mountPath
713 if ( noErr == err ) {
714 FSCatalogInfo catalogInfo;
715 err = FSGetCatalogInfo ( &ref,
722 if ( noErr == err ) {
723 actualVolume = catalogInfo.volume;
727 GetVolParmsInfoBuffer volumeParms;
728 err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
730 CFMutableDictionaryRef matchingDict;
731 io_service_t service;
733 matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
734 service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
737 if (IO_OBJECT_NULL != service) {
738 if (IOObjectConformsTo(service, kIOCDMediaClass)) {
739 returnValue = kVLCMediaAudioCD;
741 else if(IOObjectConformsTo(service, kIODVDMediaClass))
742 returnValue = kVLCMediaDVD;
743 else if(IOObjectConformsTo(service, kIOBDMediaClass))
744 returnValue = kVLCMediaBD;
747 if ([mountPath rangeOfString:@"VIDEO_TS"].location != NSNotFound)
748 returnValue = kVLCMediaVideoTSFolder;
749 else if ([mountPath rangeOfString:@"BDMV"].location != NSNotFound)
750 returnValue = kVLCMediaBDMVFolder;
753 NSArray * topLevelItems;
754 topLevelItems = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath: mountPath error: NULL];
755 for (int i = 0; i < [topLevelItems count]; i++) {
756 if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
757 returnValue = kVLCMediaSVCD;
760 if([[topLevelItems objectAtIndex:i] rangeOfString:@"VCD"].location != NSNotFound) {
761 returnValue = kVLCMediaVCD;
766 returnValue = kVLCMediaUnknown;
770 IOObjectRelease(service);
775 - (void)showOpticalAtIndex: (NSNumber *)n_index
777 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
779 unsigned int index = [n_index intValue];
780 char *diskType = [self getVolumeTypeFromMountPath:[o_opticalDevices objectAtIndex: index]];
782 if (diskType == kVLCMediaDVD || diskType == kVLCMediaVideoTSFolder)
784 [o_disc_dvd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
785 [o_disc_dvdwomenus_lbl setStringValue: [o_disc_dvd_lbl stringValue]];
786 NSString *pathToOpen;
787 if (diskType == kVLCMediaVideoTSFolder)
788 pathToOpen = [o_opticalDevices objectAtIndex: index];
790 pathToOpen = [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]];
792 [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", pathToOpen]];
793 [self showOpticalMediaView: o_disc_dvd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
795 [self setMRL: [NSString stringWithFormat: @"dvdread://%@@%i:%i-", pathToOpen, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
796 [self showOpticalMediaView: o_disc_dvdwomenus_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
799 else if (diskType == kVLCMediaAudioCD)
801 [o_disc_audiocd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
802 [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
803 [self showOpticalMediaView: o_disc_audiocd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
804 [self setMRL: [NSString stringWithFormat: @"cdda://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
806 else if (diskType == kVLCMediaVCD || diskType == kVLCMediaSVCD)
808 [o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
809 [self showOpticalMediaView: o_disc_vcd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
810 [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
812 else if (diskType == kVLCMediaBD || diskType == kVLCMediaBDMVFolder)
814 [o_disc_bd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
815 [self showOpticalMediaView: o_disc_bd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
816 if (diskType == kVLCMediaBD)
817 [self setMRL: [NSString stringWithFormat: @"bluray://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
819 [self setMRL: [NSString stringWithFormat: @"bluray://%@", [o_opticalDevices objectAtIndex: index]]];
823 msg_Warn( VLCIntf, "unknown disk type, no idea what to display" );
824 [self showOpticalMediaView: o_disc_nodisc_view withIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
830 - (void)scanOpticalMedia:(NSNotification *)o_notification
832 [o_opticalDevices removeAllObjects];
833 [o_disc_selector_pop removeAllItems];
834 [o_opticalDevices addObjectsFromArray: [[NSWorkspace sharedWorkspace] mountedRemovableMedia]];
835 if ([o_specialMediaFolders count] > 0)
836 [o_opticalDevices addObjectsFromArray: o_specialMediaFolders];
837 if ([o_opticalDevices count] > 0) {
838 for (int i = 0; i < [o_opticalDevices count] ; i++)
839 [o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: i]]];
841 if ([o_disc_selector_pop numberOfItems] <= 1)
842 [o_disc_selector_pop setHidden: YES];
844 [o_disc_selector_pop setHidden: NO];
846 [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
850 msg_Dbg( VLCIntf, "no optical media found" );
851 [o_disc_selector_pop setHidden: YES];
852 [self showOpticalMediaView: o_disc_nodisc_view withIcon: [NSImage imageNamed: @"NSApplicationIcon"]];
856 - (IBAction)discSelectorChanged:(id)sender
858 [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
861 - (IBAction)openSpecialMediaFolder:(id)sender
863 /* this is currently for VIDEO_TS and BDMV folders */
864 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
866 [o_open_panel setAllowsMultipleSelection: NO];
867 [o_open_panel setCanChooseFiles: NO];
868 [o_open_panel setCanChooseDirectories: YES];
869 [o_open_panel setTitle: [sender title]];
870 [o_open_panel setPrompt: _NS("Open")];
872 if ([o_open_panel runModal] == NSOKButton)
874 NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
875 if ([o_path length] > 0 )
877 if ([o_path rangeOfString:@"VIDEO_TS"].location != NSNotFound || [o_path rangeOfString:@"BDMV"].location != NSNotFound)
879 [o_specialMediaFolders addObject: o_path];
880 [self scanOpticalMedia: nil];
883 msg_Dbg( VLCIntf, "chosen directory is no suitable special media folder" );
888 - (IBAction)dvdreadOptionChanged:(id)sender
890 if (sender == o_disc_dvdwomenus_enablemenus_btn) {
892 [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]]]];
893 [self showOpticalMediaView: o_disc_dvd_view withIcon: [o_currentOpticalMediaIconView image]];
896 if (sender == o_disc_dvd_disablemenus_btn) {
898 [self showOpticalMediaView: o_disc_dvdwomenus_view withIcon: [o_currentOpticalMediaIconView image]];
901 if (sender == o_disc_dvdwomenus_title)
902 [o_disc_dvdwomenus_title_stp setIntValue: [o_disc_dvdwomenus_title intValue]];
903 if (sender == o_disc_dvdwomenus_title_stp)
904 [o_disc_dvdwomenus_title setIntValue: [o_disc_dvdwomenus_title_stp intValue]];
905 if (sender == o_disc_dvdwomenus_chapter)
906 [o_disc_dvdwomenus_chapter_stp setIntValue: [o_disc_dvdwomenus_chapter intValue]];
907 if (sender == o_disc_dvdwomenus_chapter_stp)
908 [o_disc_dvdwomenus_chapter setIntValue: [o_disc_dvdwomenus_chapter_stp intValue]];
910 [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]]];
913 - (IBAction)vcdOptionChanged:(id)sender
915 if (sender == o_disc_vcd_title)
916 [o_disc_vcd_title_stp setIntValue: [o_disc_vcd_title intValue]];
917 if (sender == o_disc_vcd_title_stp)
918 [o_disc_vcd_title setIntValue: [o_disc_vcd_title_stp intValue]];
919 if (sender == o_disc_vcd_chapter)
920 [o_disc_vcd_chapter_stp setIntValue: [o_disc_vcd_chapter intValue]];
921 if (sender == o_disc_vcd_chapter_stp)
922 [o_disc_vcd_chapter setIntValue: [o_disc_vcd_chapter_stp intValue]];
924 [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]]];
927 - (void)textFieldWasClicked:(NSNotification *)o_notification
929 if( [o_notification object] == o_net_udp_port )
930 [o_net_mode selectCellAtRow: 0 column: 0];
931 else if( [o_notification object] == o_net_udpm_addr ||
932 [o_notification object] == o_net_udpm_port )
933 [o_net_mode selectCellAtRow: 1 column: 0];
935 [o_net_mode selectCellAtRow: 2 column: 0];
937 [self openNetInfoChanged: nil];
940 - (IBAction)openNetModeChanged:(id)sender
942 if( sender == o_net_mode )
944 if( [[sender selectedCell] tag] == 0 )
945 [o_panel makeFirstResponder: o_net_udp_port];
946 else if ( [[sender selectedCell] tag] == 1 )
947 [o_panel makeFirstResponder: o_net_udpm_addr];
949 msg_Warn( p_intf, "Unknown sender tried to change UDP/RTP mode" );
952 [self openNetInfoChanged: nil];
955 - (IBAction)openNetStepperChanged:(id)sender
957 int i_tag = [sender tag];
961 [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
962 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
963 object: o_net_udp_port];
964 [o_panel makeFirstResponder: o_net_udp_port];
966 else if( i_tag == 1 )
968 [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
969 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
970 object: o_net_udpm_port];
971 [o_panel makeFirstResponder: o_net_udpm_port];
974 [self openNetInfoChanged: nil];
977 - (void)openNetInfoChanged:(NSNotification *)o_notification
979 NSString *o_mrl_string = [NSString string];
981 if( [o_net_udp_panel isVisible] )
984 o_mode = [[o_net_mode selectedCell] title];
986 if( [o_mode isEqualToString: _NS("Unicast")] )
988 int i_port = [o_net_udp_port intValue];
990 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
991 o_mrl_string = [NSString stringWithString: @"udp://"];
993 o_mrl_string = [NSString stringWithString: @"rtp://"];
995 if( i_port != config_GetInt( p_intf, "server-port" ) )
998 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
1001 else if( [o_mode isEqualToString: _NS("Multicast")] )
1003 NSString *o_addr = [o_net_udpm_addr stringValue];
1004 int i_port = [o_net_udpm_port intValue];
1006 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
1007 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
1009 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
1011 if( i_port != config_GetInt( p_intf, "server-port" ) )
1014 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
1020 o_mrl_string = [o_net_http_url stringValue];
1022 [self setMRL: o_mrl_string];
1025 - (IBAction)openNetUDPButtonAction:(id)sender
1027 if( sender == o_net_openUDP_btn )
1029 [NSApp beginSheet: o_net_udp_panel
1030 modalForWindow: o_panel
1032 didEndSelector: NULL
1034 [self openNetInfoChanged: nil];
1036 else if( sender == o_net_udp_cancel_btn )
1038 [o_net_udp_panel orderOut: sender];
1039 [NSApp endSheet: o_net_udp_panel];
1041 else if( sender == o_net_udp_ok_btn )
1043 NSString *o_mrl_string = [NSString string];
1044 if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
1046 int i_port = [o_net_udp_port intValue];
1048 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
1049 o_mrl_string = [NSString stringWithString: @"udp://"];
1051 o_mrl_string = [NSString stringWithString: @"rtp://"];
1053 if( i_port != config_GetInt( p_intf, "server-port" ) )
1056 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
1059 else if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Multicast")] )
1061 NSString *o_addr = [o_net_udpm_addr stringValue];
1062 int i_port = [o_net_udpm_port intValue];
1064 if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
1065 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
1067 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
1069 if( i_port != config_GetInt( p_intf, "server-port" ) )
1072 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
1075 [self setMRL: o_mrl_string];
1076 [o_net_http_url setStringValue: o_mrl_string];
1077 [o_net_udp_panel orderOut: sender];
1078 [NSApp endSheet: o_net_udp_panel];
1084 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1086 b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
1088 [o_open_panel setAllowsMultipleSelection: YES];
1089 [o_open_panel setCanChooseDirectories: YES];
1090 [o_open_panel setTitle: _NS("Open File")];
1091 [o_open_panel setPrompt: _NS("Open")];
1093 if( [o_open_panel runModal] == NSOKButton )
1095 NSArray *o_array = [NSArray array];
1096 NSArray *o_values = [[o_open_panel URLs]
1097 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
1099 for( i = 0; i < (int)[o_values count]; i++)
1101 NSDictionary *o_dic;
1102 char *psz_uri = make_URI([[[o_values objectAtIndex:i] path] UTF8String], "file");
1106 o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
1110 o_array = [o_array arrayByAddingObject: o_dic];
1113 [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
1115 [o_playlist appendArray: o_array atPos: -1 enqueue:YES];
1119 - (void)showCaptureView: theView
1122 o_view_rect = [theView frame];
1123 [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
1124 [theView setAutoresizesSubviews: YES];
1125 if (o_currentCaptureView)
1127 [[[[o_tabview tabViewItemAtIndex: 3] view] animator] replaceSubview: o_currentCaptureView with: theView];
1128 [o_currentCaptureView release];
1131 [[[[o_tabview tabViewItemAtIndex: 3] view] animator] addSubview: theView];
1132 o_currentCaptureView = theView;
1133 [o_currentCaptureView retain];
1136 - (IBAction)openCaptureModeChanged:(id)sender
1138 if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
1140 if( [[[VLCMain sharedInstance] eyeTVController] isEyeTVrunning] == YES )
1142 if( [[[VLCMain sharedInstance] eyeTVController] isDeviceConnected] == YES )
1144 [self showCaptureView: o_eyetv_running_view];
1145 [self setupChannelInfo];
1149 setEyeTVUnconnected;
1153 [self showCaptureView: o_eyetv_notLaunched_view];
1156 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
1158 [self showCaptureView: o_screen_view];
1159 [self setMRL: @"screen://"];
1160 [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
1161 [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
1162 [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
1163 [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
1164 [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
1165 [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
1167 else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Capture Device")] )
1169 [self showCaptureView: o_qtk_view];
1170 if ([o_capture_width_fld intValue] <= 0)
1171 [self qtkChanged:nil];
1173 if(!qtk_currdevice_uid)
1176 [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
1180 - (IBAction)screenStepperChanged:(id)sender
1182 [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
1183 [o_panel makeFirstResponder: o_screen_fps_fld];
1184 [self setMRL: @"screen://"];
1187 - (void)screenFPSfieldChanged:(NSNotification *)o_notification
1189 [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
1190 if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
1191 [o_screen_fps_fld setFloatValue: 1.0];
1192 [self setMRL: @"screen://"];
1195 - (IBAction)eyetvSwitchChannel:(id)sender
1197 if( sender == o_eyetv_nextProgram_btn )
1199 int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
1200 [o_eyetv_channels_pop selectItemWithTag:chanNum];
1201 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1203 else if( sender == o_eyetv_previousProgram_btn )
1205 int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
1206 [o_eyetv_channels_pop selectItemWithTag:chanNum];
1207 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1209 else if( sender == o_eyetv_channels_pop )
1211 int chanNum = [[sender selectedItem] tag];
1212 [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
1213 [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1216 msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
1219 - (IBAction)eyetvLaunch:(id)sender
1221 [[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
1224 - (IBAction)eyetvGetPlugin:(id)sender
1226 [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
1229 - (void)eyetvChanged:(NSNotification *)o_notification
1231 if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
1233 msg_Dbg( VLCIntf, "eyetv device was added" );
1234 [self showCaptureView: o_eyetv_running_view];
1235 [self setupChannelInfo];
1237 else if( [[o_notification name] isEqualToString: @"DeviceRemoved"] )
1239 /* leave the channel selection like that,
1240 * switch to our "no device" tab */
1241 msg_Dbg( VLCIntf, "eyetv device was removed" );
1242 setEyeTVUnconnected;
1244 else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
1246 /* switch to the "launch eyetv" tab */
1247 msg_Dbg( VLCIntf, "eyetv was terminated" );
1248 [self showCaptureView: o_eyetv_notLaunched_view];
1250 else if( [[o_notification name] isEqualToString: @"PluginInit"] )
1252 /* we got no device yet */
1253 msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
1254 setEyeTVUnconnected;
1258 /* little helper method, since this code needs to be run by multiple objects */
1259 - (void)setupChannelInfo
1261 /* set up channel selection */
1262 [o_eyetv_channels_pop removeAllItems];
1263 [o_eyetv_chn_bgbar setHidden: NO];
1264 [o_eyetv_chn_bgbar animate: self];
1265 [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
1266 [o_eyetv_chn_status_txt setHidden: NO];
1269 NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
1271 [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
1273 keyEquivalent: @""] setTag:x++];
1274 [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
1276 keyEquivalent: @""] setTag:x++];
1280 [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
1281 while( channel = [channels nextObject] )
1283 /* we have to add items this way, because we accept duplicates
1284 * additionally, we save a bit of time */
1285 [[[o_eyetv_channels_pop menu] addItemWithTitle: channel
1287 keyEquivalent: @""] setTag:++x];
1289 /* make Tuner the default */
1290 [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] currentChannel]];
1294 [o_eyetv_chn_bgbar setHidden: YES];
1295 [o_eyetv_chn_status_txt setHidden: YES];
1298 - (IBAction)subsChanged:(id)sender
1300 if ([o_file_sub_ckbox state] == NSOnState)
1302 [o_file_sub_btn_settings setEnabled:YES];
1303 if ([[o_file_sub_path stringValue] length] > 0) {
1304 [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_file_sub_path stringValue]]];
1305 [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_file_sub_path stringValue]]];
1310 [o_file_sub_btn_settings setEnabled:NO];
1311 [o_file_subtitles_filename_lbl setStringValue: @""];
1312 [o_file_subtitles_icon_well setImage: NULL];
1316 - (IBAction)subSettings:(id)sender
1318 [NSApp beginSheet: o_file_sub_sheet
1319 modalForWindow: [sender window]
1321 didEndSelector: NULL
1325 - (IBAction)subCloseSheet:(id)sender
1327 [self subsChanged: nil];
1328 [o_file_sub_sheet orderOut:sender];
1329 [NSApp endSheet: o_file_sub_sheet];
1332 - (IBAction)subFileBrowse:(id)sender
1334 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1336 [o_open_panel setAllowsMultipleSelection: NO];
1337 [o_open_panel setTitle: _NS("Open File")];
1338 [o_open_panel setPrompt: _NS("Open")];
1340 if( [o_open_panel runModal] == NSOKButton )
1342 NSString *o_filename = [[[o_open_panel URLs] objectAtIndex: 0] path];
1343 [o_file_sub_path setStringValue: o_filename];
1344 [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_filename]];
1345 [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_filename]];
1349 - (IBAction)subOverride:(id)sender
1351 BOOL b_state = [o_file_sub_override state];
1352 [o_file_sub_delay setEnabled: b_state];
1353 [o_file_sub_delay_stp setEnabled: b_state];
1354 [o_file_sub_fps setEnabled: b_state];
1355 [o_file_sub_fps_stp setEnabled: b_state];
1358 - (IBAction)subDelayStepperChanged:(id)sender
1360 [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
1363 - (IBAction)subFpsStepperChanged:(id)sender;
1365 [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
1368 - (IBAction)panelCancel:(id)sender
1370 [NSApp stopModalWithCode: 0];
1373 - (IBAction)panelOk:(id)sender
1375 if( [[self MRL] length] )
1376 [NSApp stopModalWithCode: 1];
1381 - (NSArray *)qtkvideoDevices
1383 if (!qtkvideoDevices)
1384 [self qtkrefreshDevices];
1385 return qtkvideoDevices;
1388 - (void)qtkrefreshDevices
1390 [qtkvideoDevices release];
1391 qtkvideoDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
1396 @implementation VLCOpenTextField
1398 - (void)mouseDown:(NSEvent *)theEvent
1400 [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
1402 [super mouseDown: theEvent];