]> git.sesse.net Git - vlc/commitdiff
macosx/framework: Export VLCExtensionsManager and VLCExtension.
authorPierre d'Herbemont <pdherbemont@free.fr>
Wed, 27 Jan 2010 01:03:21 +0000 (02:03 +0100)
committerPierre d'Herbemont <pdherbemont@free.fr>
Wed, 27 Jan 2010 01:09:07 +0000 (02:09 +0100)
This enables usage of vlc extension in Lunettes.

projects/macosx/framework/Headers/Public/VLCExtension.h [new file with mode: 0644]
projects/macosx/framework/Headers/Public/VLCExtensionsManager.h [new file with mode: 0644]
projects/macosx/framework/Sources/VLCExtension.m [new file with mode: 0644]
projects/macosx/framework/Sources/VLCExtensionsManager.m [new file with mode: 0644]
projects/macosx/framework/VLCKit.xcodeproj/project.pbxproj

diff --git a/projects/macosx/framework/Headers/Public/VLCExtension.h b/projects/macosx/framework/Headers/Public/VLCExtension.h
new file mode 100644 (file)
index 0000000..2a09219
--- /dev/null
@@ -0,0 +1,21 @@
+//
+//  VLCExtension.h
+//  VLCKit
+//
+//  Created by Pierre d'Herbemont on 1/26/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface VLCExtension : NSObject {
+    struct extension_t *_instance;
+}
+
+- (id)initWithInstance:(struct extension_t *)instance; // FIXME: Should be internal
+- (struct extension_t *)instance; // FIXME: Should be internal
+
+- (NSString *)name;
+- (NSString *)title;
+@end
diff --git a/projects/macosx/framework/Headers/Public/VLCExtensionsManager.h b/projects/macosx/framework/Headers/Public/VLCExtensionsManager.h
new file mode 100644 (file)
index 0000000..ca89a36
--- /dev/null
@@ -0,0 +1,19 @@
+//
+//  VLCExtensionsManager.h
+//  VLCKit
+//
+//  Created by Pierre d'Herbemont on 1/26/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@class VLCExtension;
+
+@interface VLCExtensionsManager : NSObject {
+    void *instance;
+}
++ (VLCExtensionsManager *)sharedManager;
+- (NSArray *)extensions;
+- (void)runExtension:(VLCExtension *)extension;
+@end
diff --git a/projects/macosx/framework/Sources/VLCExtension.m b/projects/macosx/framework/Sources/VLCExtension.m
new file mode 100644 (file)
index 0000000..52e19c1
--- /dev/null
@@ -0,0 +1,43 @@
+//
+//  VLCExtension.m
+//  VLCKit
+//
+//  Created by Pierre d'Herbemont on 1/26/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "VLCExtension.h"
+#import <vlc_extensions.h>
+
+@implementation VLCExtension
+- (NSString *)description
+{
+    return [NSString stringWithFormat:@"VLC Extension %@", [self name]];
+}
+
+- (id)initWithInstance:(struct extension_t *)instance
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    _instance = instance;
+    return self;
+}
+
+- (struct extension_t *)instance
+{
+    return _instance;
+}
+
+- (NSString *)name
+{
+    return [NSString stringWithUTF8String:_instance->psz_name];
+}
+
+- (NSString *)title
+{
+    return [NSString stringWithUTF8String:_instance->psz_title];
+}
+
+
+@end
diff --git a/projects/macosx/framework/Sources/VLCExtensionsManager.m b/projects/macosx/framework/Sources/VLCExtensionsManager.m
new file mode 100644 (file)
index 0000000..2cae205
--- /dev/null
@@ -0,0 +1,102 @@
+//
+//  VLCExtensionsManager.m
+//  VLCKit
+//
+//  Created by Pierre d'Herbemont on 1/26/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "VLCExtensionsManager.h"
+#import "VLCExtension.h"
+#import "VLCLibrary.h"
+#import "VLCLibVLCBridging.h"
+#import <vlc_extensions.h>
+
+#define _instance ((extensions_manager_t *)instance)
+
+static int DialogCallback( vlc_object_t *p_this, const char *psz_variable,
+                          vlc_value_t old_val, vlc_value_t new_val,
+                          void *param )
+{
+
+    VLCExtensionsManager *self = param;
+    assert(self);
+    assert(new_val.p_address);
+
+    extension_dialog_t *dialog = new_val.p_address;
+
+    NSLog(@"dialog callback");
+    return VLC_SUCCESS;
+}
+
+@implementation VLCExtensionsManager
+static VLCExtensionsManager *sharedManager = nil;
+
++ (VLCExtensionsManager *)sharedManager
+{
+    if (!sharedManager)
+    {
+        /* Initialize a shared instance */
+        sharedManager = [[self alloc] init];
+    }
+    return sharedManager;
+}
+
+- (void)dealloc
+{
+    vlc_object_t *libvlc = libvlc_get_vlc_instance([VLCLibrary sharedInstance]);
+    var_DelCallback(libvlc, "dialog-extension", DialogCallback, NULL);
+    vlc_object_release(libvlc);
+
+    module_unneed(_instance, _instance->p_module);
+    vlc_object_release(_instance);
+
+    [super dealloc];
+}
+
+- (NSArray *)extensions
+{
+    if (!instance)
+    {
+        vlc_object_t *libvlc = libvlc_get_vlc_instance([VLCLibrary sharedInstance]);
+        instance = vlc_object_create(libvlc, sizeof(extensions_manager_t));
+        if (!_instance)
+        {
+            vlc_object_release(libvlc);
+            return nil;
+        }
+        vlc_object_attach(_instance, libvlc);
+
+        _instance->p_module = module_need(_instance, "extension", NULL, false);
+        NSAssert(_instance->p_module, @"Unable to load extensions module");
+
+        var_Create(libvlc, "dialog-extension", VLC_VAR_ADDRESS);
+        var_AddCallback(libvlc, "dialog-extension", DialogCallback, self);
+        vlc_object_release(libvlc);
+    }
+
+    NSMutableArray *array = [NSMutableArray array];
+    extension_t *ext;
+    FOREACH_ARRAY(ext, _instance->extensions)
+        VLCExtension *extension = [[VLCExtension alloc] initWithInstance:ext];
+        [array addObject:extension];
+        [extension release];
+    FOREACH_END()
+    return array;
+}
+
+- (void)runExtension:(VLCExtension *)extension
+{
+    extension_t *ext = [extension instance];
+    NSLog(@"extension_TriggerOnly = %d", extension_TriggerOnly(_instance, ext));
+    NSLog(@"extension_IsActivated = %d", extension_IsActivated(_instance, ext));
+
+    if(extension_TriggerOnly(_instance, ext))
+        extension_Trigger(_instance, ext);
+    else
+    {
+        if(!extension_IsActivated(_instance, ext))
+            extension_Activate(_instance, ext);
+    }
+}
+@end
index 4757a48171406f80c2e0edb7476f09970d370b65..d3811c2591ace80da9d46861d33456564cb34cb3 100644 (file)
                63014B7E1042E64A00534090 /* VLCMediaListPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 63014B7D1042E64A00534090 /* VLCMediaListPlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
                6303C43A0CF45CAE0000ECC8 /* VLCMediaListAspect.m in Sources */ = {isa = PBXBuildFile; fileRef = 6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */; };
                6303C43C0CF45CC30000ECC8 /* VLCMediaListAspect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               63098FDC110E7159005F46AE /* VLCExtensionsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 63098FDA110E7159005F46AE /* VLCExtensionsManager.m */; };
