]> git.sesse.net Git - vlc/blobdiff - projects/macosx/framework/Sources/VLCLibrary.m
MobileVLCKit: updated libvlc initialization to current API
[vlc] / projects / macosx / framework / Sources / VLCLibrary.m
index 4a58f5c02affffe0d59a8bd7d2a5b9b6fe6549a6..913f0d1cbafd19cd82830190155efc195f7c0b6f 100644 (file)
 #import "VLCLibrary.h"
 #import "VLCLibVLCBridging.h"
 
+#if TARGET_OS_IPHONE
+# include "vlc-plugins.h"
+#endif
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
 static VLCLibrary * sharedLibrary = nil;
 
-void __catch_exception( void * e, const char * function, const char * file, int line_number )
-{
-    libvlc_exception_t * ex = (libvlc_exception_t *)e;
-    if( libvlc_exception_raised( ex ) )
-    {
-        NSException* libvlcException = [NSException
-            exceptionWithName:@"LibVLCException"
-            reason:[NSString stringWithFormat:@"libvlc has thrown us an error: %s (%s:%d %s)", 
-                libvlc_errmsg(), file, line_number, function]
-            userInfo:nil];
-        libvlc_exception_clear( ex );
-        @throw libvlcException;
-    }
-}
-
 @implementation VLCLibrary
 + (VLCLibrary *)sharedLibrary
 {
-    if (!sharedLibrary) 
+    if (!sharedLibrary)
     {
         /* Initialize a shared instance */
         sharedLibrary = [[self alloc] init];
@@ -60,26 +49,26 @@ void __catch_exception( void * e, const char * function, const char * file, int
     return sharedLibrary;
 }
 
-- (id)init 
+- (id)init
 {
-    if (self = [super init]) 
+    if (self = [super init])
     {
-        libvlc_exception_t ex;
-        libvlc_exception_init( &ex );
-        
         NSArray *vlcParams = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"VLCParams"];
         if (!vlcParams) {
             NSMutableArray *defaultParams = [NSMutableArray array];
-            [defaultParams addObject:@"-I macosx_dialog_provider"];                 // No actual interface, just dialogs and nagging
+            [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=-1"];                               // Let's not wreck the logs
+#if TARGET_OS_IPHONE
+//            [defaultParams addObject:@"--ffmpeg-fast"];                             // Let's disable this as it is error-prone
+            [defaultParams addObject:@"--ffmpeg-skiploopfilter=all"];
+#else
             [defaultParams addObject:@"--no-sout-keep"];
-            [defaultParams addObject:@"--ignore-config"];                           // Don't read and write VLC config files
-            [defaultParams addObject:@"--vout=macosx"];
+            [defaultParams addObject:@"--vout=macosx"];                             // Select Mac OS X video output
             [defaultParams addObject:@"--text-renderer=quartztext"];                // our CoreText-based renderer
-            [defaultParams addObject:@"--verbose=-1"];                               // Don't polute the log
-            [defaultParams addObject:@"--no-color"];
-            [defaultParams addObject:@"--no-media-library"];
-            [defaultParams addObject:@"--play-and-pause"];
+            [defaultParams addObject:@"--extraintf=macosx_dialog_provider"];        // Some extra dialog (login, progress) may come up from here
+#endif
             vlcParams = defaultParams;
         }
 
@@ -91,40 +80,35 @@ void __catch_exception( void * e, const char * function, const char * file, int
             lib_vlc_params[paramNum] = [vlcParam cStringUsingEncoding:NSASCIIStringEncoding];
             paramNum++;
         }
-        instance = (void *)libvlc_new( sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]), lib_vlc_params, &ex );
-        catch_exception( &ex );
+        unsigned argc = sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]);
+        instance = libvlc_new(argc, lib_vlc_params);
         NSAssert(instance, @"libvlc failed to initialize");
-
-        // Assignment unneeded, as the audio unit will do it for us
-        /*audio = */ [[VLCAudio alloc] initWithLibrary:self];
     }
     return self;
 }
 
-- (NSString *)version 
+- (NSString *)version
 {
     return [NSString stringWithUTF8String:libvlc_get_version()];
 }
 
-- (NSString *)changeset 
+- (NSString *)changeset
 {
     return [NSString stringWithUTF8String:libvlc_get_changeset()];
 }
 
-- (void)dealloc 
+- (void)dealloc
 {
-    if( instance ) 
+    if( instance )
         libvlc_release( instance );
-    
-    if( self == sharedLibrary ) 
+
+    if( self == sharedLibrary )
         sharedLibrary = nil;
-    
+
     instance = nil;
-    [audio release];
     [super dealloc];
 }
 
-@synthesize audio;
 @end
 
 @implementation VLCLibrary (VLCLibVLCBridging)
@@ -139,10 +123,3 @@ void __catch_exception( void * e, const char * function, const char * file, int
 }
 @end
 
-@implementation VLCLibrary (VLCAudioBridging)
-- (void)setAudio:(VLCAudio *)value
-{
-    if (!audio)
-        audio = value;
-}
-@end