mlt_multitrack mlt_multitrack_init( ) { // Allocate the multitrack object mlt_multitrack self = calloc( 1, sizeof( struct mlt_multitrack_s ) ); if ( self != NULL ) { mlt_producer producer = &self->parent; if ( mlt_producer_init( producer, self ) == 0 ) { mlt_properties properties = MLT_MULTITRACK_PROPERTIES( self ); producer->get_frame = producer_get_frame; mlt_properties_set_data( properties, "multitrack", self, 0, NULL, NULL ); mlt_properties_set( properties, "log_id", "multitrack" ); mlt_properties_set( properties, "resource", "<multitrack>" ); mlt_properties_set_int( properties, "in", 0 ); mlt_properties_set_int( properties, "out", -1 ); mlt_properties_set_int( properties, "length", 0 ); producer->close = ( mlt_destructor )mlt_multitrack_close; } else { free( self ); self = NULL; } } return self; }
void mlt_multitrack_close( mlt_multitrack self ) { if ( self != NULL && mlt_properties_dec_ref( MLT_MULTITRACK_PROPERTIES( self ) ) <= 0 ) { int i = 0; for ( i = 0; i < self->count; i ++ ) { if ( self->list[ i ] != NULL ) { mlt_event_close( self->list[ i ]->event ); mlt_producer_close( self->list[ i ]->producer ); free( self->list[ i ] ); } } // Close the producer self->parent.close = NULL; mlt_producer_close( &self->parent ); // Free the list free( self->list ); // Free the object free( self ); } }
mlt_tractor mlt_tractor_new( ) { mlt_tractor self = calloc( 1, sizeof( struct mlt_tractor_s ) ); if ( self != NULL ) { mlt_producer producer = &self->parent; if ( mlt_producer_init( producer, self ) == 0 ) { mlt_multitrack multitrack = mlt_multitrack_init( ); mlt_field field = mlt_field_new( multitrack, self ); mlt_properties props = MLT_PRODUCER_PROPERTIES( producer ); mlt_properties_set( props, "resource", "<tractor>" ); mlt_properties_set( props, "mlt_type", "mlt_producer" ); mlt_properties_set( props, "mlt_service", "tractor" ); mlt_properties_set_position( props, "in", 0 ); mlt_properties_set_position( props, "out", 0 ); mlt_properties_set_position( props, "length", 0 ); mlt_properties_set_data( props, "multitrack", multitrack, 0, ( mlt_destructor )mlt_multitrack_close, NULL ); mlt_properties_set_data( props, "field", field, 0, ( mlt_destructor )mlt_field_close, NULL ); mlt_events_listen( MLT_MULTITRACK_PROPERTIES( multitrack ), self, "producer-changed", ( mlt_listener )mlt_tractor_listener ); producer->get_frame = producer_get_frame; producer->close = ( mlt_destructor )mlt_tractor_close; producer->close_object = self; } else { free( self ); self = NULL; } } return self; }
mlt_multitrack mlt_multitrack_init( ) { // Allocate the multitrack object mlt_multitrack this = calloc( sizeof( struct mlt_multitrack_s ), 1 ); if ( this != NULL ) { mlt_producer producer = &this->parent; if ( mlt_producer_init( producer, this ) == 0 ) { mlt_properties properties = MLT_MULTITRACK_PROPERTIES( this ); producer->get_frame = producer_get_frame; mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL ); mlt_properties_set( properties, "log_id", "multitrack" ); mlt_properties_set( properties, "resource", "<multitrack>" ); mlt_properties_set_int( properties, "in", 0 ); mlt_properties_set_int( properties, "out", -1 ); mlt_properties_set_int( properties, "length", 0 ); producer->close = ( mlt_destructor )mlt_multitrack_close; } else { free( this ); this = NULL; } } return this; }
void mlt_tractor_refresh( mlt_tractor self ) { mlt_multitrack multitrack = mlt_tractor_multitrack( self ); mlt_properties multitrack_props = MLT_MULTITRACK_PROPERTIES( multitrack ); mlt_properties properties = MLT_TRACTOR_PROPERTIES( self ); mlt_events_block( multitrack_props, properties ); mlt_events_block( properties, properties ); mlt_multitrack_refresh( multitrack ); mlt_properties_set_position( properties, "in", 0 ); mlt_properties_set_position( properties, "out", mlt_properties_get_position( multitrack_props, "out" ) ); mlt_events_unblock( properties, properties ); mlt_events_unblock( multitrack_props, properties ); mlt_properties_set_position( properties, "length", mlt_properties_get_position( multitrack_props, "length" ) ); }
void mlt_multitrack_refresh( mlt_multitrack self ) { int i = 0; // Obtain the properties of this multitrack mlt_properties properties = MLT_MULTITRACK_PROPERTIES( self ); // We need to ensure that the multitrack reports the longest track as its length mlt_position length = 0; // Obtain stats on all connected services for ( i = 0; i < self->count; i ++ ) { // Get the producer from this index mlt_track track = self->list[ i ]; mlt_producer producer = track->producer; // If it's allocated then, update our stats if ( producer != NULL ) { // If we have more than 1 track, we must be in continue mode if ( self->count > 1 ) mlt_properties_set( MLT_PRODUCER_PROPERTIES( producer ), "eof", "continue" ); // Determine the longest length //if ( !mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "hide" ) ) length = mlt_producer_get_playtime( producer ) > length ? mlt_producer_get_playtime( producer ) : length; } } // Update multitrack properties now - we'll not destroy the in point here mlt_events_block( properties, properties ); mlt_properties_set_position( properties, "length", length ); mlt_events_unblock( properties, properties ); mlt_properties_set_position( properties, "out", length - 1 ); }
mlt_properties mlt_multitrack_properties( mlt_multitrack self ) { return MLT_MULTITRACK_PROPERTIES( self ); }