{
mlt_properties properties = mlt_producer_properties( obj );
mlt_properties_set( properties, "mlt_type", "producer" );
- mlt_properties_set( properties, "mlt_service", service );
+ if ( mlt_properties_get_int( properties, "_mlt_service_hidden" ) == 0 )
+ mlt_properties_set( properties, "mlt_service", service );
}
return obj;
}
// Try to obtain the multitrack associated to the tractor
mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL );
+ // Or a specific producer
+ mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL );
+
// If we don't have one, we're in trouble...
if ( multitrack != NULL )
{
mlt_producer target = mlt_multitrack_producer( multitrack );
mlt_producer_seek( target, mlt_producer_frame( parent ) );
mlt_producer_set_speed( target, mlt_producer_get_speed( parent ) );
- }
- else
- {
- fprintf( stderr, "tractor without a multitrack!!\n" );
- }
-
- // Loop through each of the tracks we're harvesting
- for ( i = 0; !done; i ++ )
- {
- // Get a frame from the producer
- mlt_service_get_frame( this->producer, &temp, i );
- // Check for last track
- done = mlt_properties_get_int( mlt_frame_properties( temp ), "last_track" );
-
- // Handle the frame
- if ( done && looking )
- {
- // Use this as output if we don't have one already
- *frame = temp;
- }
- else if ( ( !mlt_frame_is_test_card( temp ) || !mlt_frame_is_test_audio( temp ) ) && looking &&
- mlt_producer_frame( parent ) == mlt_frame_get_position( temp ) )
+ // Loop through each of the tracks we're harvesting
+ for ( i = 0; !done; i ++ )
{
- *frame = temp;
- looking = 0;
+ // Get a frame from the producer
+ mlt_service_get_frame( this->producer, &temp, i );
+
+ // Check for last track
+ done = mlt_properties_get_int( mlt_frame_properties( temp ), "last_track" );
+
+ // Handle the frame
+ if ( done && looking )
+ {
+ // Use this as output if we don't have one already
+ *frame = temp;
+ }
+ else if ( ( !mlt_frame_is_test_card( temp ) || !mlt_frame_is_test_audio( temp ) ) && looking &&
+ mlt_producer_frame( parent ) == mlt_frame_get_position( temp ) )
+ {
+ *frame = temp;
+ looking = 0;
+ }
+ else
+ {
+ // We store all other frames for now
+ store[ count ++ ] = temp;
+ }
}
- else
+
+ // Now place all the unused frames on to the properties (will be destroyed automatically)
+ while ( count -- )
{
- // We store all other frames for now
- store[ count ++ ] = temp;
+ mlt_properties frame_properties = mlt_frame_properties( *frame );
+ char label[ 30 ];
+ sprintf( label, "tractor_%d", count );
+ while ( mlt_properties_get_data( frame_properties, label, NULL ) != NULL )
+ strcat( label, "+" );
+ mlt_properties_set_data( frame_properties, label, store[ count ], 0, ( mlt_destructor )mlt_frame_close, NULL );
}
}
-
- // Now place all the unused frames on to the properties (will be destroyed automatically)
- while ( count -- )
+ else if ( producer != NULL )
{
- mlt_properties frame_properties = mlt_frame_properties( *frame );
- char label[ 30 ];
- sprintf( label, "tractor_%d", count );
- while ( mlt_properties_get_data( frame_properties, label, NULL ) != NULL )
- strcat( label, "+" );
- mlt_properties_set_data( frame_properties, label, store[ count ], 0, ( mlt_destructor )mlt_frame_close, NULL );
+ mlt_producer_seek( producer, mlt_producer_frame( parent ) );
+ mlt_producer_set_speed( producer, mlt_producer_get_speed( parent ) );
+ mlt_service_get_frame( this->producer, frame, track );
+ }
+ else
+ {
+ fprintf( stderr, "tractor without a multitrack!!\n" );
+ mlt_service_get_frame( this->producer, frame, track );
}
// Prepare the next frame
/** Close the producer.
*/
-void producer_close( mlt_producer this )
+static void producer_close( mlt_producer this )
{
mlt_tractor_close( this->child );
}
static mlt_producer create_producer( char *file )
{
- mlt_producer result = NULL;
-
- // 1st Line preferences
- if ( strstr( file, ".inigo" ) )
- result = mlt_factory_producer( "inigo_file", file );
- else if ( strstr( file, ".westley" ) )
- result = mlt_factory_producer( "westley", 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, ".tga" ) )
- result = mlt_factory_producer( "pixbuf", file );
- else if ( strstr( file, ".txt" ) )
- result = mlt_factory_producer( "pango", file );
- else if ( strstr( file, ".ogg" ) )
- result = mlt_factory_producer( "vorbis", file );
-
- // 2nd Line fallbacks
- if ( result == NULL && strstr( file, ".dv" ) )
- result = mlt_factory_producer( "libdv", file );
- else if ( result == NULL && strstr( file, ".dif" ) )
- result = mlt_factory_producer( "libdv", file );
-
- // 3rd line fallbacks
- if ( result == NULL )
- result = mlt_factory_producer( "avformat", file );
-
- // 4th line fallbacks
- if ( result == NULL )
- result = mlt_factory_producer( "ffmpeg", file );
-
- return result;
+ return mlt_factory_producer( "fezzik", file );
}
/** Create or locate a producer for the file specified.
-SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo avformat vorbis speex westley
+SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo avformat vorbis speex westley fezzik
all clean depend install:
list='$(SUBDIRS)'; \
--- /dev/null
+
+TARGET = ../libmltfezzik.so
+
+OBJS = factory.o \
+ producer_fezzik.o
+
+CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
+
+SRCS := $(OBJS:.o=.c)
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS)
+ $(CC) -shared -o $@ $(OBJS) $(LDFLAGS)
+
+depend: $(SRCS)
+ $(CC) -MM $(CFLAGS) $^ 1>.depend
+
+dist-clean: clean
+ rm -f .depend
+
+clean:
+ rm -f $(OBJS) $(TARGET)
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
--- /dev/null
+#!/bin/bash
+
+if [ "$help" != "1" ]
+then
+
+cat << EOF >> ../producers.dat
+fezzik libmltfezzik.so
+EOF
+
+fi
+
--- /dev/null
+/*
+ * factory.c -- the factory method interfaces
+ * 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.
+ */
+
+#include <string.h>
+
+#include "producer_fezzik.h"
+
+void *mlt_create_producer( char *id, void *arg )
+{
+ if ( !strcmp( id, "fezzik" ) )
+ return producer_fezzik_init( arg );
+ return NULL;
+}
+
+void *mlt_create_filter( char *id, void *arg )
+{
+ return NULL;
+}
+
+void *mlt_create_transition( char *id, void *arg )
+{
+ return NULL;
+}
+
+void *mlt_create_consumer( char *id, void *arg )
+{
+ return NULL;
+}
+
--- /dev/null
+/*
+ * producer_fezzik.c -- a normalising filter
+ * 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.
+ */
+
+#include "producer_fezzik.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <framework/mlt.h>
+
+static void track_service( mlt_tractor tractor, void *service, mlt_destructor destructor )
+{
+ mlt_properties properties = mlt_tractor_properties( tractor );
+ int registered = mlt_properties_get_int( properties, "_registered" );
+ char *key = mlt_properties_get( properties, "_registered" );
+ char *real = malloc( strlen( key ) + 2 );
+ sprintf( real, "_%s", key );
+ mlt_properties_set_data( properties, real, service, 0, destructor, NULL );
+ mlt_properties_set_int( properties, "_registered", ++ registered );
+ free( real );
+}
+
+static mlt_producer create_producer( char *file )
+{
+ mlt_producer result = NULL;
+
+ // 1st Line preferences
+ 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, ".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 );
+
+ // 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 );
+ }
+
+ // 3rd line fallbacks
+ if ( result == NULL )
+ result = mlt_factory_producer( "avformat", file );
+
+ // 4th line fallbacks
+ if ( result == NULL )
+ result = mlt_factory_producer( "ffmpeg", file );
+
+ return result;
+}
+
+static mlt_service create_filter( mlt_tractor tractor, mlt_service last, char *effect )
+{
+ char *id = strdup( effect );
+ char *arg = strchr( id, ':' );
+ if ( arg != NULL )
+ *arg ++ = '\0';
+ mlt_filter filter = mlt_factory_filter( id, arg );
+ if ( filter != NULL )
+ {
+ mlt_filter_connect( filter, last, 0 );
+ track_service( tractor, filter, ( mlt_destructor )mlt_filter_close );
+ last = mlt_filter_service( filter );
+ }
+ free( id );
+ return last;
+}
+
+mlt_producer producer_fezzik_init( char *arg )
+{
+ // Create the producer that the tractor will contain
+ mlt_producer producer = create_producer( arg );
+
+ // Build the tractor if we have a producer and it isn't already westley'd :-)
+ if ( producer != NULL && mlt_properties_get( mlt_producer_properties( producer ), "westley" ) == NULL )
+ {
+ // Construct the tractor
+ mlt_tractor tractor = mlt_tractor_init( );
+
+ // Sanity check
+ if ( tractor != NULL )
+ {
+ // Extract the tractor properties
+ mlt_properties properties = mlt_tractor_properties( tractor );
+
+ // Our producer will be the last service
+ mlt_service last = mlt_producer_service( producer );
+
+ // Set the registered count
+ mlt_properties_set_int( properties, "_registered", 0 );
+
+ // Register our producer for seeking in the tractor
+ mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL );
+
+ // Now attach normalising filters
+ last = create_filter( tractor, last, "rescale" );
+ last = create_filter( tractor, last, "resample" );
+
+ // Connect the tractor to the last
+ mlt_tractor_connect( tractor, last );
+
+ // Finally, inherit properties from producer
+ mlt_properties_inherit( properties, mlt_producer_properties( producer ) );
+
+ // Now make sure we don't lose our inherited identity
+ mlt_properties_set_int( properties, "_mlt_service_hidden", 1 );
+
+ // This is a temporary hack to ensure that westley doesn't dig too deep
+ // and fezzik doesn't overdo it with throwing rocks...
+ mlt_properties_set( properties, "westley", "was here" );
+
+ // Now, we return the producer of the tractor
+ producer = mlt_tractor_producer( tractor );
+ }
+ }
+
+ // Return the tractor's producer
+ return producer;
+}
+
--- /dev/null
+/*
+ * producer_fezzik.h -- a normalising producer
+ * 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 _PRODUCER_FEZZIK_H_
+#define _PRODUCER_FEZZIK_H_
+
+#include <framework/mlt_producer.h>
+
+extern mlt_producer producer_fezzik_init( char *args );
+
+#endif
static mlt_producer create_producer( mlt_field field, char *file )
{
- mlt_producer result = NULL;
-
- // 1st Line preferences
- 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, ".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 );
-
- // 2nd Line fallbacks
- if ( result == NULL && strstr( file, ".dv" ) )
- result = mlt_factory_producer( "libdv", file );
- else if ( result == NULL && strstr( file, ".dif" ) )
- result = mlt_factory_producer( "libdv", file );
-
- // 3rd line fallbacks
- if ( result == NULL )
- result = mlt_factory_producer( "avformat", file );
-
- // 4th line fallbacks
- if ( result == NULL )
- result = mlt_factory_producer( "ffmpeg", file );
+ mlt_producer result = mlt_factory_producer( "fezzik", file );
if ( result != NULL )
track_service( field, result, ( mlt_destructor )mlt_producer_close );
*/
static int consumer_start( mlt_consumer parent );
+static int consumer_is_stopped( mlt_consumer this );
/** This is what will be called by the factory - anything can be passed in
via the argument, but keep it simple.
// Allow thread to be started/stopped
this->start = consumer_start;
+ this->is_stopped = consumer_is_stopped;
mlt_properties_set( mlt_consumer_properties( this ), "resource", arg );
xmlFreeDoc( doc );
mlt_consumer_stop( this );
- // Tell inigo, enough already!
- if ( inigo != NULL )
- mlt_properties_set_int( mlt_service_properties( inigo ), "done", 1 );
-
return 0;
}
+static int consumer_is_stopped( mlt_consumer this )
+{
+ return 1;
+}
+
mlt_properties_set( properties, (char*) atts[0], (char*) atts[1] );
}
- if ( mlt_properties_get( properties, "mlt_service" ) != NULL )
+ service = MLT_SERVICE( mlt_factory_producer( "fezzik", mlt_properties_get( properties, "resource" ) ) );
+
+ if ( service == NULL && mlt_properties_get( properties, "mlt_service" ) != NULL )
{
service = MLT_SERVICE( mlt_factory_producer( mlt_properties_get( properties, "mlt_service" ),
mlt_properties_get( properties, "resource" ) ) );
}
- else
- {
- // Unspecified producer, use inigo
- char *args[2] = { mlt_properties_get( properties, "resource" ), 0 };
- service = MLT_SERVICE( mlt_factory_producer( "inigo", args ) );
- }
track_service( context->destructors, service, (mlt_destructor) mlt_producer_close );