void *mlt_frame_pop_audio( mlt_frame this );
void mlt_frame_close( mlt_frame this );
-
+
mlt_service:
The service base class extends properties and allows 0 to m inputs and 0 to
The public interface is defined by the following functions:
+ mlt_producer mlt_producer_new( );
int mlt_producer_init( mlt_producer this, void *child );
mlt_service mlt_producer_service( mlt_producer this );
mlt_properties mlt_producer_properties( mlt_producer this );
void mlt_producer_prepare_next( mlt_producer this );
void mlt_producer_close( mlt_producer this );
- For the sake of discussion here, we'll assume that someone wants to provide
- a new producer which random noise
-
- // Forward reference
- static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int index );
-
- mlt_producer producer_green( void *arg )
- {
- // Create a new producer
- mlt_producer this = mlt_producer_new( );
-
- // Check that we were allocated a new producer
- if ( this != NULL )
- {
- // Get the service
- mlt_service service = mlt_producer_service( this );
-
- // We need to override the get_frame method
- service->get_frame = producer_get_frame;
- }
-
- // Return this producer
- return this;
- }
-
- static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int index )
- {
- // Create a new frame
- *frame = mlt_frame_init( );
-
- // Specify the get_image
- mlt_frame_push_get_image( *frame, producer_get_image );
-
- // Specify the get_audio
- mlt_frame_push_audio( *frame, producer_get_audio );
-
- // Return that all was successful
- return 0;
- }
mlt_filter:
mlt_tractor:
-mlt_factory
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
+#include <fnmatch.h>
#include <framework/mlt.h>
+static mlt_properties dictionary = NULL;
+
static void track_service( mlt_tractor tractor, void *service, mlt_destructor destructor )
{
mlt_properties properties = mlt_tractor_properties( tractor );
free( real );
}
+static mlt_producer create_from( char *file, char *services )
+{
+ mlt_producer producer = NULL;
+ char *temp = strdup( services );
+ char *service = temp;
+ do
+ {
+ char *p = strchr( service, ',' );
+ if ( p != NULL )
+ *p ++ = '\0';
+ producer = mlt_factory_producer( service, file );
+ service = p;
+ }
+ while ( producer == NULL && service != NULL );
+ free( temp );
+ return producer;
+}
+
static mlt_producer create_producer( char *file )
{
mlt_producer result = NULL;
- // 0th Line - check for service:resource handling
+ // 1st Line - check for service:resource handling
if ( strchr( file, ':' ) )
{
char *temp = strdup( file );
free( temp );
}
- // 1st Line preferences
+ // 2nd Line preferences
if ( result == NULL )
{
- if ( strstr( file, ".inigo" ) )
- result = mlt_factory_producer( "inigo_file", file );
- else if ( strstr( file, ".mpg" ) )
- result = mlt_factory_producer( "mcmpeg", file );
- else if ( strstr( file, ".mpeg" ) )
- result = mlt_factory_producer( "mcmpeg", file );
- else if ( strstr( file, ".dv" ) )
- result = mlt_factory_producer( "mcdv", file );
- else if ( strstr( file, ".dif" ) )
- result = mlt_factory_producer( "mcdv", file );
- else if ( strstr( file, ".jpg" ) )
- result = mlt_factory_producer( "pixbuf", file );
- else if ( strstr( file, ".JPG" ) )
- result = mlt_factory_producer( "pixbuf", file );
- else if ( strstr( file, ".jpeg" ) )
- result = mlt_factory_producer( "pixbuf", file );
- else if ( strstr( file, ".png" ) )
- result = mlt_factory_producer( "pixbuf", file );
- else if ( strstr( file, ".svg" ) )
- result = mlt_factory_producer( "pixbuf", file );
- else if ( strstr( file, ".txt" ) )
- result = mlt_factory_producer( "pango", file );
- else if ( strstr( file, ".westley" ) )
- result = mlt_factory_producer( "westley", file );
- else if ( strstr( file, ".ogg" ) )
- result = mlt_factory_producer( "vorbis", file );
- }
+ int i = 0;
+ char *lookup = strdup( file );
+ char *p = lookup;
- // 2nd Line fallbacks
- if ( result == NULL )
- {
- if ( strstr( file, ".dv" ) )
- result = mlt_factory_producer( "libdv", file );
- else if ( strstr( file, ".dif" ) )
- result = mlt_factory_producer( "libdv", file );
- }
+ // We only need to load the dictionary once
+ if ( dictionary == NULL )
+ {
+ char temp[ 1024 ];
+ sprintf( temp, "%s/fezzik.dict", mlt_factory_prefix( ) );
+ dictionary = mlt_properties_load( temp );
+ }
- // 3rd line fallbacks
- if ( result == NULL )
- result = mlt_factory_producer( "avformat", file );
+ // Convert the lookup string to lower case
+ while ( *p )
+ {
+ *p = tolower( *p );
+ p ++;
+ }
+
+ // Iterate through the dictionary
+ for ( i = 0; result == NULL && i < mlt_properties_count( dictionary ); i ++ )
+ {
+ char *name = mlt_properties_get_name( dictionary, i );
+ if ( fnmatch( name, lookup, 0 ) == 0 )
+ result = create_from( file, mlt_properties_get_value( dictionary, i ) );
+ }
+
+ free( lookup );
+ }
return result;
}
{
// Create the producer that the tractor will contain
mlt_producer producer = NULL;
+
if ( arg != NULL )
producer = create_producer( arg );