Adding the mix part 1
[melted] / mlt++ / src / MltPlaylist.cpp
index 5509a58..d85012f 100644 (file)
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "MltPlaylist.h"
+#include "MltTransition.h"
 using namespace Mlt;
 
 ClipInfo::ClipInfo( mlt_playlist_clip_info *info ) :
@@ -45,28 +46,36 @@ ClipInfo::~ClipInfo( )
 }
 
 Playlist::Playlist( ) :
-       destroy( true ),
        instance( NULL )
 {
        instance = mlt_playlist_init( );
 }
 
+Playlist::Playlist( Service &producer ) :
+       instance( NULL )
+{
+       if ( producer.type( ) == playlist_type )
+       {
+               instance = ( mlt_playlist )producer.get_service( );
+               inc_ref( );
+       }
+}
+
 Playlist::Playlist( Playlist &playlist ) :
-       destroy( false ),
        instance( playlist.get_playlist( ) )
 {
+       inc_ref( );
 }
 
 Playlist::Playlist( mlt_playlist playlist ) :
-       destroy( false ),
        instance( playlist )
 {
+       inc_ref( );
 }
 
 Playlist::~Playlist( )
 {
-       if ( destroy )
-               mlt_playlist_close( instance );
+       mlt_playlist_close( instance );
 }
 
 mlt_playlist Playlist::get_playlist( )
@@ -89,17 +98,17 @@ int Playlist::clear( )
        return mlt_playlist_clear( get_playlist( ) );
 }
 
-int Playlist::append( Producer &producer, mlt_position in, mlt_position out )
+int Playlist::append( Producer &producer, int in, int out )
 {
        return mlt_playlist_append_io( get_playlist( ), producer.get_producer( ), in, out );
 }
 
-int Playlist::blank( mlt_position length )
+int Playlist::blank( int length )
 {
        return mlt_playlist_blank( get_playlist( ), length );
 }
 
-mlt_position Playlist::clip( mlt_whence whence, int index )
+int Playlist::clip( mlt_whence whence, int index )
 {
        return mlt_playlist_clip( get_playlist( ), whence, index );
 }
@@ -121,7 +130,7 @@ ClipInfo *Playlist::clip_info( int index )
        return new ClipInfo( &info );
 }
 
-int Playlist::insert( Producer &producer, int where, mlt_position in, mlt_position out )
+int Playlist::insert( Producer &producer, int where, int in, int out )
 {
        return mlt_playlist_insert( get_playlist( ), producer.get_producer( ), where, in, out );
 }
@@ -136,8 +145,22 @@ int Playlist::move( int from, int to )
        return mlt_playlist_move( get_playlist( ), from, to );
 }
 
-int Playlist::resize_clip( int clip, mlt_position in, mlt_position out )
+int Playlist::resize_clip( int clip, int in, int out )
 {
        return mlt_playlist_resize_clip( get_playlist( ), clip, in, out );
 }
 
+int Playlist::split( int clip, int position )
+{
+       return mlt_playlist_split( get_playlist( ), clip, position );
+}
+
+int Playlist::join( int clip, int count, int merge )
+{
+       return mlt_playlist_join( get_playlist( ), clip, count, merge );
+}
+
+int Playlist::mix( int clip, int length, Transition *transition )
+{
+       return mlt_playlist_mix( get_playlist( ), clip, length, transition == NULL ? NULL : transition->get_transition( ) );
+}