]> git.sesse.net Git - mlt/commitdiff
Add mlt_profile_list().
authorDan Dennedy <dan@dennedy.org>
Mon, 4 Apr 2011 05:19:17 +0000 (22:19 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 4 Apr 2011 05:19:17 +0000 (22:19 -0700)
src/framework/mlt_profile.c
src/framework/mlt_profile.h

index 06083894fbd8067fa660a253163229743689d319..e2ccc56c5a02b06d51b96c86904f33c7c91bdb9f 100644 (file)
@@ -334,3 +334,48 @@ mlt_profile mlt_profile_clone( mlt_profile profile )
        }
        return clone;
 }
+
+
+/** Get the list of profiles.
+ *
+ * The caller MUST free the returned properties object!
+ * Each entry in the list is keyed on its name, and its value is another
+ * properties object that contains the attributes of the profile.
+ * \public \memberof mlt_profile_s
+ * \return a list of profiles
+ */
+
+mlt_properties mlt_profile_list( )
+{
+       const char *prefix = getenv( "MLT_PROFILES_PATH" );
+       mlt_properties properties = mlt_properties_new();
+       mlt_properties dir = mlt_properties_new();
+       int sort = 1;
+       const char *wildcard = NULL;
+       int i;
+
+       // Load from $prefix/share/mlt/profiles if no env var
+       if ( prefix == NULL )
+               prefix = PREFIX;
+
+       mlt_properties_dir_list( dir, prefix, wildcard, sort );
+
+       for ( i = 0; i < mlt_properties_count( dir ); i++ )
+       {
+               char *filename = mlt_properties_get_value( dir, i );
+               char *profile_name = basename( filename );
+               if ( profile_name[0] != '.' && strcmp( profile_name, "Makefile" ) &&
+                    profile_name[ strlen( profile_name ) - 1 ] != '~' )
+               {
+                       mlt_properties profile = mlt_properties_load( filename );
+                       if ( profile )
+                       {
+                               mlt_properties_set_data( properties, profile_name, profile, 0,
+                                       (mlt_destructor) mlt_properties_close, NULL );
+                       }
+               }
+       }
+       mlt_properties_close( dir );
+
+       return properties;
+}
index 91e27d9ab8ef57f681fd90f3532f05c0867404ee..02638e54a7ec2eed3fa7c7ab64f096e502729684 100644 (file)
@@ -55,4 +55,5 @@ extern double mlt_profile_sar( mlt_profile profile );
 extern double mlt_profile_dar( mlt_profile profile );
 extern void mlt_profile_close( mlt_profile profile );
 extern mlt_profile mlt_profile_clone( mlt_profile profile );
+extern mlt_properties mlt_profile_list( );
 #endif