README
------
- This document provides a description of the VPS project organisation.
+ This document provides a description of the MLT project organisation.
It provides *CRITICAL* architecture information, so please read carefully
- if you plan to extend or use the VPS code base.
+ if you plan to extend or use the MLT code base.
Directories
-----------
+ docs - Location of all text and source format
documentation
+ src - All project source is provided here
- + client - Client API to access the server
+ framework - The media framework - this code is 100% posix
and as such contain no implementations
requiring additional libraries
+ ffmpeg - ffmpeg dependent modules and test code
+ mainconcept - mainconcept dependent modules and test code
+ SDL - SDL dependent modules and test code
- + server - The server implementation
+ + valerie - Client API to access the server
+ + miracle - The server implementation
Additional subdirectories may be nested below those shown and should be
documented in their parent or here.
README
------
- This document provides a description of the VPS project organisation.
+ This document provides a description of the MLT project organisation.
It provides *CRITICAL* architecture information, so please read carefully
- if you plan to extend or use the VPS code base.
+ if you plan to extend or use the MLT code base.
Directories
-----------
+ docs - Location of all text and source format
documentation
+ src - All project source is provided here
- + client - Client API to access the server
+ framework - The media framework - this code is 100% posix
and as such contain no implementations
requiring additional libraries
+ ffmpeg - ffmpeg dependent modules and test code
+ mainconcept - mainconcept dependent modules and test code
+ SDL - SDL dependent modules and test code
- + server - The server implementation
+ + valerie - Client API to access the server
+ + miracle - The server implementation
Additional subdirectories may be nested below those shown and should be
documented in their parent or here.
SRCS := $(OBJS:.o=.c)
-CFLAGS=-g -Wall -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -pthread
-all: libmlt.a
+LDFLAGS = -lm -ldl -lpthread
-libmlt.a: $(OBJS)
- $(AR) rvu $@ $(OBJS)
- ranlib $@
+all: libmlt.so
+
+libmlt.so: $(OBJS)
+ $(CC) -shared -o $@ $(OBJS) $(LDFLAGS)
depend: $(SRCS)
$(CC) -MM $(CFLAGS) $^ 1>.depend
rm -f .depend
clean:
- rm -f $(FRAMEWORK_OBJS) libmlt.a
+ rm -f $(FRAMEWORK_OBJS) libmlt.so
ifneq ($(wildcard .depend),)
include .depend
--- /dev/null
+/*
+ * mlt.h -- header file for lazy client and implementation code :-)
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _MLT_H_
+#define _MLT_H_
+
+#include "mlt_factory.h"
+#include "mlt_frame.h"
+#include "mlt_multitrack.h"
+#include "mlt_producer.h"
+#include "mlt_transition.h"
+#include "mlt_consumer.h"
+#include "mlt_filter.h"
+#include "mlt_manager.h"
+#include "mlt_playlist.h"
+#include "mlt_properties.h"
+#include "mlt_tractor.h"
+
+#endif
+
#include "config.h"
#include "mlt_factory.h"
#include "mlt_repository.h"
+#include "mlt_properties.h"
#include <stdlib.h>
/** Singleton repositories
*/
+static mlt_properties object_list = NULL;
static mlt_repository producers = NULL;
static mlt_repository filters = NULL;
static mlt_repository transitions = NULL;
/** Construct the factories.
*/
-int mlt_factory_init( )
+int mlt_factory_init( char *prefix )
{
- producers = mlt_repository_init( PREFIX_DATA "/producers.dat", "mlt_create_producer" );
- filters = mlt_repository_init( PREFIX_DATA "/filters.dat", "mlt_create_filter" );
- transitions = mlt_repository_init( PREFIX_DATA "/transitions.dat", "mlt_create_transition" );
- consumers = mlt_repository_init( PREFIX_DATA "/consumers.dat", "mlt_create_consumer" );
+ // If no directory is specified, default to install directory
+ if ( prefix == NULL )
+ prefix = PREFIX_DATA;
+
+ // Create the object list.
+ object_list = calloc( sizeof( struct mlt_properties_s ), 1 );
+ mlt_properties_init( object_list, NULL );
+
+ // Create a repository for each service type
+ producers = mlt_repository_init( object_list, prefix, "producers.dat", "mlt_create_producer" );
+ filters = mlt_repository_init( object_list, prefix, "filters.dat", "mlt_create_filter" );
+ transitions = mlt_repository_init( object_list, prefix, "transitions.dat", "mlt_create_transition" );
+ consumers = mlt_repository_init( object_list, prefix, "consumers.dat", "mlt_create_consumer" );
+
return 0;
}
/** Fetch a transition from the repository.
*/
-mlt_transition mlt_transition_filter( char *service, void *input )
+mlt_transition mlt_factory_transition( char *service, void *input )
{
return ( mlt_transition )mlt_repository_fetch( transitions, service, input );
}
mlt_repository_close( filters );
mlt_repository_close( transitions );
mlt_repository_close( consumers );
+ mlt_properties_close( object_list );
+ free( object_list );
}
#include "mlt_types.h"
-extern int mlt_factory_init( );
+extern int mlt_factory_init( char *prefix );
extern mlt_producer mlt_factory_producer( char *name, void *input );
extern mlt_filter mlt_factory_filter( char *name, void *input );
extern mlt_transition mlt_factory_transition( char *name, void *input );
mlt_producer_prepare_next( parent );
}
- fprintf( stderr, "timestamp for %d = %f\n", index, ( float )mlt_frame_get_timecode( *frame ) );
-
return 0;
}
extern mlt_service mlt_playlist_service( mlt_playlist this );
extern int mlt_playlist_append( mlt_playlist this, mlt_producer producer );
extern int mlt_playlist_pad( mlt_playlist this, mlt_timecode length );
-extern mlt_playlist_close( mlt_playlist this );
+extern void mlt_playlist_close( mlt_playlist this );
#endif
*/
#include "mlt_repository.h"
+#include "mlt_properties.h"
+
+#include <stdio.h>
#include <stdlib.h>
+#include <dlfcn.h>
+#include <string.h>
struct mlt_repository_s
{
+ struct mlt_properties_s parent;
+ mlt_properties object_list;
};
-mlt_repository mlt_repository_init( char *file, char *symbol )
+static char *construct_full_file( char *output, char *prefix, char *file )
{
- return NULL;
+ strcpy( output, prefix );
+ if ( prefix[ strlen( prefix ) - 1 ] != '/' )
+ strcat( output, "/" );
+ strcat( output, file );
+ return output;
+}
+
+static char *chomp( char *input )
+{
+ if ( input[ strlen( input ) - 1 ] == '\n' )
+ input[ strlen( input ) - 1 ] = '\0';
+ return input;
+}
+
+static mlt_properties construct_object( char *prefix, char *id )
+{
+ mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 );
+ 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 = calloc( sizeof( struct mlt_properties_s ), 1 );
+ mlt_properties_init( output, NULL );
+ mlt_properties_set_data( output, "object", object, 0, NULL, NULL );
+ mlt_properties_set( output, "id", id );
+ return output;
+}
+
+void *construct_instance( mlt_properties service_properties, char *symbol, void *input )
+{
+ // Extract the service
+ char *service = mlt_properties_get( service_properties, "id" );
+
+ // Get the object properties
+ void *object_properties = mlt_properties_get_data( service_properties, "object", NULL );
+
+ // Get the dlopen'd object
+ void *object = mlt_properties_get_data( object_properties, "dlopen", NULL );
+
+ // Get the dlsym'd symbol
+ void *( *symbol_ptr )( char *, void * ) = mlt_properties_get_data( object_properties, symbol, NULL );
+
+ // Check that we have object and open if we don't
+ if ( object == NULL )
+ {
+ char full_file[ 512 ];
+
+ // Get the prefix and id of the shared object
+ char *prefix = mlt_properties_get( object_properties, "prefix" );
+ char *file = mlt_properties_get( object_properties, "id" );
+
+ // Construct the full file
+ construct_full_file( full_file, prefix, file );
+
+ // Open the shared object
+ object = dlopen( full_file, RTLD_NOW | RTLD_GLOBAL );
+
+ // Set it on the properties
+ mlt_properties_set_data( object_properties, "dlopen", object, 0, ( void (*)( void * ) )dlclose, NULL );
+ }
+
+ // Now check if we have this symbol pointer
+ if ( object != NULL && symbol_ptr == NULL )
+ {
+ // Construct it now
+ symbol_ptr = dlsym( object, symbol );
+
+ // Set it on the properties
+ mlt_properties_set_data( object_properties, "dlsym", symbol_ptr, 0, NULL, NULL );
+ }
+
+ // Construct the service
+ return symbol_ptr != NULL ? symbol_ptr( service, input ) : NULL;
+}
+
+void destroy_properties( void *arg )
+{
+ mlt_properties_close( arg );
+ free( arg );
+}
+
+mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *data, char *symbol )
+{
+ char full_file[ 512 ];
+ FILE *file;
+
+ // Construct the repository
+ mlt_repository this = calloc( sizeof( struct mlt_repository_s ), 1 );
+ mlt_properties_init( &this->parent, NULL );
+
+ // 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 );
+
+ // Open the file
+ file = fopen( full_file, "r" );
+
+ // Parse the contents
+ if ( file != NULL )
+ {
+ char full[ 512 ];
+ char service[ 256 ];
+ char object[ 256 ];
+
+ while( fgets( full, 512, file ) )
+ {
+ chomp( full );
+
+ if ( full[ 0 ] != '#' && full[ 0 ] != '\0' && sscanf( full, "%s %s", service, object ) == 2 )
+ {
+ // Get the object properties first
+ mlt_properties object_properties = mlt_properties_get_data( object_list, object, NULL );
+
+ // If their are no properties, create them now
+ if ( object_properties == NULL )
+ {
+ // Construct the object
+ object_properties = construct_object( prefix, object );
+
+ // Add it to the object list
+ mlt_properties_set_data( object_list, object, object_properties, 0, destroy_properties, NULL );
+ }
+
+ // Now construct a property for the service
+ mlt_properties service_properties = construct_service( object_properties, service );
+
+ // Add it to the repository
+ mlt_properties_set_data( &this->parent, service, service_properties, 0, destroy_properties, NULL );
+ }
+ }
+
+ // Close the file
+ fclose( file );
+ }
+
+ return this;
}
void *mlt_repository_fetch( mlt_repository this, char *service, void *input )
{
+ // Get the service properties
+ mlt_properties service_properties = mlt_properties_get_data( &this->parent, service, NULL );
+
+ // If the service exists
+ if ( service_properties != NULL )
+ {
+ // Get the symbol that is used to generate this service
+ char *symbol = mlt_properties_get( &this->parent, "_symbol" );
+
+ // Now get an instance of the service
+ return construct_instance( service_properties, symbol, input );
+ }
+
return NULL;
}
void mlt_repository_close( mlt_repository this )
{
+ mlt_properties_close( &this->parent );
+ free( this );
}
#ifndef _MLT_REPOSITORY_H_
#define _MLT_REPOSITORY_H_
+#include "mlt_types.h"
+
/** Repository structure forward reference.
*/
/** Public functions.
*/
-extern mlt_repository mlt_repository_init( char *file, char *symbol );
+extern mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *file, char *symbol );
extern void *mlt_repository_fetch( mlt_repository this, char *service, void *input );
extern void mlt_repository_close( mlt_repository this );
-TARGET=libmltcore.so
+TARGET = ../libmltcore.so
OBJS = factory.o \
producer_ppm.o \
filter_greyscale.o \
transition_composite.o
-CFLAGS=-I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
SRCS := $(OBJS:.o=.c)
-TARGET = factory.o \
- libmltdv.so
+TARGET = ../libmltdv.so
-OBJS = producer_libdv.o
+OBJS = factory.o \
+ producer_libdv.o
-CFLAGS=-I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
LDFLAGS=-ldv -lpthread
-TARGET = libmltgtk2.so
+TARGET = ../libmltgtk2.so
OBJS = factory.o \
producer_pixbuf.o
-CFLAGS=`pkg-config gdk-pixbuf-2.0 --cflags` -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = `pkg-config gdk-pixbuf-2.0 --cflags` -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
-LDFLAGS=`pkg-config gdk-pixbuf-2.0 --libs`
+LDFLAGS = `pkg-config gdk-pixbuf-2.0 --libs`
SRCS := $(OBJS:.o=.c)
-TARGET = libmltsdl.so
+TARGET = ../libmltsdl.so
OBJS = factory.o \
consumer_sdl.o
-CFLAGS=-I../../ `sdl-config --cflags` -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -I../../ `sdl-config --cflags` -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
LDFLAGS= `sdl-config --libs`
--- /dev/null
+TARGET = dan charlie
+
+CFLAGS = -I .. -Wall -rdynamic -pthread
+
+LDFLAGS = -L ../framework -lmlt
+
+all: $(TARGET)
+
+dan: dan.o
+ $(CC) dan.o -o $@ $(LDFLAGS)
+
+charlie: charlie.o
+ $(CC) charlie.o -o $@ $(LDFLAGS)
+
+clean:
+ rm -f dan.o charlie.o dan charlie
+
+depend: dan.c charlie.c
+ $(CC) -MM $(CFLAGS) $^ 1>.depend
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
-#include "mlt_producer.h"
-#include "mlt_consumer.h"
-#include "mlt_filter.h"
-#include "mlt_tractor.h"
-#include "mlt_transition.h"
-#include "mlt_multitrack.h"
-
-#include "producer_libdv.h"
-#include "producer_ppm.h"
-#include "filter_deinterlace.h"
-#include "filter_greyscale.h"
-#include "consumer_sdl.h"
+#include <framework/mlt_factory.h>
+
+#include <framework/mlt_producer.h>
+#include <framework/mlt_consumer.h>
+#include <framework/mlt_filter.h>
+#include <framework/mlt_tractor.h>
+#include <framework/mlt_transition.h>
+#include <framework/mlt_multitrack.h>
#include <stdio.h>
char *file1 = NULL;
char *file2 = NULL;
- // Start the consumer...
- mlt_consumer sdl_out = consumer_sdl_init( NULL );
-
- fprintf( stderr, "Press return to continue\n" );
- fgets( temp, 132, stdin );
+ mlt_factory_init( "../modules" );
if ( argc >= 2 )
file1 = argv[ 1 ];
if ( argc >= 3 )
file2 = argv[ 2 ];
+ // Start the consumer...
+ mlt_consumer sdl_out = mlt_factory_consumer( "sdl", NULL );
+
+ fprintf( stderr, "Press return to continue\n" );
+ fgets( temp, 132, stdin );
+
// Create the producer(s)
+ mlt_producer dv1 = mlt_factory_producer( "libdv", file1 );
+ mlt_producer dv2 = mlt_factory_producer( "libdv", file2 );
//mlt_producer dv1 = producer_ppm_init( NULL );
//mlt_producer dv2 = producer_ppm_init( NULL );
- mlt_producer dv1 = producer_libdv_init( file1 );
- mlt_producer dv2 = producer_libdv_init( file2 );
+ // Connect a producer to our sdl consumer
mlt_consumer_connect( sdl_out, mlt_producer_service( dv1 ) );
fprintf( stderr, "Press return to continue\n" );
mlt_multitrack_connect( multitrack, dv2, 1 );
// Create a filter and associate it to track 0
- mlt_filter filter = filter_deinterlace_init( NULL );
+ mlt_filter filter = mlt_factory_filter( "deinterlace", NULL );
mlt_filter_connect( filter, mlt_multitrack_service( multitrack ), 0 );
mlt_filter_set_in_and_out( filter, 0, 5 );
// Create another
- mlt_filter greyscale = filter_greyscale_init( NULL );
+ mlt_filter greyscale = mlt_factory_filter( "greyscale", NULL );
mlt_filter_connect( greyscale, mlt_filter_service( filter ), 0 );
mlt_filter_set_in_and_out( greyscale, 0, 10 );
fgets( temp, 132, stdin );
// Close everything...
- mlt_consumer_close( sdl_out );
- mlt_tractor_close( tractor );
- mlt_filter_close( filter );
- mlt_multitrack_close( multitrack );
- mlt_producer_close( dv1 );
- mlt_producer_close( dv2 );
+ //mlt_consumer_close( sdl_out );
+ //mlt_tractor_close( tractor );
+ //mlt_filter_close( filter );
+ //mlt_filter_close( greyscale );
+ //mlt_multitrack_close( multitrack );
+ //mlt_producer_close( dv1 );
+ //mlt_producer_close( dv2 );
+
+ mlt_factory_close( );
return 0;
}
-#include "mlt_producer.h"
-#include "mlt_consumer.h"
-#include "mlt_filter.h"
-#include "mlt_tractor.h"
-#include "mlt_transition.h"
-#include "mlt_multitrack.h"
-#include "producer_libdv.h"
-#include "filter_deinterlace.h"
-#include "consumer_sdl.h"
-#include "producer_ppm.h"
-#include "producer_pixbuf.h"
-#include "transition_composite.h"
+#include <framework/mlt.h>
#include <stdio.h>
char *file1 = NULL;
char *file2 = NULL;
+ mlt_factory_init( "../modules" );
+
if ( argc >= 2 )
file1 = argv[ 1 ];
if ( argc >= 3 )
file2 = argv[ 2 ];
// Start the consumer...
- mlt_consumer sdl_out = consumer_sdl_init( NULL );
+ mlt_consumer sdl_out = mlt_factory_consumer( "sdl", NULL );
// Create the producer(s)
- mlt_producer dv1 = producer_libdv_init( file1 );
+ mlt_producer dv1 = mlt_factory_producer( "libdv", file1 );
//mlt_producer dv1 = producer_pixbuf_init( file1 );
//mlt_producer dv2 = producer_libdv_init( file2 );
- mlt_producer dv2 = producer_pixbuf_init( file2 );
+ mlt_producer dv2 = mlt_factory_producer( "pixbuf", file2 );
// Register producers(s) with a multitrack object
mlt_multitrack multitrack = mlt_multitrack_init( );
mlt_multitrack_connect( multitrack, dv2, 1 );
// Create a filter and associate it to track 0
- mlt_filter filter = filter_deinterlace_init( NULL );
+ mlt_filter filter = mlt_factory_filter( "deinterlace", NULL );
mlt_filter_connect( filter, mlt_multitrack_service( multitrack ), 0 );
mlt_filter_set_in_and_out( filter, 0, 1000 );
// Define a transition
- mlt_transition transition = transition_composite_init( NULL );
+ mlt_transition transition = mlt_factory_transition( "composite", NULL );
mlt_transition_connect( transition, mlt_filter_service( filter ), 0, 1 );
mlt_transition_set_in_and_out( transition, 0, 1000 );
fgets( temp, 132, stdin );
// Close everything...
- mlt_consumer_close( sdl_out );
- mlt_tractor_close( tractor );
- mlt_filter_close( filter );
- mlt_multitrack_close( multitrack );
- mlt_producer_close( dv1 );
- mlt_producer_close( dv2 );
+ //mlt_consumer_close( sdl_out );
+ //mlt_tractor_close( tractor );
+ //mlt_filter_close( filter );
+ //mlt_multitrack_close( multitrack );
+ //mlt_producer_close( dv1 );
+ //mlt_producer_close( dv2 );
return 0;
}
SRCS := $(OBJS:.o=.c)
-CFLAGS=-g -Wall -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -pthread
-all: libmlt.a
+LDFLAGS = -lm -ldl -lpthread
-libmlt.a: $(OBJS)
- $(AR) rvu $@ $(OBJS)
- ranlib $@
+all: libmlt.so
+
+libmlt.so: $(OBJS)
+ $(CC) -shared -o $@ $(OBJS) $(LDFLAGS)
depend: $(SRCS)
$(CC) -MM $(CFLAGS) $^ 1>.depend
rm -f .depend
clean:
- rm -f $(FRAMEWORK_OBJS) libmlt.a
+ rm -f $(FRAMEWORK_OBJS) libmlt.so
ifneq ($(wildcard .depend),)
include .depend
--- /dev/null
+/*
+ * mlt.h -- header file for lazy client and implementation code :-)
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _MLT_H_
+#define _MLT_H_
+
+#include "mlt_factory.h"
+#include "mlt_frame.h"
+#include "mlt_multitrack.h"
+#include "mlt_producer.h"
+#include "mlt_transition.h"
+#include "mlt_consumer.h"
+#include "mlt_filter.h"
+#include "mlt_manager.h"
+#include "mlt_playlist.h"
+#include "mlt_properties.h"
+#include "mlt_tractor.h"
+
+#endif
+
#include "config.h"
#include "mlt_factory.h"
#include "mlt_repository.h"
+#include "mlt_properties.h"
#include <stdlib.h>
/** Singleton repositories
*/
+static mlt_properties object_list = NULL;
static mlt_repository producers = NULL;
static mlt_repository filters = NULL;
static mlt_repository transitions = NULL;
/** Construct the factories.
*/
-int mlt_factory_init( )
+int mlt_factory_init( char *prefix )
{
- producers = mlt_repository_init( PREFIX_DATA "/producers.dat", "mlt_create_producer" );
- filters = mlt_repository_init( PREFIX_DATA "/filters.dat", "mlt_create_filter" );
- transitions = mlt_repository_init( PREFIX_DATA "/transitions.dat", "mlt_create_transition" );
- consumers = mlt_repository_init( PREFIX_DATA "/consumers.dat", "mlt_create_consumer" );
+ // If no directory is specified, default to install directory
+ if ( prefix == NULL )
+ prefix = PREFIX_DATA;
+
+ // Create the object list.
+ object_list = calloc( sizeof( struct mlt_properties_s ), 1 );
+ mlt_properties_init( object_list, NULL );
+
+ // Create a repository for each service type
+ producers = mlt_repository_init( object_list, prefix, "producers.dat", "mlt_create_producer" );
+ filters = mlt_repository_init( object_list, prefix, "filters.dat", "mlt_create_filter" );
+ transitions = mlt_repository_init( object_list, prefix, "transitions.dat", "mlt_create_transition" );
+ consumers = mlt_repository_init( object_list, prefix, "consumers.dat", "mlt_create_consumer" );
+
return 0;
}
/** Fetch a transition from the repository.
*/
-mlt_transition mlt_transition_filter( char *service, void *input )
+mlt_transition mlt_factory_transition( char *service, void *input )
{
return ( mlt_transition )mlt_repository_fetch( transitions, service, input );
}
mlt_repository_close( filters );
mlt_repository_close( transitions );
mlt_repository_close( consumers );
+ mlt_properties_close( object_list );
+ free( object_list );
}
#include "mlt_types.h"
-extern int mlt_factory_init( );
+extern int mlt_factory_init( char *prefix );
extern mlt_producer mlt_factory_producer( char *name, void *input );
extern mlt_filter mlt_factory_filter( char *name, void *input );
extern mlt_transition mlt_factory_transition( char *name, void *input );
mlt_producer_prepare_next( parent );
}
- fprintf( stderr, "timestamp for %d = %f\n", index, ( float )mlt_frame_get_timecode( *frame ) );
-
return 0;
}
extern mlt_service mlt_playlist_service( mlt_playlist this );
extern int mlt_playlist_append( mlt_playlist this, mlt_producer producer );
extern int mlt_playlist_pad( mlt_playlist this, mlt_timecode length );
-extern mlt_playlist_close( mlt_playlist this );
+extern void mlt_playlist_close( mlt_playlist this );
#endif
*/
#include "mlt_repository.h"
+#include "mlt_properties.h"
+
+#include <stdio.h>
#include <stdlib.h>
+#include <dlfcn.h>
+#include <string.h>
struct mlt_repository_s
{
+ struct mlt_properties_s parent;
+ mlt_properties object_list;
};
-mlt_repository mlt_repository_init( char *file, char *symbol )
+static char *construct_full_file( char *output, char *prefix, char *file )
{
- return NULL;
+ strcpy( output, prefix );
+ if ( prefix[ strlen( prefix ) - 1 ] != '/' )
+ strcat( output, "/" );
+ strcat( output, file );
+ return output;
+}
+
+static char *chomp( char *input )
+{
+ if ( input[ strlen( input ) - 1 ] == '\n' )
+ input[ strlen( input ) - 1 ] = '\0';
+ return input;
+}
+
+static mlt_properties construct_object( char *prefix, char *id )
+{
+ mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 );
+ 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 = calloc( sizeof( struct mlt_properties_s ), 1 );
+ mlt_properties_init( output, NULL );
+ mlt_properties_set_data( output, "object", object, 0, NULL, NULL );
+ mlt_properties_set( output, "id", id );
+ return output;
+}
+
+void *construct_instance( mlt_properties service_properties, char *symbol, void *input )
+{
+ // Extract the service
+ char *service = mlt_properties_get( service_properties, "id" );
+
+ // Get the object properties
+ void *object_properties = mlt_properties_get_data( service_properties, "object", NULL );
+
+ // Get the dlopen'd object
+ void *object = mlt_properties_get_data( object_properties, "dlopen", NULL );
+
+ // Get the dlsym'd symbol
+ void *( *symbol_ptr )( char *, void * ) = mlt_properties_get_data( object_properties, symbol, NULL );
+
+ // Check that we have object and open if we don't
+ if ( object == NULL )
+ {
+ char full_file[ 512 ];
+
+ // Get the prefix and id of the shared object
+ char *prefix = mlt_properties_get( object_properties, "prefix" );
+ char *file = mlt_properties_get( object_properties, "id" );
+
+ // Construct the full file
+ construct_full_file( full_file, prefix, file );
+
+ // Open the shared object
+ object = dlopen( full_file, RTLD_NOW | RTLD_GLOBAL );
+
+ // Set it on the properties
+ mlt_properties_set_data( object_properties, "dlopen", object, 0, ( void (*)( void * ) )dlclose, NULL );
+ }
+
+ // Now check if we have this symbol pointer
+ if ( object != NULL && symbol_ptr == NULL )
+ {
+ // Construct it now
+ symbol_ptr = dlsym( object, symbol );
+
+ // Set it on the properties
+ mlt_properties_set_data( object_properties, "dlsym", symbol_ptr, 0, NULL, NULL );
+ }
+
+ // Construct the service
+ return symbol_ptr != NULL ? symbol_ptr( service, input ) : NULL;
+}
+
+void destroy_properties( void *arg )
+{
+ mlt_properties_close( arg );
+ free( arg );
+}
+
+mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *data, char *symbol )
+{
+ char full_file[ 512 ];
+ FILE *file;
+
+ // Construct the repository
+ mlt_repository this = calloc( sizeof( struct mlt_repository_s ), 1 );
+ mlt_properties_init( &this->parent, NULL );
+
+ // 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 );
+
+ // Open the file
+ file = fopen( full_file, "r" );
+
+ // Parse the contents
+ if ( file != NULL )
+ {
+ char full[ 512 ];
+ char service[ 256 ];
+ char object[ 256 ];
+
+ while( fgets( full, 512, file ) )
+ {
+ chomp( full );
+
+ if ( full[ 0 ] != '#' && full[ 0 ] != '\0' && sscanf( full, "%s %s", service, object ) == 2 )
+ {
+ // Get the object properties first
+ mlt_properties object_properties = mlt_properties_get_data( object_list, object, NULL );
+
+ // If their are no properties, create them now
+ if ( object_properties == NULL )
+ {
+ // Construct the object
+ object_properties = construct_object( prefix, object );
+
+ // Add it to the object list
+ mlt_properties_set_data( object_list, object, object_properties, 0, destroy_properties, NULL );
+ }
+
+ // Now construct a property for the service
+ mlt_properties service_properties = construct_service( object_properties, service );
+
+ // Add it to the repository
+ mlt_properties_set_data( &this->parent, service, service_properties, 0, destroy_properties, NULL );
+ }
+ }
+
+ // Close the file
+ fclose( file );
+ }
+
+ return this;
}
void *mlt_repository_fetch( mlt_repository this, char *service, void *input )
{
+ // Get the service properties
+ mlt_properties service_properties = mlt_properties_get_data( &this->parent, service, NULL );
+
+ // If the service exists
+ if ( service_properties != NULL )
+ {
+ // Get the symbol that is used to generate this service
+ char *symbol = mlt_properties_get( &this->parent, "_symbol" );
+
+ // Now get an instance of the service
+ return construct_instance( service_properties, symbol, input );
+ }
+
return NULL;
}
void mlt_repository_close( mlt_repository this )
{
+ mlt_properties_close( &this->parent );
+ free( this );
}
#ifndef _MLT_REPOSITORY_H_
#define _MLT_REPOSITORY_H_
+#include "mlt_types.h"
+
/** Repository structure forward reference.
*/
/** Public functions.
*/
-extern mlt_repository mlt_repository_init( char *file, char *symbol );
+extern mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *file, char *symbol );
extern void *mlt_repository_fetch( mlt_repository this, char *service, void *input );
extern void mlt_repository_close( mlt_repository this );
-TARGET=libmltcore.so
+TARGET = ../libmltcore.so
OBJS = factory.o \
producer_ppm.o \
filter_greyscale.o \
transition_composite.o
-CFLAGS=-I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
SRCS := $(OBJS:.o=.c)
-TARGET = factory.o \
- libmltdv.so
+TARGET = ../libmltdv.so
-OBJS = producer_libdv.o
+OBJS = factory.o \
+ producer_libdv.o
-CFLAGS=-I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
LDFLAGS=-ldv -lpthread
-TARGET = libmltgtk2.so
+TARGET = ../libmltgtk2.so
OBJS = factory.o \
producer_pixbuf.o
-CFLAGS=`pkg-config gdk-pixbuf-2.0 --cflags` -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = `pkg-config gdk-pixbuf-2.0 --cflags` -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
-LDFLAGS=`pkg-config gdk-pixbuf-2.0 --libs`
+LDFLAGS = `pkg-config gdk-pixbuf-2.0 --libs`
SRCS := $(OBJS:.o=.c)
-TARGET = libmltsdl.so
+TARGET = ../libmltsdl.so
OBJS = factory.o \
consumer_sdl.o
-CFLAGS=-I../../ `sdl-config --cflags` -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+CFLAGS = -I../../ `sdl-config --cflags` -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
LDFLAGS= `sdl-config --libs`
--- /dev/null
+TARGET = dan charlie
+
+CFLAGS = -I .. -Wall -rdynamic -pthread
+
+LDFLAGS = -L ../framework -lmlt
+
+all: $(TARGET)
+
+dan: dan.o
+ $(CC) dan.o -o $@ $(LDFLAGS)
+
+charlie: charlie.o
+ $(CC) charlie.o -o $@ $(LDFLAGS)
+
+clean:
+ rm -f dan.o charlie.o dan charlie
+
+depend: dan.c charlie.c
+ $(CC) -MM $(CFLAGS) $^ 1>.depend
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
-#include "mlt_producer.h"
-#include "mlt_consumer.h"
-#include "mlt_filter.h"
-#include "mlt_tractor.h"
-#include "mlt_transition.h"
-#include "mlt_multitrack.h"
-
-#include "producer_libdv.h"
-#include "producer_ppm.h"
-#include "filter_deinterlace.h"
-#include "filter_greyscale.h"
-#include "consumer_sdl.h"
+#include <framework/mlt_factory.h>
+
+#include <framework/mlt_producer.h>
+#include <framework/mlt_consumer.h>
+#include <framework/mlt_filter.h>
+#include <framework/mlt_tractor.h>
+#include <framework/mlt_transition.h>
+#include <framework/mlt_multitrack.h>
#include <stdio.h>
char *file1 = NULL;
char *file2 = NULL;
- // Start the consumer...
- mlt_consumer sdl_out = consumer_sdl_init( NULL );
-
- fprintf( stderr, "Press return to continue\n" );
- fgets( temp, 132, stdin );
+ mlt_factory_init( "../modules" );
if ( argc >= 2 )
file1 = argv[ 1 ];
if ( argc >= 3 )
file2 = argv[ 2 ];
+ // Start the consumer...
+ mlt_consumer sdl_out = mlt_factory_consumer( "sdl", NULL );
+
+ fprintf( stderr, "Press return to continue\n" );
+ fgets( temp, 132, stdin );
+
// Create the producer(s)
+ mlt_producer dv1 = mlt_factory_producer( "libdv", file1 );
+ mlt_producer dv2 = mlt_factory_producer( "libdv", file2 );
//mlt_producer dv1 = producer_ppm_init( NULL );
//mlt_producer dv2 = producer_ppm_init( NULL );
- mlt_producer dv1 = producer_libdv_init( file1 );
- mlt_producer dv2 = producer_libdv_init( file2 );
+ // Connect a producer to our sdl consumer
mlt_consumer_connect( sdl_out, mlt_producer_service( dv1 ) );
fprintf( stderr, "Press return to continue\n" );
mlt_multitrack_connect( multitrack, dv2, 1 );
// Create a filter and associate it to track 0
- mlt_filter filter = filter_deinterlace_init( NULL );
+ mlt_filter filter = mlt_factory_filter( "deinterlace", NULL );
mlt_filter_connect( filter, mlt_multitrack_service( multitrack ), 0 );
mlt_filter_set_in_and_out( filter, 0, 5 );
// Create another
- mlt_filter greyscale = filter_greyscale_init( NULL );
+ mlt_filter greyscale = mlt_factory_filter( "greyscale", NULL );
mlt_filter_connect( greyscale, mlt_filter_service( filter ), 0 );
mlt_filter_set_in_and_out( greyscale, 0, 10 );
fgets( temp, 132, stdin );
// Close everything...
- mlt_consumer_close( sdl_out );
- mlt_tractor_close( tractor );
- mlt_filter_close( filter );
- mlt_multitrack_close( multitrack );
- mlt_producer_close( dv1 );
- mlt_producer_close( dv2 );
+ //mlt_consumer_close( sdl_out );
+ //mlt_tractor_close( tractor );
+ //mlt_filter_close( filter );
+ //mlt_filter_close( greyscale );
+ //mlt_multitrack_close( multitrack );
+ //mlt_producer_close( dv1 );
+ //mlt_producer_close( dv2 );
+
+ mlt_factory_close( );
return 0;
}
-#include "mlt_producer.h"
-#include "mlt_consumer.h"
-#include "mlt_filter.h"
-#include "mlt_tractor.h"
-#include "mlt_transition.h"
-#include "mlt_multitrack.h"
-#include "producer_libdv.h"
-#include "filter_deinterlace.h"
-#include "consumer_sdl.h"
-#include "producer_ppm.h"
-#include "producer_pixbuf.h"
-#include "transition_composite.h"
+#include <framework/mlt.h>
#include <stdio.h>
char *file1 = NULL;
char *file2 = NULL;
+ mlt_factory_init( "../modules" );
+
if ( argc >= 2 )
file1 = argv[ 1 ];
if ( argc >= 3 )
file2 = argv[ 2 ];
// Start the consumer...
- mlt_consumer sdl_out = consumer_sdl_init( NULL );
+ mlt_consumer sdl_out = mlt_factory_consumer( "sdl", NULL );
// Create the producer(s)
- mlt_producer dv1 = producer_libdv_init( file1 );
+ mlt_producer dv1 = mlt_factory_producer( "libdv", file1 );
//mlt_producer dv1 = producer_pixbuf_init( file1 );
//mlt_producer dv2 = producer_libdv_init( file2 );
- mlt_producer dv2 = producer_pixbuf_init( file2 );
+ mlt_producer dv2 = mlt_factory_producer( "pixbuf", file2 );
// Register producers(s) with a multitrack object
mlt_multitrack multitrack = mlt_multitrack_init( );
mlt_multitrack_connect( multitrack, dv2, 1 );
// Create a filter and associate it to track 0
- mlt_filter filter = filter_deinterlace_init( NULL );
+ mlt_filter filter = mlt_factory_filter( "deinterlace", NULL );
mlt_filter_connect( filter, mlt_multitrack_service( multitrack ), 0 );
mlt_filter_set_in_and_out( filter, 0, 1000 );
// Define a transition
- mlt_transition transition = transition_composite_init( NULL );
+ mlt_transition transition = mlt_factory_transition( "composite", NULL );
mlt_transition_connect( transition, mlt_filter_service( filter ), 0, 1 );
mlt_transition_set_in_and_out( transition, 0, 1000 );
fgets( temp, 132, stdin );
// Close everything...
- mlt_consumer_close( sdl_out );
- mlt_tractor_close( tractor );
- mlt_filter_close( filter );
- mlt_multitrack_close( multitrack );
- mlt_producer_close( dv1 );
- mlt_producer_close( dv2 );
+ //mlt_consumer_close( sdl_out );
+ //mlt_tractor_close( tractor );
+ //mlt_filter_close( filter );
+ //mlt_multitrack_close( multitrack );
+ //mlt_producer_close( dv1 );
+ //mlt_producer_close( dv2 );
return 0;
}