MltParser.o \
MltPlaylist.o \
MltProducer.o \
+ MltProfile.o \
MltProperties.o \
MltPushConsumer.o \
MltResponse.o \
#include "MltParser.h"
#include "MltPlaylist.h"
#include "MltProducer.h"
+#include "MltProfile.h"
#include "MltProperties.h"
#include "MltPushConsumer.h"
#ifndef WIN32
#include <string.h>
#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
{
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 );
}
}
}
namespace Mlt
{
class Service;
+ class Profile;
class MLTPP_DECLSPEC Consumer : public Service
{
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 );
/**
* MltFactory.cpp - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
+ * Copyright (C) 2008 Dan Dennedy <dan@dennedy.org>
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
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
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 * );
#include <stdlib.h>
#include <string.h>
#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
{
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 );
}
}
}
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 );
#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 );
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 );
#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 );
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 );
#include "MltProducer.h"
#include "MltFilter.h"
+#include "MltProfile.h"
using namespace Mlt;
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 ) :
{
class Service;
class Filter;
+ class Profile;
class MLTPP_DECLSPEC Producer : public Service
{
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 );
--- /dev/null
+/**
+ * MltProfile.cpp - MLT Wrapper
+ * Copyright (C) 2008 Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 );
+}
--- /dev/null
+/**
+ * MltProfile.h - MLT Wrapper
+ * Copyright (C) 2008 Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 <framework/mlt.h>
+
+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
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( ) )
// 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 );
// 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 );
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 );
#include <string.h>
#include "MltService.h"
#include "MltFilter.h"
+#include "MltProfile.h"
using namespace Mlt;
Service::Service( ) :
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;
class Properties;
class Filter;
class Frame;
+ class Profile;
class MLTPP_DECLSPEC Service : public Properties
{
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 );
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( );
class Multitrack;
class Transition;
class Filter;
+ class Profile;
class MLTPP_DECLSPEC Tractor : public Producer
{
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( );
#include <stdlib.h>
#include <string.h>
#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
{
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 );
}
}
}
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 );
*/
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( );
%include <MltGeometry.h>
%include <MltService.h>
%include <MltProducer.h>
+%include <MltProfile.h>
%include <MltPlaylist.h>
%include <MltConsumer.h>
%include <MltFilter.h>
-#!/bin/env perl
+#!/usr/bin/env perl
# Import required modules
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( ) )
{
$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" );
# 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" )
+#!/usr/bin/env ruby
+
require 'mltpp'
def command
# 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
# 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
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
[ 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 )
-#!/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
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( );
{
private:
Event *event;
+ Profile profile;
public:
Custom( char *name = "Custom", int port = 5290, char *config = NULL ) :
Response *received( char *command, char *document )
{
cerr << document << endl;
- Producer producer( "westley-xml", document );
+ Producer producer( profile, "westley-xml", document );
return push( command, &producer );
}