From 44b1a9af480b617d3ad42b032c47bce2e08cf8a1 Mon Sep 17 00:00:00 2001 From: blendamedt Date: Tue, 4 Mar 2008 20:47:58 +0000 Subject: [PATCH] src/modules/frei0r/factory.c: load metadata on request (thx for patch from Dan Dennedy) added "tags" metadata with type "Video" for frei0r plugins git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1097 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/modules/frei0r/factory.c | 82 +++++++++++++++++------------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/src/modules/frei0r/factory.c b/src/modules/frei0r/factory.c index e981de77..e3e2fae1 100644 --- a/src/modules/frei0r/factory.c +++ b/src/modules/frei0r/factory.c @@ -34,62 +34,54 @@ extern void filter_close( mlt_filter this ); extern void transition_close( mlt_transition this ); extern mlt_frame transition_process( mlt_transition transition, mlt_frame a_frame, mlt_frame b_frame ); -static mlt_properties subtag ( mlt_properties prop , char *name , mlt_serialiser serialise_yaml ){ - mlt_properties ret = mlt_properties_get_data( prop , name , NULL ); - - if (!ret){ - ret = mlt_properties_new ( ); - mlt_properties_set_data ( prop , name , ret , 0 , ( mlt_destructor )mlt_properties_close , serialise_yaml ); +static mlt_properties fill_param_info ( mlt_service_type type, const char *service_name, char *name ) +{ + void* handle=dlopen(name,RTLD_LAZY); + if (!handle) return NULL; + void (*plginfo)(f0r_plugin_info_t*)=dlsym(handle,"f0r_get_plugin_info"); + void (*param_info)(f0r_param_info_t*,int param_index)=dlsym(handle,"f0r_get_param_info"); + if (!plginfo || !param_info) { + dlclose(handle); + return NULL; } - return ret; -} - -void fill_param_info ( mlt_repository repository , void* handle, f0r_plugin_info_t* info , mlt_service_type type , char* name ) { - + mlt_properties metadata = mlt_properties_new(); + f0r_plugin_info_t info; + char string[48]; int j=0; - void (*param_info)(f0r_param_info_t*,int param_index)=dlsym(handle,"f0r_get_param_info"); - mlt_properties metadata_properties=NULL; + + plginfo(&info); + snprintf ( string, sizeof(string) , "%d.%d" , info.major_version , info.minor_version ); + mlt_properties_set ( metadata, "title" , info.name ); + mlt_properties_set ( metadata, "version", string ); + mlt_properties_set ( metadata, "identifier" , service_name ); + mlt_properties_set ( metadata, "description" , info.explanation ); + mlt_properties_set ( metadata, "creator" , info.author ); switch (type){ case filter_type: - metadata_properties=mlt_repository_filters(repository); + mlt_properties_set ( metadata, "type" , "filter" ); break; case transition_type: - metadata_properties=mlt_repository_transitions(repository); + mlt_properties_set ( metadata, "type" , "transition" ); break; default: - metadata_properties=NULL; - } - - if (!metadata_properties){ - return; + break; } - mlt_properties this_item_properties = mlt_properties_get_data( metadata_properties , name , NULL ); - mlt_properties metadata = subtag( this_item_properties , "metadata" , ( mlt_serialiser )mlt_properties_serialise_yaml ); - - char descstr[2048]; - snprintf ( descstr, 2048 , "%s (Version: %d.%d)" , info->explanation , info->major_version , info->minor_version ); - mlt_properties_set ( metadata, "title" , info->name ); - mlt_properties_set ( metadata, "identifier" , name ); - mlt_properties_set ( metadata, "description" , descstr ); - mlt_properties_set ( metadata, "creator" , info->author ); - - mlt_properties parameter = subtag ( metadata , "parameters" , NULL ); - mlt_properties tags = subtag ( metadata , "tags" , NULL ); + mlt_properties parameter = mlt_properties_new ( ); + mlt_properties_set_data ( metadata , "parameters" , parameter , 0 , ( mlt_destructor )mlt_properties_close, NULL ); + mlt_properties tags = mlt_properties_new ( ); + mlt_properties_set_data ( metadata , "tags" , tags , 0 , ( mlt_destructor )mlt_properties_close, NULL ); mlt_properties_set ( tags , "0" , "Video" ); - char numstr[512]; - - for (j=0;jnum_params;j++){ - snprintf ( numstr , 512 , "%d" , j ); - mlt_properties pnum = subtag ( parameter , numstr , NULL ); - + for (j=0;j