From 1a4cf7f5285d16d0530ea03c2b524be7c1aa5dbc Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Sat, 21 Aug 2004 16:50:53 +0000 Subject: [PATCH] Constructor clean up git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@384 d19143bc-622f-0410-bfdd-b5b2a6649095 --- mlt++/src/MltConsumer.cpp | 24 ++++++++++++++++++++++-- mlt++/src/MltFilter.cpp | 24 ++++++++++++++++++++++-- mlt++/src/MltProperties.cpp | 16 ++++++++++++++++ mlt++/src/MltProperties.h | 4 +++- mlt++/src/MltTransition.cpp | 22 +++++++++++++++++++++- 5 files changed, 84 insertions(+), 6 deletions(-) diff --git a/mlt++/src/MltConsumer.cpp b/mlt++/src/MltConsumer.cpp index 370101d..6fdcbc2 100644 --- a/mlt++/src/MltConsumer.cpp +++ b/mlt++/src/MltConsumer.cpp @@ -18,14 +18,34 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include #include "MltConsumer.h" using namespace Mlt; -Consumer::Consumer( char *id, char *service ) : +Consumer::Consumer( char *id, char *arg ) : destroy( true ), instance( NULL ) { - instance = mlt_factory_consumer( id, service ); + if ( arg != NULL ) + { + instance = mlt_factory_consumer( id, arg ); + } + else + { + if ( strchr( id, ':' ) ) + { + char *temp = strdup( id ); + char *arg = strchr( temp, ':' ) + 1; + *( arg - 1 ) = '\0'; + instance = mlt_factory_consumer( temp, arg ); + free( temp ); + } + else + { + instance = mlt_factory_consumer( id, NULL ); + } + } } Consumer::Consumer( Consumer &consumer ) : diff --git a/mlt++/src/MltFilter.cpp b/mlt++/src/MltFilter.cpp index afb3916..9fa0439 100644 --- a/mlt++/src/MltFilter.cpp +++ b/mlt++/src/MltFilter.cpp @@ -18,14 +18,34 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include #include "MltFilter.h" using namespace Mlt; -Filter::Filter( char *id, char *service ) : +Filter::Filter( char *id, char *arg ) : destroy( true ), instance( NULL ) { - instance = mlt_factory_filter( id, service ); + if ( arg != NULL ) + { + instance = mlt_factory_filter( id, arg ); + } + else + { + if ( strchr( id, ':' ) ) + { + char *temp = strdup( id ); + char *arg = strchr( temp, ':' ) + 1; + *( arg - 1 ) = '\0'; + instance = mlt_factory_filter( temp, arg ); + free( temp ); + } + else + { + instance = mlt_factory_filter( id, NULL ); + } + } } Filter::Filter( Filter &filter ) : diff --git a/mlt++/src/MltProperties.cpp b/mlt++/src/MltProperties.cpp index 8725d20..40d7081 100644 --- a/mlt++/src/MltProperties.cpp +++ b/mlt++/src/MltProperties.cpp @@ -152,3 +152,19 @@ void Properties::dump( FILE *output ) { mlt_properties_dump( get_properties( ), output ); } + +int Properties::save( char *file ) +{ + int error = 0; + FILE *f = fopen( file, "w" ); + if ( f != NULL ) + { + dump( f ); + fclose( f ); + } + else + { + error = 1; + } + return error; +} diff --git a/mlt++/src/MltProperties.h b/mlt++/src/MltProperties.h index ead92bf..1734200 100644 --- a/mlt++/src/MltProperties.h +++ b/mlt++/src/MltProperties.h @@ -34,13 +34,14 @@ namespace Mlt private: bool destroy; mlt_properties instance; + protected: + virtual mlt_properties get_properties( ); public: Properties( ); Properties( Properties &properties ); Properties( mlt_properties properties ); Properties( char *file ); virtual ~Properties( ); - virtual mlt_properties get_properties( ); bool is_valid( ); int count( ); char *get( char *name ); @@ -60,6 +61,7 @@ namespace Mlt int inherit( Properties &that ); int rename( char *source, char *dest ); void dump( FILE *output = stderr ); + int save( char *file ); }; } diff --git a/mlt++/src/MltTransition.cpp b/mlt++/src/MltTransition.cpp index f858614..2456a78 100644 --- a/mlt++/src/MltTransition.cpp +++ b/mlt++/src/MltTransition.cpp @@ -18,6 +18,8 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include #include "MltTransition.h" using namespace Mlt; @@ -25,7 +27,25 @@ Transition::Transition( char *id, char *arg ) : destroy( true ), instance( NULL ) { - instance = mlt_factory_transition( id, arg ); + if ( arg != NULL ) + { + instance = mlt_factory_transition( id, arg ); + } + else + { + if ( strchr( id, ':' ) ) + { + char *temp = strdup( id ); + char *arg = strchr( temp, ':' ) + 1; + *( arg - 1 ) = '\0'; + instance = mlt_factory_transition( temp, arg ); + free( temp ); + } + else + { + instance = mlt_factory_transition( id, NULL ); + } + } } Transition::Transition( Transition &transition ) : -- 1.7.4.4