Constructor clean up
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 21 Aug 2004 16:50:53 +0000 (16:50 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 21 Aug 2004 16:50:53 +0000 (16:50 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@384 d19143bc-622f-0410-bfdd-b5b2a6649095

mlt++/src/MltConsumer.cpp
mlt++/src/MltFilter.cpp
mlt++/src/MltProperties.cpp
mlt++/src/MltProperties.h
mlt++/src/MltTransition.cpp

index 370101d..6fdcbc2 100644 (file)
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <stdlib.h>
+#include <string.h>
 #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 ) :
index afb3916..9fa0439 100644 (file)
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <stdlib.h>
+#include <string.h>
 #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 ) :
index 8725d20..40d7081 100644 (file)
@@ -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;
+}
index ead92bf..1734200 100644 (file)
@@ -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 );
        };
 }
 
index f858614..2456a78 100644 (file)
@@ -18,6 +18,8 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <stdlib.h>
+#include <string.h>
 #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 ) :