From e8ada1d332c877b479afa8ab1f4229c261a90821 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Tue, 19 Jun 2012 21:09:48 -0700 Subject: [PATCH] add mlt_producer_seek_time and mlt_producer_frame_time --- src/framework/mlt_producer.c | 30 ++++++++++++++++++++++++++++++ src/framework/mlt_producer.h | 2 ++ src/mlt++/MltProducer.cpp | 10 ++++++++++ src/mlt++/MltProducer.h | 2 ++ 4 files changed, 44 insertions(+) diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index ff2a5939..b3795819 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -287,6 +287,7 @@ mlt_properties mlt_producer_properties( mlt_producer self ) * \param position set the "play head" position of the producer * \return false * \todo Document how the properties affect behavior. + * \see mlt_producer_seek_time */ int mlt_producer_seek( mlt_producer self, mlt_position position ) @@ -325,6 +326,22 @@ int mlt_producer_seek( mlt_producer self, mlt_position position ) return 0; } +/** Seek to a specified time string. + * + * \public \memberof mlt_producer_s + * \param self a producer + * \param time set the "play head" position of the producer to the time string + * \return false + * \see mlt_producer_seek + */ + +int mlt_producer_seek_time( mlt_producer self, const char* time ) +{ + mlt_properties_set( MLT_PRODUCER_PROPERTIES(self), "_seek_time", time ); + mlt_position position = mlt_properties_get_position( MLT_PRODUCER_PROPERTIES(self), "_seek_time" ); + return mlt_producer_seek( self, position ); +} + /** Get the current position (relative to in point). * * \public \memberof mlt_producer_s @@ -349,6 +366,19 @@ mlt_position mlt_producer_frame( mlt_producer self ) return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "_frame" ); } +/** Get the current position (relative to start of producer) as a time string. + * + * \public \memberof mlt_producer_s + * \param self a producer + * \param format the time value format + * \return the position of the "play head" regardless of the in point + */ + +char* mlt_producer_frame_time( mlt_producer self, mlt_time_format format ) +{ + return mlt_properties_get_time( MLT_PRODUCER_PROPERTIES( self ), "_frame", format ); +} + /** Set the playing speed. * * \public \memberof mlt_producer_s diff --git a/src/framework/mlt_producer.h b/src/framework/mlt_producer.h index 0f942d8f..8e226f2b 100644 --- a/src/framework/mlt_producer.h +++ b/src/framework/mlt_producer.h @@ -93,8 +93,10 @@ extern mlt_producer mlt_producer_new( mlt_profile ); extern mlt_service mlt_producer_service( mlt_producer self ); extern mlt_properties mlt_producer_properties( mlt_producer self ); extern int mlt_producer_seek( mlt_producer self, mlt_position position ); +extern int mlt_producer_seek_time( mlt_producer self, const char* time ); extern mlt_position mlt_producer_position( mlt_producer self ); extern mlt_position mlt_producer_frame( mlt_producer self ); +char* mlt_producer_frame_time( mlt_producer self, mlt_time_format ); extern int mlt_producer_set_speed( mlt_producer self, double speed ); extern double mlt_producer_get_speed( mlt_producer self ); extern double mlt_producer_get_fps( mlt_producer self ); diff --git a/src/mlt++/MltProducer.cpp b/src/mlt++/MltProducer.cpp index 739649b8..0e3842a1 100644 --- a/src/mlt++/MltProducer.cpp +++ b/src/mlt++/MltProducer.cpp @@ -111,6 +111,11 @@ int Producer::seek( int position ) return mlt_producer_seek( get_producer( ), position ); } +int Producer::seek( const char *time ) +{ + return mlt_producer_seek_time( get_producer( ), time ); +} + int Producer::position( ) { return mlt_producer_position( get_producer( ) ); @@ -121,6 +126,11 @@ int Producer::frame( ) return mlt_producer_frame( get_producer( ) ); } +char* Producer::frame_time( mlt_time_format format ) +{ + return mlt_producer_frame_time( get_producer(), format ); +} + int Producer::set_speed( double speed ) { return mlt_producer_set_speed( get_producer( ), speed ); diff --git a/src/mlt++/MltProducer.h b/src/mlt++/MltProducer.h index 92695943..473f2f41 100644 --- a/src/mlt++/MltProducer.h +++ b/src/mlt++/MltProducer.h @@ -52,8 +52,10 @@ namespace Mlt mlt_producer get_parent( ); mlt_service get_service( ); int seek( int position ); + int seek( const char* time ); int position( ); int frame( ); + char* frame_time( mlt_time_format = mlt_time_smpte ); int set_speed( double speed ); int pause( ); double get_speed( ); -- 2.39.2