#import "open.h"
#import "output.h"
#import "eyetv.h"
+#import "misc.h"
#import <vlc_url.h>
*****************************************************************************/
@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")];
[o_capture_width_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Image width")]];
[o_capture_height_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Image height")]];
+ // setup start / stop time fields
+ [o_file_starttime_fld setFormatter:[[[PositionFormatter alloc] init] autorelease]];
+ [o_file_stoptime_fld setFormatter:[[[PositionFormatter alloc] init] autorelease]];
+
[self qtkvideoDevices];
[o_qtk_video_device_pop removeAllItems];
msg_Dbg(VLCIntf, "Found %lu video capture devices", [qtkvideoDevices count]);
[[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: @""];
}
o_mrl = newMRL;
[o_mrl retain];
- [o_mrl_fld setStringValue: o_mrl];
+ [o_mrl_fld performSelectorOnMainThread:@selector(setStringValue:) withObject:o_mrl waitUntilDone:NO];
if ([o_mrl length] > 0)
[o_btn_ok setEnabled: YES];
else
[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]]];
p_item->list.i[[o_file_sub_size_pop indexOfSelectedItem]]]];
}
}
- NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
- NSUInteger componentCount = [components count];
- NSInteger tempValue;
- if (componentCount == 1)
- tempValue = 1000000 * ([[components objectAtIndex:0] intValue]);
- else if (componentCount == 2)
- tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue]);
- else if (componentCount == 3)
- tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue]);
- if (tempValue > 0)
- [o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
- components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
- componentCount = [components count];
- if (componentCount == 1)
- tempValue = 1000000 * ([[components objectAtIndex:0] intValue]);
- else if (componentCount == 2)
- tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue]);
- else if (componentCount == 3)
- tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue]);
- if (tempValue > 0)
- [o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
+ if ([o_file_custom_timing_ckb state] == NSOnState) {
+ NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
+ NSUInteger componentCount = [components count];
+ NSInteger tempValue = 0;
+ if (componentCount == 1)
+ tempValue = [[components objectAtIndex:0] intValue];
+ else if (componentCount == 2)
+ tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
+ else if (componentCount == 3)
+ tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
+ if (tempValue > 0)
+ [o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
+ components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
+ componentCount = [components count];
+ if (componentCount == 1)
+ tempValue = [[components objectAtIndex:0] intValue];
+ else if (componentCount == 2)
+ tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
+ else if (componentCount == 3)
+ tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
+ if (tempValue > 0)
+ [o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
+ }
if ([o_output_ckbox state] == NSOnState) {
NSArray * soutMRL = [o_sout_options soutMRL];
NSUInteger count = [soutMRL count];
for (NSUInteger i = 0 ; i < count ; i++)
- [o_options addObject: [NSString stringWithString: [soutMRL objectAtIndex: i]]];
+ [o_options addObject: [NSString stringWithString: [soutMRL objectAtIndex:i]]];
}
if ([o_file_slave_ckbox state] && o_file_slave_path)
[o_options addObject: [NSString stringWithFormat: @"input-slave=%@", o_file_slave_path]];
/* apply the options to our item(s) */
[o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
if (b_autoplay)
- [[[VLCMain sharedInstance] playlist] appendArray: @[o_dic] atPos: -1 enqueue:NO];
+ [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:NO];
else
- [[[VLCMain sharedInstance] playlist] appendArray: @[o_dic] atPos: -1 enqueue:YES];
+ [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:YES];
}
}
{
NSInteger i_selectedDevice = [o_qtk_video_device_pop indexOfSelectedItem];
if ([qtkvideoDevices count] >= 1) {
- NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex: 0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
+ NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex:0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
[o_capture_width_fld setIntValue: [sizes sizeValue].width];
[o_capture_height_fld setIntValue: [sizes sizeValue].height];
NSMutableArray *o_values = [NSMutableArray arrayWithCapacity:count];
NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
for (NSUInteger i = 0; i < count; i++)
- [o_values addObject: [[o_urls objectAtIndex: i] path]];
+ [o_values addObject: [[o_urls objectAtIndex:i] path]];
[o_values sortUsingSelector:@selector(caseInsensitiveCompare:)];
for (NSUInteger i = 0; i < count; i++) {
if (returnCode == NSFileHandlingPanelOKButton) {
if (o_file_path)
[o_file_path release];
- o_file_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+ o_file_path = [[[o_open_panel URLs] objectAtIndex:0] path];
[o_file_path retain];
[self openFilePathChanged: nil];
}
if ([o_open_panel runModal] == NSOKButton) {
if (o_file_slave_path)
[o_file_slave_path release];
- o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+ o_file_slave_path = [[[o_open_panel URLs] objectAtIndex:0] path];
[o_file_slave_path retain];
}
}
[[[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",
NSUInteger count = [o_allMediaDevices count];
if (count > 0) {
for (NSUInteger i = 0; i < count ; i++) {
- NSDictionary *o_dict = [o_allMediaDevices objectAtIndex: i];
+ NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:i];
[o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_dict objectForKey:@"path"]]];
}
- (IBAction)discSelectorChanged:(id)sender
{
- NSDictionary *o_dict = [o_allMediaDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]];
+ NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]];
[self showOpticalAtPath:o_dict];
}
/* work-around for Mountain Lion, which treats folders called "BDMV" including an item named "INDEX.BDM"
* as a _FILE_. Don't ask, move on. There is nothing to see here */
[o_open_panel setCanChooseFiles: YES];
- [o_open_panel setAllowedFileTypes:@[@"public.directory"]];
+ [o_open_panel setAllowedFileTypes:[NSArray arrayWithObject:@"public.directory"]];
if ([o_open_panel runModal] == NSOKButton) {
- NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+ NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path];
if ([o_path length] > 0) {
[NSThread detachNewThreadSelector:@selector(scanSpecialPath:) toTarget:self withObject:o_path];
}
- (IBAction)dvdreadOptionChanged:(id)sender
{
- NSDictionary *o_dict = [o_allMediaDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]];
+ NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]];
NSString *o_device_path = [o_dict objectForKey:@"devicePath"];
if (sender == o_disc_dvdwomenus_enablemenus_btn) {
if (sender == o_disc_vcd_chapter_stp)
[o_disc_vcd_chapter setIntValue: [o_disc_vcd_chapter_stp intValue]];
- NSString *o_device_path = [[o_allMediaDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]] objectForKey:@"devicePath"];
+ NSString *o_device_path = [[o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]] objectForKey:@"devicePath"];
[self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", o_device_path, [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
}
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_open_panel setPrompt: _NS("Open")];
if ([o_open_panel runModal] == NSOKButton) {
- o_sub_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+ o_sub_path = [[[o_open_panel URLs] objectAtIndex:0] path];
[o_sub_path retain];
[o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_sub_path]];
[o_file_sub_path_fld setStringValue: [o_file_subtitles_filename_lbl stringValue]];
[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