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 )
{
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 )
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.
*/