Added the parser object and moved type identity into mlt
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 5 Oct 2004 10:45:50 +0000 (10:45 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 5 Oct 2004 10:45:50 +0000 (10:45 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@463 d19143bc-622f-0410-bfdd-b5b2a6649095

mlt++/src/Makefile
mlt++/src/Mlt.h
mlt++/src/MltFrame.cpp
mlt++/src/MltFrame.h
mlt++/src/MltParser.cpp [new file with mode: 0644]
mlt++/src/MltParser.h [new file with mode: 0644]
mlt++/src/MltService.cpp
mlt++/src/MltService.h
mlt++/swig/mltpp.i

index ea24b27..79601d6 100644 (file)
@@ -14,6 +14,7 @@ OBJS = MltConsumer.o \
           MltFrame.o \
           MltMiracle.o \
           MltMultitrack.o \
+          MltParser.o \
           MltPlaylist.o \
           MltProducer.o \
           MltProperties.o \
index c5ba627..820354e 100644 (file)
@@ -30,6 +30,7 @@
 #include "MltFrame.h"
 #include "MltMiracle.h"
 #include "MltMultitrack.h"
+#include "MltParser.h"
 #include "MltPlaylist.h"
 #include "MltProducer.h"
 #include "MltProperties.h"
index 4457cec..546220d 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include "MltFrame.h"
+#include "MltProducer.h"
 using namespace Mlt;
 
 Frame::Frame( mlt_frame frame ) :
@@ -82,3 +83,7 @@ unsigned char *Frame::get_waveform( int w, int h )
        return mlt_frame_get_waveform( get_frame( ), w, h );
 }
 
+Producer *Frame::get_original_producer( )
+{
+       return new Producer( mlt_frame_get_original_producer( get_frame( ) ) );
+}
index f54fd44..030ae0d 100644 (file)
@@ -27,6 +27,7 @@
 namespace Mlt
 {
        class Properties;
+       class Producer;
 
        class Frame : public Properties
        {
@@ -42,6 +43,7 @@ namespace Mlt
                        unsigned char *fetch_image( mlt_image_format format, int w, int h, int writable = 0 );
                        int16_t *get_audio( mlt_audio_format &format, int &frequency, int &channels, int &samples );
                        unsigned char *get_waveform( int w, int h );
+                       Producer *get_original_producer( );
        };
 }
 
diff --git a/mlt++/src/MltParser.cpp b/mlt++/src/MltParser.cpp
new file mode 100644 (file)
index 0000000..5cd3c07
--- /dev/null
@@ -0,0 +1,284 @@
+/**
+ * MltParser.cpp - MLT Wrapper
+ * Copyright (C) 2004-2005 Charles Yates
+ * 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 Lesser 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 "Mlt.h"
+using namespace Mlt;
+
+static int on_invalid_cb( mlt_parser self, mlt_service object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Service service( object );
+       return parser->on_invalid( &service );
+}
+
+static int on_unknown_cb( mlt_parser self, mlt_service object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Service service( object );
+       return parser->on_unknown( &service );
+}
+
+static int on_start_producer_cb( mlt_parser self, mlt_producer object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Producer producer( object );
+       return parser->on_start_producer( &producer );
+}
+
+static int on_end_producer_cb( mlt_parser self, mlt_producer object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Producer producer( object );
+       return parser->on_end_producer( &producer );
+}
+
+static int on_start_playlist_cb( mlt_parser self, mlt_playlist object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Playlist playlist( object );
+       return parser->on_start_playlist( &playlist );
+}
+
+static int on_end_playlist_cb( mlt_parser self, mlt_playlist object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Playlist playlist( object );
+       return parser->on_end_playlist( &playlist );
+}
+
+static int on_start_tractor_cb( mlt_parser self, mlt_tractor object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Tractor tractor( object );
+       return parser->on_start_tractor( &tractor );
+}
+
+static int on_end_tractor_cb( mlt_parser self, mlt_tractor object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Tractor tractor( object );
+       return parser->on_end_tractor( &tractor );
+}
+
+static int on_start_multitrack_cb( mlt_parser self, mlt_multitrack object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Multitrack multitrack( object );
+       return parser->on_start_multitrack( &multitrack );
+}
+
+static int on_end_multitrack_cb( mlt_parser self, mlt_multitrack object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Multitrack multitrack( object );
+       return parser->on_end_multitrack( &multitrack );
+}
+
+static int on_start_track_cb( mlt_parser self )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       return parser->on_start_track( );
+}
+
+static int on_end_track_cb( mlt_parser self )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       return parser->on_end_track( );
+}
+
+static int on_start_filter_cb( mlt_parser self, mlt_filter object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Filter filter( object );
+       return parser->on_start_filter( &filter );
+}
+
+static int on_end_filter_cb( mlt_parser self, mlt_filter object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Filter filter( object );
+       return parser->on_end_filter( &filter );
+}
+
+static int on_start_transition_cb( mlt_parser self, mlt_transition object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Transition transition( object );
+       return parser->on_start_transition( &transition );
+}
+
+static int on_end_transition_cb( mlt_parser self, mlt_transition object )
+{
+       mlt_properties properties = mlt_parser_properties( self );
+       Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
+       Transition transition( object );
+       return parser->on_end_transition( &transition );
+}
+
+Parser::Parser( ) :
+       Properties( false )
+{
+       parser = mlt_parser_new( );
+       set( "_parser_object", this, 0 );
+       parser->on_invalid = on_invalid_cb;
+       parser->on_unknown = on_unknown_cb;
+       parser->on_start_producer = on_start_producer_cb;
+       parser->on_end_producer = on_end_producer_cb;
+       parser->on_start_playlist = on_start_playlist_cb;
+       parser->on_end_playlist = on_end_playlist_cb;
+       parser->on_start_tractor = on_start_tractor_cb;
+       parser->on_end_tractor = on_end_tractor_cb;
+       parser->on_start_multitrack = on_start_multitrack_cb;
+       parser->on_end_multitrack = on_end_multitrack_cb;
+       parser->on_start_track = on_start_track_cb;
+       parser->on_end_track = on_end_track_cb;
+       parser->on_start_filter = on_start_filter_cb;
+       parser->on_end_filter = on_end_filter_cb;
+       parser->on_start_transition = on_start_transition_cb;
+       parser->on_end_transition = on_end_transition_cb;
+}
+
+Parser::~Parser( )
+{
+       mlt_parser_close( parser );
+}
+
+mlt_properties Parser::get_properties( )
+{
+       return mlt_parser_properties( parser );
+}
+
+int Parser::start( Service &service )
+{
+       return mlt_parser_start( parser, service.get_service( ) );
+}
+
+int Parser::on_invalid( Service *object )
+{
+       object->debug( "Invalid" );
+       return 0;
+}
+
+int Parser::on_unknown( Service *object )
+{
+       object->debug( "Unknown" );
+       return 0;
+}
+
+int Parser::on_start_producer( Producer *object )
+{
+       object->debug( "on_start_producer" );
+       return 0;
+}
+
+int Parser::on_end_producer( Producer *object )
+{
+       object->debug( "on_end_producer" );
+       return 0;
+}
+
+int Parser::on_start_playlist( Playlist *object )
+{
+       object->debug( "on_start_playlist" );
+       return 0;
+}
+
+int Parser::on_end_playlist( Playlist *object )
+{
+       object->debug( "on_end_playlist" );
+       return 0;
+}
+
+int Parser::on_start_tractor( Tractor *object )
+{
+       object->debug( "on_start_tractor" );
+       return 0;
+}
+
+int Parser::on_end_tractor( Tractor *object )
+{
+       object->debug( "on_end_tractor" );
+       return 0;
+}
+
+int Parser::on_start_multitrack( Multitrack *object )
+{
+       object->debug( "on_start_multitrack" );
+       return 0;
+}
+
+int Parser::on_end_multitrack( Multitrack *object )
+{
+       object->debug( "on_end_multitrack" );
+       return 0;
+}
+
+int Parser::on_start_track( )
+{
+       fprintf( stderr, "on_start_track\n" );
+       return 0;
+}
+
+int Parser::on_end_track( )
+{
+       fprintf( stderr, "on_end_track\n" );
+       return 0;
+}
+
+int Parser::on_start_filter( Filter *object )
+{
+       object->debug( "on_start_filter" );
+       return 0;
+}
+
+int Parser::on_end_filter( Filter *object )
+{
+       object->debug( "on_end_filter" );
+       return 0;
+}
+
+int Parser::on_start_transition( Transition *object )
+{
+       object->debug( "on_start_transition" );
+       return 0;
+}
+
+int Parser::on_end_transition( Transition *object )
+{
+       object->debug( "on_end_transition" );
+       return 0;
+}
+
+
diff --git a/mlt++/src/MltParser.h b/mlt++/src/MltParser.h
new file mode 100644 (file)
index 0000000..397834e
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * MltParser.h - MLT Wrapper
+ * Copyright (C) 2004-2005 Charles Yates
+ * 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 Lesser 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 _MLTPP_PARSER_H_
+#define _MLTPP_PARSER_H_
+
+#include <framework/mlt.h>
+#include "MltProperties.h"
+
+namespace Mlt
+{
+       class Properties;
+       class Service;
+       class Producer;
+       class Playlist;
+       class Tractor;
+       class Multitrack;
+       class Filter;
+       class Transition;
+
+       class Parser : public Properties
+       {
+               private:
+                       mlt_parser parser;
+               protected:
+                       virtual mlt_properties get_properties( );       
+               public:
+                       Parser( );
+                       ~Parser( );
+                       int start( Service &service );
+                       virtual int on_invalid( Service *object );
+                       virtual int on_unknown( Service *object );
+                       virtual int on_start_producer( Producer *object );
+                       virtual int on_end_producer( Producer *object );
+                       virtual int on_start_playlist( Playlist *object );
+                       virtual int on_end_playlist( Playlist *object );
+                       virtual int on_start_tractor( Tractor *object );
+                       virtual int on_end_tractor( Tractor *object );
+                       virtual int on_start_multitrack( Multitrack *object );
+                       virtual int on_end_multitrack( Multitrack *object );
+                       virtual int on_start_track( );
+                       virtual int on_end_track( );
+                       virtual int on_start_filter( Filter *object );
+                       virtual int on_end_filter( Filter *object );
+                       virtual int on_start_transition( Transition *object );
+                       virtual int on_end_transition( Transition *object );
+       };
+}
+
+#endif
index b20b6b1..c349cf4 100644 (file)
@@ -82,38 +82,9 @@ Frame *Service::get_frame( int index )
        return result;
 }
 
-service_type Service::type( )
+mlt_service_type Service::type( )
 {
-       service_type type = invalid_type;
-       if ( is_valid( ) )
-       {
-               char *mlt_type = get( "mlt_type" );
-               char *resource = get( "resource" );
-               if ( mlt_type == NULL )
-                       type = unknown_type;
-               else if ( !strcmp( mlt_type, "producer" ) )
-                       type = producer_type;
-               else if ( !strcmp( mlt_type, "mlt_producer" ) )
-               {
-                       if ( resource == NULL )
-                               type = producer_type;
-                       else if ( !strcmp( resource, "<playlist>" ) )
-                               type = playlist_type;
-                       else if ( !strcmp( resource, "<tractor>" ) )
-                               type = tractor_type;
-                       else if ( !strcmp( resource, "<multitrack>" ) )
-                               type = multitrack_type;
-               }
-               else if ( !strcmp( mlt_type, "filter" ) )
-                       type = filter_type;
-               else if ( !strcmp( mlt_type, "transition" ) )
-                       type = transition_type;
-               else if ( !strcmp( mlt_type, "consumer" ) )
-                       type = consumer_type;
-               else
-                       type = unknown_type;
-       }
-       return type;
+       return mlt_service_identify( get_service( ) );
 }
 
 int Service::attach( Filter &filter )
index 1e8a936..0e5af04 100644 (file)
@@ -32,20 +32,6 @@ namespace Mlt
        class Filter;
        class Frame;
 
-       enum service_type
-       {
-               invalid_type,
-               unknown_type,
-               producer_type,
-               playlist_type,
-               tractor_type,
-               multitrack_type,
-               filter_type,
-               transition_type,
-               consumer_type,
-               field_type
-       };
-
        class Service : public Properties
        {
                private:
@@ -61,7 +47,7 @@ namespace Mlt
                        Service *consumer( );
                        Service *producer( );
                        Frame *get_frame( int index = 0 );
-                       service_type type( );
+                       mlt_service_type type( );
                        int attach( Filter &filter );
                        int detach( Filter &filter );
                        Filter *filter( int index );
index 518b93c..5249eb5 100644 (file)
@@ -48,6 +48,7 @@ namespace Mlt {
 %newobject Tractor::multitrack( );
 %newobject Tractor::field( );
 %newobject Tractor::track( int );
+%newobject Frame::get_original_producer( );
 %newobject Miracle::execute( char * );
 %newobject Miracle::push( char *, Service & );
 }
@@ -70,6 +71,7 @@ namespace Mlt {
 %include <MltMultitrack.h>
 %include <MltField.h>
 %include <MltTractor.h>
+%include <MltParser.h>
 %include <MltFilteredConsumer.h>
 %include <MltMiracle.h>
 %include <MltResponse.h>