]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_producer.c
mlt_consumer_start(): check return value from mlt_properties_get_int()
[mlt] / src / framework / mlt_producer.c
index e49f1395e54fecc3c572e0ef69a3d78c80920617..b37958197855d193f72c085ee1216de267297fa8 100644 (file)
@@ -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,12 +366,25 @@ 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
  * \param self a producer
  * \param speed the new speed as a relative factor (1.0 = normal)
- * \return
+ * \return true if error
  */
 
 int mlt_producer_set_speed( mlt_producer self, double speed )
@@ -509,6 +539,21 @@ mlt_position mlt_producer_get_length( mlt_producer self )
        return mlt_properties_get_position( MLT_PRODUCER_PROPERTIES( self ), "length" );
 }
 
+/** Get the total, unedited length of the producer as a time string.
+ *
+ * The value returned by a live streaming producer is unknown.
+ *
+ * \public \memberof mlt_producer_s
+ * \param self a producer
+ * \param format the time value format
+ * \return the duration of the producer regardless of in and out points
+ */
+
+char* mlt_producer_get_length_time( mlt_producer self, mlt_time_format format )
+{
+    return mlt_properties_get_time( MLT_PRODUCER_PROPERTIES( self ), "length", format );
+}
+
 /** Prepare for next frame.
  *
  * Advance the play out position. If the speed is less than zero, it will
@@ -656,15 +701,17 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind
                int i = 0;
                mlt_properties p_props = MLT_PRODUCER_PROPERTIES( self );
                mlt_properties f_props = MLT_FRAME_PROPERTIES( *frame );
+               mlt_properties_lock( p_props );
                int count = mlt_properties_count( p_props );
                for ( i = 0; i < count; i ++ )
                {
                        char *name = mlt_properties_get_name( p_props, i );
                        if ( !strncmp( name, "meta.", 5 ) )
-                               mlt_properties_set( f_props, name, mlt_properties_get( p_props, name ) );
+                               mlt_properties_set( f_props, name, mlt_properties_get_value( p_props, i ) );
                        else if ( !strncmp( name, "set.", 4 ) )
-                               mlt_properties_set( f_props, name + 4, mlt_properties_get( p_props, name ) );
+                               mlt_properties_set( f_props, name + 4, mlt_properties_get_value( p_props, i ) );
                }
+               mlt_properties_unlock( p_props );
        }
 
        return result;
@@ -709,7 +756,7 @@ mlt_filter mlt_producer_filter( mlt_producer self, int index )
        return mlt_service_filter( MLT_PRODUCER_SERVICE( self ), index );
 }
 
-/** Clone self producer.
+/** Clone a producer.
  *
  * \private \memberof mlt_producer_s
  * \param self a producer
@@ -948,7 +995,7 @@ int mlt_producer_optimise( mlt_producer self )
                        int count = 0;
                        int clones = 0;
                        int max_clones = 0;
-                       mlt_producer producer = mlt_properties_get_data( producers, name, &count );
+                       mlt_producer producer = mlt_properties_get_data_at( producers, k, &count );
                        if ( producer != NULL && count > 1 )
                        {
                                clip_references *refs = mlt_properties_get_data( properties, name, &count );