X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=mlt%2B%2B%2Fsrc%2FMltProducer.cpp;h=39a93db156f43007e02102ebe4df4ce749041292;hb=55757b000043f6e370b9e963ce2e3542962c03c0;hp=31ace144312f268ed8f1960b313fb81814be7326;hpb=3e2991e189a71045210d8c97458c452d6c2f02da;p=melted diff --git a/mlt++/src/MltProducer.cpp b/mlt++/src/MltProducer.cpp index 31ace14..39a93db 100644 --- a/mlt++/src/MltProducer.cpp +++ b/mlt++/src/MltProducer.cpp @@ -20,24 +20,28 @@ #include "MltProducer.h" #include "MltFilter.h" +#include "MltProfile.h" using namespace Mlt; Producer::Producer( ) : - instance( NULL ) + instance( NULL ), + parent_( NULL ) { } -Producer::Producer( char *id, char *service ) : - instance( NULL ) +Producer::Producer( Profile& profile, char *id, char *service ) : + instance( NULL ), + parent_( NULL ) { if ( id != NULL && service != NULL ) - instance = mlt_factory_producer( id, service ); + instance = mlt_factory_producer( profile.get_profile(), id, service ); else - instance = mlt_factory_producer( "fezzik", id != NULL ? id : service ); + instance = mlt_factory_producer( profile.get_profile(), "fezzik", id != NULL ? id : service ); } Producer::Producer( Service &producer ) : - instance( NULL ) + instance( NULL ), + parent_( NULL ) { mlt_service_type type = producer.type( ); if ( type == producer_type || type == playlist_type || @@ -49,20 +53,32 @@ Producer::Producer( Service &producer ) : } Producer::Producer( mlt_producer producer ) : - instance( producer ) + instance( producer ), + parent_( NULL ) { inc_ref( ); } Producer::Producer( Producer &producer ) : - instance( producer.get_producer( ) ) + instance( producer.get_producer( ) ), + parent_( NULL ) { inc_ref( ); } +Producer::Producer( Producer *producer ) : + instance( producer != NULL ? producer->get_producer( ) : NULL ), + parent_( NULL ) +{ + if ( is_valid( ) ) + inc_ref( ); +} + Producer::~Producer( ) { + delete parent_; mlt_producer_close( instance ); + instance = NULL; } mlt_producer Producer::get_producer( ) @@ -75,6 +91,13 @@ mlt_producer Producer::get_parent( ) return get_producer( ) != NULL && mlt_producer_cut_parent( get_producer( ) ) != NULL ? mlt_producer_cut_parent( get_producer( ) ) : get_producer( ); } +Producer &Producer::parent( ) +{ + if ( is_cut( ) && parent_ == NULL ) + parent_ = new Producer( get_parent( ) ); + return parent_ == NULL ? *this : *parent_; +} + mlt_service Producer::get_service( ) { return mlt_producer_service( get_producer( ) ); @@ -145,7 +168,12 @@ Producer *Producer::cut( int in, int out ) bool Producer::is_cut( ) { - return mlt_producer_is_cut( get_producer( ) ); + return mlt_producer_is_cut( get_producer( ) ) != 0; +} + +bool Producer::is_blank( ) +{ + return mlt_producer_is_blank( get_producer( ) ) != 0; } bool Producer::same_clip( Producer &that ) @@ -157,3 +185,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( ) ); +}