]> git.sesse.net Git - mlt/commitdiff
Simplified playlist access
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 7 Nov 2004 14:12:52 +0000 (14:12 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 7 Nov 2004 14:12:52 +0000 (14:12 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@510 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_playlist.c
src/framework/mlt_playlist.h

index 6ebf37af89576a6aa9c78d63e0e9514b3f98a00e..ddcc28f7e4be3c51072dd27062b2ab1873f1d383 100644 (file)
@@ -286,52 +286,59 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer source,
        return mlt_playlist_virtual_refresh( this );
 }
 
-/** Seek in the virtual playlist.
-*/
-
-static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressive )
+static mlt_producer mlt_playlist_locate( mlt_playlist this, mlt_position *position, int *clip, int *total )
 {
-       // Default producer to blank
+       // Default producer to NULL
        mlt_producer producer = NULL;
 
-       // Map playlist position to real producer in virtual playlist
-       mlt_position position = mlt_producer_frame( &this->parent );
-
-       mlt_position original = position;
-
-       // Total number of frames
-       int64_t total = 0;
-
-       // Get the properties
-       mlt_properties properties = mlt_playlist_properties( this );
-
-       // Get the eof handling
-       char *eof = mlt_properties_get( properties, "eof" );
-
-       // Index for the main loop
-       int i = 0;
-
        // Loop for each producer until found
-       for ( i = 0; i < this->count; i ++ )
+       for ( *clip = 0; *clip < this->count; *clip += 1 )
        {
                // Increment the total
-               total += this->list[ i ]->frame_count;
+               *total += this->list[ *clip ]->frame_count;
 
                // Check if the position indicates that we have found the clip
                // Note that 0 length clips get skipped automatically
-               if ( position < this->list[ i ]->frame_count )
+               if ( *position < this->list[ *clip ]->frame_count )
                {
                        // Found it, now break
-                       producer = this->list[ i ]->producer;
+                       producer = this->list[ *clip ]->producer;
                        break;
                }
                else
                {
                        // Decrement position by length of this entry
-                       position -= this->list[ i ]->frame_count;
+                       *position -= this->list[ *clip ]->frame_count;
                }
        }
 
+       return producer;
+}
+
+/** Seek in the virtual playlist.
+*/
+
+static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressive )
+{
+       // Map playlist position to real producer in virtual playlist
+       mlt_position position = mlt_producer_frame( &this->parent );
+
+       // Keep the original position since we change it while iterating through the list
+       mlt_position original = position;
+
+       // Clip index and total
+       int i = 0;
+       int total = 0;
+
+       // Locate the producer for the position
+       mlt_producer producer = mlt_playlist_locate( this, &position, &i, &total );
+
+       // Get the properties
+       mlt_properties properties = mlt_playlist_properties( this );
+
+       // Get the eof handling
+       char *eof = mlt_properties_get( properties, "eof" );
+
        // Seek in real producer to relative position
        if ( producer != NULL )
        {
@@ -932,7 +939,7 @@ int mlt_playlist_mix_add( mlt_playlist this, int clip, mlt_transition transition
        return error;
 }
 
-/** Return the clip at the position.
+/** Return the clip at the clip index.
 */
 
 mlt_producer mlt_playlist_get_clip( mlt_playlist this, int clip )
@@ -942,6 +949,25 @@ mlt_producer mlt_playlist_get_clip( mlt_playlist this, int clip )
        return NULL;
 }
 
+/** Return the clip at the specified position.
+*/
+
+mlt_producer mlt_playlist_get_clip_at( mlt_playlist this, int position )
+{
+       int index = 0, total = 0;
+       return mlt_playlist_locate( this, &position, &index, &total );
+}
+
+/** Return the clip index of the specified position.
+*/
+
+int mlt_playlist_get_clip_index_at( mlt_playlist this, int position )
+{
+       int index = 0, total = 0;
+       mlt_playlist_locate( this, &position, &index, &total );
+       return index;
+}
+
 /** Determine if the clip is a mix.
 */
 
index a7dd3f28ef666d70ffaad7ade570172b39375324..50b236d194190822475f1f32c664ab856b12a42a 100644 (file)
@@ -68,6 +68,8 @@ extern int mlt_playlist_join( mlt_playlist self, int clip, int count, int merge
 extern int mlt_playlist_mix( mlt_playlist self, int clip, int length, mlt_transition transition );
 extern int mlt_playlist_mix_add( mlt_playlist self, int clip, mlt_transition transition );
 extern mlt_producer mlt_playlist_get_clip( mlt_playlist self, int clip );
+extern mlt_producer mlt_playlist_get_clip_at( mlt_playlist self, int position );
+extern int mlt_playlist_get_clip_index_at( mlt_playlist self, int position );
 extern int mlt_playlist_clip_is_mix( mlt_playlist self, int clip );
 extern void mlt_playlist_close( mlt_playlist self );