]> git.sesse.net Git - mlt/commitdiff
added modules/westley
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Wed, 21 Jan 2004 06:24:52 +0000 (06:24 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Wed, 21 Jan 2004 06:24:52 +0000 (06:24 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@88 d19143bc-622f-0410-bfdd-b5b2a6649095

34 files changed:
docs/services.txt
mlt/docs/services.txt
mlt/src/framework/mlt_multitrack.c
mlt/src/framework/mlt_multitrack.h
mlt/src/framework/mlt_repository.c
mlt/src/framework/mlt_service.c
mlt/src/framework/mlt_service.h
mlt/src/framework/mlt_tractor.c
mlt/src/framework/mlt_types.h
mlt/src/modules/Makefile
mlt/src/modules/westley/Makefile [new file with mode: 0644]
mlt/src/modules/westley/configure [new file with mode: 0755]
mlt/src/modules/westley/consumer_westley.c [new file with mode: 0644]
mlt/src/modules/westley/consumer_westley.h [new file with mode: 0644]
mlt/src/modules/westley/factory.c [new file with mode: 0644]
mlt/src/modules/westley/producer_westley.c [new file with mode: 0644]
mlt/src/modules/westley/producer_westley.h [new file with mode: 0644]
mlt/src/tests/dan.c
src/framework/mlt_multitrack.c
src/framework/mlt_multitrack.h
src/framework/mlt_repository.c
src/framework/mlt_service.c
src/framework/mlt_service.h
src/framework/mlt_tractor.c
src/framework/mlt_types.h
src/modules/Makefile
src/modules/westley/Makefile [new file with mode: 0644]
src/modules/westley/configure [new file with mode: 0755]
src/modules/westley/consumer_westley.c [new file with mode: 0644]
src/modules/westley/consumer_westley.h [new file with mode: 0644]
src/modules/westley/factory.c [new file with mode: 0644]
src/modules/westley/producer_westley.c [new file with mode: 0644]
src/modules/westley/producer_westley.h [new file with mode: 0644]
src/tests/dan.c

index 5c72310223a8ecc4dbfcae2fe0ee54bd484ed761..50f3caddacf8248565d632da77db5083732bde87 100644 (file)
@@ -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
 
index 5c72310223a8ecc4dbfcae2fe0ee54bd484ed761..50f3caddacf8248565d632da77db5083732bde87 100644 (file)
@@ -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
 
index 28d598f5dc9600ffeb3855cad7043294417ff57a..2faaf69ae5dfe698aaed07adcb2861ff94ffbe3c 100644 (file)
@@ -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", "<mulitrack>" );
+                       mlt_properties_set( properties, "resource", "<multitrack>" );
                }
                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 
index 3f6d8d9ad603285bed2b4f723189bfeaa71f6454..c4097528ee01380b4f48f64c49f13ca5e71953c7 100644 (file)
@@ -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
 
index dcb2c25797678c4424acc28b46fb001c5370aaab..9c25b2151e6d34f1bae8e32cefc31c97feb0eaf0 100644 (file)
@@ -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 );
index 8e626d41b49fadb37dbdf0522a4c17b3eb61966a..f432aae8774b2288c647908e654ef8dda873715e 100644 (file)
@@ -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.
 */
 
index 88b91b5019b1c5d95d685322498f2dfe2127c35f..8ad43a8ffefb6affde3b911814f364bd629d8273 100644 (file)
@@ -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
 
