From 2085323abc65a3325b4e9f1a9733dcf126756862 Mon Sep 17 00:00:00 2001 From: ddennedy Date: Sat, 2 Feb 2008 09:05:43 +0000 Subject: [PATCH] add MltProfile and update examples git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@1054 d19143bc-622f-0410-bfdd-b5b2a6649095 --- mlt++/src/Makefile | 1 + mlt++/src/Mlt.h | 1 + mlt++/src/MltConsumer.cpp | 17 ++++-- mlt++/src/MltConsumer.h | 4 +- mlt++/src/MltFactory.cpp | 17 +++--- mlt++/src/MltFactory.h | 9 ++- mlt++/src/MltFilter.cpp | 9 ++- mlt++/src/MltFilter.h | 3 +- mlt++/src/MltFilteredConsumer.cpp | 4 +- mlt++/src/MltFilteredConsumer.h | 3 +- mlt++/src/MltFilteredProducer.cpp | 4 +- mlt++/src/MltFilteredProducer.h | 3 +- mlt++/src/MltProducer.cpp | 7 +- mlt++/src/MltProducer.h | 3 +- mlt++/src/MltProfile.cpp | 122 +++++++++++++++++++++++++++++++++++++ mlt++/src/MltProfile.h | 63 +++++++++++++++++++ mlt++/src/MltPushConsumer.cpp | 16 +++--- mlt++/src/MltPushConsumer.h | 3 +- mlt++/src/MltService.cpp | 6 ++ mlt++/src/MltService.h | 2 + mlt++/src/MltTractor.cpp | 4 +- mlt++/src/MltTractor.h | 3 +- mlt++/src/MltTransition.cpp | 9 ++- mlt++/src/MltTransition.h | 3 +- mlt++/swig/mltpp.i | 9 ++- mlt++/swig/perl/play.pl | 9 ++- mlt++/swig/python/play.py | 7 ++- mlt++/swig/ruby/miracle.rb | 2 + mlt++/swig/ruby/play.rb | 7 ++- mlt++/swig/ruby/thumbs.rb | 7 ++- mlt++/swig/tcl/play.tcl | 7 +- mlt++/test/play.cpp | 5 +- mlt++/test/server.cpp | 3 +- 33 files changed, 303 insertions(+), 69 deletions(-) create mode 100644 mlt++/src/MltProfile.cpp create mode 100644 mlt++/src/MltProfile.h diff --git a/mlt++/src/Makefile b/mlt++/src/Makefile index eed0512..9dc09c6 100644 --- a/mlt++/src/Makefile +++ b/mlt++/src/Makefile @@ -25,6 +25,7 @@ OBJS = MltConsumer.o \ MltParser.o \ MltPlaylist.o \ MltProducer.o \ + MltProfile.o \ MltProperties.o \ MltPushConsumer.o \ MltResponse.o \ diff --git a/mlt++/src/Mlt.h b/mlt++/src/Mlt.h index 7abb1dc..0a8e4e8 100644 --- a/mlt++/src/Mlt.h +++ b/mlt++/src/Mlt.h @@ -37,6 +37,7 @@ #include "MltParser.h" #include "MltPlaylist.h" #include "MltProducer.h" +#include "MltProfile.h" #include "MltProperties.h" #include "MltPushConsumer.h" #ifndef WIN32 diff --git a/mlt++/src/MltConsumer.cpp b/mlt++/src/MltConsumer.cpp index 0a0a402..a36b63e 100644 --- a/mlt++/src/MltConsumer.cpp +++ b/mlt++/src/MltConsumer.cpp @@ -22,20 +22,27 @@ #include #include "MltConsumer.h" #include "MltEvent.h" +#include "MltProfile.h" using namespace Mlt; Consumer::Consumer( ) : instance( NULL ) { - instance = mlt_factory_consumer( NULL, NULL ); + instance = mlt_factory_consumer( NULL, NULL, NULL ); } -Consumer::Consumer( char *id, char *arg ) : +Consumer::Consumer( Profile& profile ) : + instance( NULL ) +{ + instance = mlt_factory_consumer( profile.get_profile(), NULL, NULL ); +} + +Consumer::Consumer( Profile& profile, char *id, char *arg ) : instance( NULL ) { if ( id == NULL || arg != NULL ) { - instance = mlt_factory_consumer( id, arg ); + instance = mlt_factory_consumer( profile.get_profile(), id, arg ); } else { @@ -44,12 +51,12 @@ Consumer::Consumer( char *id, char *arg ) : char *temp = strdup( id ); char *arg = strchr( temp, ':' ) + 1; *( arg - 1 ) = '\0'; - instance = mlt_factory_consumer( temp, arg ); + instance = mlt_factory_consumer( profile.get_profile(), temp, arg ); free( temp ); } else { - instance = mlt_factory_consumer( id, NULL ); + instance = mlt_factory_consumer( profile.get_profile(), id, NULL ); } } } diff --git a/mlt++/src/MltConsumer.h b/mlt++/src/MltConsumer.h index dc4c87d..52a2882 100644 --- a/mlt++/src/MltConsumer.h +++ b/mlt++/src/MltConsumer.h @@ -30,6 +30,7 @@ namespace Mlt { class Service; + class Profile; class MLTPP_DECLSPEC Consumer : public Service { @@ -37,7 +38,8 @@ namespace Mlt mlt_consumer instance; public: Consumer( ); - Consumer( char *id , char *service = NULL ); + Consumer( Profile& profile ); + Consumer( Profile& profile, char *id , char *service = NULL ); Consumer( Service &consumer ); Consumer( Consumer &consumer ); Consumer( mlt_consumer consumer ); diff --git a/mlt++/src/MltFactory.cpp b/mlt++/src/MltFactory.cpp index f32018a..38a4200 100644 --- a/mlt++/src/MltFactory.cpp +++ b/mlt++/src/MltFactory.cpp @@ -1,6 +1,7 @@ /** * MltFactory.cpp - MLT Wrapper * Copyright (C) 2004-2005 Charles Yates + * Copyright (C) 2008 Dan Dennedy * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -35,24 +36,24 @@ Properties *Factory::event_object( ) return new Properties( mlt_factory_event_object( ) ); } -Producer *Factory::producer( char *id, char *arg ) +Producer *Factory::producer( Profile& profile, char *id, char *arg ) { - return new Producer( id, arg ); + return new Producer( profile, id, arg ); } -Filter *Factory::filter( char *id, char *arg ) +Filter *Factory::filter( Profile& profile, char *id, char *arg ) { - return new Filter( id, arg ); + return new Filter( profile, id, arg ); } -Transition *Factory::transition( char *id, char *arg ) +Transition *Factory::transition( Profile& profile, char *id, char *arg ) { - return new Transition( id, arg ); + return new Transition( profile, id, arg ); } -Consumer *Factory::consumer( char *id, char *arg ) +Consumer *Factory::consumer( Profile& profile, char *id, char *arg ) { - return new Consumer( id, arg ); + return new Consumer( profile, id, arg ); } #ifdef WIN32 diff --git a/mlt++/src/MltFactory.h b/mlt++/src/MltFactory.h index f92cedb..db4cfa9 100644 --- a/mlt++/src/MltFactory.h +++ b/mlt++/src/MltFactory.h @@ -36,16 +36,17 @@ namespace Mlt class Filter; class Transition; class Consumer; + class Profile; class MLTPP_DECLSPEC Factory { public: static int init( char *arg = NULL ); static Properties *event_object( ); - static Producer *producer( char *id, char *arg = NULL ); - static Filter *filter( char *id, char *arg = NULL ); - static Transition *transition( char *id, char *arg = NULL ); - static Consumer *consumer( char *id, char *arg = NULL ); + static Producer *producer( Profile& profile, char *id, char *arg = NULL ); + static Filter *filter( Profile& profile, char *id, char *arg = NULL ); + static Transition *transition( Profile& profile, char *id, char *arg = NULL ); + static Consumer *consumer( Profile& profile, char *id, char *arg = NULL ); #ifdef WIN32 static char *getenv( const char * ); static int setenv( const char *, const char * ); diff --git a/mlt++/src/MltFilter.cpp b/mlt++/src/MltFilter.cpp index 90a178e..f6aea23 100644 --- a/mlt++/src/MltFilter.cpp +++ b/mlt++/src/MltFilter.cpp @@ -21,14 +21,15 @@ #include #include #include "MltFilter.h" +#include "MltProfile.h" using namespace Mlt; -Filter::Filter( char *id, char *arg ) : +Filter::Filter( Profile& profile, char *id, char *arg ) : instance( NULL ) { if ( arg != NULL ) { - instance = mlt_factory_filter( id, arg ); + instance = mlt_factory_filter( profile.get_profile(), id, arg ); } else { @@ -37,12 +38,12 @@ Filter::Filter( char *id, char *arg ) : char *temp = strdup( id ); char *arg = strchr( temp, ':' ) + 1; *( arg - 1 ) = '\0'; - instance = mlt_factory_filter( temp, arg ); + instance = mlt_factory_filter( profile.get_profile(), temp, arg ); free( temp ); } else { - instance = mlt_factory_filter( id, NULL ); + instance = mlt_factory_filter( profile.get_profile(), id, NULL ); } } } diff --git a/mlt++/src/MltFilter.h b/mlt++/src/MltFilter.h index 3be254c..8efb4e4 100644 --- a/mlt++/src/MltFilter.h +++ b/mlt++/src/MltFilter.h @@ -30,13 +30,14 @@ namespace Mlt { class Service; + class Profile; class MLTPP_DECLSPEC Filter : public Service { private: mlt_filter instance; public: - Filter( char *id, char *service = NULL ); + Filter( Profile& profile, char *id, char *service = NULL ); Filter( Service &filter ); Filter( Filter &filter ); Filter( mlt_filter filter ); diff --git a/mlt++/src/MltFilteredConsumer.cpp b/mlt++/src/MltFilteredConsumer.cpp index d414da9..73ee474 100644 --- a/mlt++/src/MltFilteredConsumer.cpp +++ b/mlt++/src/MltFilteredConsumer.cpp @@ -21,8 +21,8 @@ #include "MltFilteredConsumer.h" using namespace Mlt; -FilteredConsumer::FilteredConsumer( char *id, char *arg ) : - Consumer( id, arg ) +FilteredConsumer::FilteredConsumer( Profile& profile, char *id, char *arg ) : + Consumer( profile, id, arg ) { // Create a reference to the first service first = new Service( *this ); diff --git a/mlt++/src/MltFilteredConsumer.h b/mlt++/src/MltFilteredConsumer.h index f1c1fff..21427ec 100644 --- a/mlt++/src/MltFilteredConsumer.h +++ b/mlt++/src/MltFilteredConsumer.h @@ -32,13 +32,14 @@ namespace Mlt class Consumer; class Service; class Filter; + class Profile; class MLTPP_DECLSPEC FilteredConsumer : public Consumer { private: Service *first; public: - FilteredConsumer( char *id, char *arg = NULL ); + FilteredConsumer( Profile& profile, char *id, char *arg = NULL ); FilteredConsumer( Consumer &consumer ); virtual ~FilteredConsumer( ); int connect( Service &service ); diff --git a/mlt++/src/MltFilteredProducer.cpp b/mlt++/src/MltFilteredProducer.cpp index 95a322c..33d8a81 100644 --- a/mlt++/src/MltFilteredProducer.cpp +++ b/mlt++/src/MltFilteredProducer.cpp @@ -21,8 +21,8 @@ #include "MltFilteredProducer.h" using namespace Mlt; -FilteredProducer::FilteredProducer( char *id, char *arg ) : - Producer( id, arg ) +FilteredProducer::FilteredProducer( Profile& profile, char *id, char *arg ) : + Producer( profile, id, arg ) { // Create a reference to the last service last = new Service( *this ); diff --git a/mlt++/src/MltFilteredProducer.h b/mlt++/src/MltFilteredProducer.h index ce76c86..943f620 100644 --- a/mlt++/src/MltFilteredProducer.h +++ b/mlt++/src/MltFilteredProducer.h @@ -32,13 +32,14 @@ namespace Mlt class Producer; class Service; class Filter; + class Profile; class MLTPP_DECLSPEC FilteredProducer : public Producer { private: Service *last; public: - FilteredProducer( char *id, char *arg = NULL ); + FilteredProducer( Profile* profile, char *id, char *arg = NULL ); virtual ~FilteredProducer( ); int attach( Filter &filter ); int detach( Filter &filter ); diff --git a/mlt++/src/MltProducer.cpp b/mlt++/src/MltProducer.cpp index 1b06e91..39a93db 100644 --- a/mlt++/src/MltProducer.cpp +++ b/mlt++/src/MltProducer.cpp @@ -20,6 +20,7 @@ #include "MltProducer.h" #include "MltFilter.h" +#include "MltProfile.h" using namespace Mlt; Producer::Producer( ) : @@ -28,14 +29,14 @@ Producer::Producer( ) : { } -Producer::Producer( char *id, char *service ) : +Producer::Producer( Profile& profile, char *id, char *service ) : instance( NULL ), parent_( NULL ) { if ( id != NULL && service != NULL ) - instance = mlt_factory_producer( id, service ); + instance = mlt_factory_producer( profile.get_profile(), id, service ); else - instance = mlt_factory_producer( "fezzik", id != NULL ? id : service ); + instance = mlt_factory_producer( profile.get_profile(), "fezzik", id != NULL ? id : service ); } Producer::Producer( Service &producer ) : diff --git a/mlt++/src/MltProducer.h b/mlt++/src/MltProducer.h index 35c2f0e..09a4977 100644 --- a/mlt++/src/MltProducer.h +++ b/mlt++/src/MltProducer.h @@ -31,6 +31,7 @@ namespace Mlt { class Service; class Filter; + class Profile; class MLTPP_DECLSPEC Producer : public Service { @@ -39,7 +40,7 @@ namespace Mlt Producer *parent_; public: Producer( ); - Producer( char *id, char *service = NULL ); + Producer( Profile& profile, char *id, char *service = NULL ); Producer( Service &producer ); Producer( mlt_producer producer ); Producer( Producer &producer ); diff --git a/mlt++/src/MltProfile.cpp b/mlt++/src/MltProfile.cpp new file mode 100644 index 0000000..0df73dc --- /dev/null +++ b/mlt++/src/MltProfile.cpp @@ -0,0 +1,122 @@ +/** + * MltProfile.cpp - MLT Wrapper + * Copyright (C) 2008 Dan Dennedy + * + * 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 "MltProfile.h" +#include "MltProperties.h" +using namespace Mlt; + +Profile::Profile( ) : + instance( NULL ) +{ + instance = mlt_profile_init( NULL ); +} + +Profile::Profile( const char* name ) : + instance( NULL ) +{ + instance = mlt_profile_init( name ); +} + +Profile::Profile( Properties& properties ) : + instance( NULL ) +{ + instance = mlt_profile_load_properties( properties.get_properties() ); +} + +Profile::Profile( mlt_profile profile ) : + instance( profile ) +{ +} + +Profile::~Profile( ) +{ + if ( instance ) + mlt_profile_close( instance ); + instance = NULL; +} + +mlt_profile Profile::get_profile( ) const +{ + return instance; +} + +char* Profile::description() const +{ + return instance->description; +} + +int Profile::frame_rate_num() const +{ + return instance->frame_rate_num; +} + +int Profile::frame_rate_den() const +{ + return instance->frame_rate_den; +} + +double Profile::fps() const +{ + return mlt_profile_fps( instance ); +} + +int Profile::width() const +{ + return instance->width; +} + +int Profile::height() const +{ + return instance->height; +} + +bool Profile::progressive() const +{ + return instance->progressive; +} + +int Profile::sample_aspect_num() const +{ + return instance->sample_aspect_num; +} + +int Profile::sample_aspect_den() const +{ + return instance->sample_aspect_den; +} + +double Profile::sar() const +{ + return mlt_profile_sar( instance ); +} + +int Profile::display_aspect_num() const +{ + return instance->display_aspect_num; +} + +int Profile::display_aspect_den() const +{ + return instance->display_aspect_den; +} + +double Profile::dar() const +{ + return mlt_profile_dar( instance ); +} diff --git a/mlt++/src/MltProfile.h b/mlt++/src/MltProfile.h new file mode 100644 index 0000000..2a1f891 --- /dev/null +++ b/mlt++/src/MltProfile.h @@ -0,0 +1,63 @@ +/** + * MltProfile.h - MLT Wrapper + * Copyright (C) 2008 Dan Dennedy + * + * 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_PROFILE_H_ +#define _MLTPP_PROFILE_H_ + +#include "config.h" + +#ifdef SWIG +#define MLTPP_DECLSPEC +#endif + +#include + +namespace Mlt +{ + class Properties; + + class MLTPP_DECLSPEC Profile + { + private: + mlt_profile instance; + public: + Profile( ); + Profile( const char* name ); + Profile( Properties& properties ); + Profile( mlt_profile profile ); + ~Profile(); + + mlt_profile get_profile( ) const; + char* description() const; + int frame_rate_num() const; + int frame_rate_den() const; + double fps() const; + int width() const; + int height() const; + bool progressive() const; + int sample_aspect_num() const; + int sample_aspect_den() const; + double sar() const; + int display_aspect_num() const; + int display_aspect_den() const; + double dar() const; + }; +} + +#endif diff --git a/mlt++/src/MltPushConsumer.cpp b/mlt++/src/MltPushConsumer.cpp index 7d96218..041687f 100644 --- a/mlt++/src/MltPushConsumer.cpp +++ b/mlt++/src/MltPushConsumer.cpp @@ -39,8 +39,8 @@ static void filter_destructor( void *arg ) delete filter; } -PushConsumer::PushConsumer( char *id , char *service ) : - Consumer( id, service ), +PushConsumer::PushConsumer( Profile& profile, char *id , char *service ) : + Consumer( profile, id, service ), m_private( new PushPrivate( ) ) { if ( is_valid( ) ) @@ -53,20 +53,20 @@ PushConsumer::PushConsumer( char *id , char *service ) : // We might need resize and rescale filters so we'll create them now // NB: Try to use the best rescaler available here - Filter *resize = new Filter( "resize" ); - Filter *rescale = new Filter( "mcrescale" ); + Filter *resize = new Filter( profile, "resize" ); + Filter *rescale = new Filter( profile, "mcrescale" ); if ( !rescale->is_valid( ) ) { delete rescale; - rescale = new Filter( "gtkrescale" ); + rescale = new Filter( profile, "gtkrescale" ); } if ( !rescale->is_valid( ) ) { delete rescale; - rescale = new Filter( "rescale" ); + rescale = new Filter( profile, "rescale" ); } - Filter *convert = new Filter( "avcolour_space" ); + Filter *convert = new Filter( profile, "avcolour_space" ); set( "filter_convert", convert, 0, filter_destructor ); set( "filter_resize", resize, 0, filter_destructor ); @@ -136,7 +136,7 @@ int PushConsumer::drain( ) // Convenience function - generates a frame with an image of a given size Frame *PushConsumer::construct( int size ) { - mlt_frame f = mlt_frame_init( ); + mlt_frame f = mlt_frame_init( get_service() ); Frame *frame = new Frame( f ); uint8_t *buffer = ( uint8_t * )mlt_pool_alloc( size ); frame->set( "image", buffer, size, mlt_pool_release ); diff --git a/mlt++/src/MltPushConsumer.h b/mlt++/src/MltPushConsumer.h index 105d7fa..1eacf93 100644 --- a/mlt++/src/MltPushConsumer.h +++ b/mlt++/src/MltPushConsumer.h @@ -30,13 +30,14 @@ namespace Mlt class Frame; class Service; class PushPrivate; + class Profile; class MLTPP_DECLSPEC PushConsumer : public Consumer { private: PushPrivate *m_private; public: - PushConsumer( char *id , char *service = NULL ); + PushConsumer( Profile& profile, char *id , char *service = NULL ); virtual ~PushConsumer( ); void set_render( int width, int height, double aspect_ratio ); virtual int connect( Service &service ); diff --git a/mlt++/src/MltService.cpp b/mlt++/src/MltService.cpp index 078a289..88751ab 100644 --- a/mlt++/src/MltService.cpp +++ b/mlt++/src/MltService.cpp @@ -21,6 +21,7 @@ #include #include "MltService.h" #include "MltFilter.h" +#include "MltProfile.h" using namespace Mlt; Service::Service( ) : @@ -83,6 +84,11 @@ Service *Service::consumer( ) return new Service( mlt_service_consumer( get_service( ) ) ); } +Profile *Service::profile( ) +{ + return new Profile( mlt_service_profile( get_service() ) ); +} + Frame *Service::get_frame( int index ) { mlt_frame frame = NULL; diff --git a/mlt++/src/MltService.h b/mlt++/src/MltService.h index aa2c0e2..2079614 100644 --- a/mlt++/src/MltService.h +++ b/mlt++/src/MltService.h @@ -33,6 +33,7 @@ namespace Mlt class Properties; class Filter; class Frame; + class Profile; class MLTPP_DECLSPEC Service : public Properties { @@ -50,6 +51,7 @@ namespace Mlt int connect_producer( Service &producer, int index = 0 ); Service *consumer( ); Service *producer( ); + Profile *profile( ); Frame *get_frame( int index = 0 ); mlt_service_type type( ); int attach( Filter &filter ); diff --git a/mlt++/src/MltTractor.cpp b/mlt++/src/MltTractor.cpp index 09e53eb..ab29155 100644 --- a/mlt++/src/MltTractor.cpp +++ b/mlt++/src/MltTractor.cpp @@ -53,10 +53,10 @@ Tractor::Tractor( Tractor &tractor ) : inc_ref( ); } -Tractor::Tractor( char *id, char *resource ) : +Tractor::Tractor( Profile& profile, char *id, char *resource ) : instance( NULL ) { - Producer producer( id, resource ); + Producer producer( profile, id, resource ); if ( producer.is_valid( ) && producer.type( ) == tractor_type ) { instance = ( mlt_tractor )producer.get_producer( ); diff --git a/mlt++/src/MltTractor.h b/mlt++/src/MltTractor.h index 3b220aa..9fe5d79 100644 --- a/mlt++/src/MltTractor.h +++ b/mlt++/src/MltTractor.h @@ -34,6 +34,7 @@ namespace Mlt class Multitrack; class Transition; class Filter; + class Profile; class MLTPP_DECLSPEC Tractor : public Producer { @@ -44,7 +45,7 @@ namespace Mlt Tractor( Service &tractor ); Tractor( mlt_tractor tractor ); Tractor( Tractor &tractor ); - Tractor( char *id, char *arg = NULL ); + Tractor( Profile& profile, char *id, char *arg = NULL ); virtual ~Tractor( ); virtual mlt_tractor get_tractor( ); mlt_producer get_producer( ); diff --git a/mlt++/src/MltTransition.cpp b/mlt++/src/MltTransition.cpp index 5a18c8e..34fa531 100644 --- a/mlt++/src/MltTransition.cpp +++ b/mlt++/src/MltTransition.cpp @@ -21,14 +21,15 @@ #include #include #include "MltTransition.h" +#include "MltProfile.h" using namespace Mlt; -Transition::Transition( char *id, char *arg ) : +Transition::Transition( Profile& profile, char *id, char *arg ) : instance( NULL ) { if ( arg != NULL ) { - instance = mlt_factory_transition( id, arg ); + instance = mlt_factory_transition( profile.get_profile(), id, arg ); } else { @@ -37,12 +38,12 @@ Transition::Transition( char *id, char *arg ) : char *temp = strdup( id ); char *arg = strchr( temp, ':' ) + 1; *( arg - 1 ) = '\0'; - instance = mlt_factory_transition( temp, arg ); + instance = mlt_factory_transition( profile.get_profile(), temp, arg ); free( temp ); } else { - instance = mlt_factory_transition( id, NULL ); + instance = mlt_factory_transition( profile.get_profile(), id, NULL ); } } } diff --git a/mlt++/src/MltTransition.h b/mlt++/src/MltTransition.h index 66ed23f..e0559af 100644 --- a/mlt++/src/MltTransition.h +++ b/mlt++/src/MltTransition.h @@ -29,13 +29,14 @@ namespace Mlt { class Service; + class Profile; class MLTPP_DECLSPEC Transition : public Service { private: mlt_transition instance; public: - Transition( char *id, char *arg = NULL ); + Transition( Profile& profile, char *id, char *arg = NULL ); Transition( Service &transition ); Transition( Transition &transition ); Transition( mlt_transition transition ); diff --git a/mlt++/swig/mltpp.i b/mlt++/swig/mltpp.i index 60d842d..e456af8 100644 --- a/mlt++/swig/mltpp.i +++ b/mlt++/swig/mltpp.i @@ -30,10 +30,10 @@ */ namespace Mlt { -%newobject Factory::producer( char *, char * ); -%newobject Factory::filter( char *, char * ); -%newobject Factory::transition( char *, char * ); -%newobject Factory::consumer( char *, char * ); +%newobject Factory::producer( Profile &, char *, char * ); +%newobject Factory::filter( Profile &, char *, char * ); +%newobject Factory::transition( Profile &, char *, char * ); +%newobject Factory::consumer( Profile &, char *, char * ); %newobject Properties::listen( char *, void *, mlt_listener ); %newobject Service::producer( ); %newobject Service::consumer( ); @@ -66,6 +66,7 @@ namespace Mlt { %include %include %include +%include %include %include %include diff --git a/mlt++/swig/perl/play.pl b/mlt++/swig/perl/play.pl index aae79e3..87047b9 100755 --- a/mlt++/swig/perl/play.pl +++ b/mlt++/swig/perl/play.pl @@ -1,4 +1,4 @@ -#!/bin/env perl +#!/usr/bin/env perl # Import required modules use mltpp; @@ -6,8 +6,11 @@ use mltpp; # Not sure why the mltpp::Factory.init method fails... mltpp::mlt_factory_init( undef ); +# Establish the MLT profile +$profile = new mltpp::Profile( undef ); + # Create the producer -$p = new mltpp::Producer( $ARGV[0] ); +$p = new mltpp::Producer( $profile, $ARGV[0] ); if ( $p->is_valid( ) ) { @@ -15,7 +18,7 @@ if ( $p->is_valid( ) ) $p->set( "eof", "loop" ); # Create the consumer - $c = new mltpp::FilteredConsumer( "sdl" ); + $c = new mltpp::FilteredConsumer( $profile, "sdl" ); # Turn of the default rescaling $c->set( "rescale", "none" ); diff --git a/mlt++/swig/python/play.py b/mlt++/swig/python/play.py index 70be84d..ce45c7b 100755 --- a/mlt++/swig/python/play.py +++ b/mlt++/swig/python/play.py @@ -8,12 +8,15 @@ import sys # Start the mlt system mltpp.Factory.init( ) +# Establish a profile +profile = mltpp.Profile( ) + # Create the producer -p = mltpp.Producer( sys.argv[1] ) +p = mltpp.Producer( profile, sys.argv[1] ) if p: # Create the consumer - c = mltpp.Consumer( "sdl" ) + c = mltpp.Consumer( profile, "sdl" ) # Turn off the default rescaling c.set( "rescale", "none" ) diff --git a/mlt++/swig/ruby/miracle.rb b/mlt++/swig/ruby/miracle.rb index 2b5afc0..1340a6c 100755 --- a/mlt++/swig/ruby/miracle.rb +++ b/mlt++/swig/ruby/miracle.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + require 'mltpp' def command diff --git a/mlt++/swig/ruby/play.rb b/mlt++/swig/ruby/play.rb index 9577e4e..1ec995b 100755 --- a/mlt++/swig/ruby/play.rb +++ b/mlt++/swig/ruby/play.rb @@ -6,16 +6,19 @@ require 'mltpp' # Create the mlt system Mltpp::Factory::init +# Establish the mlt profile +profile = Mltpp::Profile.new + # Get and check the argument file = ARGV.shift raise "Usage: test.rb file" if file.nil? # Create the producer -producer = Mltpp::Factory::producer( file ) +producer = Mltpp::Factory::producer( profile, file ) raise "Unable to load #{file}" if !producer.is_valid # Create the consumer -consumer = Mltpp::Consumer.new( "sdl" ) +consumer = Mltpp::Consumer.new( profile, "sdl" ) raise "Unable to open sdl consumer" if !consumer.is_valid # Turn off the default rescaling diff --git a/mlt++/swig/ruby/thumbs.rb b/mlt++/swig/ruby/thumbs.rb index 9e28782..f91c598 100755 --- a/mlt++/swig/ruby/thumbs.rb +++ b/mlt++/swig/ruby/thumbs.rb @@ -6,6 +6,9 @@ require 'mltpp' # Create the mlt system Mltpp::Factory::init +# Establish the mlt profile +profile = Mltpp::Profile.new + # Get and check the argument file = ARGV.shift name = ARGV.shift @@ -14,7 +17,7 @@ size = "192x144" if size.nil? raise "Usage: thumbs.rb file name [ size ]" if file.nil? || name.nil? # Create the producer -producer = Mltpp::Producer.new( file ) +producer = Mltpp::Producer.new( profile, file ) raise "Unable to load #{file}" if !producer.is_valid # Construct the playlist @@ -27,7 +30,7 @@ out = producer.get_int( "out" ); [ 0, 0.25, 0.5, 0.75, 1 ].each { |x| playlist.append( producer, x*out, x*out ) } # Create the thumb nail generator -generator = Mltpp::Consumer.new( "avformat", "#{name}%d.jpg" ) +generator = Mltpp::Consumer.new( profile, "avformat", "#{name}%d.jpg" ) generator.set( "real_time", "0" ) generator.set( "progressive", "1" ) generator.set( "size", size ) diff --git a/mlt++/swig/tcl/play.tcl b/mlt++/swig/tcl/play.tcl index 5180b93..2b182c7 100755 --- a/mlt++/swig/tcl/play.tcl +++ b/mlt++/swig/tcl/play.tcl @@ -1,10 +1,11 @@ -#!/bin/env tclsh +#!/usr/bin/env tclsh load mltpp.so mltpp.Factory.init +set profile [Profile] set arg1 [lindex $argv 0] -set p [factory_producer fezzik $arg1] -set c [factory_consumer sdl ""] +set p [factory_producer $profile fezzik $arg1] +set c [factory_consumer $profile sdl ""] set r [mlt_consumer_properties $c] mlt_properties_set $r "rescale" "none" consumer_connect $c $p diff --git a/mlt++/test/play.cpp b/mlt++/test/play.cpp index 459875d..f759374 100644 --- a/mlt++/test/play.cpp +++ b/mlt++/test/play.cpp @@ -5,8 +5,9 @@ using namespace Mlt; int main( int argc, char **argv ) { Factory::init( NULL ); - Producer producer( argv[ 1 ] ); - Consumer consumer; + Profile profile; + Producer producer( profile, argv[ 1 ] ); + Consumer consumer( profile ); consumer.set( "rescale", "none" ); consumer.connect( producer ); consumer.run( ); diff --git a/mlt++/test/server.cpp b/mlt++/test/server.cpp index bcedd6f..ce6b869 100644 --- a/mlt++/test/server.cpp +++ b/mlt++/test/server.cpp @@ -10,6 +10,7 @@ class Custom : public Miracle { private: Event *event; + Profile profile; public: Custom( char *name = "Custom", int port = 5290, char *config = NULL ) : @@ -29,7 +30,7 @@ class Custom : public Miracle Response *received( char *command, char *document ) { cerr << document << endl; - Producer producer( "westley-xml", document ); + Producer producer( profile, "westley-xml", document ); return push( command, &producer ); } -- 1.7.4.4