]> git.sesse.net Git - vlc/blobdiff - projects/macosx/framework/Sources/VLCLibrary.m
macosx/framework: Get rid of VLCMediaListAspect, and remove a bunch of exception.
[vlc] / projects / macosx / framework / Sources / VLCLibrary.m
index d7d3d38cbd01c0fa368857bdc33415e612d62614..ac699e09fac0adbae09a4fd3ea203b3d9577cf2f 100644 (file)
@@ -41,7 +41,7 @@ void __catch_exception( void * e, const char * function, const char * file, int
     {
         NSException* libvlcException = [NSException
             exceptionWithName:@"LibVLCException"
-            reason:[NSString stringWithFormat:@"libvlc has thrown us an error: %s (%s:%d %s)", 
+            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 );
@@ -49,33 +49,10 @@ void __catch_exception( void * e, const char * function, const char * file, int
     }
 }
 
-void * CreateSharedLibraryOnStartup( void ) 
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    
-    /* This library is not loaded for no reason, so let's create
-     * a VLCLibrary instance. */
-    [VLCLibrary sharedLibrary];
-    
-    [pool release];
-    
-    return NULL;
-}
-
-void * DestroySharedLibraryAtExit( void )
-{
-    /* Release the global object that may have been alloc-ed
-     * in -[VLCLibrary init] */
-    [sharedLibrary release];
-    sharedLibrary = nil;
-
-    return NULL;
-}
-
 @implementation VLCLibrary
 + (VLCLibrary *)sharedLibrary
 {
-    if (!sharedLibrary) 
+    if (!sharedLibrary)
     {
         /* Initialize a shared instance */
         sharedLibrary = [[self alloc] init];
@@ -83,38 +60,66 @@ void * DestroySharedLibraryAtExit( void )
     return sharedLibrary;
 }
 
-- (id)init 
+- (id)init
 {
-    if (self = [super init]) 
+    if (self = [super init])
     {
         libvlc_exception_t ex;
         libvlc_exception_init( &ex );
-        
-        const char * lib_vlc_params[] = { 
-            "-I", "dummy", "--vout=minimal_macosx", 
-            "--no-video-title-show", "--no-sout-keep", "--ignore-config",
-                       "--opengl-provider=minimal_macosx",
-                       "-verbose=-1"
-            //, "--control=motion", "--motion-use-rotate", "--video-filter=rotate"
-        };
-        
-        instance = (void *)libvlc_new( sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]), lib_vlc_params, &ex );
-        catch_exception( &ex );
-        
+
+        NSArray *vlcParams = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"VLCParams"];
+        if (!vlcParams) {
+            NSMutableArray *defaultParams = [NSMutableArray array];
+            [defaultParams addObject:@"--no-video-title-show"];                     // Don't show the title on overlay when starting to play
+            [defaultParams addObject:@"--no-sout-keep"];
+            [defaultParams addObject:@"--ignore-config"];                           // Don't read and write VLC config files
+            [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 stdio log
+            [defaultParams addObject:@"--syslog"];                                  // log to syslog
+            [defaultParams addObject:@"--log-verbose=4"];                           // log everything
+            [defaultParams addObject:@"--no-color"];                                // Don't use color in output (Xcode doesn't show it)
+            [defaultParams addObject:@"--no-media-library"];                        // We don't need the media library
+            [defaultParams addObject:@"--play-and-pause"];                          // We want every movie to pause instead of stopping at eof
+            [defaultParams addObject:@"--extraintf=macosx_dialog_provider"];        // Some extra dialog (login, progress) may come up from here
+            vlcParams = defaultParams;
+        }
+
+        NSUInteger paramNum = 0;
+        NSUInteger count = [vlcParams count];
+        const char *lib_vlc_params[count];
+        while (paramNum < count) {
+            NSString *vlcParam = [vlcParams objectAtIndex:paramNum];
+            lib_vlc_params[paramNum] = [vlcParam cStringUsingEncoding:NSASCIIStringEncoding];
+            paramNum++;
+        }
+        instance = (void *)libvlc_new( sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]), 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;
 }
 
-- (void)dealloc 
+- (NSString *)version
 {
-    if( instance ) 
+    return [NSString stringWithUTF8String:libvlc_get_version()];
+}
+
+- (NSString *)changeset
+{
+    return [NSString stringWithUTF8String:libvlc_get_changeset()];
+}
+
+- (void)dealloc
+{
+    if( instance )
         libvlc_release( instance );
-    
-    if( self == sharedLibrary ) 
+
+    if( self == sharedLibrary )
         sharedLibrary = nil;
-    
+
     instance = nil;
     [audio release];
     [super dealloc];