From 52d8310e82be1fcbcd0b0da3c7ad7036159cbd7a Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Wed, 8 Dec 2010 23:43:05 -0800 Subject: [PATCH] Add mlt_consumer_position (Mlt::Consumer::position). --- configure | 2 +- src/framework/mlt_consumer.c | 41 +++++++++++++++++++++++++++++++----- src/framework/mlt_consumer.h | 2 ++ src/framework/mlt_types.h | 1 + src/melt/melt.c | 2 +- src/mlt++/MltConsumer.cpp | 5 +++++ src/mlt++/MltConsumer.h | 1 + 7 files changed, 47 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 30ff6bb3..b0531138 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #!/bin/sh export version=0.5.11 -export soversion=2 +export soversion=3 show_help() { diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index b13c802b..bcd44896 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -44,8 +44,9 @@ pthread_mutex_t mlt_sdl_mutex = PTHREAD_MUTEX_INITIALIZER; static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ); static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ); -static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name ); +static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer this, char *name ); static void apply_profile_properties( mlt_consumer this, mlt_profile profile, mlt_properties properties ); +static void on_consumer_frame_show( mlt_properties owner, mlt_consumer this, mlt_frame frame ); /** Initialize a consumer service. * @@ -101,6 +102,7 @@ int mlt_consumer_init( mlt_consumer this, void *child, mlt_profile profile ) mlt_events_register( properties, "consumer-frame-show", ( mlt_transmitter )mlt_consumer_frame_show ); mlt_events_register( properties, "consumer-frame-render", ( mlt_transmitter )mlt_consumer_frame_render ); mlt_events_register( properties, "consumer-stopped", NULL ); + mlt_events_listen( properties, this, "consumer-frame-show", ( mlt_listener )on_consumer_frame_show ); // Register a property-changed listener to handle the profile property - // subsequent properties can override the profile @@ -144,12 +146,12 @@ static void apply_profile_properties( mlt_consumer this, mlt_profile profile, ml /** The property-changed event listener * * \private \memberof mlt_consumer_s - * \param owner the service a service (ignored) + * \param owner the events object * \param this the consumer * \param name the name of the property that changed */ -static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name ) +static void mlt_consumer_property_changed( mlt_properties owner, mlt_consumer this, char *name ) { if ( !strcmp( name, "profile" ) ) { @@ -273,7 +275,7 @@ static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, * * \private \memberof mlt_consumer_s * \param listener a function pointer that will be invoked - * \param owner a properties list that will be passed to \p listener + * \param owner the events object that will be passed to \p listener * \param this a service that will be passed to \p listener * \param args an array of pointers - the first entry is passed as a string to \p listener */ @@ -290,7 +292,7 @@ static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner * * \private \memberof mlt_consumer_s * \param listener a function pointer that will be invoked - * \param owner a properties list that will be passed to \p listener + * \param owner the events object that will be passed to \p listener * \param this a service that will be passed to \p listener * \param args an array of pointers - the first entry is passed as a string to \p listener */ @@ -301,6 +303,22 @@ static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties own listener( owner, this, ( mlt_frame )args[ 0 ] ); } +/** A listener on the consumer-frame-show event + * + * Saves the position of the frame shown. + * + * \private \memberof mlt_consumer_s + * \param owner the events object + * \param consumer the consumer on which this event occurred + * \param frame the frame that was shown + */ + +static void on_consumer_frame_show( mlt_properties owner, mlt_consumer consumer, mlt_frame frame ) +{ + if ( frame ) + consumer->position = mlt_frame_get_position( frame ); +} + /** Create a new consumer. * * \public \memberof mlt_consumer_s @@ -1020,3 +1038,16 @@ void mlt_consumer_close( mlt_consumer this ) } } } + +/** Get the position of the last frame shown. + * + * \public \memberof mlt_consumer_s + * \param consumer a consumer + * \return the position + */ + +mlt_position mlt_consumer_position( mlt_consumer consumer ) +{ + return consumer->position; +} + diff --git a/src/framework/mlt_consumer.h b/src/framework/mlt_consumer.h index 736d0a2c..acd3916b 100644 --- a/src/framework/mlt_consumer.h +++ b/src/framework/mlt_consumer.h @@ -112,6 +112,7 @@ struct mlt_consumer_s mlt_frame put; int put_active; mlt_event event_listener; + mlt_position position; }; #define MLT_CONSUMER_SERVICE( consumer ) ( &( consumer )->parent ) @@ -131,5 +132,6 @@ extern int mlt_consumer_stop( mlt_consumer self ); extern int mlt_consumer_is_stopped( mlt_consumer self ); extern void mlt_consumer_stopped( mlt_consumer self ); extern void mlt_consumer_close( mlt_consumer ); +extern mlt_position mlt_consumer_position( mlt_consumer ); #endif diff --git a/src/framework/mlt_types.h b/src/framework/mlt_types.h index 05c7bf5c..c4a7df82 100644 --- a/src/framework/mlt_types.h +++ b/src/framework/mlt_types.h @@ -123,5 +123,6 @@ typedef char *( *mlt_serialiser )( void *, int length );/**< pointer to serializ #define MLT_TRACTOR(x) ( ( mlt_tractor )( x ) ) /**< Cast to a Tractor pointer */ #define MLT_FILTER(x) ( ( mlt_filter )( x ) ) /**< Cast to a Filter pointer */ #define MLT_TRANSITION(x) ( ( mlt_transition )( x ) ) /**< Cast to a Transition pointer */ +#define MLT_CONSUMER(x) ( ( mlt_consumer )( x ) ) /**< Cast to a Consumer pointer */ #endif diff --git a/src/melt/melt.c b/src/melt/melt.c index caba2889..b8e974d7 100644 --- a/src/melt/melt.c +++ b/src/melt/melt.c @@ -281,7 +281,7 @@ static void transport( mlt_producer producer, mlt_consumer consumer ) } else { - fprintf( stderr, "Current Position: %10d\r", (int)mlt_producer_position( producer ) ); + fprintf( stderr, "Current Position: %10d\r", (int)mlt_consumer_position( consumer ) ); } } diff --git a/src/mlt++/MltConsumer.cpp b/src/mlt++/MltConsumer.cpp index 69558f1c..40f094a3 100644 --- a/src/mlt++/MltConsumer.cpp +++ b/src/mlt++/MltConsumer.cpp @@ -135,3 +135,8 @@ int Consumer::run( ) } return ret; } + +int Consumer::position( ) +{ + return mlt_consumer_position( get_consumer() ); +} diff --git a/src/mlt++/MltConsumer.h b/src/mlt++/MltConsumer.h index 772764bc..c9d2c4c8 100644 --- a/src/mlt++/MltConsumer.h +++ b/src/mlt++/MltConsumer.h @@ -52,6 +52,7 @@ namespace Mlt void purge( ); int stop( ); bool is_stopped( ); + int position( ); }; } -- 2.39.2