X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fframework%2Fmlt_profile.c;fp=src%2Fframework%2Fmlt_profile.c;h=e2ccc56c5a02b06d51b96c86904f33c7c91bdb9f;hb=42eec4e241d043cbdb85009934fc1cea76ae8b05;hp=06083894fbd8067fa660a253163229743689d319;hpb=3e4af204a6d3fa8ac606fe26baaf3a6f27282fdf;p=mlt diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index 06083894..e2ccc56c 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -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; +}