|
@@ -51,36 +51,7 @@ static VLCLibrary * sharedLibrary = nil;
|
|
|
- (id)init
|
|
|
{
|
|
|
if (self = [super init]) {
|
|
|
- NSArray *vlcParams;
|
|
|
-#if TARGET_OS_IPHONE
|
|
|
- vlcParams = @[@"--no-color",
|
|
|
- @"--no-osd",
|
|
|
- @"--no-video-title-show",
|
|
|
- @"--no-stats",
|
|
|
- @"--verbose=3",
|
|
|
- @"--avcodec-fast",
|
|
|
- @"--avcodec-skiploopfilter=all",
|
|
|
- @"--no-audio-time-stretch"
|
|
|
- ];
|
|
|
-#else
|
|
|
- vlcParams = [[NSUserDefaults standardUserDefaults] objectForKey:@"VLCParams"];
|
|
|
- if (!vlcParams) {
|
|
|
- NSMutableArray *defaultParams = [NSMutableArray array];
|
|
|
- [defaultParams addObject:@"--play-and-pause"]; // We want every movie to pause instead of stopping at eof
|
|
|
- [defaultParams addObject:@"--no-color"]; // Don't use color in output (Xcode doesn't show it)
|
|
|
- [defaultParams addObject:@"--no-video-title-show"]; // Don't show the title on overlay when starting to play
|
|
|
- [defaultParams addObject:@"--verbose=4"]; // Let's not wreck the logs
|
|
|
- [defaultParams addObject:@"--no-sout-keep"];
|
|
|
- [defaultParams addObject:@"--vout=macosx"]; // Select Mac OS X video output
|
|
|
- [defaultParams addObject:@"--text-renderer=quartztext"]; // our CoreText-based renderer
|
|
|
- [defaultParams addObject:@"--extraintf=macosx_dialog_provider"]; // Some extra dialog (login, progress) may come up from here
|
|
|
-
|
|
|
- [[NSUserDefaults standardUserDefaults] setObject:defaultParams forKey:@"VLCParams"];
|
|
|
- [[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
-
|
|
|
- vlcParams = defaultParams;
|
|
|
- }
|
|
|
-#endif
|
|
|
+ NSArray *vlcParams = [self _defaultOptions];
|
|
|
|
|
|
NSUInteger paramNum = 0;
|
|
|
NSUInteger count = [vlcParams count];
|
|
@@ -97,6 +68,70 @@ static VLCLibrary * sharedLibrary = nil;
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
+- (id)initWithOptions:(NSArray*)options
|
|
|
+{
|
|
|
+ if (self = [super init]) {
|
|
|
+ NSArray *vlcParams = [self _defaultOptions];
|
|
|
+
|
|
|
+ NSUInteger paramNum = 0;
|
|
|
+ NSUInteger count = [vlcParams count];
|
|
|
+ NSUInteger optionsCount = [options count];
|
|
|
+ const char *lib_vlc_params[count+optionsCount];
|
|
|
+
|
|
|
+ /* add default stuff */
|
|
|
+ while (paramNum < count) {
|
|
|
+ NSString *vlcParam = vlcParams[paramNum];
|
|
|
+ lib_vlc_params[paramNum] = [vlcParam cStringUsingEncoding:NSASCIIStringEncoding];
|
|
|
+ paramNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* add requested options */
|
|
|
+ paramNum = 0;
|
|
|
+ while (paramNum < count) {
|
|
|
+ NSString *vlcParam = options[paramNum];
|
|
|
+ lib_vlc_params[paramNum] = [vlcParam cStringUsingEncoding:NSASCIIStringEncoding];
|
|
|
+ paramNum++;
|
|
|
+ }
|
|
|
+ unsigned argc = sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]);
|
|
|
+ instance = libvlc_new(argc, lib_vlc_params);
|
|
|
+ NSAssert(instance, @"libvlc failed to initialize");
|
|
|
+ }
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSArray *)_defaultOptions
|
|
|
+{
|
|
|
+ NSArray *vlcParams;
|
|
|
+#if TARGET_OS_IPHONE
|
|
|
+ vlcParams = @[@"--no-color",
|
|
|
+ @"--no-osd",
|
|
|
+ @"--no-video-title-show",
|
|
|
+ @"--no-stats",
|
|
|
+ @"--avcodec-fast",
|
|
|
+ @"--avcodec-skiploopfilter=all"];
|
|
|
+#else
|
|
|
+ vlcParams = [[NSUserDefaults standardUserDefaults] objectForKey:@"VLCParams"];
|
|
|
+ if (!vlcParams) {
|
|
|
+ NSMutableArray *defaultParams = [NSMutableArray array];
|
|
|
+ [defaultParams addObject:@"--play-and-pause"]; // We want every movie to pause instead of stopping at eof
|
|
|
+ [defaultParams addObject:@"--no-color"]; // Don't use color in output (Xcode doesn't show it)
|
|
|
+ [defaultParams addObject:@"--no-video-title-show"]; // Don't show the title on overlay when starting to play
|
|
|
+ [defaultParams addObject:@"--verbose=4"]; // Let's not wreck the logs
|
|
|
+ [defaultParams addObject:@"--no-sout-keep"];
|
|
|
+ [defaultParams addObject:@"--vout=macosx"]; // Select Mac OS X video output
|
|
|
+ [defaultParams addObject:@"--text-renderer=quartztext"]; // our CoreText-based renderer
|
|
|
+ [defaultParams addObject:@"--extraintf=macosx_dialog_provider"]; // Some extra dialog (login, progress) may come up from here
|
|
|
+
|
|
|
+ [[NSUserDefaults standardUserDefaults] setObject:defaultParams forKey:@"VLCParams"];
|
|
|
+ [[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
+
|
|
|
+ vlcParams = defaultParams;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
+ return vlcParams;
|
|
|
+}
|
|
|
+
|
|
|
- (NSString *)version
|
|
|
{
|
|
|
return @(libvlc_get_version());
|