X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_multitrack.c;h=d3496de9ce0c524fb4659c7caa2636490718d52d;hb=1a50e779cfd5e1bc6a80054f6f56e64280c2dc41;hp=924733773d00f80a356206e1bf64b9db3eb8b6a6;hpb=4ed2712bbdac2182c7c0d6477ac77c9f92aaf02a;p=melted diff --git a/src/framework/mlt_multitrack.c b/src/framework/mlt_multitrack.c index 9247337..d3496de 100644 --- a/src/framework/mlt_multitrack.c +++ b/src/framework/mlt_multitrack.c @@ -21,6 +21,7 @@ #include "config.h" #include "mlt_multitrack.h" +#include "mlt_playlist.h" #include "mlt_frame.h" #include @@ -56,7 +57,9 @@ mlt_multitrack mlt_multitrack_init( ) 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 ); } else { @@ -95,7 +98,7 @@ mlt_properties mlt_multitrack_properties( mlt_multitrack this ) /** Initialise timecode related information. */ -static void mlt_multitrack_refresh( mlt_multitrack this ) +void mlt_multitrack_refresh( mlt_multitrack this ) { int i = 0; @@ -140,7 +143,7 @@ static void mlt_multitrack_refresh( mlt_multitrack this ) // Update multitrack properties now - we'll not destroy the in point here mlt_properties_set_timecode( properties, "length", length ); mlt_properties_set_timecode( properties, "out", length ); - mlt_properties_set_timecode( properties, "playtime", length - mlt_properties_get_timecode( properties, "in" ) ); + mlt_properties_set_double( properties, "fps", fps ); } /** Connect a producer to a given track. @@ -221,6 +224,12 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind // Get the frame from the producer mlt_service_get_frame( mlt_producer_service( producer ), frame, 0 ); + + // Indicate speed of this producer + mlt_properties producer_properties = mlt_producer_properties( parent ); + double speed = mlt_properties_get_double( producer_properties, "speed" ); + mlt_properties properties = mlt_frame_properties( *frame ); + mlt_properties_set_double( properties, "speed", speed ); } else { @@ -236,11 +245,64 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind // Move on to the next frame if ( index >= this->count ) mlt_producer_prepare_next( parent ); + + // Refresh our stats + mlt_multitrack_refresh( this ); } return 0; } +/** Determine the clip point. +*/ + +mlt_timecode mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ) +{ + int first = 1; + mlt_timecode position = 0; + int i = 0; + + for ( i = 0; i < this->count; i ++ ) + { + // Get the producer + mlt_producer producer = this->list[ i ]; + + if ( producer != NULL ) + { + // Get the properties of this producer + mlt_properties properties = mlt_producer_properties( producer ); + + // Determine if it's a playlist + mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); + + // We only consider playlists + if ( playlist != NULL ) + { + // Locate the smallest timecode + if ( first ) + { + // First position found + position = mlt_playlist_clip( playlist, whence, index ); + + // We're no longer first + first = 0; + } + else + { + // Obtain the clip position in this playlist + mlt_timecode position2 = mlt_playlist_clip( playlist, whence, index ); + + // If this position is prior to the first, then use it + if ( position2 < position ) + position = position2; + } + } + } + } + + return position; +} + /** Close this instance. */