index 1bbcace77b411d2bbfe1cad90feff5c0105bc789..707d5c51ee6d8f22ac5c5ca8c52d16fcabdb743b 100644 (file)
@@ -57,6 +57,8 @@ mlt_tractor mlt_tractor_init( )
                {
                        producer->get_frame = producer_get_frame;
                        mlt_properties_set( mlt_producer_properties( producer ), "resource", "<tractor>" );
+                       mlt_properties_set( mlt_producer_properties( producer ), "mlt_type", "producer" );
+                       mlt_properties_set( mlt_producer_properties( producer ), "mlt_service", "tractor" );
                }
                else
                {
index 162602f6f1f8ebb8ed68f352deee2435bb2d7161..a4707c9bc002cccf8bdd02ac703bfa9a1b7b01a6 100644 (file)
@@ -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
index 52c26fccc623c5bc94661c30aaa9f1c6d64f899d..45f7a31cf0449638a79fc380b3d5dbf68362c29c 100644 (file)
@@ -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 (file)
index 0000000..576a6ea
--- /dev/null
@@ -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 (executable)
index 0000000..b971570
--- /dev/null
@@ -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 (file)
index 0000000..8bdb583
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * consumer_westley.c -- a libxml2 serialiser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <libxml/tree.h>
+
+/** 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" ), "<multitrack>" ) == 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" ), "<playlist>" ) == 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 (file)
index 0000000..8b94db4
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * consumer_westley.h -- a libxml2 serialiser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt_consumer.h>
+
+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 (file)
index 0000000..e60cd56
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 "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 (file)
index 0000000..6616f3c
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * producer_libdv.c -- a libxml2 parser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <libxml/parser.h>
+
+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 (file)
index 0000000..979a0d7
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * producer_westley.h -- a libxml2 parser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt_producer.h>
+
+extern mlt_producer producer_westley_init( char *filename );
+
+#endif
index 0035b26958e8184647da93c5037d1aa6ad5cc641..d62abdf446d51437de910edecd3ae89b40e4b47e 100644 (file)
@@ -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 );
index 28d598f5dc9600ffeb3855cad7043294417ff57a..2faaf69ae5dfe698aaed07adcb2861ff94ffbe3c 100644 (file)
@@ -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", "<mulitrack>" );
+                       mlt_properties_set( properties, "resource", "<multitrack>" );
                }
                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 
index 3f6d8d9ad603285bed2b4f723189bfeaa71f6454..c4097528ee01380b4f48f64c49f13ca5e71953c7 100644 (file)
@@ -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
 
index dcb2c25797678c4424acc28b46fb001c5370aaab..9c25b2151e6d34f1bae8e32cefc31c97feb0eaf0 100644 (file)
@@ -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 );
index 8e626d41b49fadb37dbdf0522a4c17b3eb61966a..f432aae8774b2288c647908e654ef8dda873715e 100644 (file)
@@ -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.
 */
 
index 88b91b5019b1c5d95d685322498f2dfe2127c35f..8ad43a8ffefb6affde3b911814f364bd629d8273 100644 (file)
@@ -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
 
index 1bbcace77b411d2bbfe1cad90feff5c0105bc789..707d5c51ee6d8f22ac5c5ca8c52d16fcabdb743b 100644 (file)
@@ -57,6 +57,8 @@ mlt_tractor mlt_tractor_init( )
                {
                        producer->get_frame = producer_get_frame;
                        mlt_properties_set( mlt_producer_properties( producer ), "resource", "<tractor>" );
+                       mlt_properties_set( mlt_producer_properties( producer ), "mlt_type", "producer" );
+                       mlt_properties_set( mlt_producer_properties( producer ), "mlt_service", "tractor" );
                }
                else
                {
index 162602f6f1f8ebb8ed68f352deee2435bb2d7161..a4707c9bc002cccf8bdd02ac703bfa9a1b7b01a6 100644 (file)
@@ -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
index 52c26fccc623c5bc94661c30aaa9f1c6d64f899d..45f7a31cf0449638a79fc380b3d5dbf68362c29c 100644 (file)
@@ -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 (file)
index 0000000..576a6ea
--- /dev/null
@@ -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 (executable)
index 0000000..b971570
--- /dev/null
@@ -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 (file)
index 0000000..8bdb583
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * consumer_westley.c -- a libxml2 serialiser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <libxml/tree.h>
+
+/** 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" ), "<multitrack>" ) == 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" ), "<playlist>" ) == 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 (file)
index 0000000..8b94db4
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * consumer_westley.h -- a libxml2 serialiser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt_consumer.h>
+
+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 (file)
index 0000000..e60cd56
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 "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 (file)
index 0000000..6616f3c
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * producer_libdv.c -- a libxml2 parser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <libxml/parser.h>
+
+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 (file)
index 0000000..979a0d7
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * producer_westley.h -- a libxml2 parser of mlt service networks
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt_producer.h>
+
+extern mlt_producer producer_westley_init( char *filename );
+
+#endif
index 0035b26958e8184647da93c5037d1aa6ad5cc641..d62abdf446d51437de910edecd3ae89b40e4b47e 100644 (file)
@@ -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 );