X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Favformat%2Ffactory.c;h=54adf936d9026e1b41c6bc32b1e808d2920e23bd;hb=4fc3fa1bf4116848c423837437d75f103cdd0154;hp=5ccb204f4518167d83f104860a46e4ea54f44f4c;hpb=6fbad87cfc97a367c4e47216b83c9e433253aa9e;p=melted diff --git a/src/modules/avformat/factory.c b/src/modules/avformat/factory.c index 5ccb204..54adf93 100644 --- a/src/modules/avformat/factory.c +++ b/src/modules/avformat/factory.c @@ -20,13 +20,16 @@ #include #include +#include -#include -#include "producer_avformat.h" -#include "consumer_avformat.h" -#include "filter_avcolour_space.h" -#include "filter_avdeinterlace.h" -#include "filter_avresample.h" +#include + +extern mlt_consumer consumer_avformat_init( mlt_profile profile, char *file ); +extern mlt_filter filter_avcolour_space_init( void *arg ); +extern mlt_filter filter_avdeinterlace_init( void *arg ); +extern mlt_filter filter_avresample_init( char *arg ); +extern mlt_filter filter_swscale_init( mlt_profile profile, char *arg ); +extern mlt_producer producer_avformat_init( mlt_profile profile, char *file ); // ffmpeg Header files #include @@ -87,42 +90,76 @@ static void avformat_init( ) pthread_mutex_init( &avformat_mutex, NULL ); av_register_all( ); mlt_factory_register_for_clean_up( NULL, avformat_destroy ); - av_log_set_level( -1 ); + av_log_set_level( mlt_log_get_level() ); } } -void *mlt_create_producer( char *id, void *arg ) +static void *create_service( mlt_profile profile, mlt_service_type type, const char *id, void *arg ) { avformat_init( ); +#ifdef CODECS if ( !strcmp( id, "avformat" ) ) - return producer_avformat_init( arg ); - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - avformat_init( ); + { + if ( type == producer_type ) + return producer_avformat_init( profile, arg ); + else if ( type == consumer_type ) + return consumer_avformat_init( profile, arg ); + } +#endif +#ifdef FILTERS if ( !strcmp( id, "avcolour_space" ) ) return filter_avcolour_space_init( arg ); -#ifdef USE_MMX if ( !strcmp( id, "avdeinterlace" ) ) return filter_avdeinterlace_init( arg ); -#endif if ( !strcmp( id, "avresample" ) ) return filter_avresample_init( arg ); +#ifdef SWSCALE + if ( !strcmp( id, "swscale" ) ) + return filter_swscale_init( profile, arg ); +#endif +#endif return NULL; } -void *mlt_create_transition( char *id, void *arg ) +static mlt_properties avformat_metadata( mlt_service_type type, const char *id, void *data ) { - return NULL; + char file[ PATH_MAX ]; + const char *service_type = NULL; + switch ( type ) + { + case consumer_type: + service_type = "consumer"; + break; + case filter_type: + service_type = "filter"; + break; + case producer_type: + service_type = "producer"; + break; + case transition_type: + service_type = "transition"; + break; + default: + return NULL; + } + snprintf( file, PATH_MAX, "%s/avformat/%s_%s.yml", mlt_environment( "MLT_DATA" ), service_type, id ); + return mlt_properties_parse_yaml( file ); } -void *mlt_create_consumer( char *id, void *arg ) +MLT_REPOSITORY { - avformat_init( ); - if ( !strcmp( id, "avformat" ) ) - return consumer_avformat_init( arg ); - return NULL; +#ifdef CODECS + MLT_REGISTER( consumer_type, "avformat", create_service ); + MLT_REGISTER( producer_type, "avformat", create_service ); + MLT_REGISTER_METADATA( producer_type, "avformat", avformat_metadata, NULL ); +#endif +#ifdef FILTERS + MLT_REGISTER( filter_type, "avcolour_space", create_service ); + MLT_REGISTER( filter_type, "avcolor_space", create_service ); + MLT_REGISTER( filter_type, "avdeinterlace", create_service ); + MLT_REGISTER( filter_type, "avresample", create_service ); +#ifdef SWSCALE + MLT_REGISTER( filter_type, "swscale", create_service ); +#endif +#endif } -