#include "mlt.h"
#include "mlt_repository.h"
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
mlt_prefix = strdup( prefix );
// Create the object list.
- object_list = calloc( sizeof( struct mlt_properties_s ), 1 );
- mlt_properties_init( object_list, NULL );
+ object_list = mlt_properties_new( );
// Create a repository for each service type
producers = mlt_repository_init( object_list, prefix, "producers.dat", "mlt_create_producer" );
void mlt_field_close( mlt_field this )
{
- //mlt_tractor_close( this->tractor );
- //mlt_multitrack_close( this->multitrack );
free( this );
}
struct mlt_repository_s
{
struct mlt_properties_s parent;
- mlt_properties object_list;
};
static char *construct_full_file( char *output, char *prefix, char *file )
static mlt_properties construct_object( char *prefix, char *id )
{
mlt_properties output = mlt_properties_new( );
- mlt_properties_init( output, NULL );
mlt_properties_set( output, "prefix", prefix );
mlt_properties_set( output, "id", id );
return output;
static mlt_properties construct_service( mlt_properties object, char *id )
{
mlt_properties output = mlt_properties_new( );
- mlt_properties_init( output, NULL );
mlt_properties_set_data( output, "object", object, 0, NULL, NULL );
mlt_properties_set( output, "id", id );
return output;
fprintf( stderr, "Failed to load plugin: %s\n", dlerror() );
// Set it on the properties
- mlt_properties_set_data( object_properties, "dlopen", object, 0, ( void (*)( void * ) )dlclose, NULL );
+ mlt_properties_set_data( object_properties, "dlopen", object, 0, ( mlt_destructor )dlclose, NULL );
}
// Now check if we have this symbol pointer
// Add the symbol to THIS repository properties.
mlt_properties_set( &this->parent, "_symbol", symbol );
- // Asociate the repository to the global object_list
- this->object_list = object_list;
-
// Construct full file
construct_full_file( full_file, prefix, data );
*/
static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int track );
+static void producer_close( mlt_producer this );
/** Constructor for the tractor.
mlt_producer producer = &this->parent;
if ( mlt_producer_init( producer, this ) == 0 )
{
- producer->get_frame = producer_get_frame;
mlt_properties_set( mlt_producer_properties( producer ), "resource", "<tractor>" );
mlt_properties_set( mlt_producer_properties( producer ), "mlt_type", "mlt_producer" );
mlt_properties_set( mlt_producer_properties( producer ), "mlt_service", "tractor" );
+
+ producer->get_frame = producer_get_frame;
+ producer->close = producer_close;
}
else
{
void mlt_tractor_close( mlt_tractor this )
{
+ this->parent.close = NULL;
mlt_producer_close( &this->parent );
free( this );
}
+/** Close the producer.
+*/
+
+void producer_close( mlt_producer this )
+{
+ mlt_tractor_close( this->child );
+}
+
// Get inigo's properties
mlt_properties inigo_props = mlt_producer_properties( inigo );
- // Get the field service from inigo
- mlt_field field = mlt_properties_get_data( inigo_props, "field", 0 );
-
// Get the last group
mlt_properties group = mlt_properties_get_data( inigo_props, "group", 0 );
mlt_properties properties = mlt_consumer_properties( consumer );
mlt_properties_inherit( properties, group );
- // Connect consumer to tractor
- mlt_consumer_connect( consumer, mlt_field_service( field ) );
+ // Connect consumer to inigo
+ mlt_consumer_connect( consumer, mlt_producer_service( inigo ) );
// Start the consumer
mlt_consumer_start( consumer );
{
// 1st Line preferences
if ( strstr( file, ".inigo" ) )
- {
- char *args[ 2 ] = { file, NULL };
- result = mlt_factory_producer( "inigo", args );
- }
+ result = mlt_factory_producer( "inigo_file", file );
else if ( strstr( file, ".westley" ) )
result = mlt_factory_producer( "westley", file );
else if ( strstr( file, ".mpg" ) )
-SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo avformat vorbis westley
+SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo avformat vorbis speex westley
all clean depend install:
list='$(SUBDIRS)'; \
mlt_properties properties = mlt_filter_properties( this );
mlt_filter_init( this, NULL );
this->process = filter_process;
- mlt_properties_set( properties, "start", "40,40:20x20" );
+ mlt_properties_set( properties, "start", "0,0:100x100" );
mlt_properties_set( properties, "end", "" );
return this;
}
cat << EOF >> ../producers.dat
inigo libmltinigo.so
+inigo_file libmltinigo.so
EOF
fi
void *mlt_create_producer( char *id, void *arg )
{
+ if ( !strcmp( id, "inigo_file" ) )
+ return producer_inigo_file_init( arg );
if ( !strcmp( id, "inigo" ) )
return producer_inigo_init( arg );
return NULL;
#include <framework/mlt.h>
-static mlt_producer parse_inigo( char *file )
+mlt_producer producer_inigo_file_init( char *file )
{
FILE *input = fopen( file, "r" );
char **args = calloc( sizeof( char * ), 1000 );
return result;
}
-static mlt_producer create_producer( char *file )
+static void track_service( mlt_field field, void *service, mlt_destructor destructor )
+{
+ mlt_properties properties = mlt_field_properties( field );
+ int registered = mlt_properties_get_int( properties, "registered" );
+ char *key = mlt_properties_get( properties, "registered" );
+ mlt_properties_set_data( properties, key, service, 0, destructor, NULL );
+ mlt_properties_set_int( properties, "registered", ++ registered );
+}
+
+static mlt_producer create_producer( mlt_field field, char *file )
{
mlt_producer result = NULL;
// 1st Line preferences
if ( strstr( file, ".inigo" ) )
- result = parse_inigo( file );
+ result = mlt_factory_producer( "inigo_file", file );
else if ( strstr( file, ".mpg" ) )
result = mlt_factory_producer( "mcmpeg", file );
else if ( strstr( file, ".mpeg" ) )
if ( result == NULL )
result = mlt_factory_producer( "ffmpeg", file );
- return result;
-}
+ if ( result != NULL )
+ track_service( field, result, ( mlt_destructor )mlt_producer_close );
-static void track_service( mlt_field field, void *service, mlt_destructor destructor )
-{
- mlt_properties properties = mlt_field_properties( field );
- int registered = mlt_properties_get_int( properties, "registered" );
- char *key = mlt_properties_get( properties, "registered" );
- mlt_properties_set_data( properties, key, service, 0, destructor, NULL );
- mlt_properties_set_int( properties, "registered", ++ registered );
+ return result;
}
static mlt_filter create_filter( mlt_field field, char *id, int track )
mlt_playlist_append( playlist, producer );
producer = NULL;
mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track ++ );
+ track_service( field, playlist, ( mlt_destructor )mlt_playlist_close );
playlist = mlt_playlist_init( );
}
else if ( strstr( argv[ i ], "=" ) )
{
if ( producer != NULL )
mlt_playlist_append( playlist, producer );
- producer = create_producer( argv[ i ] );
+ producer = create_producer( field, argv[ i ] );
if ( producer != NULL )
{
properties = mlt_producer_properties( producer );
}
}
- // Connect producer to playlist
+ // Connect last producer to playlist
if ( producer != NULL )
mlt_playlist_append( playlist, producer );
- // We must have a producer at this point
+ // Track the last playlist too
+ track_service( field, playlist, ( mlt_destructor )mlt_playlist_close );
+
+ // We must have a playlist to connect
if ( mlt_playlist_count( playlist ) > 0 )
- {
- // Connect multitrack to producer
mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track );
- }
mlt_tractor tractor = mlt_field_tractor( field );
mlt_producer prod = mlt_tractor_producer( tractor );
#include <framework/mlt_producer.h>
+extern mlt_producer producer_inigo_file_init( char *args );
extern mlt_producer producer_inigo_init( char **args );
#endif
/*
- * producer_libdv.c -- a libxml2 parser of mlt service networks
+ * producer_westley.c -- a libxml2 parser of mlt service networks
* Copyright (C) 2003-2004 Ushodaya Enterprises Limited
* Author: Dan Dennedy <dan@dennedy.org>
*
mlt_producer producer_westley_init( char *filename )
{
+ static int init = 0;
xmlSAXHandler *sax = calloc( 1, sizeof( xmlSAXHandler ) );
struct deserialise_context_s *context = calloc( 1, sizeof( struct deserialise_context_s ) );
+ mlt_properties properties = NULL;
+ int i = 0;
context->producer_map = mlt_properties_new();
context->destructors = mlt_properties_new();
sax->startElement = on_start_element;
sax->endElement = on_end_element;
- xmlInitParser();
+ if ( !init )
+ {
+ xmlInitParser();
+ init = 1;
+ }
+
xmlSAXUserParseFile( sax, context, filename );
- xmlCleanupParser();
free( sax );
- mlt_properties_close( context->producer_map );
+ // Need the complete producer list for various reasons
+ properties = context->destructors;
+ // Get the last producer on the stack
mlt_service service = context_pop_service( context );
- // make the returned service destroy the connected services
- mlt_properties_set_data( mlt_service_properties( service ), "__destructors__", context->destructors, 0, (mlt_destructor) mlt_properties_close, NULL );
- free( context );
- mlt_properties_set( mlt_service_properties( service ), "resource", filename );
+ // Do we actually have a producer here?
+ if ( service != NULL )
+ {
+ // Now make sure we don't have a reference to the service in the properties
+ for ( i = mlt_properties_count( properties ) - 1; i >= 1; i -- )
+ {
+ char *name = mlt_properties_get_name( properties, i );
+ if ( mlt_properties_get_data( properties, name, NULL ) == service )
+ {
+ mlt_properties_set_data( properties, name, service, 0, NULL, NULL );
+ break;
+ }
+ }
+
+ // make the returned service destroy the connected services
+ mlt_properties_set_data( mlt_service_properties( service ), "__destructors__", context->destructors, 0, (mlt_destructor) mlt_properties_close, NULL );
+
+ // Now assign additional properties
+ mlt_properties_set( mlt_service_properties( service ), "resource", filename );
+ }
+ else
+ {
+ // Clean up
+ mlt_properties_close( properties );
+ }
+
+ free( context->stack_service );
+ mlt_properties_close( context->producer_map );
+ free( context );
return MLT_PRODUCER( service );
}