*****************************************************************************/
@implementation VLCOpen
+@synthesize fileSubDelay, fileSubFps;
+
#pragma mark -
#pragma mark Init
[o_disc_selector_pop removeAllItems];
[o_disc_selector_pop setHidden: NO];
- NSString *o_videots = _NS("Open VIDEO_TS folder");
- NSString *o_bdmv = _NS("Open BDMV folder");
+ NSString *o_videots = _NS("Open VIDEO_TS / BDMV folder");
[o_disc_nodisc_lbl setStringValue: _NS("Insert Disc")];
[o_disc_nodisc_videots_btn setTitle: o_videots];
- [o_disc_nodisc_bdmv_btn setTitle: o_bdmv];
[o_disc_audiocd_lbl setStringValue: _NS("Audio CD")];
[o_disc_audiocd_trackcount_lbl setStringValue: @""];
[o_disc_audiocd_videots_btn setTitle: o_videots];
- [o_disc_audiocd_bdmv_btn setTitle: o_bdmv];
[o_disc_dvd_lbl setStringValue: @""];
[o_disc_dvd_disablemenus_btn setTitle: _NS("Disable DVD menus")];
[o_disc_dvd_videots_btn setTitle: o_videots];
- [o_disc_dvd_bdmv_btn setTitle: o_bdmv];
[o_disc_dvdwomenus_lbl setStringValue: @""];
[o_disc_dvdwomenus_enablemenus_btn setTitle: _NS("Enable DVD menus")];
[o_disc_dvdwomenus_videots_btn setTitle: o_videots];
- [o_disc_dvdwomenus_bdmv_btn setTitle: o_bdmv];
[o_disc_dvdwomenus_title_lbl setStringValue: _NS("Title")];
[o_disc_dvdwomenus_chapter_lbl setStringValue: _NS("Chapter")];
[o_disc_vcd_title_lbl setStringValue: _NS("Title")];
[o_disc_vcd_chapter_lbl setStringValue: _NS("Chapter")];
[o_disc_vcd_videots_btn setTitle: o_videots];
- [o_disc_vcd_bdmv_btn setTitle: o_bdmv];
[o_disc_bd_videots_btn setTitle: o_videots];
- [o_disc_bd_bdmv_btn setTitle: o_bdmv];
[o_net_udp_port_lbl setStringValue: _NS("Port")];
[o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
for (int ivideo = 0; ivideo < deviceCount; ivideo++) {
QTCaptureDevice *qtk_device;
qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
- [o_qtk_video_device_pop addItemWithTitle: [qtk_device localizedDisplayName]];
+ // allow same name for multiple times
+ [[o_qtk_video_device_pop menu] addItemWithTitle:[qtk_device localizedDisplayName] action:nil keyEquivalent:@""];
- if ([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid])
+ if ([[[qtk_device uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid])
[o_qtk_video_device_pop selectItemAtIndex:ivideo];
}
} else {
NSUInteger deviceCount = [qtkaudioDevices count];
for (int iaudio = 0; iaudio < deviceCount; iaudio++) {
- QTCaptureDevice *qtkaudio_device;
- qtkaudio_device = [qtkaudioDevices objectAtIndex:iaudio];
- [o_qtk_audio_device_pop addItemWithTitle: [qtkaudio_device localizedDisplayName]];
- [o_screen_qtk_audio_pop addItemWithTitle: [qtkaudio_device localizedDisplayName]];
- if ([[[qtkaudio_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtkaudio_currdevice_uid]) {
+ QTCaptureDevice *qtkaudio_device = [qtkaudioDevices objectAtIndex:iaudio];
+
+ // allow same name for multiple times
+ [[o_qtk_audio_device_pop menu] addItemWithTitle:[qtkaudio_device localizedDisplayName] action:nil keyEquivalent:@""];
+ [[o_screen_qtk_audio_pop menu] addItemWithTitle:[qtkaudio_device localizedDisplayName] action:nil keyEquivalent:@""];
+
+ if ([[[qtkaudio_device uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtkaudio_currdevice_uid]) {
[o_qtk_audio_device_pop selectItemAtIndex:iaudio];
[o_screen_qtk_audio_pop selectItemAtIndex:iaudio];
}
[[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
[[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
- [self performSelector:@selector(qtkToggleUIElements:) withObject:nil afterDelay:.3];
- [self performSelector:@selector(scanOpticalMedia:) withObject:nil afterDelay:.5];
+
+ [self qtkToggleUIElements:nil];
+ [self scanOpticalMedia:nil];
[self setMRL: @""];
}
int i_result;
- b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
-
[o_tabview selectTabViewItemAtIndex: i_type];
[o_file_sub_ckbox setState: NSOffState];
[o_options addObject: [NSString stringWithFormat: @"sub-file=%@", o_sub_path]];
if ([o_file_sub_override state] == NSOnState) {
- [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)([o_file_sub_delay intValue] * 10)]];
- [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
+ [o_options addObject: [NSString stringWithFormat: @"sub-delay=%f", ([self fileSubDelay] * 10)]];
+ [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [self fileSubFps]]];
}
[o_options addObject: [NSString stringWithFormat:
@"subsdec-encoding=%@", [[o_file_sub_encoding_pop selectedItem] representedObject]]];
if ([o_file_custom_timing_ckb state] == NSOnState) {
NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
NSUInteger componentCount = [components count];
- NSInteger tempValue;
+ NSInteger tempValue = 0;
if (componentCount == 1)
tempValue = [[components objectAtIndex:0] intValue];
else if (componentCount == 2)
/* apply the options to our item(s) */
[o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
- if (b_autoplay)
- [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:NO];
- else
- [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:YES];
+
+ [[[VLCMain sharedInstance] playlist] addPlaylistItems:[NSArray arrayWithObject:o_dic]];
}
}
- (void)openFile
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
- b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
[o_open_panel setAllowsMultipleSelection: YES];
[o_open_panel setCanChooseDirectories: YES];
[o_array addObject: o_dic];
}
- if (b_autoplay)
- [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:NO];
- else
- [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:YES];
+
+ [[[VLCMain sharedInstance] playlist] addPlaylistItems:o_array];
}
}
[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] displayIfNeeded];
}
-- (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
++ (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
{
OSStatus err;
FSRef ref;
return @"";
}
-- (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath
++ (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath
{
OSStatus err;
FSRef ref;
if (noErr == err)
actualVolume = catalogInfo.volume;
else
- return NULL;
+ goto out;
}
else
- return NULL;
+ goto out;
GetVolParmsInfoBuffer volumeParms;
err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
CFMutableDictionaryRef matchingDict;
io_service_t service;
- if (!volumeParms.vMDeviceID)
- return NULL;
+ if (!volumeParms.vMDeviceID) {
+ goto out;
+ }
matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
- NSString *returnValue;
+
+ NSString *returnValue = nil;
if (IO_OBJECT_NULL != service) {
- if (IOObjectConformsTo(service, kIOCDMediaClass)) {
+ if (IOObjectConformsTo(service, kIOCDMediaClass))
returnValue = kVLCMediaAudioCD;
- }
else if (IOObjectConformsTo(service, kIODVDMediaClass))
returnValue = kVLCMediaDVD;
else if (IOObjectConformsTo(service, kIOBDMediaClass))
returnValue = kVLCMediaBD;
- else {
- if ([mountPath rangeOfString:@"VIDEO_TS" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
- returnValue = kVLCMediaVideoTSFolder;
- else if ([mountPath rangeOfString:@"BDMV" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
- returnValue = kVLCMediaBDMVFolder;
- else {
- // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
- NSFileManager * fm = [[NSFileManager alloc] init];
-
- NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
- for (int i = 0; i < [dirContents count]; i++) {
- NSString *currentFile = [dirContents objectAtIndex:i];
- NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
-
- BOOL isDir;
- if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
- {
- if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame) {
- returnValue = kVLCMediaSVCD;
- break;
- }
- if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame) {
- returnValue = kVLCMediaVCD;
- break;
- }
- if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame) {
- returnValue = kVLCMediaBDMVFolder;
- break;
- }
- if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame) {
- returnValue = kVLCMediaVideoTSFolder;
- break;
- }
- }
- }
+ IOObjectRelease(service);
- [fm release];
+ if (returnValue)
+ return returnValue;
+ }
- if (!returnValue)
+out:
+ if ([mountPath rangeOfString:@"VIDEO_TS" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
+ returnValue = kVLCMediaVideoTSFolder;
+ else if ([mountPath rangeOfString:@"BDMV" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
+ returnValue = kVLCMediaBDMVFolder;
+ else {
+ // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
+ NSFileManager * fm = [[NSFileManager alloc] init];
+
+ NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
+ for (int i = 0; i < [dirContents count]; i++) {
+ NSString *currentFile = [dirContents objectAtIndex:i];
+ NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
+
+ BOOL isDir;
+ if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
+ {
+ if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame) {
+ returnValue = kVLCMediaSVCD;
+ break;
+ }
+ if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame) {
+ returnValue = kVLCMediaVCD;
+ break;
+ }
+ if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame) {
+ returnValue = kVLCMediaBDMVFolder;
+ break;
+ }
+ if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame) {
returnValue = kVLCMediaVideoTSFolder;
+ break;
+ }
}
}
- IOObjectRelease(service);
+ [fm release];
+
+ if (!returnValue)
+ returnValue = kVLCMediaVideoTSFolder;
}
+
return returnValue;
}
- (NSDictionary *)scanPath:(NSString *)o_path
{
- NSString *o_type = [self getVolumeTypeFromMountPath:o_path];
+ NSString *o_type = [VLCOpen getVolumeTypeFromMountPath:o_path];
NSImage *o_image = [[NSWorkspace sharedWorkspace] iconForFile: o_path];
NSString *o_device_path;
+ // BDMV path must not end with BDMV directory
+ if([o_type isEqualToString: kVLCMediaBDMVFolder]) {
+ if([[o_path lastPathComponent] isEqualToString: @"BDMV"]) {
+ o_path = [o_path stringByDeletingLastPathComponent];
+ }
+ }
+
if ([o_type isEqualToString: kVLCMediaVideoTSFolder] ||
[o_type isEqualToString: kVLCMediaBD] ||
[o_type isEqualToString: kVLCMediaBDMVFolder] ||
[o_type isEqualToString: kVLCMediaUnknown])
o_device_path = o_path;
else
- o_device_path = [self getBSDNodeFromMountPath:o_path];
+ o_device_path = [VLCOpen getBSDNodeFromMountPath:o_path];
return [NSDictionary dictionaryWithObjectsAndKeys: o_path, @"path",
o_device_path, @"devicePath",
if (channels) {
NSString *channel;
[[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
- while (channel = [channels nextObject])
+ while ((channel = [channels nextObject]) != nil)
/* we have to add items this way, because we accept duplicates
* additionally, we save a bit of time */
[[[o_eyetv_channels_pop menu] addItemWithTitle: channel action: nil keyEquivalent: @""] setTag:++x];
[o_file_sub_fps_stp setEnabled: b_state];
}
-- (IBAction)subDelayStepperChanged:(id)sender
-{
- [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
-}
-
-- (IBAction)subFpsStepperChanged:(id)sender;
-{
- [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
-}
-
#pragma mark -
#pragma mark Miscellaneous