]> git.sesse.net Git - mlt/commitdiff
Add mlt_consumer_position (Mlt::Consumer::position).
authorDan Dennedy <dan@dennedy.org>
Thu, 9 Dec 2010 07:43:05 +0000 (23:43 -0800)
committerDan Dennedy <dan@dennedy.org>
Thu, 9 Dec 2010 07:43:05 +0000 (23:43 -0800)
configure
src/framework/mlt_consumer.c
src/framework/mlt_consumer.h
src/framework/mlt_types.h
src/melt/melt.c
src/mlt++/MltConsumer.cpp
src/mlt++/MltConsumer.h

index 30ff6bb34d5e92171391b02b34856c5d875dae84..b0531138003c55d5b0273d757b8e3e2313d1a2c2 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 export version=0.5.11
-export soversion=2
+export soversion=3
 
 show_help()
 {
index b13c802b7f4b2e31381828b59d8e52743f964e75..bcd44896e7bca37c43263bf20e5cfa505f692c03 100644 (file)
@@ -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;
+}
+               
index 736d0a2c3fb8918b853394713876d473317cbab0..acd3916baedbfe9074899adae331d537bf6749b9 100644 (file)
@@ -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
index 05c7bf5c95e839b9c317ae70543bdcfb5a964c30..c4a7df8255fc1e4f797c20f396862e1fc2b2f89e 100644 (file)
@@ -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
index caba2889269bc91c219fde5822f448fffd122e05..b8e974d704c4c618c58d30253e73f3dcefa03710 100644 (file)
@@ -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 ) );
                                }
                        }
 
index 69558f1c34b44a581744b204e3586bd26f96f90e..40f094a3fc7d9052cdd38b9d20dfdafd23625017 100644 (file)
@@ -135,3 +135,8 @@ int Consumer::run( )
        }
        return ret;
 }
+
+int Consumer::position( )
+{
+       return mlt_consumer_position( get_consumer() );
+}
index 772764bc6416750021686e2238406c3b78f18458..c9d2c4c8d28a284c6dfa38811124f39c9a9bb48e 100644 (file)
@@ -52,6 +52,7 @@ namespace Mlt
                        void purge( );
                        int stop( );
                        bool is_stopped( );
+                       int position( );
        };
 }