]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_factory.c
On Windows locate plugins and data by directory relative to current directory.
[mlt] / src / framework / mlt_factory.c
index bb7619d081eea0aca5a3a6948e61c6ea19604c9c..ebfc1076bf7de9b9ccdf6968c2f329c62733b9a4 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WIN32
+#include <windows.h>
+/** the default subdirectory of the libdir for holding modules (plugins) */
+#define PREFIX_LIB "lib\\mlt"
+/** the default subdirectory of the install prefix for holding module (plugin) data */
+#define PREFIX_DATA "share\\mlt"
+#else
 /** the default subdirectory of the libdir for holding modules (plugins) */
 #define PREFIX_LIB LIBDIR "/mlt"
 /** the default subdirectory of the install prefix for holding module (plugin) data */
 #define PREFIX_DATA PREFIX "/share/mlt"
-
+#endif
 
 /** holds the full path to the modules directory - initialized and retained for the entire session */
 static char *mlt_directory = NULL;
@@ -76,7 +83,7 @@ static void mlt_factory_create_done( mlt_listener listener, mlt_properties owner
 
 /** Construct the repository and factories.
  *
- * The environment variable MLT_PRODUCER is the name of a default producer often used by other services, defaults to "fezzil".
+ * The environment variable MLT_PRODUCER is the name of a default producer often used by other services, defaults to "loader".
  *
  * The environment variable MLT_CONSUMER is the name of a default consumer, defaults to "sdl".
  *
@@ -95,6 +102,21 @@ static void mlt_factory_create_done( mlt_listener listener, mlt_properties owner
 
 mlt_repository mlt_factory_init( const char *directory )
 {
+       if ( ! global_properties )
+               global_properties = mlt_properties_new( );
+
+       // Allow property refresh on a subsequent initialisation
+       if ( global_properties )
+       {
+               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" ), "loader" );
+               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 );
+       }
+
        // Only initialise once
        if ( mlt_directory == NULL )
        {
@@ -124,9 +146,6 @@ mlt_repository mlt_factory_init( const char *directory )
                mlt_events_register( event_object, "consumer-create-request", ( mlt_transmitter )mlt_factory_create_request );
                mlt_events_register( event_object, "consumer-create-done", ( mlt_transmitter )mlt_factory_create_done );
 
-               // Create the global properties
-               global_properties = mlt_properties_new( );
-
                // Create the repository of services
                repository = mlt_repository_init( directory );
 
@@ -134,18 +153,6 @@ mlt_repository mlt_factory_init( const char *directory )
                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 repository;
 }
 
@@ -226,7 +233,7 @@ static void set_common_properties( mlt_properties properties, mlt_profile profil
  * \return a new producer
  */
 
-mlt_producer mlt_factory_producer( mlt_profile profile, const char *service, void *input )
+mlt_producer mlt_factory_producer( mlt_profile profile, const char *service, const void *input )
 {
        mlt_producer obj = NULL;
 
@@ -259,7 +266,7 @@ mlt_producer mlt_factory_producer( mlt_profile profile, const char *service, voi
  * \return a new filter
  */
 
-mlt_filter mlt_factory_filter( mlt_profile profile, const char *service, void *input )
+mlt_filter mlt_factory_filter( mlt_profile profile, const char *service, const void *input )
 {
        mlt_filter obj = NULL;
 
@@ -288,7 +295,7 @@ mlt_filter mlt_factory_filter( mlt_profile profile, const char *service, void *i
  * \return a new transition
  */
 
-mlt_transition mlt_factory_transition( mlt_profile profile, const char *service, void *input )
+mlt_transition mlt_factory_transition( mlt_profile profile, const char *service, const void *input )
 {
        mlt_transition obj = NULL;
 
@@ -317,7 +324,7 @@ mlt_transition mlt_factory_transition( mlt_profile profile, const char *service,
  * \return a new consumer
  */
 
-mlt_consumer mlt_factory_consumer( mlt_profile profile, const char *service, void *input )
+mlt_consumer mlt_factory_consumer( mlt_profile profile, const char *service, const void *input )
 {
        mlt_consumer obj = NULL;
 
@@ -365,9 +372,15 @@ void mlt_factory_close( )
        {
                mlt_properties_close( event_object );
                mlt_properties_close( global_properties );
-               mlt_repository_close( repository );
+               if ( repository )
+                       mlt_repository_close( repository );
                free( mlt_directory );
                mlt_directory = NULL;
                mlt_pool_close( );
        }
 }
+
+mlt_properties mlt_global_properties( )
+{
+       return global_properties;
+}