X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Finigo%2Finigo.c;h=5adfc445f8a56fb66ca2ac813de919ad56e799bc;hb=051194b9cd65f82daa3618d385b068c5cc02122f;hp=da12d01a446a2678e2fc01506c3ac9f5c0563b94;hpb=d33f444d4ef4c7bc4074d07a49eca0ab7d108394;p=melted diff --git a/src/inigo/inigo.c b/src/inigo/inigo.c index da12d01..5adfc44 100644 --- a/src/inigo/inigo.c +++ b/src/inigo/inigo.c @@ -265,6 +265,56 @@ static void transport( mlt_producer producer, mlt_consumer consumer ) } } +static void query_metadata( mlt_repository repo, mlt_service_type type, char *typestr, char *id ) +{ + mlt_properties metadata = mlt_repository_metadata( repo, type, id ); + if ( metadata ) + { + char *s = mlt_properties_serialise_yaml( metadata ); + fprintf( stderr, "%s", s ); + free( s ); + } + else + { + fprintf( stderr, "# No metadata for %s \"%s\"\n", typestr, id ); + } +} + +static void query_services( mlt_repository repo, mlt_service_type type ) +{ + mlt_properties services = NULL; + char *typestr = NULL; + switch ( type ) + { + case consumer_type: + services = mlt_repository_consumers( repo ); + typestr = "consumers"; + break; + case filter_type: + services = mlt_repository_filters( repo ); + typestr = "filters"; + break; + case producer_type: + services = mlt_repository_producers( repo ); + typestr = "producers"; + break; + case transition_type: + services = mlt_repository_transitions( repo ); + typestr = "transitions"; + break; + default: + return; + } + fprintf( stderr, "---\n%s:\n", typestr ); + if ( services ) + { + int j; + for ( j = 0; j < mlt_properties_count( services ); j++ ) + fprintf( stderr, " - %s\n", mlt_properties_get_name( services, j ) ); + } + fprintf( stderr, "...\n" ); +} + int main( int argc, char **argv ) { int i; @@ -283,7 +333,7 @@ int main( int argc, char **argv ) #endif // Construct the factory - mlt_factory_init( NULL ); + mlt_repository repo = mlt_factory_init( NULL ); for ( i = 1; i < argc; i ++ ) { @@ -307,6 +357,45 @@ int main( int argc, char **argv ) if ( pname && pname[0] != '-' ) profile = mlt_profile_init( pname ); } + // Look for the query option + else if ( !strcmp( argv[ i ], "-query" ) ) + { + const char *pname = argv[ ++ i ]; + if ( pname && pname[0] != '-' ) + { + if ( !strcmp( pname, "consumers" ) || !strcmp( pname, "consumer" ) ) + query_services( repo, consumer_type ); + else if ( !strcmp( pname, "filters" ) || !strcmp( pname, "filter" ) ) + query_services( repo, filter_type ); + else if ( !strcmp( pname, "producers" ) || !strcmp( pname, "producer" ) ) + query_services( repo, producer_type ); + else if ( !strcmp( pname, "transitions" ) || !strcmp( pname, "transition" ) ) + query_services( repo, transition_type ); + + else if ( !strncmp( pname, "consumer=", 9 ) ) + query_metadata( repo, consumer_type, "consumer", strchr( pname, '=' ) + 1 ); + else if ( !strncmp( pname, "filter=", 7 ) ) + query_metadata( repo, filter_type, "filter", strchr( pname, '=' ) + 1 ); + else if ( !strncmp( pname, "producer=", 9 ) ) + query_metadata( repo, producer_type, "producer", strchr( pname, '=' ) + 1 ); + else if ( !strncmp( pname, "transition=", 11 ) ) + query_metadata( repo, transition_type, "transition", strchr( pname, '=' ) + 1 ); + else + goto query_all; + } + else + { +query_all: + query_services( repo, consumer_type ); + query_services( repo, filter_type ); + query_services( repo, producer_type ); + query_services( repo, transition_type ); + fprintf( stderr, "# You can query the metadata for a specific service using:\n" + "# -query =\n" + "# where is one of: consumer, filter, producer, or transition.\n" ); + } + goto exit_factory; + } } // Create profile if not set explicitly @@ -404,6 +493,8 @@ int main( int argc, char **argv ) else { fprintf( stderr, "Usage: inigo [ -profile name ]\n" + " [ -query [ consumers | filters | producers | transitions |\n" + " type=identifer ] ]\n" " [ -serialise [ filename.inigo ] ]\n" " [ -group [ name=value ]* ]\n" " [ -consumer id[:arg] [ name=value ]* [ silent=1 ] [ progress=1 ] ]\n" @@ -429,6 +520,9 @@ int main( int argc, char **argv ) // Close the factory mlt_profile_close( profile ); + +exit_factory: + mlt_factory_close( ); return 0;