* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <stdlib.h>
+#include <string.h>
#include "MltConsumer.h"
+#include "MltEvent.h"
+#include "MltProfile.h"
using namespace Mlt;
-Consumer::Consumer( char *id, char *service ) :
- destroy( true ),
+Consumer::Consumer( ) :
instance( NULL )
{
- instance = mlt_factory_consumer( id, service );
+ 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, char *id, char *arg ) :
+ instance( NULL )
+{
+ if ( id == NULL || arg != NULL )
+ {
+ instance = mlt_factory_consumer( profile.get_profile(), id, arg );
+ }
+ else
+ {
+ if ( strchr( id, ':' ) )
+ {
+ char *temp = strdup( id );
+ char *arg = strchr( temp, ':' ) + 1;
+ *( arg - 1 ) = '\0';
+ instance = mlt_factory_consumer( profile.get_profile(), temp, arg );
+ free( temp );
+ }
+ else
+ {
+ instance = mlt_factory_consumer( profile.get_profile(), id, NULL );
+ }
+ }
+}
+
+Consumer::Consumer( Service &consumer ) :
+ instance( NULL )
+{
+ if ( consumer.type( ) == consumer_type )
+ {
+ instance = ( mlt_consumer )consumer.get_service( );
+ inc_ref( );
+ }
}
Consumer::Consumer( Consumer &consumer ) :
- destroy( false ),
instance( consumer.get_consumer( ) )
{
+ inc_ref( );
}
Consumer::Consumer( mlt_consumer consumer ) :
- destroy( false ),
instance( consumer )
{
+ inc_ref( );
}
Consumer::~Consumer( )
{
- if ( destroy )
- {
- stop( );
- mlt_consumer_close( instance );
- }
+ mlt_consumer_close( instance );
}
mlt_consumer Consumer::get_consumer( )
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;
+}