X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_repository.c;h=df83e9efa7f59580dd2ad3dc358fb99ef10d8720;hb=51f99c29759e71318c4c575f8a68cf1b5d1c5137;hp=bdadb282beca062c1d8ab2ce8d42809b94b5110d;hpb=c12656788f6548138759e3fd30cd7ac6d3318b96;p=melted diff --git a/src/framework/mlt_repository.c b/src/framework/mlt_repository.c index bdadb28..df83e9e 100644 --- a/src/framework/mlt_repository.c +++ b/src/framework/mlt_repository.c @@ -1,8 +1,10 @@ -/* - * repository.c -- provides a map between service and shared objects - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * Contributor: Dan Dennedy +/** + * \file mlt_repository.c + * \brief provides a map between service and shared objects + * + * Copyright (C) 2003-2008 Ushodaya Enterprises Limited + * \author Charles Yates + * Dan Dennedy * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,12 +24,18 @@ #include "mlt_repository.h" #include "mlt_properties.h" #include "mlt_tokeniser.h" +#include "mlt_log.h" #include #include #include #include +/** \brief Repository class + * + * \extends mlt_properties_s + */ + struct mlt_repository_s { struct mlt_properties_s parent; // a list of object files @@ -45,7 +53,7 @@ mlt_repository mlt_repository_init( const char *directory ) // Safety check if ( directory == NULL || strcmp( directory, "" ) == 0 ) return NULL; - + // Construct the repository mlt_repository this = calloc( sizeof( struct mlt_repository_s ), 1 ); mlt_properties_init( &this->parent, this ); @@ -58,7 +66,7 @@ mlt_repository mlt_repository_init( const char *directory ) mlt_properties dir = mlt_properties_new(); int count = mlt_properties_dir_list( dir, directory, NULL, 0 ); int i; - + // Iterate over files for ( i = 0; i < count; i++ ) { @@ -71,17 +79,17 @@ mlt_repository mlt_repository_init( const char *directory ) flags |= RTLD_GLOBAL; // Open the shared object - void *object = dlopen( object_name, flags ); + void *object = dlopen( object_name, flags ); if ( object != NULL ) { // Get the registration function mlt_repository_callback symbol_ptr = dlsym( object, "mlt_register" ); - + // Call the registration function if ( symbol_ptr != NULL ) { symbol_ptr( this ); - + // Register the object file for closure mlt_properties_set_data( &this->parent, object_name, object, 0, ( mlt_destructor )dlclose, NULL ); } @@ -92,10 +100,12 @@ mlt_repository mlt_repository_init( const char *directory ) } else if ( strstr( object_name, "libmlt" ) ) { - fprintf( stderr, "%s, %s: failed to dlopen %s\n", __FILE__, __FUNCTION__, object_name ); + mlt_log( NULL, MLT_LOG_WARNING, "%s: failed to dlopen %s\n (%s)\n", __FUNCTION__, object_name, dlerror() ); } } - + + mlt_properties_close( dir ); + return this; } @@ -166,7 +176,7 @@ void *mlt_repository_create( mlt_repository this, mlt_profile profile, mlt_servi if ( properties != NULL ) { mlt_register_callback symbol_ptr = mlt_properties_get_data( properties, "symbol", NULL ); - + // Construct the service return ( symbol_ptr != NULL ) ? symbol_ptr( profile, type, service, input ) : NULL; } @@ -236,7 +246,7 @@ mlt_properties mlt_repository_metadata( mlt_repository self, mlt_service_type ty { mlt_properties metadata = NULL; mlt_properties properties = get_service_properties( self, type, service ); - + // If this is a valid service if ( properties ) { @@ -252,10 +262,10 @@ mlt_properties mlt_repository_metadata( mlt_repository self, mlt_service_type ty { // Fetch the callback data arg void *data = mlt_properties_get_data( properties, "metadata_cb_data", NULL ); - + // Fetch the metadata through the callback metadata = callback( type, service, data ); - + // Cache the metadata if ( metadata ) // Include dellocation and serialisation @@ -266,7 +276,7 @@ mlt_properties mlt_repository_metadata( mlt_repository self, mlt_service_type ty return metadata; } -static const char *getenv_locale() +static char *getenv_locale() { char *s = getenv( "LANGUAGE" ); if ( s && s[0] ) @@ -284,14 +294,14 @@ static const char *getenv_locale() } /** Return a list of user-preferred language codes taken from environment variables. -*/ +*/ mlt_properties mlt_repository_languages( mlt_repository self ) { mlt_properties languages = mlt_properties_get_data( &self->parent, "languages", NULL ); if ( languages ) return languages; - + languages = mlt_properties_new(); char *locale = getenv_locale(); if ( locale )