From: Pierre d'Herbemont Date: Wed, 27 Jan 2010 01:03:21 +0000 (+0100) Subject: macosx/framework: Export VLCExtensionsManager and VLCExtension. X-Git-Tag: 1.1.0-ff~831 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ed8db5db22eec520b1a4110d98201124088c06ea;p=vlc macosx/framework: Export VLCExtensionsManager and VLCExtension. This enables usage of vlc extension in Lunettes. --- diff --git a/projects/macosx/framework/Headers/Public/VLCExtension.h b/projects/macosx/framework/Headers/Public/VLCExtension.h new file mode 100644 index 0000000000..2a0921914c --- /dev/null +++ b/projects/macosx/framework/Headers/Public/VLCExtension.h @@ -0,0 +1,21 @@ +// +// VLCExtension.h +// VLCKit +// +// Created by Pierre d'Herbemont on 1/26/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import + + +@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 index 0000000000..ca89a36fbb --- /dev/null +++ b/projects/macosx/framework/Headers/Public/VLCExtensionsManager.h @@ -0,0 +1,19 @@ +// +// VLCExtensionsManager.h +// VLCKit +// +// Created by Pierre d'Herbemont on 1/26/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import + +@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 index 0000000000..52e19c18f8 --- /dev/null +++ b/projects/macosx/framework/Sources/VLCExtension.m @@ -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 + +@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 index 0000000000..2cae205d61 --- /dev/null +++ b/projects/macosx/framework/Sources/VLCExtensionsManager.m @@ -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 + +#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 diff --git a/projects/macosx/framework/VLCKit.xcodeproj/project.pbxproj b/projects/macosx/framework/VLCKit.xcodeproj/project.pbxproj index 4757a48171..d3811c2591 100644 --- a/projects/macosx/framework/VLCKit.xcodeproj/project.pbxproj +++ b/projects/macosx/framework/VLCKit.xcodeproj/project.pbxproj @@ -64,6 +64,10 @@ 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, ); }; }; @@ -139,6 +143,10 @@ 63030CC70CCA652C0088ECD1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = ""; }; 6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListAspect.m; sourceTree = ""; }; 6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMediaListAspect.h; path = Public/VLCMediaListAspect.h; sourceTree = ""; }; + 63098FDA110E7159005F46AE /* VLCExtensionsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCExtensionsManager.m; sourceTree = ""; }; + 63099114110F0EC3005F46AE /* VLCExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCExtension.m; sourceTree = ""; }; + 63099949110FC791005F46AE /* VLCExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCExtension.h; path = Public/VLCExtension.h; sourceTree = ""; }; + 6309994A110FC791005F46AE /* VLCExtensionsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCExtensionsManager.h; path = Public/VLCExtensionsManager.h; sourceTree = ""; }; 632A0E830D3835C400AFC99B /* VLCStreamSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCStreamSession.h; path = Public/VLCStreamSession.h; sourceTree = ""; }; 632A0E840D3835C400AFC99B /* VLCStreamSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCStreamSession.m; sourceTree = ""; }; 632A0EC10D38392E00AFC99B /* VLCStreamOutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCStreamOutput.h; path = Public/VLCStreamOutput.h; sourceTree = ""; }; @@ -247,6 +255,8 @@ EF78BD450CAEEFF600354E6E /* VLCVideoView.m */, EF78BD440CAEEFF600354E6E /* VLCTime.m */, EF73118F0CB5797B009473B4 /* VLCAudio.m */, + 63098FDA110E7159005F46AE /* VLCExtensionsManager.m */, + 63099114110F0EC3005F46AE /* VLCExtension.m */, 632A0F7B0D38F78500AFC99B /* Stream */, ); path = Sources; @@ -330,6 +340,8 @@ EF78BD1A0CAEEEE700354E6E /* VLCVideoView.h */, EF78BD190CAEEEE700354E6E /* VLCTime.h */, EF73118E0CB5797B009473B4 /* VLCAudio.h */, + 63099949110FC791005F46AE /* VLCExtension.h */, + 6309994A110FC791005F46AE /* VLCExtensionsManager.h */, 632A0F7C0D38F79200AFC99B /* Stream */, ); name = Public; @@ -369,6 +381,8 @@ 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; }; @@ -567,6 +581,8 @@ 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; }; @@ -624,6 +640,7 @@ LIBRARY_SEARCH_PATHS = "$(VLC_FRAMEWORK)/lib"; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( + "-lvlccore", "-single_module", "-read_only_relocs", suppress,