+ mlt_log_error( NULL, "[producer_xml] Invalid top of stack on transition close\n" );
+ }
+
+ if ( service )
+ {
+ mlt_service_close( service );
+ free( service );
+ }
+}
+
+static void on_start_consumer( deserialise_context context, const xmlChar *name, const xmlChar **atts)
+{
+ if ( context->pass == 1 )
+ {
+ mlt_properties properties = mlt_properties_new();
+
+ mlt_properties_set_lcnumeric( properties, context->lc_numeric );
+ context_push_service( context, (mlt_service) properties, mlt_dummy_consumer_type );
+
+ // Set the properties from attributes
+ for ( ; atts != NULL && *atts != NULL; atts += 2 )
+ mlt_properties_set( properties, (const char*) atts[0], (const char*) atts[1] );
+ }
+}
+
+static void on_end_consumer( deserialise_context context, const xmlChar *name )
+{
+ if ( context->pass == 1 )
+ {
+ // Get the consumer from the stack
+ enum service_type type;
+ mlt_properties properties = (mlt_properties) context_pop_service( context, &type );
+
+ if ( properties && type == mlt_dummy_consumer_type )
+ {
+ qualify_property( context, properties, "resource" );
+ qualify_property( context, properties, "target" );
+ char *resource = mlt_properties_get( properties, "resource" );
+
+ if ( context->multi_consumer > 1 || context->qglsl )
+ {
+ // Instantiate the multi consumer
+ if ( !context->consumer )
+ {
+ if ( context->qglsl )
+ context->consumer = context->qglsl;
+ else
+ context->consumer = mlt_factory_consumer( context->profile, "multi", NULL );
+ if ( context->consumer )
+ {
+ // Track this consumer
+ track_service( context->destructors, MLT_CONSUMER_SERVICE(context->consumer), (mlt_destructor) mlt_consumer_close );
+ mlt_properties_set_lcnumeric( MLT_CONSUMER_PROPERTIES(context->consumer), context->lc_numeric );
+ }
+ }
+ if ( context->consumer )
+ {
+ // Set this properties object on multi consumer
+ char key[20];
+ snprintf( key, sizeof(key), "%d", context->consumer_count++ );
+ mlt_properties_inc_ref( properties );
+ mlt_properties_set_data( MLT_CONSUMER_PROPERTIES(context->consumer), key, properties, 0,
+ (mlt_destructor) mlt_properties_close, NULL );
+ }
+ }
+ else
+ {
+ // Instantiate the consumer
+ char *id = trim( mlt_properties_get( properties, "mlt_service" ) );
+ context->consumer = mlt_factory_consumer( context->profile, id, resource );
+ if ( context->consumer )
+ {
+ // Track this consumer
+ track_service( context->destructors, MLT_CONSUMER_SERVICE(context->consumer), (mlt_destructor) mlt_consumer_close );
+ mlt_properties_set_lcnumeric( MLT_CONSUMER_PROPERTIES(context->consumer), context->lc_numeric );
+
+ // Inherit the properties
+ mlt_properties_inherit( MLT_CONSUMER_PROPERTIES(context->consumer), properties );
+ }
+ }
+ }
+ // Close the dummy
+ if ( properties )
+ mlt_properties_close( properties );