]> git.sesse.net Git - mlt/commitdiff
Add a frei0r param name mapping system.
authorDan Dennedy <dan@dennedy.org>
Fri, 22 Mar 2013 06:01:18 +0000 (23:01 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 22 Mar 2013 06:01:18 +0000 (23:01 -0700)
For apps that set frei0r parameters by their name, this provides
backwards compatibility when a frei0r parameter name changes.

src/modules/frei0r/factory.c
src/modules/frei0r/frei0r_helper.c
src/modules/frei0r/param_name_map.yml [new file with mode: 0644]

index 614026abf68430869bead2a5943b615241f209fa..a3f8eb78fb0869498f94b8ec9881f9272031aeb6 100644 (file)
@@ -328,6 +328,15 @@ static void * load_lib( mlt_profile profile, mlt_service_type type , void* handl
                snprintf( minor, sizeof( minor ), "%d", info.minor_version );
                mlt_properties_set_double( properties, "version", info.major_version +  info.minor_version / pow( 10, strlen( minor ) ) );
 
+               // Use the global param name map for backwards compatibility when
+               // param names change and setting frei0r params by name instead of index.
+               mlt_properties param_name_map = mlt_properties_get_data( mlt_global_properties(), "frei0r.param_name_map", NULL );
+               if ( param_name_map ) {
+                       // Lookup my plugin in the map
+                       param_name_map = mlt_properties_get_data( param_name_map, name, NULL );
+                       mlt_properties_set_data( properties, "_param_name_map", param_name_map, 0, NULL, NULL );
+               }
+
                return ret;
        }else{
                mlt_log_error( NULL, "frei0r plugin \"%s\" is missing a function\n", name );
@@ -400,6 +409,12 @@ MLT_REPOSITORY
        snprintf( dirname, PATH_MAX, "%s/frei0r/blacklist.txt", mlt_environment( "MLT_DATA" ) );
        mlt_properties blacklist = mlt_properties_load( dirname );
 
+       // Load a param name map into global properties for backwards compatibility when
+       // param names change and setting frei0r params by name instead of index.
+       snprintf( dirname, PATH_MAX, "%s/frei0r/param_name_map.yml", mlt_environment( "MLT_DATA" ) );
+       mlt_properties_set_data( mlt_global_properties(), "frei0r.param_name_map",
+               mlt_properties_parse_yaml( dirname ), 0, (mlt_destructor) mlt_properties_close, NULL );
+
        while (dircount--){
 
                mlt_properties direntries = mlt_properties_new();
index fdb74c41a1701f620797952a4b576fdb491e117f..61df9a2e6fc1aea6fbc3c487e5fbf49035b0d951 100644 (file)
@@ -94,6 +94,17 @@ int process_frei0r_item( mlt_service service, double position, double time, mlt_
                        char *val = mlt_properties_get( prop , index );
                        if ( !val )
                                val = mlt_properties_get( prop , pinfo.name );
+                       if ( !val ) {
+                               // Use the backwards-compatibility param name map.
+                               mlt_properties map = mlt_properties_get_data( prop, "_param_name_map", NULL );
+                               if ( map ) {
+                                       int j;
+                                       for ( j = 0; !val && j < mlt_properties_count(map); j++ ) {
+                                               if ( !strcmp(mlt_properties_get_value(map, j), index) )
+                                                       val = mlt_properties_get( prop , mlt_properties_get_name(map, j) );
+                                       }
+                               }
+                       }
                        if ( val ) {
                                switch (pinfo.type) {
                                        case F0R_PARAM_DOUBLE:
diff --git a/src/modules/frei0r/param_name_map.yml b/src/modules/frei0r/param_name_map.yml
new file mode 100644 (file)
index 0000000..b4cb87e
--- /dev/null
@@ -0,0 +1,3 @@
+# MLT frei0r param name mapping from old name to current index
+# plugin:
+#   param_name: index