]> 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)
1  2 
src/modules/frei0r/factory.c

index 30f593e13df8772af24d00e60d6026942abc7ebd,e214292d6dddd78ebe00e40085861937d4f15098..ad9ecb777d0ce4d26f6c14802322c56697f97561
@@@ -45,6 -45,8 +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 +124,9 @@@ static mlt_properties fill_param_info 
        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;
        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 );
                mlt_properties_set_data ( parameter , string , pnum , 0 , ( mlt_destructor )mlt_properties_close, NULL );
                f0r_param_info_t paraminfo;
                param_info(&paraminfo,j);
 -              mlt_properties_set ( pnum , "identifier" , paraminfo.name );
 +              mlt_properties_set ( pnum , "identifier" , string );
                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);
@@@ -278,13 -310,13 +310,13 @@@ static void * load_lib( mlt_profile pro
                        }
                }
                check_thread_safe( properties, name );
 -              mlt_properties_set_data(properties, "_dlclose_handle", handle , sizeof (void*) , NULL , NULL );
 +              mlt_properties_set_data(properties, "_dlclose_handle", handle , sizeof ( handle ) , NULL , NULL );
                mlt_properties_set_data(properties, "_dlclose", dlclose , sizeof (void*) , NULL , NULL );
 -              mlt_properties_set_data(properties, "f0r_construct", f0r_construct , sizeof(void*),NULL,NULL);
 -              mlt_properties_set_data(properties, "f0r_update", f0r_update , sizeof(void*),NULL,NULL);
 +              mlt_properties_set_data(properties, "f0r_construct", f0r_construct , sizeof( f0r_construct ),NULL,NULL);
 +              mlt_properties_set_data(properties, "f0r_update", f0r_update , sizeof( f0r_update ),NULL,NULL);
                if (f0r_update2)
 -                      mlt_properties_set_data(properties, "f0r_update2", f0r_update2 , sizeof(void*),NULL,NULL);
 -              mlt_properties_set_data(properties, "f0r_destruct", f0r_destruct , sizeof(void*),NULL,NULL);
 +                      mlt_properties_set_data(properties, "f0r_update2", f0r_update2 , sizeof( f0r_update2 ),NULL,NULL);
 +              mlt_properties_set_data(properties, "f0r_destruct", f0r_destruct , sizeof( f0r_destruct ),NULL,NULL);
                mlt_properties_set_data(properties, "f0r_get_plugin_info", f0r_get_plugin_info , sizeof(void*),NULL,NULL);
                mlt_properties_set_data(properties, "f0r_get_param_info", f0r_get_param_info , sizeof(void*),NULL,NULL);
                mlt_properties_set_data(properties, "f0r_set_param_value", f0r_set_param_value , sizeof(void*),NULL,NULL);
@@@ -387,10 -419,9 +419,10 @@@ MLT_REPOSITOR
                        char* firstname = strtok_r( shortname, ".", &save_firstptr );
  #endif
                        char pluginname[1024]="frei0r.";
 -                      strcat(pluginname,firstname);
 +                      if ( firstname )
 +                              strncat( pluginname, firstname, sizeof( pluginname ) - strlen( pluginname ) -1 );
  
 -                      if ( mlt_properties_get( blacklist, firstname ) )
 +                      if ( firstname && mlt_properties_get( blacklist, firstname ) )
                                continue;
  
                        void* handle=dlopen(strcat(name, LIBSUF),RTLD_LAZY);