X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Fproducer_consumer.c;h=78c5bcc241fac8cdec4ec2bc6b9dd0b16fb222d6;hb=5f48fd1ddbd803c132952ad90290b0fc78a36286;hp=ec575a2df93ebbfe353b023c69ce1bb9b2a0b276;hpb=8c69000b4c4a8423a5025f0463805da562714eaa;p=melted diff --git a/src/modules/core/producer_consumer.c b/src/modules/core/producer_consumer.c index ec575a2..78c5bcc 100644 --- a/src/modules/core/producer_consumer.c +++ b/src/modules/core/producer_consumer.c @@ -30,6 +30,7 @@ struct context_s { mlt_producer producer; mlt_consumer consumer; mlt_profile profile; + int is_close_profile; }; typedef struct context_s *context; @@ -85,23 +86,39 @@ static int get_frame( mlt_producer this, mlt_frame_ptr frame, int index ) cx = mlt_pool_alloc( sizeof( struct context_s ) ); mlt_properties_set_data( properties, "context", cx, 0, mlt_pool_release, NULL ); cx->this = this; - cx->profile = mlt_profile_init( mlt_properties_get( properties, "profile" ) ); + char *profile_name = mlt_properties_get( properties, "profile" ); + mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( this ) ); + + if ( profile_name ) + { + cx->profile = mlt_profile_init( profile_name ); + cx->is_close_profile = 1; + } + else + { + cx->profile = profile; + cx->is_close_profile = 0; + } // For now, we must conform the nested network's frame rate to the parent network's // framerate. - mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( this ) ); cx->profile->frame_rate_num = profile->frame_rate_num; cx->profile->frame_rate_den = profile->frame_rate_den; // We will encapsulate a consumer cx->consumer = mlt_consumer_new( cx->profile ); - mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( cx->consumer ), "real_time", 0 ); + // Do not use _pass_list on real_time so that it defaults to 0 in the absence of + // an explicit real_time property. + mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( cx->consumer ), "real_time", + mlt_properties_get_int( properties, "real_time" ) ); + mlt_properties_pass_list( MLT_CONSUMER_PROPERTIES( cx->consumer ), properties, + "buffer, prefill" ); // Encapsulate a real producer for the resource cx->producer = mlt_factory_producer( cx->profile, mlt_environment( "MLT_PRODUCER" ), mlt_properties_get( properties, "resource" ) ); mlt_properties_pass_list( properties, MLT_PRODUCER_PROPERTIES( cx->producer ), - "in, out, length, resource" ); + "out, length" ); // Since we control the seeking, prevent it from seeking on its own mlt_producer_set_speed( cx->producer, 0 ); @@ -116,14 +133,14 @@ static int get_frame( mlt_producer this, mlt_frame_ptr frame, int index ) if ( frame ) { // Our "in" needs to be the same, keep it so - mlt_properties_pass_list( MLT_PRODUCER_PROPERTIES( cx->producer ), properties, "in" ); + mlt_properties_pass_list( MLT_PRODUCER_PROPERTIES( cx->producer ), properties, "in, out" ); // Seek the producer to the correct place // Calculate our positions double actual_position = mlt_producer_get_speed( this ) * (double)mlt_producer_position( this ); mlt_position need_first = floor( actual_position ); mlt_producer_seek( cx->producer, need_first ); - + // Get the nested frame mlt_frame nested_frame = mlt_consumer_rt_frame( cx->consumer ); @@ -144,8 +161,11 @@ static int get_frame( mlt_producer this, mlt_frame_ptr frame, int index ) // Inform the normalizers about our video properties mlt_properties frame_props = MLT_FRAME_PROPERTIES( *frame ); mlt_properties_set_double( frame_props, "aspect_ratio", mlt_profile_sar( cx->profile ) ); - mlt_properties_set_double( frame_props, "width", cx->profile->width ); - mlt_properties_set_double( frame_props, "height", cx->profile->height ); + mlt_properties_set_int( frame_props, "width", cx->profile->width ); + mlt_properties_set_int( frame_props, "height", cx->profile->height ); + mlt_properties_set_int( frame_props, "real_width", cx->profile->width ); + mlt_properties_set_int( frame_props, "real_height", cx->profile->height ); + mlt_properties_set_int( frame_props, "progressive", cx->profile->progressive ); } // Calculate the next timecode @@ -164,7 +184,8 @@ static void producer_close( mlt_producer this ) mlt_consumer_stop( cx->consumer ); mlt_consumer_close( cx->consumer ); mlt_producer_close( cx->producer ); - free( cx->profile ); + if ( cx->is_close_profile ) + mlt_profile_close( cx->profile ); } this->close = NULL; @@ -188,8 +209,10 @@ mlt_producer producer_consumer_init( mlt_profile profile, mlt_service_type type, // Get the properties of this producer mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); mlt_properties_set( properties, "resource", arg ); + mlt_properties_pass_list( properties, MLT_PRODUCER_PROPERTIES( real_producer ), "out, length" ); - mlt_producer_close( real_producer ); + // Done with the producer - will re-open later when we have the profile property + mlt_producer_close( real_producer ); } else {