+               63099116110F0EC3005F46AE /* VLCExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63099114110F0EC3005F46AE /* VLCExtension.m */; };
+               6309994B110FC791005F46AE /* VLCExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 63099949110FC791005F46AE /* VLCExtension.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               6309994C110FC791005F46AE /* VLCExtensionsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6309994A110FC791005F46AE /* VLCExtensionsManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
                632A0E850D3835C400AFC99B /* VLCStreamSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 632A0E830D3835C400AFC99B /* VLCStreamSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
                632A0E860D3835C400AFC99B /* VLCStreamSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 632A0E840D3835C400AFC99B /* VLCStreamSession.m */; };
                632A0EC30D38392E00AFC99B /* VLCStreamOutput.h in Headers */ = {isa = PBXBuildFile; fileRef = 632A0EC10D38392E00AFC99B /* VLCStreamOutput.h */; settings = {ATTRIBUTES = (Public, ); }; };
                63030CC70CCA652C0088ECD1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = "<group>"; };
                6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListAspect.m; sourceTree = "<group>"; };
                6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMediaListAspect.h; path = Public/VLCMediaListAspect.h; sourceTree = "<group>"; };
+               63098FDA110E7159005F46AE /* VLCExtensionsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCExtensionsManager.m; sourceTree = "<group>"; };
+               63099114110F0EC3005F46AE /* VLCExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCExtension.m; sourceTree = "<group>"; };
+               63099949110FC791005F46AE /* VLCExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCExtension.h; path = Public/VLCExtension.h; sourceTree = "<group>"; };
+               6309994A110FC791005F46AE /* VLCExtensionsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCExtensionsManager.h; path = Public/VLCExtensionsManager.h; sourceTree = "<group>"; };
                632A0E830D3835C400AFC99B /* VLCStreamSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCStreamSession.h; path = Public/VLCStreamSession.h; sourceTree = "<group>"; };
                632A0E840D3835C400AFC99B /* VLCStreamSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCStreamSession.m; sourceTree = "<group>"; };
                632A0EC10D38392E00AFC99B /* VLCStreamOutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCStreamOutput.h; path = Public/VLCStreamOutput.h; sourceTree = "<group>"; };
                                EF78BD450CAEEFF600354E6E /* VLCVideoView.m */,
                                EF78BD440CAEEFF600354E6E /* VLCTime.m */,
                                EF73118F0CB5797B009473B4 /* VLCAudio.m */,
