]> git.sesse.net Git - mlt/commitdiff
Merge branch 'frei0r-metadata'
authorDan Dennedy <dan@dennedy.org>
Sun, 17 Mar 2013 20:15:37 +0000 (13:15 -0700)
committerDan Dennedy <dan@dennedy.org>
Sun, 17 Mar 2013 20:15:37 +0000 (13:15 -0700)
src/modules/frei0r/factory.c

index 30f593e13df8772af24d00e60d6026942abc7ebd..ad9ecb777d0ce4d26f6c14802322c56697f97561 100644 (file)
@@ -45,6 +45,8 @@
 
 #define GET_FREI0R_PATH (getenv("FREI0R_PATH") ? getenv("FREI0R_PATH") : getenv("MLT_FREI0R_PLUGIN_PATH") ? getenv("MLT_FREI0R_PLUGIN_PATH") : FREI0R_PLUGIN_PATH)
 
+#define CLAMP( x, min, max ) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
+
 extern mlt_filter filter_frei0r_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
 extern mlt_frame filter_process( mlt_filter this, mlt_frame frame );
 extern void filter_close( mlt_filter this );
@@ -122,6 +124,9 @@ static mlt_properties fill_param_info ( mlt_service_type type, const char *servi
        void (*param_info)(f0r_param_info_t*,int param_index)=dlsym(handle,"f0r_get_param_info");
        void (*f0r_init)(void)=dlsym(handle,"f0r_init");
        void (*f0r_deinit)(void)=dlsym(handle,"f0r_deinit");
+       f0r_instance_t (*f0r_construct)(unsigned int , unsigned int)=dlsym(handle, "f0r_construct");
+       void (*f0r_destruct)(f0r_instance_t)=dlsym(handle, "f0r_destruct");
+       void (*f0r_get_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index)=dlsym(handle,"f0r_get_param_value" );
        if (!plginfo || !param_info) {
                dlclose(handle);
                return NULL;
@@ -132,6 +137,12 @@ static mlt_properties fill_param_info ( mlt_service_type type, const char *servi
        int j=0;
 
        f0r_init();
+       f0r_instance_t instance = f0r_construct(720, 576);
+       if (!instance) {
+               f0r_deinit();
+               dlclose(handle);
+               return NULL;
+       }
        plginfo(&info);
        snprintf ( string, sizeof(string) , "%d" , info.minor_version );
        mlt_properties_set_double ( metadata, "schema_version" , 0.1 );
@@ -171,27 +182,48 @@ static mlt_properties fill_param_info ( mlt_service_type type, const char *servi
                mlt_properties_set ( pnum , "title" , paraminfo.name );
                mlt_properties_set ( pnum , "description" , paraminfo.explanation);
                if ( paraminfo.type == F0R_PARAM_DOUBLE ){
+                       double deflt = 0;
                        mlt_properties_set ( pnum , "type" , "float" );
                        mlt_properties_set ( pnum , "minimum" , "0" );
                        mlt_properties_set ( pnum , "maximum" , "1" );
-                       mlt_properties_set ( pnum , "readonly" , "no" );
+                       f0r_get_param_value( instance, &deflt, j);
+                       mlt_properties_set_double ( pnum, "default", deflt );
+                       mlt_properties_set ( pnum , "mutable" , "yes" );
                        mlt_properties_set ( pnum , "widget" , "spinner" );
                }else
                if ( paraminfo.type == F0R_PARAM_BOOL ){
+                       double deflt = 0;
                        mlt_properties_set ( pnum , "type" , "boolean" );
                        mlt_properties_set ( pnum , "minimum" , "0" );
                        mlt_properties_set ( pnum , "maximum" , "1" );
-                       mlt_properties_set ( pnum , "readonly" , "no" );
+                       f0r_get_param_value( instance, &deflt, j);
+                       mlt_properties_set_double ( pnum, "default", deflt );
+                       mlt_properties_set ( pnum , "mutable" , "yes" );
+                       mlt_properties_set ( pnum , "widget" , "checkbox" );
                }else
                if ( paraminfo.type == F0R_PARAM_COLOR ){
+                       char colorstr[8];
+                       f0r_param_color_t deflt = {0, 0, 0};
+
                        mlt_properties_set ( pnum , "type" , "color" );
-                       mlt_properties_set ( pnum , "readonly" , "no" );
+                       f0r_get_param_value( instance, &deflt, j);
+                       sprintf( colorstr, "#%02x%02x%02x", (unsigned) CLAMP(deflt.r * 255, 0 , 255),
+                               (unsigned) CLAMP(deflt.g * 255, 0 , 255), (unsigned) CLAMP(deflt.b * 255, 0 , 255));
+                       colorstr[7] = 0;
+                       mlt_properties_set ( pnum , "default", colorstr );
+                       mlt_properties_set ( pnum , "mutable" , "yes" );
+                       mlt_properties_set ( pnum , "widget" , "color" );
                }else
                if ( paraminfo.type == F0R_PARAM_STRING ){
+                       char *deflt = NULL;
                        mlt_properties_set ( pnum , "type" , "string" );
-                       mlt_properties_set ( pnum , "readonly" , "no" );
+                       f0r_get_param_value( instance, &deflt, j );
+                       mlt_properties_set ( pnum , "default", deflt );
+                       mlt_properties_set ( pnum , "mutable" , "yes" );
+                       mlt_properties_set ( pnum , "widget" , "text" );
                }
        }
+       f0r_destruct(instance);
        f0r_deinit();
        dlclose(handle);
        free(name);