]> git.sesse.net Git - mlt/blobdiff - mlt++/src/MltProperties.cpp
More event stuff
[mlt] / mlt++ / src / MltProperties.cpp
index 72dcba3dc790d152f2127b5298b088b0a0f0ebc8..13b8198490f41130a8790f9df854dee3ee7ec0c6 100644 (file)
  */
 
 #include "MltProperties.h"
+#include "MltEvent.h"
 using namespace Mlt;
 
-PropertiesInstance::PropertiesInstance( ) :
-       destroy( true ),
+Properties::Properties( ) :
        instance( NULL )
 {
        instance = mlt_properties_new( );
 }
 
-PropertiesInstance::PropertiesInstance( Properties &properties ) :
-       destroy( false ),
+Properties::Properties( bool dummy ) :
+       instance( NULL )
+{
+}
+
+Properties::Properties( Properties &properties ) :
        instance( properties.get_properties( ) )
 {
+       fprintf( stderr, "Incrementing ref count on properties #1\n" );
+       inc_ref( );
 }
 
-PropertiesInstance::PropertiesInstance( mlt_properties properties ) :
-       destroy( false ),
+Properties::Properties( mlt_properties properties ) :
        instance( properties )
 {
+       fprintf( stderr, "Incrementing ref count on properties #2\n" );
+       inc_ref( );
 }
 
-PropertiesInstance::~PropertiesInstance( )
+Properties::Properties( char *file ) :
+       instance( NULL )
 {
-       if ( destroy )
-               mlt_properties_close( instance );
+       instance = mlt_properties_load( file );
+}
+
+Properties::~Properties( )
+{
+       mlt_properties_close( instance );
+}
+
+mlt_properties Properties::get_properties( )
+{
+       return instance;
+}
+
+int Properties::inc_ref( )
+{
+       return mlt_properties_inc_ref( get_properties( ) );
+}
+
+int Properties::dec_ref( )
+{
+       return mlt_properties_dec_ref( get_properties( ) );
+}
+
+bool Properties::is_valid( )
+{
+       return get_properties( ) != NULL;
 }
 
 int Properties::count( )
@@ -91,9 +123,92 @@ int Properties::set( char *name, void *value, int size, mlt_destructor destructo
        return mlt_properties_set_data( get_properties( ), name, value, size, destructor, serialiser );
 }
 
-mlt_properties PropertiesInstance::get_properties( )
+int Properties::pass_values( Properties &that, char *prefix )
 {
-       return instance;
+       return mlt_properties_pass( get_properties( ), that.get_properties( ), prefix );
+}
+
+int Properties::parse( char *namevalue )
+{
+       return mlt_properties_parse( get_properties( ), namevalue );
+}
+
+char *Properties::get_name( int index )
+{
+       return mlt_properties_get_name( get_properties( ), index );
+}
+
+char *Properties::get( int index )
+{
+       return mlt_properties_get_value( get_properties( ), index );
+}
+
+void *Properties::get_data( int index, int &size )
+{
+       return mlt_properties_get_data_at( get_properties( ), index, &size );
+}
+
+void Properties::mirror( Properties &that )
+{
+       mlt_properties_mirror( get_properties( ), that.get_properties( ) );
+}
+
+int Properties::inherit( Properties &that )
+{
+       return mlt_properties_inherit( get_properties( ), that.get_properties( ) );
+}
+
+int Properties::rename( char *source, char *dest )
+{
+       return mlt_properties_rename( get_properties( ), source, dest );
+}
+
+void Properties::dump( FILE *output )
+{
+       mlt_properties_dump( get_properties( ), output );
 }
 
+void Properties::debug( char *title, FILE *output )
+{
+       mlt_properties_debug( get_properties( ), title, 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;
+}
+
+void Properties::listen( char *id, void *object, mlt_listener listener )
+{
+       char key[ 128 ];
+       mlt_event event = mlt_events_listen( get_properties( ), object, id, listener );
+       if ( event != NULL )
+       {
+               sprintf( key, "_%p", event );
+               mlt_properties_set_data( get_properties( ), key, event, 0, ( mlt_destructor )mlt_event_close, NULL );
+       }
+}
+
+Event *Properties::setup_wait_for( char *id )
+{
+       return new Event( mlt_events_setup_wait_for( get_properties( ), id ) );
+}
+
+void Properties::wait_for( Event *event, bool destroy )
+{
+       mlt_events_wait_for( get_properties( ), event->get_event( ) );
+       if ( destroy )
+               mlt_events_close_wait_for( get_properties( ), event->get_event( ) );
+}