+                               63098FDA110E7159005F46AE /* VLCExtensionsManager.m */,
+                               63099114110F0EC3005F46AE /* VLCExtension.m */,
                                632A0F7B0D38F78500AFC99B /* Stream */,
                        );
                        path = Sources;
                                EF78BD1A0CAEEEE700354E6E /* VLCVideoView.h */,
                                EF78BD190CAEEEE700354E6E /* VLCTime.h */,
                                EF73118E0CB5797B009473B4 /* VLCAudio.h */,
+                               63099949110FC791005F46AE /* VLCExtension.h */,
+                               6309994A110FC791005F46AE /* VLCExtensionsManager.h */,
                                632A0F7C0D38F79200AFC99B /* Stream */,
                        );
                        name = Public;
                                632A0E850D3835C400AFC99B /* VLCStreamSession.h in Headers */,
                                632A0EC30D38392E00AFC99B /* VLCStreamOutput.h in Headers */,
                                63014B7E1042E64A00534090 /* VLCMediaListPlayer.h in Headers */,
+                               6309994B110FC791005F46AE /* VLCExtension.h in Headers */,
+                               6309994C110FC791005F46AE /* VLCExtensionsManager.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                632A0E860D3835C400AFC99B /* VLCStreamSession.m in Sources */,
                                632A0EC40D38392E00AFC99B /* VLCStreamOutput.m in Sources */,
                                63014A7A1042ACE100534090 /* VLCMediaListPlayer.m in Sources */,
+                               63098FDC110E7159005F46AE /* VLCExtensionsManager.m in Sources */,
+                               63099116110F0EC3005F46AE /* VLCExtension.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                LIBRARY_SEARCH_PATHS = "$(VLC_FRAMEWORK)/lib";
                                ONLY_ACTIVE_ARCH = YES;
                                OTHER_LDFLAGS = (
+                                       "-lvlccore",
                                        "-single_module",
                                        "-read_only_relocs",
                                        suppress,