*/
static char *mlt_prefix = NULL;
+static mlt_properties global_properties = NULL;
static mlt_properties object_list = NULL;
static mlt_repository producers = NULL;
static mlt_repository filters = NULL;
// Only initialise once
if ( mlt_prefix == NULL )
{
+ // Allow user over rides
+ if ( prefix == NULL )
+ prefix = getenv( "MLT_REPOSITORY" );
+
// If no directory is specified, default to install directory
if ( prefix == NULL )
prefix = PREFIX_DATA;
// Initialise the pool
mlt_pool_init( );
+ // 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( );
return mlt_prefix;
}
+/** Get a value from the environment.
+*/
+
+char *mlt_environment( char *name )
+{
+ return mlt_properties_get( global_properties, name );
+}
+
/** Fetch a producer from the repository.
*/
mlt_producer mlt_factory_producer( char *service, void *input )
{
- mlt_producer obj = mlt_repository_fetch( producers, service, input );
+ mlt_producer obj = NULL;
+
+ // Pick up the default normalising producer if necessary
+ if ( service == NULL )
+ service = mlt_environment( "MLT_PRODUCER" );
+
+ // Try to instantiate via the specified service
+ obj = mlt_repository_fetch( producers, service, input );
+
if ( obj != NULL )
{
mlt_properties properties = mlt_producer_properties( obj );
mlt_consumer mlt_factory_consumer( char *service, void *input )
{
- mlt_consumer obj = mlt_repository_fetch( consumers, service, input );
+ mlt_consumer obj = NULL;
+
+ if ( service == NULL )
+ service = mlt_environment( "MLT_CONSUMER" );
+
+ obj = mlt_repository_fetch( consumers, service, input );
+
if ( obj != NULL )
{
mlt_properties properties = mlt_consumer_properties( obj );
return obj;
}
+/** Register an object for clean up.
+*/
+
+void mlt_factory_register_for_clean_up( void *ptr, mlt_destructor destructor )
+{
+ char unique[ 256 ];
+ sprintf( unique, "%08d", mlt_properties_count( global_properties ) );
+ mlt_properties_set_data( global_properties, unique, ptr, 0, destructor, NULL );
+}
+
/** Close the factory.
*/
mlt_repository_close( filters );
mlt_repository_close( transitions );
mlt_repository_close( consumers );
+ mlt_properties_close( global_properties );
mlt_properties_close( object_list );
free( mlt_prefix );
mlt_prefix = NULL;