X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=mlt%2B%2B%2Fsrc%2FMltFilter.cpp;h=6fbc93a3ce313b6adaa8cb7158488e8d4e484b62;hb=7494c523c06d7a54da55075f40a71643cc700712;hp=7bb79687d3f0df85e7d0aacf6566dafb25e0a9c1;hpb=01c1d44e8df201c3061cf20addf5421d21d8bcb0;p=melted diff --git a/mlt++/src/MltFilter.cpp b/mlt++/src/MltFilter.cpp index 7bb7968..6fbc93a 100644 --- a/mlt++/src/MltFilter.cpp +++ b/mlt++/src/MltFilter.cpp @@ -18,66 +18,96 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include #include "MltFilter.h" +#include "MltProfile.h" using namespace Mlt; -mlt_service Filter::get_service( ) +Filter::Filter( Profile& profile, const char *id, const char *arg ) : + instance( NULL ) { - return mlt_filter_service( get_filter( ) ); + if ( arg != NULL ) + { + instance = mlt_factory_filter( profile.get_profile(), id, arg ); + } + else + { + if ( strchr( id, ':' ) ) + { + char *temp = strdup( id ); + char *arg = strchr( temp, ':' ) + 1; + *( arg - 1 ) = '\0'; + instance = mlt_factory_filter( profile.get_profile(), temp, arg ); + free( temp ); + } + else + { + instance = mlt_factory_filter( profile.get_profile(), id, NULL ); + } + } } -int Filter::connect( Service &service, int index ) +Filter::Filter( Service &filter ) : + instance( NULL ) { - return mlt_filter_connect( get_filter( ), service.get_service( ), index ); + if ( filter.type( ) == filter_type ) + { + instance = ( mlt_filter )filter.get_service( ); + inc_ref( ); + } } -void Filter::set_in_and_out( mlt_position in, mlt_position out ) +Filter::Filter( Filter &filter ) : + Mlt::Service( filter ), + instance( filter.get_filter( ) ) { - mlt_filter_set_in_and_out( get_filter( ), in, out ); + inc_ref( ); } -mlt_position Filter::get_in( ) +Filter::Filter( mlt_filter filter ) : + instance( filter ) { - return mlt_filter_get_in( get_filter( ) ); + inc_ref( ); } -mlt_position Filter::get_out( ) +Filter::~Filter( ) { - return mlt_filter_get_out( get_filter( ) ); + mlt_filter_close( instance ); } -int Filter::get_track( ) +mlt_filter Filter::get_filter( ) { - return mlt_filter_get_track( get_filter( ) ); + return instance; +} + +mlt_service Filter::get_service( ) +{ + return mlt_filter_service( get_filter( ) ); } -mlt_filter FilterInstance::get_filter( ) +int Filter::connect( Service &service, int index ) { - return instance; + return mlt_filter_connect( get_filter( ), service.get_service( ), index ); } -FilterInstance::FilterInstance( char *id, char *service ) : - destroy( true ), - instance( NULL ) +void Filter::set_in_and_out( int in, int out ) { - instance = mlt_factory_filter( id, service ); + mlt_filter_set_in_and_out( get_filter( ), in, out ); } -FilterInstance::FilterInstance( Filter &filter ) : - destroy( false ), - instance( filter.get_filter( ) ) +int Filter::get_in( ) { + return mlt_filter_get_in( get_filter( ) ); } -FilterInstance::FilterInstance( mlt_filter filter ) : - destroy( false ), - instance( filter ) +int Filter::get_out( ) { + return mlt_filter_get_out( get_filter( ) ); } -FilterInstance::~FilterInstance( ) +int Filter::get_track( ) { - if ( destroy ) - mlt_filter_close( instance ); + return mlt_filter_get_track( get_filter( ) ); }