X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Ftests%2Fcharlie.c;h=7130b1d8267b1359a515bd785d43c4beacd5c7a8;hb=ced3d0b8c0520e4c8208166e3218e0caacba1efa;hp=f807b5d67e3c910d99031b3c92949d5268762481;hpb=e4c9ccbcef39cadaccbad655bc6e36e825bf3dde;p=melted diff --git a/src/tests/charlie.c b/src/tests/charlie.c index f807b5d..7130b1d 100644 --- a/src/tests/charlie.c +++ b/src/tests/charlie.c @@ -4,21 +4,34 @@ #include +#include "io.h" + mlt_producer create_producer( char *file ) { mlt_producer result = NULL; // 1st Line preferences - if ( strstr( file, ".mpg" ) ) + if ( strstr( file, ".inigo" ) ) + { + char *args[ 2 ] = { file, NULL }; + result = mlt_factory_producer( "inigo", args ); + } + else if ( strstr( file, ".mpg" ) ) result = mlt_factory_producer( "mcmpeg", file ); else if ( strstr( file, ".mpeg" ) ) result = mlt_factory_producer( "mcmpeg", file ); + else if ( strstr( file, ".dat" ) ) + result = mlt_factory_producer( "mcmpeg", file ); else if ( strstr( file, ".dv" ) ) result = mlt_factory_producer( "mcdv", file ); else if ( strstr( file, ".dif" ) ) result = mlt_factory_producer( "mcdv", file ); else if ( strstr( file, ".jpg" ) ) result = mlt_factory_producer( "pixbuf", file ); + else if ( strstr( file, ".JPG" ) ) + result = mlt_factory_producer( "pixbuf", file ); + else if ( strstr( file, ".jpeg" ) ) + result = mlt_factory_producer( "pixbuf", file ); else if ( strstr( file, ".png" ) ) result = mlt_factory_producer( "pixbuf", file ); @@ -31,12 +44,62 @@ mlt_producer create_producer( char *file ) return result; } -mlt_consumer create_consumer( char *id ) +void transport_action( mlt_producer producer, char *value ) +{ + mlt_properties properties = mlt_producer_properties( producer ); + + switch( value[ 0 ] ) + { + case 'q': + mlt_properties_set_int( properties, "done", 1 ); + break; + case '0': + mlt_producer_set_speed( producer, 1 ); + mlt_producer_seek( producer, 0 ); + break; + case '1': + mlt_producer_set_speed( producer, -5 ); + break; + case '2': + mlt_producer_set_speed( producer, -2.5 ); + break; + case '3': + mlt_producer_set_speed( producer, -1 ); + break; + case '4': + mlt_producer_set_speed( producer, -0.5 ); + break; + case '5': + mlt_producer_set_speed( producer, 0 ); + break; + case '6': + mlt_producer_set_speed( producer, 0.5 ); + break; + case '7': + mlt_producer_set_speed( producer, 1 ); + break; + case '8': + mlt_producer_set_speed( producer, 2.5 ); + break; + case '9': + mlt_producer_set_speed( producer, 5 ); + break; + } +} + +mlt_consumer create_consumer( char *id, mlt_producer producer ) { char *arg = strchr( id, ':' ); if ( arg != NULL ) *arg ++ = '\0'; - return mlt_factory_consumer( id, arg ); + mlt_consumer consumer = mlt_factory_consumer( id, arg ); + if ( consumer != NULL ) + { + mlt_properties properties = mlt_consumer_properties( consumer ); + mlt_properties_set_data( properties, "transport_callback", transport_action, 0, NULL, NULL ); + mlt_properties_set_data( properties, "transport_producer", producer, 0, NULL, NULL ); + } + return consumer; } void track_service( mlt_field field, void *service, mlt_destructor destructor ) @@ -48,20 +111,6 @@ void track_service( mlt_field field, void *service, mlt_destructor destructor ) mlt_properties_set_int( properties, "registered", ++ registered ); } -mlt_filter create_filter( mlt_field field, char *id, int track ) -{ - char *arg = strchr( id, ':' ); - if ( arg != NULL ) - *arg ++ = '\0'; - mlt_filter filter = mlt_factory_filter( id, arg ); - if ( filter != NULL ) - { - mlt_field_plant_filter( field, filter, track ); - track_service( field, filter, ( mlt_destructor )mlt_filter_close ); - } - return filter; -} - void set_properties( mlt_service service, char *namevalue ) { mlt_properties properties = mlt_service_properties( service ); @@ -70,9 +119,16 @@ void set_properties( mlt_service service, char *namevalue ) void transport( mlt_producer producer ) { - char temp[ 132 ]; - fprintf( stderr, "Press return to continue\n" ); - fgets( temp, 132, stdin ); + mlt_properties properties = mlt_producer_properties( producer ); + + term_init( ); + fprintf( stderr, "Press 'q' to continue\n" ); + while( mlt_properties_get_int( properties, "done" ) == 0 ) + { + int value = term_read( ); + if ( value != -1 ) + transport_action( producer, ( char * )&value ); + } } int main( int argc, char **argv ) @@ -80,10 +136,8 @@ int main( int argc, char **argv ) int i; mlt_service service = NULL; mlt_consumer consumer = NULL; - mlt_multitrack multitrack = NULL; mlt_producer producer = NULL; mlt_playlist playlist = NULL; - mlt_field field = NULL; // Construct the factory mlt_factory_init( getenv( "MLT_REPOSITORY" ) ); @@ -91,29 +145,15 @@ int main( int argc, char **argv ) // Set up containers playlist = mlt_playlist_init( ); - // Construct the field - field = mlt_field_init( ); - mlt_properties properties = mlt_field_properties( field ); - mlt_properties_set_int( properties, "registered", 0 ); - - // Get the multitrack from the field - multitrack = mlt_field_multitrack( field ); - // Parse the arguments for ( i = 1; i < argc; i ++ ) { if ( !strcmp( argv[ i ], "-consumer" ) ) { - consumer = create_consumer( argv[ ++ i ] ); + consumer = create_consumer( argv[ ++ i ], mlt_playlist_producer( playlist ) ); if ( consumer != NULL ) service = mlt_consumer_service( consumer ); } - else if ( !strcmp( argv[ i ], "-filter" ) ) - { - mlt_filter filter = create_filter( field, argv[ ++ i ], 0 ); - if ( filter != NULL ) - service = mlt_filter_service( filter ); - } else if ( !strstr( argv[ i ], "=" ) ) { if ( producer != NULL ) @@ -130,25 +170,21 @@ int main( int argc, char **argv ) // If we have no consumer, default to sdl if ( consumer == NULL ) - consumer= mlt_factory_consumer( "sdl", NULL ); + consumer = create_consumer( "sdl", mlt_playlist_producer( playlist ) ); // Connect producer to playlist if ( producer != NULL ) mlt_playlist_append( playlist, producer ); - // Connect multitrack to producer - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), 0 ); - - // Connect consumer to tractor - mlt_consumer_connect( consumer, mlt_field_service( field ) ); + // Connect consumer to playlist + mlt_consumer_connect( consumer, mlt_playlist_service( playlist ) ); // Transport functionality - transport( mlt_multitrack_producer( multitrack ) ); + transport( mlt_playlist_producer( playlist ) ); // Close the services mlt_consumer_close( consumer ); - mlt_field_close( field ); - mlt_producer_close( producer ); + mlt_playlist_close( playlist ); // Close the factory mlt_factory_close( );