Constness changes
[melted] / mlt++ / src / MltConsumer.cpp
index 657c816..1b5c4df 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include "MltConsumer.h"
+#include "MltEvent.h"
+#include "MltProfile.h"
 using namespace Mlt;
 
-Consumer::Consumer( char *id, char *arg ) :
+Consumer::Consumer( ) :
        instance( NULL )
 {
-       if ( arg != NULL )
+       instance = mlt_factory_consumer( NULL, NULL, NULL );
+}
+
+Consumer::Consumer( Profile& profile ) :
+       instance( NULL )
+{
+       instance = mlt_factory_consumer( profile.get_profile(), NULL, NULL );
+}
+
+Consumer::Consumer( Profile& profile, const char *id, const char *arg ) :
+       instance( NULL )
+{
+       if ( id == NULL || arg != NULL )
        {
-               instance = mlt_factory_consumer( id, arg );
+               instance = mlt_factory_consumer( profile.get_profile(), id, arg );
        }
        else
        {
@@ -37,12 +51,12 @@ Consumer::Consumer( char *id, char *arg ) :
                        char *temp = strdup( id );
                        char *arg = strchr( temp, ':' ) + 1;
                        *( arg - 1 ) = '\0';
-                       instance = mlt_factory_consumer( temp, arg );
+                       instance = mlt_factory_consumer( profile.get_profile(), temp, arg );
                        free( temp );
                }
                else
                {
-                       instance = mlt_factory_consumer( id, NULL );
+                       instance = mlt_factory_consumer( profile.get_profile(), id, NULL );
                }
        }
 }
@@ -58,6 +72,7 @@ Consumer::Consumer( Service &consumer ) :
 }
 
 Consumer::Consumer( Consumer &consumer ) :
+       Mlt::Service( consumer ),
        instance( consumer.get_consumer( ) )
 {
        inc_ref( );
@@ -109,3 +124,14 @@ bool Consumer::is_stopped( )
        return mlt_consumer_is_stopped( get_consumer( ) ) != 0;
 }
 
+int Consumer::run( )
+{
+       int ret = start( );
+       if ( !is_stopped( ) )
+       {
+               Event *e = setup_wait_for( "consumer-stopped" );
+               wait_for( e );
+               delete e;
+       }
+       return ret;
+}