sdl hacks
[melted] / src / framework / mlt_factory.c
index 85da148..0b4df21 100644 (file)
 */
 
 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;
 static mlt_repository transitions = NULL;
 static mlt_repository consumers = NULL;
+static int unique_id = 0;
 
 /** Construct the factories.
 */
@@ -51,6 +53,13 @@ int mlt_factory_init( char *prefix )
                // Store the prefix for later retrieval
                mlt_prefix = strdup( prefix );
 
+               // Initialise the pool
+               mlt_pool_init( );
+
+               // Create the global properties
+               global_properties = mlt_properties_new( );
+               mlt_properties_set( global_properties, "MLT_NORMALISATION", getenv( "MLT_NORMALISATION" ) );
+
                // Create the object list.
                object_list = mlt_properties_new( );
 
@@ -72,6 +81,14 @@ const char *mlt_factory_prefix( )
        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.
 */
 
@@ -81,6 +98,7 @@ mlt_producer mlt_factory_producer( char *service, void *input )
        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 );
@@ -97,6 +115,7 @@ mlt_filter mlt_factory_filter( char *service, void *input )
        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 );
        }
@@ -112,6 +131,7 @@ mlt_transition mlt_factory_transition( char *service, void *input )
        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 );
        }
@@ -127,6 +147,7 @@ mlt_consumer mlt_factory_consumer( char *service, void *input )
        if ( obj != 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 );
        }
@@ -145,8 +166,10 @@ void mlt_factory_close( )
                mlt_repository_close( transitions );
                mlt_repository_close( consumers );
                mlt_properties_close( object_list );
+               mlt_properties_close( global_properties );
                free( mlt_prefix );
                mlt_prefix = NULL;
+               mlt_pool_close( );
        }
 }