X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_factory.c;h=d81c0c231d864651cc3a550332dbe7325b5a4a83;hb=f0f9e433051b21e14471bb48bc5d140e6c2b14c5;hp=1272a8e794400fef5fffab95d8230a04d1ea704e;hpb=b79a3f74f655a4ab8bb087454624d11eca6d9b34;p=melted diff --git a/src/framework/mlt_factory.c b/src/framework/mlt_factory.c index 1272a8e..d81c0c2 100644 --- a/src/framework/mlt_factory.c +++ b/src/framework/mlt_factory.c @@ -3,22 +3,21 @@ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited * Author: Charles Yates * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "config.h" #include "mlt.h" #include "mlt_repository.h" @@ -26,6 +25,9 @@ #include #include +#define PREFIX_LIB LIBDIR "/mlt" +#define PREFIX_DATA PREFIX "/share/mlt" + /** Singleton repositories */ @@ -68,7 +70,7 @@ int mlt_factory_init( const char *prefix ) // If no directory is specified, default to install directory if ( prefix == NULL ) - prefix = PREFIX_DATA; + prefix = PREFIX_LIB; // Store the prefix for later retrieval mlt_prefix = strdup( prefix ); @@ -90,10 +92,6 @@ int mlt_factory_init( const char *prefix ) // Create the global properties global_properties = mlt_properties_new( ); - mlt_properties_set_or_default( global_properties, "MLT_NORMALISATION", getenv( "MLT_NORMALISATION" ), "PAL" ); - mlt_properties_set_or_default( global_properties, "MLT_PRODUCER", getenv( "MLT_PRODUCER" ), "fezzik" ); - mlt_properties_set_or_default( global_properties, "MLT_CONSUMER", getenv( "MLT_CONSUMER" ), "sdl" ); - mlt_properties_set( global_properties, "MLT_TEST_CARD", getenv( "MLT_TEST_CARD" ) ); // Create the object list. object_list = mlt_properties_new( ); @@ -108,6 +106,18 @@ int mlt_factory_init( const char *prefix ) atexit( mlt_factory_close ); } + // Allow property refresh on a subsequent initialisation + if ( global_properties != NULL ) + { + mlt_properties_set_or_default( global_properties, "MLT_NORMALISATION", getenv( "MLT_NORMALISATION" ), "PAL" ); + mlt_properties_set_or_default( global_properties, "MLT_PRODUCER", getenv( "MLT_PRODUCER" ), "fezzik" ); + mlt_properties_set_or_default( global_properties, "MLT_CONSUMER", getenv( "MLT_CONSUMER" ), "sdl" ); + mlt_properties_set( global_properties, "MLT_TEST_CARD", getenv( "MLT_TEST_CARD" ) ); + mlt_properties_set_or_default( global_properties, "MLT_PROFILE", getenv( "MLT_PROFILE" ), "dv_pal" ); + mlt_properties_set_or_default( global_properties, "MLT_DATA", getenv( "MLT_DATA" ), PREFIX_DATA ); + } + + return 0; } @@ -132,13 +142,37 @@ const char *mlt_factory_prefix( ) char *mlt_environment( const char *name ) { - return mlt_properties_get( global_properties, name ); + if ( global_properties ) + return mlt_properties_get( global_properties, name ); + else + return NULL; +} + +/** Set a value in the environment. +*/ + +int mlt_environment_set( const char *name, const char *value ) +{ + if ( global_properties ) + return mlt_properties_set( global_properties, name, value ); + else + return -1; +} + +static void set_common_properties( mlt_properties properties, mlt_profile profile, const char *type, const char *service ) +{ + mlt_properties_set_int( properties, "_unique_id", ++ unique_id ); + mlt_properties_set( properties, "mlt_type", type ); + if ( mlt_properties_get_int( properties, "_mlt_service_hidden" ) == 0 ) + mlt_properties_set( properties, "mlt_service", service ); + if ( profile != NULL ) + mlt_properties_set_data( properties, "_profile", profile, 0, NULL, NULL ); } /** Fetch a producer from the repository. */ -mlt_producer mlt_factory_producer( const char *service, void *input ) +mlt_producer mlt_factory_producer( mlt_profile profile, const char *service, void *input ) { mlt_producer obj = NULL; @@ -152,15 +186,12 @@ mlt_producer mlt_factory_producer( const char *service, void *input ) // Try to instantiate via the specified service if ( obj == NULL ) { - obj = mlt_repository_fetch( producers, service, input ); + obj = mlt_repository_fetch( producers, profile, producer_type, service, input ); mlt_events_fire( event_object, "producer-create-done", service, input, obj, NULL ); if ( obj != NULL ) { mlt_properties properties = MLT_PRODUCER_PROPERTIES( obj ); - mlt_properties_set_int( properties, "_unique_id", ++ unique_id ); - mlt_properties_set( properties, "mlt_type", "producer" ); - if ( mlt_properties_get_int( properties, "_mlt_service_hidden" ) == 0 ) - mlt_properties_set( properties, "mlt_service", service ); + set_common_properties( properties, profile, "producer", service ); } } return obj; @@ -169,7 +200,7 @@ mlt_producer mlt_factory_producer( const char *service, void *input ) /** Fetch a filter from the repository. */ -mlt_filter mlt_factory_filter( const char *service, void *input ) +mlt_filter mlt_factory_filter( mlt_profile profile, const char *service, void *input ) { mlt_filter obj = NULL; @@ -178,16 +209,14 @@ mlt_filter mlt_factory_filter( const char *service, void *input ) if ( obj == NULL ) { - obj = mlt_repository_fetch( filters, service, input ); + obj = mlt_repository_fetch( filters, profile, filter_type, service, input ); mlt_events_fire( event_object, "filter-create-done", service, input, obj, NULL ); } if ( obj != NULL ) { mlt_properties properties = MLT_FILTER_PROPERTIES( obj ); - mlt_properties_set_int( properties, "_unique_id", ++ unique_id ); - mlt_properties_set( properties, "mlt_type", "filter" ); - mlt_properties_set( properties, "mlt_service", service ); + set_common_properties( properties, profile, "filter", service ); } return obj; } @@ -195,7 +224,7 @@ mlt_filter mlt_factory_filter( const char *service, void *input ) /** Fetch a transition from the repository. */ -mlt_transition mlt_factory_transition( const char *service, void *input ) +mlt_transition mlt_factory_transition( mlt_profile profile, const char *service, void *input ) { mlt_transition obj = NULL; @@ -204,16 +233,14 @@ mlt_transition mlt_factory_transition( const char *service, void *input ) if ( obj == NULL ) { - obj = mlt_repository_fetch( transitions, service, input ); + obj = mlt_repository_fetch( transitions, profile, filter_type, service, input ); mlt_events_fire( event_object, "transition-create-done", service, input, obj, NULL ); } if ( obj != NULL ) { mlt_properties properties = MLT_TRANSITION_PROPERTIES( obj ); - mlt_properties_set_int( properties, "_unique_id", ++ unique_id ); - mlt_properties_set( properties, "mlt_type", "transition" ); - mlt_properties_set( properties, "mlt_service", service ); + set_common_properties( properties, profile, "transition", service ); } return obj; } @@ -221,7 +248,7 @@ mlt_transition mlt_factory_transition( const char *service, void *input ) /** Fetch a consumer from the repository */ -mlt_consumer mlt_factory_consumer( const char *service, void *input ) +mlt_consumer mlt_factory_consumer( mlt_profile profile, const char *service, void *input ) { mlt_consumer obj = NULL; @@ -233,19 +260,14 @@ mlt_consumer mlt_factory_consumer( const char *service, void *input ) if ( obj == NULL ) { - obj = mlt_repository_fetch( consumers, service, input ); + obj = mlt_repository_fetch( consumers, profile, consumer_type, service, input ); mlt_events_fire( event_object, "consumer-create-done", service, input, obj, NULL ); } if ( obj != NULL ) { - mlt_filter filter = mlt_factory_filter( "data_show", NULL ); mlt_properties properties = MLT_CONSUMER_PROPERTIES( obj ); - mlt_properties_set_int( properties, "_unique_id", ++ unique_id ); - mlt_properties_set( properties, "mlt_type", "consumer" ); - mlt_properties_set( properties, "mlt_service", service ); - mlt_service_attach( MLT_CONSUMER_SERVICE( obj ), filter ); - mlt_filter_close( filter ); + set_common_properties( properties, profile, "consumer", service ); } return obj; } @@ -279,4 +301,3 @@ void mlt_factory_close( ) mlt_pool_close( ); } } -