X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Ffezzik%2Fproducer_fezzik.c;h=9a0d9f3a647c32fd550cbf257642b9747b5a15a5;hb=026972a9994471c1c1e5a714ac29d9d638cef027;hp=429cf802b4588cf2773db2842db97482393da88c;hpb=263e253a65f403b90eecf0b46b692e326e970b29;p=melted diff --git a/src/modules/fezzik/producer_fezzik.c b/src/modules/fezzik/producer_fezzik.c index 429cf80..9a0d9f3 100644 --- a/src/modules/fezzik/producer_fezzik.c +++ b/src/modules/fezzik/producer_fezzik.c @@ -31,18 +31,6 @@ static mlt_properties dictionary = NULL; static mlt_properties normalisers = NULL; -static void track_service( mlt_tractor tractor, void *service, mlt_destructor destructor ) -{ - mlt_properties properties = mlt_tractor_properties( tractor ); - int registered = mlt_properties_get_int( properties, "_registered" ); - char *key = mlt_properties_get( properties, "_registered" ); - char *real = malloc( strlen( key ) + 2 ); - sprintf( real, "_%s", key ); - mlt_properties_set_data( properties, real, service, 0, destructor, NULL ); - mlt_properties_set_int( properties, "_registered", ++ registered ); - free( real ); -} - static mlt_producer create_from( char *file, char *services ) { mlt_producer producer = NULL; @@ -117,7 +105,7 @@ static mlt_producer create_producer( char *file ) return result; } -static mlt_service create_filter( mlt_tractor tractor, mlt_service last, char *effect, int *created ) +static void create_filter( mlt_producer producer, char *effect, int *created ) { char *id = strdup( effect ); char *arg = strchr( id, ':' ); @@ -126,16 +114,15 @@ static mlt_service create_filter( mlt_tractor tractor, mlt_service last, char *e mlt_filter filter = mlt_factory_filter( id, arg ); if ( filter != NULL ) { - mlt_filter_connect( filter, last, 0 ); - track_service( tractor, filter, ( mlt_destructor )mlt_filter_close ); - last = mlt_filter_service( filter ); + mlt_properties_set_int( mlt_filter_properties( filter ), "_fezzik", 1 ); + mlt_producer_attach( producer, filter ); + mlt_filter_close( filter ); *created = 1; } free( id ); - return last; } -static mlt_service attach_normalisers( mlt_tractor tractor, mlt_service last ) +static void attach_normalisers( mlt_producer producer ) { // Loop variable int i; @@ -160,71 +147,33 @@ static mlt_service attach_normalisers( mlt_tractor tractor, mlt_service last ) char *value = mlt_properties_get_value( normalisers, i ); mlt_tokeniser_parse_new( tokeniser, value, "," ); for ( j = 0; !created && j < mlt_tokeniser_count( tokeniser ); j ++ ) - last = create_filter( tractor, last, mlt_tokeniser_get_string( tokeniser, j ), &created ); + create_filter( producer, mlt_tokeniser_get_string( tokeniser, j ), &created ); } // Close the tokeniser mlt_tokeniser_close( tokeniser ); - - return last; } mlt_producer producer_fezzik_init( char *arg ) { - // Create the producer that the tractor will contain + // Create the producer mlt_producer producer = NULL; + mlt_properties properties = NULL; if ( arg != NULL ) producer = create_producer( arg ); - // Build the tractor if we have a producer and it isn't already westley'd :-) - if ( producer != NULL && mlt_properties_get( mlt_producer_properties( producer ), "westley" ) == NULL ) - { - // Construct the tractor - mlt_tractor tractor = mlt_tractor_init( ); - - // Sanity check - if ( tractor != NULL ) - { - // Extract the tractor properties - mlt_properties properties = mlt_tractor_properties( tractor ); - - // Our producer will be the last service - mlt_service last = mlt_producer_service( producer ); - - // Set the registered count - mlt_properties_set_int( properties, "_registered", 0 ); + if ( producer != NULL ) + properties = mlt_producer_properties( producer ); - // Register our producer for seeking in the tractor - mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); + // Attach filters if we have a producer and it isn't already westley'd :-) + if ( producer != NULL && mlt_properties_get( properties, "westley" ) == NULL && mlt_properties_get( properties, "_westley" ) == NULL ) + attach_normalisers( producer ); - // Now attach normalising filters - last = attach_normalisers( tractor, last ); - - // Connect the tractor to the last - mlt_tractor_connect( tractor, last ); - - // Finally, inherit properties from producer - mlt_properties_inherit( properties, mlt_producer_properties( producer ) ); - - // Now make sure we don't lose our inherited identity - mlt_properties_set_int( properties, "_mlt_service_hidden", 1 ); - - // This is a temporary hack to ensure that westley doesn't dig too deep - // and fezzik doesn't overdo it with throwing rocks... - mlt_properties_set( properties, "westley", "was here" ); - - // We need to ensure that all further properties are mirrored in the producer - mlt_properties_mirror( properties, mlt_producer_properties( producer ) ); - - // Ensure that the inner producer ignores the in point - mlt_properties_set_int( mlt_producer_properties( producer ), "ignore_points", 1 ); - - // Now, we return the producer of the tractor - producer = mlt_tractor_producer( tractor ); - } - } + // Now make sure we don't lose our identity + if ( properties != NULL ) + mlt_properties_set_int( properties, "_mlt_service_hidden", 1 ); - // Return the tractor's producer + // Return the producer return producer; }