Commit cbc12cea authored by Felix Paul Kühne's avatar Felix Paul Kühne

VLCLibrary: add the ability to launch individual instances with custom options

parent 0727f244
......@@ -50,6 +50,13 @@
*/
+ (VLCLibrary *)sharedLibrary;
/**
* returns an individual instance which can be customized with options
* \param a NSArray with NSString instance containing the options
* \return the individual library instance
*/
- (id)initWithOptions:(NSArray*)options;
/**
* Returns the library's version
* \return The library version example "0.9.0-git Grishenko".
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment