From: ddennedy Date: Wed, 21 Jan 2004 06:24:52 +0000 (+0000) Subject: added modules/westley X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=520454d526bdcd58f1ac6ab7532dc2529b822808;p=melted added modules/westley git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@88 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/docs/services.txt b/docs/services.txt index 5c72310..50f3cad 100644 --- a/docs/services.txt +++ b/docs/services.txt @@ -539,6 +539,7 @@ Transitions Known Bugs The luma map must be the same size as the B frame. + The PGM parser does not handle comments. mix diff --git a/mlt/docs/services.txt b/mlt/docs/services.txt index 5c72310..50f3cad 100644 --- a/mlt/docs/services.txt +++ b/mlt/docs/services.txt @@ -539,6 +539,7 @@ Transitions Known Bugs The luma map must be the same size as the B frame. + The PGM parser does not handle comments. mix diff --git a/mlt/src/framework/mlt_multitrack.c b/mlt/src/framework/mlt_multitrack.c index 28d598f..2faaf69 100644 --- a/mlt/src/framework/mlt_multitrack.c +++ b/mlt/src/framework/mlt_multitrack.c @@ -61,7 +61,7 @@ mlt_multitrack mlt_multitrack_init( ) producer->get_frame = producer_get_frame; mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL ); mlt_properties_set( properties, "log_id", "multitrack" ); - mlt_properties_set( properties, "resource", "" ); + mlt_properties_set( properties, "resource", "" ); } else { @@ -189,6 +189,28 @@ int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int trac return result; } +/** Get the number of tracks. +*/ + +int mlt_multitrack_count( mlt_multitrack this ) +{ + return this->count; +} + +/** Get an individual track as a producer. +*/ + +mlt_producer mlt_multitrack_track( mlt_multitrack this, int track ) +{ + mlt_producer producer = NULL; + + if ( this->list != NULL && track < this->count ) + producer = this->list[ track ]; + + return producer; +} + + /** Determine the clip point. Special case here: a 'producer' has no concept of multiple clips - only the diff --git a/mlt/src/framework/mlt_multitrack.h b/mlt/src/framework/mlt_multitrack.h index 3f6d8d9..c409752 100644 --- a/mlt/src/framework/mlt_multitrack.h +++ b/mlt/src/framework/mlt_multitrack.h @@ -33,6 +33,8 @@ extern mlt_properties mlt_multitrack_properties( mlt_multitrack this ); extern int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track ); extern mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ); extern void mlt_multitrack_close( mlt_multitrack this ); +extern int mlt_multitrack_count( mlt_multitrack this ); +extern mlt_producer mlt_multitrack_track( mlt_multitrack this, int track ); #endif diff --git a/mlt/src/framework/mlt_repository.c b/mlt/src/framework/mlt_repository.c index dcb2c25..9c25b21 100644 --- a/mlt/src/framework/mlt_repository.c +++ b/mlt/src/framework/mlt_repository.c @@ -94,6 +94,8 @@ static void *construct_instance( mlt_properties service_properties, char *symbol // Open the shared object object = dlopen( full_file, RTLD_NOW | RTLD_GLOBAL ); + if ( object == NULL ) + 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 ); diff --git a/mlt/src/framework/mlt_service.c b/mlt/src/framework/mlt_service.c index 8e626d4..f432aae 100644 --- a/mlt/src/framework/mlt_service.c +++ b/mlt/src/framework/mlt_service.c @@ -172,6 +172,24 @@ void mlt_service_connect( mlt_service this, mlt_service that ) base->out = that; } + +/** Get the first connected producer service. +*/ + +mlt_service mlt_service_get_producer( mlt_service this ) +{ + mlt_service producer = NULL; + + // Get the service base + mlt_service_base *base = this->private; + + if ( base->in != NULL ) + producer = base->in[ 0 ]; + + return producer; +} + + /** Get the service state. */ diff --git a/mlt/src/framework/mlt_service.h b/mlt/src/framework/mlt_service.h index 88b91b5..8ad43a8 100644 --- a/mlt/src/framework/mlt_service.h +++ b/mlt/src/framework/mlt_service.h @@ -74,6 +74,7 @@ extern int mlt_service_has_input( mlt_service this ); extern int mlt_service_has_output( mlt_service this ); extern int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); extern int mlt_service_is_active( mlt_service this ); +extern mlt_service mlt_service_get_producer( mlt_service this ); #endif diff --git a/mlt/src/framework/mlt_tractor.c b/mlt/src/framework/mlt_tractor.c index 1bbcace..707d5c5 100644 --- a/mlt/src/framework/mlt_tractor.c +++ b/mlt/src/framework/mlt_tractor.c @@ -57,6 +57,8 @@ mlt_tractor mlt_tractor_init( ) { producer->get_frame = producer_get_frame; mlt_properties_set( mlt_producer_properties( producer ), "resource", "" ); + mlt_properties_set( mlt_producer_properties( producer ), "mlt_type", "producer" ); + mlt_properties_set( mlt_producer_properties( producer ), "mlt_service", "tractor" ); } else { diff --git a/mlt/src/framework/mlt_types.h b/mlt/src/framework/mlt_types.h index 162602f..a4707c9 100644 --- a/mlt/src/framework/mlt_types.h +++ b/mlt/src/framework/mlt_types.h @@ -48,5 +48,11 @@ typedef struct mlt_consumer_s *mlt_consumer; typedef void ( *mlt_destructor )( void * ); typedef char *( *mlt_serialiser )( void *, int length ); +#define MLT_SERVICE(x) ( ( mlt_service )( x ) ) +#define MLT_PRODUCER(x) ( ( mlt_producer )( x ) ) +#define MLT_MULTITRACK(x) ( ( mlt_multitrack )( x ) ) +#define MLT_PLAYLIST(x) ( ( mlt_playlist )( x ) ) +#define MLT_FILTER(x) ( ( mlt_filter )( x ) ) +#define MLT_TRANSITION(x) ( ( mlt_transition )( x ) ) #endif diff --git a/mlt/src/modules/Makefile b/mlt/src/modules/Makefile index 52c26fc..45f7a31 100644 --- a/mlt/src/modules/Makefile +++ b/mlt/src/modules/Makefile @@ -1,4 +1,4 @@ -SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo +SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo westley all clean depend install: list='$(SUBDIRS)'; \ diff --git a/mlt/src/modules/westley/Makefile b/mlt/src/modules/westley/Makefile new file mode 100644 index 0000000..576a6ea --- /dev/null +++ b/mlt/src/modules/westley/Makefile @@ -0,0 +1,30 @@ + +TARGET = ../libmltwestley.so + +OBJS = factory.o \ + consumer_westley.o \ + producer_westley.o + +CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread `xml2-config --cflags` + +LDFLAGS = `xml2-config --libs` + +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 diff --git a/mlt/src/modules/westley/configure b/mlt/src/modules/westley/configure new file mode 100755 index 0000000..b971570 --- /dev/null +++ b/mlt/src/modules/westley/configure @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ "$help" != "1" ] +then + +cat << EOF >> ../producers.dat +westley libmltwestley.so +EOF + +cat << EOF >> ../consumers.dat +westley libmltwestley.so +EOF + +fi + diff --git a/mlt/src/modules/westley/consumer_westley.c b/mlt/src/modules/westley/consumer_westley.c new file mode 100644 index 0000000..8bdb583 --- /dev/null +++ b/mlt/src/modules/westley/consumer_westley.c @@ -0,0 +1,175 @@ +/* + * consumer_westley.c -- a libxml2 serialiser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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 "consumer_westley.h" +#include +#include +#include +#include +#include +#include + +/** Forward references to static functions. +*/ + +static int consumer_start( mlt_consumer parent ); + +/** This is what will be called by the factory - anything can be passed in + via the argument, but keep it simple. +*/ + +mlt_consumer consumer_westley_init( char *arg ) +{ + // Create the consumer object + mlt_consumer this = calloc( sizeof( struct mlt_consumer_s ), 1 ); + + // If no malloc'd and consumer init ok + if ( this != NULL && mlt_consumer_init( this, NULL ) == 0 ) + { + // We have stuff to clean up, so override the close method + //parent->close = consumer_close; + + // Allow thread to be started/stopped + this->start = consumer_start; + + // Return the consumer produced + return this; + } + + // malloc or consumer init failed + free( this ); + + // Indicate failure + return NULL; +} + +void serialise_service( mlt_service service ) +{ + // Iterate over consumer/producer connections + while ( service != NULL ) + { + char *mlt_type = mlt_properties_get( mlt_service_properties(service ), "mlt_type" ); + + // Tell about the producer + if ( strcmp( mlt_type, "producer" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' mlt_service '%s' resource '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "mlt_service" ), + mlt_properties_get( mlt_service_properties( service ), "resource" ) ); + } + + // Tell about the framework container producers + else if ( strcmp( mlt_type, "mlt_producer" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' resource '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "resource" ) ); + + // Recurse on multitrack's tracks + if ( strcmp( mlt_properties_get( mlt_service_properties( service ), "resource" ), "" ) == 0 ) + { + int i; + + fprintf( stderr, "contains...\n" ); + for ( i = 0; i < mlt_multitrack_count( MLT_MULTITRACK( service ) ); i++ ) + serialise_service( MLT_SERVICE( mlt_multitrack_track( MLT_MULTITRACK( service ), i ) ) ); + fprintf( stderr, "...done.\n" ); + } + + // Recurse on playlist's clips + else if ( strcmp( mlt_properties_get( mlt_service_properties( service ), "resource" ), "" ) == 0 ) + { + int i; + mlt_playlist_clip_info info; + + fprintf( stderr, "contains...\n" ); + for ( i = 0; i < mlt_playlist_count( MLT_PLAYLIST( service ) ); i++ ) + { + if ( ! mlt_playlist_get_clip_info( MLT_PLAYLIST( service ), &info, i ) ) + serialise_service( MLT_SERVICE( info.producer ) ); + } + fprintf( stderr, "...done.\n" ); + } + } + + // Tell about a filter + else if ( strcmp( mlt_type, "filter" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' mlt_service '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "mlt_service" ) ); + + fprintf( stderr, "is applied to\n" ); + + // Recurse on connected producer + serialise_service( MLT_SERVICE( MLT_FILTER( service )->producer ) ); + } + + // Tell about a transition + else if ( strcmp( mlt_type, "transition" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' mlt_service '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "mlt_service" ) ); + + fprintf( stderr, "is applied to\n" ); + + // Recurse on connected producer + serialise_service( MLT_SERVICE( MLT_TRANSITION( service )->producer ) ); + } + + // Get the next connected service + service = mlt_service_get_producer( service ); + if ( service != NULL ) + fprintf( stderr, "is connected to\n" ); + } +} + +static int consumer_start( mlt_consumer this ) +{ + // get a handle on properties + mlt_properties properties = mlt_consumer_properties( this ); + + mlt_service inigo = NULL; + + fprintf( stderr, "mlt_type '%s' mlt_service '%s'\n", + mlt_properties_get( properties, "mlt_type" ), + mlt_properties_get( properties, "mlt_service" ) ); + + // Get the producer service + mlt_service service = mlt_service_get_producer( mlt_consumer_service( this ) ); + if ( service != NULL ) + { + fprintf( stderr, "is connected to\n" ); + + // Remember inigo + if ( mlt_properties_get( mlt_service_properties( service ), "mlt_service" ) != NULL && + strcmp( mlt_properties_get( mlt_service_properties( service ), "mlt_service" ), "inigo" ) == 0 ) + inigo = service; + + serialise_service( service ); + } + + mlt_consumer_stop( this ); + + // Tell inigo, enough already! + if ( inigo != NULL ) + mlt_properties_set_int( mlt_service_properties( inigo ), "done", 1 ); + + return 0; +} + diff --git a/mlt/src/modules/westley/consumer_westley.h b/mlt/src/modules/westley/consumer_westley.h new file mode 100644 index 0000000..8b94db4 --- /dev/null +++ b/mlt/src/modules/westley/consumer_westley.h @@ -0,0 +1,28 @@ +/* + * consumer_westley.h -- a libxml2 serialiser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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 _CONSUMER_WESTLEY_H_ +#define _CONSUMER_WESTLEY_H_ + +#include + +extern mlt_consumer consumer_westley_init( char * ); + +#endif diff --git a/mlt/src/modules/westley/factory.c b/mlt/src/modules/westley/factory.c new file mode 100644 index 0000000..e60cd56 --- /dev/null +++ b/mlt/src/modules/westley/factory.c @@ -0,0 +1,49 @@ +/* + * factory.c -- the factory method interfaces + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Charles Yates + * + * 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 + +#include "consumer_westley.h" +#include "producer_westley.h" + +void *mlt_create_producer( char *id, void *arg ) +{ + if ( !strcmp( id, "westley" ) ) + return producer_westley_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 ) +{ + if ( !strcmp( id, "westley" ) ) + return consumer_westley_init( arg ); + return NULL; +} + diff --git a/mlt/src/modules/westley/producer_westley.c b/mlt/src/modules/westley/producer_westley.c new file mode 100644 index 0000000..6616f3c --- /dev/null +++ b/mlt/src/modules/westley/producer_westley.c @@ -0,0 +1,78 @@ +/* + * producer_libdv.c -- a libxml2 parser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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_westley.h" +#include +#include +#include +#include + +#include + +static mlt_producer parse_westley( char *file ) +{ + return NULL; +} + +mlt_producer producer_westley_init( char *filename ) +{ + int i; + int track = 0; + mlt_producer producer = NULL; + mlt_playlist playlist = mlt_playlist_init( ); + mlt_properties group = mlt_properties_new( ); + mlt_properties properties = group; + mlt_field field = mlt_field_init( ); + mlt_properties field_properties = mlt_field_properties( field ); + mlt_multitrack multitrack = mlt_field_multitrack( field ); + + // We need to track the number of registered filters + mlt_properties_set_int( field_properties, "registered", 0 ); + + // Parse + producer = parse_westley( filename ); + + // TODO + + // Connect producer to playlist + if ( producer != NULL ) + mlt_playlist_append( playlist, producer ); + + // We must have a producer at this point + 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 ); + mlt_properties props = mlt_tractor_properties( tractor ); + mlt_properties_set( mlt_producer_properties( prod ), "resource", filename ); + mlt_properties_set_data( props, "multitrack", multitrack, 0, NULL, NULL ); + mlt_properties_set_data( props, "field", field, 0, NULL, NULL ); + mlt_properties_set_data( props, "group", group, 0, NULL, NULL ); + mlt_properties_set_position( props, "length", mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) + 1 ); + mlt_producer_set_in_and_out( prod, 0, mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) ); + mlt_properties_set_double( props, "fps", mlt_producer_get_fps( mlt_multitrack_producer( multitrack ) ) ); + + return mlt_tractor_producer( tractor ); +} + diff --git a/mlt/src/modules/westley/producer_westley.h b/mlt/src/modules/westley/producer_westley.h new file mode 100644 index 0000000..979a0d7 --- /dev/null +++ b/mlt/src/modules/westley/producer_westley.h @@ -0,0 +1,28 @@ +/* + * producer_westley.h -- a libxml2 parser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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_WESTLEY_H_ +#define _PRODUCER_WESTLEY_H_ + +#include + +extern mlt_producer producer_westley_init( char *filename ); + +#endif diff --git a/mlt/src/tests/dan.c b/mlt/src/tests/dan.c index 0035b26..d62abdf 100644 --- a/mlt/src/tests/dan.c +++ b/mlt/src/tests/dan.c @@ -19,7 +19,7 @@ int main( int argc, char **argv ) // Start the consumer... int vstd = mlt_video_standard_ntsc; //mlt_consumer consumer = mlt_factory_consumer( "bluefish", &vstd ); - mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" ); + mlt_consumer consumer = mlt_factory_consumer( "westley", "PAL" ); // Create the producer(s) mlt_producer dv1 = mlt_factory_producer( "libdv", file1 ); diff --git a/src/framework/mlt_multitrack.c b/src/framework/mlt_multitrack.c index 28d598f..2faaf69 100644 --- a/src/framework/mlt_multitrack.c +++ b/src/framework/mlt_multitrack.c @@ -61,7 +61,7 @@ mlt_multitrack mlt_multitrack_init( ) producer->get_frame = producer_get_frame; mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL ); mlt_properties_set( properties, "log_id", "multitrack" ); - mlt_properties_set( properties, "resource", "" ); + mlt_properties_set( properties, "resource", "" ); } else { @@ -189,6 +189,28 @@ int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int trac return result; } +/** Get the number of tracks. +*/ + +int mlt_multitrack_count( mlt_multitrack this ) +{ + return this->count; +} + +/** Get an individual track as a producer. +*/ + +mlt_producer mlt_multitrack_track( mlt_multitrack this, int track ) +{ + mlt_producer producer = NULL; + + if ( this->list != NULL && track < this->count ) + producer = this->list[ track ]; + + return producer; +} + + /** Determine the clip point. Special case here: a 'producer' has no concept of multiple clips - only the diff --git a/src/framework/mlt_multitrack.h b/src/framework/mlt_multitrack.h index 3f6d8d9..c409752 100644 --- a/src/framework/mlt_multitrack.h +++ b/src/framework/mlt_multitrack.h @@ -33,6 +33,8 @@ extern mlt_properties mlt_multitrack_properties( mlt_multitrack this ); extern int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track ); extern mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ); extern void mlt_multitrack_close( mlt_multitrack this ); +extern int mlt_multitrack_count( mlt_multitrack this ); +extern mlt_producer mlt_multitrack_track( mlt_multitrack this, int track ); #endif diff --git a/src/framework/mlt_repository.c b/src/framework/mlt_repository.c index dcb2c25..9c25b21 100644 --- a/src/framework/mlt_repository.c +++ b/src/framework/mlt_repository.c @@ -94,6 +94,8 @@ static void *construct_instance( mlt_properties service_properties, char *symbol // Open the shared object object = dlopen( full_file, RTLD_NOW | RTLD_GLOBAL ); + if ( object == NULL ) + 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 ); diff --git a/src/framework/mlt_service.c b/src/framework/mlt_service.c index 8e626d4..f432aae 100644 --- a/src/framework/mlt_service.c +++ b/src/framework/mlt_service.c @@ -172,6 +172,24 @@ void mlt_service_connect( mlt_service this, mlt_service that ) base->out = that; } + +/** Get the first connected producer service. +*/ + +mlt_service mlt_service_get_producer( mlt_service this ) +{ + mlt_service producer = NULL; + + // Get the service base + mlt_service_base *base = this->private; + + if ( base->in != NULL ) + producer = base->in[ 0 ]; + + return producer; +} + + /** Get the service state. */ diff --git a/src/framework/mlt_service.h b/src/framework/mlt_service.h index 88b91b5..8ad43a8 100644 --- a/src/framework/mlt_service.h +++ b/src/framework/mlt_service.h @@ -74,6 +74,7 @@ extern int mlt_service_has_input( mlt_service this ); extern int mlt_service_has_output( mlt_service this ); extern int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); extern int mlt_service_is_active( mlt_service this ); +extern mlt_service mlt_service_get_producer( mlt_service this ); #endif diff --git a/src/framework/mlt_tractor.c b/src/framework/mlt_tractor.c index 1bbcace..707d5c5 100644 --- a/src/framework/mlt_tractor.c +++ b/src/framework/mlt_tractor.c @@ -57,6 +57,8 @@ mlt_tractor mlt_tractor_init( ) { producer->get_frame = producer_get_frame; mlt_properties_set( mlt_producer_properties( producer ), "resource", "" ); + mlt_properties_set( mlt_producer_properties( producer ), "mlt_type", "producer" ); + mlt_properties_set( mlt_producer_properties( producer ), "mlt_service", "tractor" ); } else { diff --git a/src/framework/mlt_types.h b/src/framework/mlt_types.h index 162602f..a4707c9 100644 --- a/src/framework/mlt_types.h +++ b/src/framework/mlt_types.h @@ -48,5 +48,11 @@ typedef struct mlt_consumer_s *mlt_consumer; typedef void ( *mlt_destructor )( void * ); typedef char *( *mlt_serialiser )( void *, int length ); +#define MLT_SERVICE(x) ( ( mlt_service )( x ) ) +#define MLT_PRODUCER(x) ( ( mlt_producer )( x ) ) +#define MLT_MULTITRACK(x) ( ( mlt_multitrack )( x ) ) +#define MLT_PLAYLIST(x) ( ( mlt_playlist )( x ) ) +#define MLT_FILTER(x) ( ( mlt_filter )( x ) ) +#define MLT_TRANSITION(x) ( ( mlt_transition )( x ) ) #endif diff --git a/src/modules/Makefile b/src/modules/Makefile index 52c26fc..45f7a31 100644 --- a/src/modules/Makefile +++ b/src/modules/Makefile @@ -1,4 +1,4 @@ -SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo +SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo westley all clean depend install: list='$(SUBDIRS)'; \ diff --git a/src/modules/westley/Makefile b/src/modules/westley/Makefile new file mode 100644 index 0000000..576a6ea --- /dev/null +++ b/src/modules/westley/Makefile @@ -0,0 +1,30 @@ + +TARGET = ../libmltwestley.so + +OBJS = factory.o \ + consumer_westley.o \ + producer_westley.o + +CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread `xml2-config --cflags` + +LDFLAGS = `xml2-config --libs` + +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 diff --git a/src/modules/westley/configure b/src/modules/westley/configure new file mode 100755 index 0000000..b971570 --- /dev/null +++ b/src/modules/westley/configure @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ "$help" != "1" ] +then + +cat << EOF >> ../producers.dat +westley libmltwestley.so +EOF + +cat << EOF >> ../consumers.dat +westley libmltwestley.so +EOF + +fi + diff --git a/src/modules/westley/consumer_westley.c b/src/modules/westley/consumer_westley.c new file mode 100644 index 0000000..8bdb583 --- /dev/null +++ b/src/modules/westley/consumer_westley.c @@ -0,0 +1,175 @@ +/* + * consumer_westley.c -- a libxml2 serialiser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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 "consumer_westley.h" +#include +#include +#include +#include +#include +#include + +/** Forward references to static functions. +*/ + +static int consumer_start( mlt_consumer parent ); + +/** This is what will be called by the factory - anything can be passed in + via the argument, but keep it simple. +*/ + +mlt_consumer consumer_westley_init( char *arg ) +{ + // Create the consumer object + mlt_consumer this = calloc( sizeof( struct mlt_consumer_s ), 1 ); + + // If no malloc'd and consumer init ok + if ( this != NULL && mlt_consumer_init( this, NULL ) == 0 ) + { + // We have stuff to clean up, so override the close method + //parent->close = consumer_close; + + // Allow thread to be started/stopped + this->start = consumer_start; + + // Return the consumer produced + return this; + } + + // malloc or consumer init failed + free( this ); + + // Indicate failure + return NULL; +} + +void serialise_service( mlt_service service ) +{ + // Iterate over consumer/producer connections + while ( service != NULL ) + { + char *mlt_type = mlt_properties_get( mlt_service_properties(service ), "mlt_type" ); + + // Tell about the producer + if ( strcmp( mlt_type, "producer" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' mlt_service '%s' resource '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "mlt_service" ), + mlt_properties_get( mlt_service_properties( service ), "resource" ) ); + } + + // Tell about the framework container producers + else if ( strcmp( mlt_type, "mlt_producer" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' resource '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "resource" ) ); + + // Recurse on multitrack's tracks + if ( strcmp( mlt_properties_get( mlt_service_properties( service ), "resource" ), "" ) == 0 ) + { + int i; + + fprintf( stderr, "contains...\n" ); + for ( i = 0; i < mlt_multitrack_count( MLT_MULTITRACK( service ) ); i++ ) + serialise_service( MLT_SERVICE( mlt_multitrack_track( MLT_MULTITRACK( service ), i ) ) ); + fprintf( stderr, "...done.\n" ); + } + + // Recurse on playlist's clips + else if ( strcmp( mlt_properties_get( mlt_service_properties( service ), "resource" ), "" ) == 0 ) + { + int i; + mlt_playlist_clip_info info; + + fprintf( stderr, "contains...\n" ); + for ( i = 0; i < mlt_playlist_count( MLT_PLAYLIST( service ) ); i++ ) + { + if ( ! mlt_playlist_get_clip_info( MLT_PLAYLIST( service ), &info, i ) ) + serialise_service( MLT_SERVICE( info.producer ) ); + } + fprintf( stderr, "...done.\n" ); + } + } + + // Tell about a filter + else if ( strcmp( mlt_type, "filter" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' mlt_service '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "mlt_service" ) ); + + fprintf( stderr, "is applied to\n" ); + + // Recurse on connected producer + serialise_service( MLT_SERVICE( MLT_FILTER( service )->producer ) ); + } + + // Tell about a transition + else if ( strcmp( mlt_type, "transition" ) == 0 ) + { + fprintf( stderr, "mlt_type '%s' mlt_service '%s'\n", mlt_type, + mlt_properties_get( mlt_service_properties( service ), "mlt_service" ) ); + + fprintf( stderr, "is applied to\n" ); + + // Recurse on connected producer + serialise_service( MLT_SERVICE( MLT_TRANSITION( service )->producer ) ); + } + + // Get the next connected service + service = mlt_service_get_producer( service ); + if ( service != NULL ) + fprintf( stderr, "is connected to\n" ); + } +} + +static int consumer_start( mlt_consumer this ) +{ + // get a handle on properties + mlt_properties properties = mlt_consumer_properties( this ); + + mlt_service inigo = NULL; + + fprintf( stderr, "mlt_type '%s' mlt_service '%s'\n", + mlt_properties_get( properties, "mlt_type" ), + mlt_properties_get( properties, "mlt_service" ) ); + + // Get the producer service + mlt_service service = mlt_service_get_producer( mlt_consumer_service( this ) ); + if ( service != NULL ) + { + fprintf( stderr, "is connected to\n" ); + + // Remember inigo + if ( mlt_properties_get( mlt_service_properties( service ), "mlt_service" ) != NULL && + strcmp( mlt_properties_get( mlt_service_properties( service ), "mlt_service" ), "inigo" ) == 0 ) + inigo = service; + + serialise_service( service ); + } + + mlt_consumer_stop( this ); + + // Tell inigo, enough already! + if ( inigo != NULL ) + mlt_properties_set_int( mlt_service_properties( inigo ), "done", 1 ); + + return 0; +} + diff --git a/src/modules/westley/consumer_westley.h b/src/modules/westley/consumer_westley.h new file mode 100644 index 0000000..8b94db4 --- /dev/null +++ b/src/modules/westley/consumer_westley.h @@ -0,0 +1,28 @@ +/* + * consumer_westley.h -- a libxml2 serialiser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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 _CONSUMER_WESTLEY_H_ +#define _CONSUMER_WESTLEY_H_ + +#include + +extern mlt_consumer consumer_westley_init( char * ); + +#endif diff --git a/src/modules/westley/factory.c b/src/modules/westley/factory.c new file mode 100644 index 0000000..e60cd56 --- /dev/null +++ b/src/modules/westley/factory.c @@ -0,0 +1,49 @@ +/* + * factory.c -- the factory method interfaces + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Charles Yates + * + * 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 + +#include "consumer_westley.h" +#include "producer_westley.h" + +void *mlt_create_producer( char *id, void *arg ) +{ + if ( !strcmp( id, "westley" ) ) + return producer_westley_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 ) +{ + if ( !strcmp( id, "westley" ) ) + return consumer_westley_init( arg ); + return NULL; +} + diff --git a/src/modules/westley/producer_westley.c b/src/modules/westley/producer_westley.c new file mode 100644 index 0000000..6616f3c --- /dev/null +++ b/src/modules/westley/producer_westley.c @@ -0,0 +1,78 @@ +/* + * producer_libdv.c -- a libxml2 parser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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_westley.h" +#include +#include +#include +#include + +#include + +static mlt_producer parse_westley( char *file ) +{ + return NULL; +} + +mlt_producer producer_westley_init( char *filename ) +{ + int i; + int track = 0; + mlt_producer producer = NULL; + mlt_playlist playlist = mlt_playlist_init( ); + mlt_properties group = mlt_properties_new( ); + mlt_properties properties = group; + mlt_field field = mlt_field_init( ); + mlt_properties field_properties = mlt_field_properties( field ); + mlt_multitrack multitrack = mlt_field_multitrack( field ); + + // We need to track the number of registered filters + mlt_properties_set_int( field_properties, "registered", 0 ); + + // Parse + producer = parse_westley( filename ); + + // TODO + + // Connect producer to playlist + if ( producer != NULL ) + mlt_playlist_append( playlist, producer ); + + // We must have a producer at this point + 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 ); + mlt_properties props = mlt_tractor_properties( tractor ); + mlt_properties_set( mlt_producer_properties( prod ), "resource", filename ); + mlt_properties_set_data( props, "multitrack", multitrack, 0, NULL, NULL ); + mlt_properties_set_data( props, "field", field, 0, NULL, NULL ); + mlt_properties_set_data( props, "group", group, 0, NULL, NULL ); + mlt_properties_set_position( props, "length", mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) + 1 ); + mlt_producer_set_in_and_out( prod, 0, mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) ); + mlt_properties_set_double( props, "fps", mlt_producer_get_fps( mlt_multitrack_producer( multitrack ) ) ); + + return mlt_tractor_producer( tractor ); +} + diff --git a/src/modules/westley/producer_westley.h b/src/modules/westley/producer_westley.h new file mode 100644 index 0000000..979a0d7 --- /dev/null +++ b/src/modules/westley/producer_westley.h @@ -0,0 +1,28 @@ +/* + * producer_westley.h -- a libxml2 parser of mlt service networks + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * 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_WESTLEY_H_ +#define _PRODUCER_WESTLEY_H_ + +#include + +extern mlt_producer producer_westley_init( char *filename ); + +#endif diff --git a/src/tests/dan.c b/src/tests/dan.c index 0035b26..d62abdf 100644 --- a/src/tests/dan.c +++ b/src/tests/dan.c @@ -19,7 +19,7 @@ int main( int argc, char **argv ) // Start the consumer... int vstd = mlt_video_standard_ntsc; //mlt_consumer consumer = mlt_factory_consumer( "bluefish", &vstd ); - mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" ); + mlt_consumer consumer = mlt_factory_consumer( "westley", "PAL" ); // Create the producer(s) mlt_producer dv1 = mlt_factory_producer( "libdv", file1 );