+ int multi = 0;
+ int qglsl = 0;
+
+ for ( i = 1; i < argc; i ++ ) {
+ // See if we need multi consumer.
+ multi += !strcmp( argv[i], "-consumer" );
+ // Seee if we need the qglsl variant of multi consumer.
+ if ( !strncmp( argv[i], "glsl.", 5 ) || !strncmp( argv[i], "movit.", 6 ) )
+ qglsl = 1;
+ }
+ // Disable qglsl if xgl is being used!
+ for ( i = 1; qglsl && i < argc; i ++ )
+ if ( !strcmp( argv[i], "xgl" ) )
+ qglsl = 0;
+
+ if ( multi > 1 || qglsl )
+ {
+ // If there is more than one -consumer use the 'multi' consumer.
+ int k = 0;
+ char key[20];
+
+ if ( *consumer )
+ mlt_consumer_close( *consumer );
+ *consumer = create_consumer( profile, ( qglsl? "qglsl" : "multi" ) );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( *consumer );
+ for ( i = 1; i < argc; i ++ )
+ {
+ if ( !strcmp( argv[ i ], "-consumer" ) && argv[ i + 1 ])
+ {
+ // Create a properties object for each sub-consumer
+ mlt_properties new_props = mlt_properties_new();
+ snprintf( key, sizeof(key), "%d", k++ );
+ mlt_properties_set_data( properties, key, new_props, 0,
+ (mlt_destructor) mlt_properties_close, NULL );
+ if ( strchr( argv[i + 1], ':' ) )
+ {
+ char *temp = strdup( argv[++i] );
+ char *service = temp;
+ char *target = strchr( temp, ':' );
+ *target++ = 0;
+ mlt_properties_set( new_props, "mlt_service", service );
+ mlt_properties_set( new_props, "target", target );
+ }
+ else
+ {
+ mlt_properties_set( new_props, "mlt_service", argv[ ++i ] );
+ }
+ while ( argv[ i + 1 ] && strchr( argv[ i + 1 ], '=' ) )
+ mlt_properties_parse( new_props, argv[ ++ i ] );
+ }
+ }
+ }
+ else for ( i = 1; i < argc; i ++ )