/** Singleton repositories
*/
-static char *mlt_prefix = NULL;
+static char *mlt_directory = NULL;
static mlt_properties global_properties = NULL;
static mlt_repository repository = NULL;
static mlt_properties event_object = NULL;
/** Construct the factories.
*/
-mlt_repository mlt_factory_init( const char *prefix )
+mlt_repository mlt_factory_init( const char *directory )
{
// Only initialise once
- if ( mlt_prefix == NULL )
+ if ( mlt_directory == NULL )
{
// Allow user over rides
- if ( prefix == NULL || !strcmp( prefix, "" ) )
- prefix = getenv( "MLT_REPOSITORY" );
+ if ( directory == NULL || !strcmp( directory, "" ) )
+ directory = getenv( "MLT_REPOSITORY" );
// If no directory is specified, default to install directory
- if ( prefix == NULL )
- prefix = PREFIX_LIB;
+ if ( directory == NULL )
+ directory = PREFIX_LIB;
// Store the prefix for later retrieval
- mlt_prefix = strdup( prefix );
+ mlt_directory = strdup( directory );
// Initialise the pool
mlt_pool_init( );
global_properties = mlt_properties_new( );
// Create the repository of services
- repository = mlt_repository_init( prefix );
+ repository = mlt_repository_init( directory );
// Force a clean up when app closes
atexit( mlt_factory_close );
return event_object;
}
-/** Fetch the prefix used in this instance.
+/** Fetch the module directory used in this instance.
*/
-const char *mlt_factory_prefix( )
+const char *mlt_factory_directory( )
{
- return mlt_prefix;
+ return mlt_directory;
}
/** Get a value from the environment.
// Try to instantiate via the specified service
if ( obj == NULL )
{
- obj = mlt_repository_fetch( repository, profile, producer_type, service, input );
+ obj = mlt_repository_create( repository, profile, producer_type, service, input );
mlt_events_fire( event_object, "producer-create-done", service, input, obj, NULL );
if ( obj != NULL )
{
if ( obj == NULL )
{
- obj = mlt_repository_fetch( repository, profile, filter_type, service, input );
+ obj = mlt_repository_create( repository, profile, filter_type, service, input );
mlt_events_fire( event_object, "filter-create-done", service, input, obj, NULL );
}
if ( obj == NULL )
{
- obj = mlt_repository_fetch( repository, profile, transition_type, service, input );
+ obj = mlt_repository_create( repository, profile, transition_type, service, input );
mlt_events_fire( event_object, "transition-create-done", service, input, obj, NULL );
}
if ( obj == NULL )
{
- obj = mlt_repository_fetch( repository, profile, consumer_type, service, input );
+ obj = mlt_repository_create( repository, profile, consumer_type, service, input );
mlt_events_fire( event_object, "consumer-create-done", service, input, obj, NULL );
}
void mlt_factory_close( )
{
- if ( mlt_prefix != NULL )
+ if ( mlt_directory != NULL )
{
mlt_properties_close( event_object );
mlt_properties_close( global_properties );
mlt_repository_close( repository );
- free( mlt_prefix );
- mlt_prefix = NULL;
+ free( mlt_directory );
+ mlt_directory = NULL;
mlt_pool_close( );
}
}
mlt_properties transitions;
};
-mlt_repository mlt_repository_init( const char *prefix )
+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 );
this->filters = mlt_properties_new();
this->producers = mlt_properties_new();
this->transitions = mlt_properties_new();
-
+
// Get the directory list
mlt_properties dir = mlt_properties_new();
- int count = mlt_properties_dir_list( dir, prefix, NULL, 0 );
+ int count = mlt_properties_dir_list( dir, directory, NULL, 0 );
int i;
// Iterate over files
}
}
-void *mlt_repository_fetch( mlt_repository this, mlt_profile profile, mlt_service_type type, const char *service, void *input )
+void *mlt_repository_create( mlt_repository this, mlt_profile profile, mlt_service_type type, const char *service, void *input )
{
void *( *symbol_ptr )( mlt_profile, mlt_service_type, const char *, void * ) = NULL;