From cdf2dbd4142d046054baf2f675ff5bec30bb449a Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Thu, 11 Nov 2004 19:20:48 +0000 Subject: [PATCH] Playlist reorganisation git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@520 d19143bc-622f-0410-bfdd-b5b2a6649095 --- mlt++/src/MltPlaylist.cpp | 67 +++++++++++++++++++++++++++++++++++++++---- mlt++/src/MltPlaylist.h | 7 ++++- mlt++/src/MltProducer.cpp | 10 ++++++ mlt++/src/MltProducer.h | 2 + mlt++/src/MltProperties.cpp | 10 ++++++ mlt++/src/MltProperties.h | 2 + mlt++/src/MltTractor.cpp | 24 +++++++++++++++ mlt++/src/MltTractor.h | 6 ++++ 8 files changed, 121 insertions(+), 7 deletions(-) diff --git a/mlt++/src/MltPlaylist.cpp b/mlt++/src/MltPlaylist.cpp index 4bb38b7..2f6314f 100644 --- a/mlt++/src/MltPlaylist.cpp +++ b/mlt++/src/MltPlaylist.cpp @@ -24,6 +24,21 @@ #include "MltTransition.h" using namespace Mlt; +ClipInfo::ClipInfo( ) : + clip( 0 ), + producer( NULL ), + cut( NULL ), + start( 0 ), + resource( NULL ), + frame_in( 0 ), + frame_out( 0 ), + frame_count( 0 ), + length( 0 ), + fps( 0 ), + repeat( 0 ) +{ +} + ClipInfo::ClipInfo( mlt_playlist_clip_info *info ) : clip( info->clip ), producer( new Producer( info->producer ) ), @@ -46,6 +61,24 @@ ClipInfo::~ClipInfo( ) free( resource ); } +void ClipInfo::update( mlt_playlist_clip_info *info ) +{ + delete producer; + delete cut; + free( resource ); + clip = info->clip; + producer = new Producer( info->producer ); + cut = new Producer( info->cut ); + start = info->start; + resource = strdup( info->resource ); + frame_in = info->frame_in; + frame_out = info->frame_out; + frame_count = info->frame_count; + length = info->length; + fps = info->fps; + repeat = info->repeat; +} + Playlist::Playlist( ) : instance( NULL ) { @@ -124,11 +157,14 @@ Producer *Playlist::current( ) return new Producer( mlt_playlist_current( get_playlist( ) ) ); } -ClipInfo *Playlist::clip_info( int index ) +ClipInfo *Playlist::clip_info( int index, ClipInfo *info ) { - mlt_playlist_clip_info info; - mlt_playlist_get_clip_info( get_playlist( ), &info, index ); - return new ClipInfo( &info ); + mlt_playlist_clip_info clip_info; + mlt_playlist_get_clip_info( get_playlist( ), &clip_info, index ); + if ( info == NULL ) + return new ClipInfo( &clip_info ); + info->update( &clip_info ); + return info; } int Playlist::insert( Producer &producer, int where, int in, int out ) @@ -178,12 +214,14 @@ int Playlist::repeat( int clip, int count ) Producer *Playlist::get_clip( int clip ) { - return new Producer( mlt_playlist_get_clip( get_playlist( ), clip ) ); + mlt_producer producer = mlt_playlist_get_clip( get_playlist( ), clip ); + return producer != NULL ? new Producer( producer ) : NULL; } Producer *Playlist::get_clip_at( int position ) { - return new Producer( mlt_playlist_get_clip_at( get_playlist( ), position ) ); + mlt_producer producer = mlt_playlist_get_clip_at( get_playlist( ), position ); + return producer != NULL ? new Producer( producer ) : NULL; } int Playlist::get_clip_index_at( int position ) @@ -196,3 +234,20 @@ bool Playlist::is_mix( int clip ) return mlt_playlist_clip_is_mix( get_playlist( ), clip ) != 0; } +bool Playlist::is_blank( int clip ) +{ + return mlt_playlist_is_blank( get_playlist( ), clip ); +} + +Producer *Playlist::replace_with_blank( int clip ) +{ + mlt_producer producer = mlt_playlist_replace_with_blank( get_playlist( ), clip ); + Producer *object = producer != NULL ? new Producer( producer ) : NULL; + mlt_producer_close( producer ); + return object; +} + +void Playlist::consolidate_blanks( int keep_length ) +{ + return mlt_playlist_consolidate_blanks( get_playlist( ), keep_length ); +} diff --git a/mlt++/src/MltPlaylist.h b/mlt++/src/MltPlaylist.h index 8aae7fb..bbb8b0e 100644 --- a/mlt++/src/MltPlaylist.h +++ b/mlt++/src/MltPlaylist.h @@ -35,8 +35,10 @@ namespace Mlt class ClipInfo { public: + ClipInfo( ); ClipInfo( mlt_playlist_clip_info *info ); ~ClipInfo( ); + void update( mlt_playlist_clip_info *info ); int clip; Producer *producer; Producer *cut; @@ -69,7 +71,7 @@ namespace Mlt int clip( mlt_whence whence, int index ); int current_clip( ); Producer *current( ); - ClipInfo *clip_info( int index ); + ClipInfo *clip_info( int index, ClipInfo *info = NULL ); int insert( Producer &producer, int where, int in = -1, int out = -1 ); int remove( int where ); int move( int from, int to ); @@ -83,6 +85,9 @@ namespace Mlt Producer *get_clip_at( int position ); int get_clip_index_at( int position ); bool is_mix( int clip ); + bool is_blank( int clip ); + void consolidate_blanks( int keep_length = 0 ); + Producer *replace_with_blank( int clip ); }; } diff --git a/mlt++/src/MltProducer.cpp b/mlt++/src/MltProducer.cpp index 31ace14..8eae08c 100644 --- a/mlt++/src/MltProducer.cpp +++ b/mlt++/src/MltProducer.cpp @@ -148,6 +148,11 @@ bool Producer::is_cut( ) return mlt_producer_is_cut( get_producer( ) ); } +bool Producer::is_blank( ) +{ + return mlt_producer_is_blank( get_producer( ) ); +} + bool Producer::same_clip( Producer &that ) { return mlt_producer_cut_parent( get_producer( ) ) == mlt_producer_cut_parent( that.get_producer( ) ); @@ -157,3 +162,8 @@ bool Producer::runs_into( Producer &that ) { return same_clip( that ) && get_out( ) == ( that.get_in( ) - 1 ); } + +void Producer::optimise( ) +{ + mlt_producer_optimise( get_producer( ) ); +} diff --git a/mlt++/src/MltProducer.h b/mlt++/src/MltProducer.h index 3015285..2196ec7 100644 --- a/mlt++/src/MltProducer.h +++ b/mlt++/src/MltProducer.h @@ -57,8 +57,10 @@ namespace Mlt int get_playtime( ); Producer *cut( int in = 0, int out = -1 ); bool is_cut( ); + bool is_blank( ); bool same_clip( Producer &that ); bool runs_into( Producer &that ); + void optimise( ); }; } diff --git a/mlt++/src/MltProperties.cpp b/mlt++/src/MltProperties.cpp index 403fcc8..98e87f9 100644 --- a/mlt++/src/MltProperties.cpp +++ b/mlt++/src/MltProperties.cpp @@ -73,6 +73,16 @@ int Properties::dec_ref( ) return mlt_properties_dec_ref( get_properties( ) ); } +void Properties::block( void *object ) +{ + mlt_events_block( get_properties( ), object ); +} + +void Properties::unblock( void *object ) +{ + mlt_events_unblock( get_properties( ), object ); +} + bool Properties::is_valid( ) { return get_properties( ) != NULL; diff --git a/mlt++/src/MltProperties.h b/mlt++/src/MltProperties.h index 33d92f4..7952da0 100644 --- a/mlt++/src/MltProperties.h +++ b/mlt++/src/MltProperties.h @@ -46,6 +46,8 @@ namespace Mlt virtual ~Properties( ); int inc_ref( ); int dec_ref( ); + void block( void *object = NULL ); + void unblock( void *object = NULL ); bool is_valid( ); int count( ); char *get( char *name ); diff --git a/mlt++/src/MltTractor.cpp b/mlt++/src/MltTractor.cpp index 19c8a24..d7bd8d6 100644 --- a/mlt++/src/MltTractor.cpp +++ b/mlt++/src/MltTractor.cpp @@ -21,6 +21,8 @@ #include "MltTractor.h" #include "MltMultitrack.h" #include "MltField.h" +#include "MltTransition.h" +#include "MltFilter.h" using namespace Mlt; Tractor::Tractor( ) : @@ -95,3 +97,25 @@ int Tractor::count( ) { return mlt_multitrack_count( mlt_tractor_multitrack( get_tractor( ) ) ); } + +void Tractor::plant_transition( Transition &transition, int a_track, int b_track ) +{ + mlt_field_plant_transition( mlt_tractor_field( get_tractor( ) ), transition.get_transition( ), a_track, b_track ); +} + +void Tractor::plant_transition( Transition *transition, int a_track, int b_track ) +{ + if ( transition != NULL ) + mlt_field_plant_transition( mlt_tractor_field( get_tractor( ) ), transition->get_transition( ), a_track, b_track ); +} + +void Tractor::plant_filter( Filter &filter, int track ) +{ + mlt_field_plant_filter( mlt_tractor_field( get_tractor( ) ), filter.get_filter( ), track ); +} + +void Tractor::plant_filter( Filter *filter, int track ) +{ + mlt_field_plant_filter( mlt_tractor_field( get_tractor( ) ), filter->get_filter( ), track ); +} + diff --git a/mlt++/src/MltTractor.h b/mlt++/src/MltTractor.h index 014f395..6638d7e 100644 --- a/mlt++/src/MltTractor.h +++ b/mlt++/src/MltTractor.h @@ -30,6 +30,8 @@ namespace Mlt class Producer; class Field; class Multitrack; + class Transition; + class Filter; class Tractor : public Producer { @@ -49,6 +51,10 @@ namespace Mlt int set_track( Producer &producer, int index ); Producer *track( int index ); int count( ); + void plant_transition( Transition &transition, int a_track = 0, int b_track = 1 ); + void plant_transition( Transition *transition, int a_track = 0, int b_track = 1 ); + void plant_filter( Filter &filter, int track = 0 ); + void plant_filter( Filter *filter, int track = 0 ); }; } -- 1.7.4.4