Use the following definitions in a Makefile to compile and link with mlt++:
- CXXFLAGS=`mlt-config -Wall`
- LDFLAGS=-lmlt++
+ CXXFLAGS=`mlt-config -Wall`
+ LDFLAGS=-lmlt++
+
+ Include files for the classes can either be explicitly included, ie:
+
+ #include <mlt++/MltProducer.h>
+ etc
+
+ Or you can include all using:
+
+ #include <mlt++/Mlt.h>
All definitions are placed in an Mlt namespace, and adhere closely to the C
naming convention. Mappings always follow the pattern:
ie: mlt_playlist_append ==> Mlt::Playlist.append
etc
+ Additionally, you can specify:
+
+ using namespace Mlt;
+
+ To avoid the enforced use of the Mlt:: prefix.
+
Enumerators and macros are reused directly from the C library.
CLASS HIERARCHY
Note that you get an object back - it is never the original object, but a
wrapping object. This is done to keep consistency with the C api which may
- instantiate C instances - therefore there it cannot be assumed that a C++
- object exists for all mlt service instances.
+ instantiate C instances - therefore it cannot be assumed that a C++ object
+ exists for all mlt service instances.
As such, it is mandatory that you delete these objects. The original will
- not be affected. Further to that, all modifications (to properties or its
+ not be affected. However, all other modifications (to properties or its
state of connection) will be reflected in the original object.
- This excludes the use of the RTTI to determine the real type of the object -
- this can only be done by parsing the objects properties.
+ This approach excludes the use of RTTI to determine the real type of the
+ object - this can only be done by parsing the objects properties.
- Non-NULL objects may be invalid - always use the is_valid method to
- check validity before use.
+ Objects may be invalid - always use the is_valid method to check validity
+ before use.
LIMITATIONS
-----------
- The mechanisms for the definition of new services have deliberately not
- been exposed by the C++ wrappings - this is done to ensure that service
+ The mechanisms for the definition of new services are deliberately
+ excluded from the C++ wrappings - this is done to ensure that service
networks constructed can be serialised and used by existing applications
which are based on the C API (such as miracle).
+
#include "MltConsumer.h"
using namespace Mlt;
-mlt_service Consumer::get_service( )
+Consumer::Consumer( char *id, char *service ) :
+ destroy( true ),
+ instance( NULL )
{
- return mlt_consumer_service( get_consumer( ) );
+ instance = mlt_factory_consumer( id, service );
}
-int Consumer::connect( Service &service )
+Consumer::Consumer( Consumer &consumer ) :
+ destroy( false ),
+ instance( consumer.get_consumer( ) )
{
- return mlt_consumer_connect( get_consumer( ), service.get_service( ) );
}
-int Consumer::start( )
+Consumer::Consumer( mlt_consumer consumer ) :
+ destroy( false ),
+ instance( consumer )
{
- return mlt_consumer_start( get_consumer( ) );
}
-int Consumer::stop( )
+Consumer::~Consumer( )
{
- return mlt_consumer_stop( get_consumer( ) );
+ if ( destroy )
+ mlt_consumer_close( instance );
}
-int Consumer::is_stopped( )
+mlt_consumer Consumer::get_consumer( )
{
- return mlt_consumer_is_stopped( get_consumer( ) );
+ return instance;
}
-mlt_consumer ConsumerInstance::get_consumer( )
+mlt_service Consumer::get_service( )
{
- return instance;
+ return mlt_consumer_service( get_consumer( ) );
}
-ConsumerInstance::ConsumerInstance( char *id, char *service ) :
- destroy( true ),
- instance( NULL )
+int Consumer::connect( Service &service )
{
- instance = mlt_factory_consumer( id, service );
+ return mlt_consumer_connect( get_consumer( ), service.get_service( ) );
}
-ConsumerInstance::ConsumerInstance( Consumer &consumer ) :
- destroy( false ),
- instance( consumer.get_consumer( ) )
+int Consumer::start( )
{
+ return mlt_consumer_start( get_consumer( ) );
}
-ConsumerInstance::ConsumerInstance( mlt_consumer consumer ) :
- destroy( false ),
- instance( consumer )
+int Consumer::stop( )
{
+ return mlt_consumer_stop( get_consumer( ) );
}
-ConsumerInstance::~ConsumerInstance( )
+int Consumer::is_stopped( )
{
- if ( destroy )
- mlt_consumer_close( instance );
+ return mlt_consumer_is_stopped( get_consumer( ) );
}
+
namespace Mlt
{
+ class Service;
+
class Consumer : public Service
{
+ private:
+ bool destroy;
+ mlt_consumer instance;
public:
- virtual mlt_consumer get_consumer( ) = 0;
+ Consumer( char *id, char *service = NULL );
+ Consumer( Consumer &consumer );
+ Consumer( mlt_consumer consumer );
+ virtual ~Consumer( );
+ virtual mlt_consumer get_consumer( );
mlt_service get_service( );
int connect( Service &service );
int start( );
int stop( );
int is_stopped( );
};
-
- class ConsumerInstance : public Consumer
- {
- private:
- bool destroy;
- mlt_consumer instance;
- public:
- mlt_consumer get_consumer( );
- ConsumerInstance( char *id, char *service = NULL );
- ConsumerInstance( Consumer &consumer );
- ConsumerInstance( mlt_consumer consumer );
- virtual ~ConsumerInstance( );
- };
}
#endif
return mlt_factory_init( arg );
}
-Producer *Factory::producer( char *id, char *arg )
-{
- return new ProducerInstance( id, arg );
-}
-
-Filter *Factory::filter( char *id, char *arg )
-{
- return new FilterInstance( id, arg );
-}
-
-Transition *Factory::transition( char *id, char *arg )
-{
- return new TransitionInstance( id, arg );
-}
-
-Consumer *Factory::consumer( char *id, char *arg )
-{
- return new ConsumerInstance( id, arg );
-}
-
void Factory::close( )
{
mlt_factory_close( );
{
public:
static int init( char *arg = NULL );
- 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 void close( );
};
}
#include "MltFilter.h"
using namespace Mlt;
-mlt_service Filter::get_service( )
+Filter::Filter( char *id, char *service ) :
+ destroy( true ),
+ instance( NULL )
{
- return mlt_filter_service( get_filter( ) );
+ instance = mlt_factory_filter( id, service );
}
-int Filter::connect( Service &service, int index )
+Filter::Filter( Filter &filter ) :
+ destroy( false ),
+ instance( filter.get_filter( ) )
{
- return mlt_filter_connect( get_filter( ), service.get_service( ), index );
}
-void Filter::set_in_and_out( mlt_position in, mlt_position out )
+Filter::Filter( mlt_filter filter ) :
+ destroy( false ),
+ instance( filter )
{
- mlt_filter_set_in_and_out( get_filter( ), in, out );
}
-mlt_position Filter::get_in( )
+Filter::~Filter( )
{
- return mlt_filter_get_in( get_filter( ) );
+ if ( destroy )
+ mlt_filter_close( instance );
}
-mlt_position Filter::get_out( )
+mlt_filter Filter::get_filter( )
{
- return mlt_filter_get_out( get_filter( ) );
+ return instance;
}
-int Filter::get_track( )
+mlt_service Filter::get_service( )
{
- return mlt_filter_get_track( get_filter( ) );
+ return mlt_filter_service( get_filter( ) );
}
-mlt_filter FilterInstance::get_filter( )
+int Filter::connect( Service &service, int index )
{
- return instance;
+ return mlt_filter_connect( get_filter( ), service.get_service( ), index );
}
-FilterInstance::FilterInstance( char *id, char *service ) :
- destroy( true ),
- instance( NULL )
+void Filter::set_in_and_out( mlt_position in, mlt_position out )
{
- instance = mlt_factory_filter( id, service );
+ mlt_filter_set_in_and_out( get_filter( ), in, out );
}
-FilterInstance::FilterInstance( Filter &filter ) :
- destroy( false ),
- instance( filter.get_filter( ) )
+mlt_position Filter::get_in( )
{
+ return mlt_filter_get_in( get_filter( ) );
}
-FilterInstance::FilterInstance( mlt_filter filter ) :
- destroy( false ),
- instance( filter )
+mlt_position Filter::get_out( )
{
+ return mlt_filter_get_out( get_filter( ) );
}
-FilterInstance::~FilterInstance( )
+int Filter::get_track( )
{
- if ( destroy )
- mlt_filter_close( instance );
+ return mlt_filter_get_track( get_filter( ) );
}
+
namespace Mlt
{
+ class Service;
+
class Filter : public Service
{
+ private:
+ bool destroy;
+ mlt_filter instance;
public:
- virtual mlt_filter get_filter( ) = 0;
+ Filter( char *id, char *service = NULL );
+ Filter( Filter &filter );
+ Filter( mlt_filter filter );
+ virtual ~Filter( );
+ virtual mlt_filter get_filter( );
mlt_service get_service( );
int connect( Service &service, int index = 0 );
void set_in_and_out( mlt_position in, mlt_position out );
mlt_position get_out( );
int get_track( );
};
-
- class FilterInstance : public Filter
- {
- private:
- bool destroy;
- mlt_filter instance;
- public:
- mlt_filter get_filter( );
- FilterInstance( char *id, char *service = NULL );
- FilterInstance( Filter &filter );
- FilterInstance( mlt_filter filter );
- virtual ~FilterInstance( );
- };
}
#endif
#include "MltFrame.h"
using namespace Mlt;
-mlt_properties Frame::get_properties( )
+Frame::Frame( mlt_frame frame ) :
+ destroy( true ),
+ instance( frame )
{
- return mlt_frame_properties( get_frame( ) );
}
-uint8_t *Frame::get_image( mlt_image_format &format, int &w, int &h, int writable )
+Frame::Frame( Frame &frame ) :
+ destroy( false ),
+ instance( frame.get_frame( ) )
{
- uint8_t *image = NULL;
- mlt_frame_get_image( get_frame( ), &image, &format, &w, &h, writable );
- return image;
}
-int16_t *Frame::get_audio( mlt_audio_format &format, int &frequency, int &channels, int &samples )
+Frame::~Frame( )
{
- int16_t *audio = NULL;
- mlt_frame_get_audio( get_frame( ), &audio, &format, &frequency, &channels, &samples );
- return audio;
+ if ( destroy )
+ mlt_frame_close( instance );
}
-mlt_frame FrameInstance::get_frame( )
+mlt_frame Frame::get_frame( )
{
return instance;
}
-FrameInstance::FrameInstance( mlt_frame frame ) :
- destroy( true ),
- instance( frame )
+mlt_properties Frame::get_properties( )
{
+ return mlt_frame_properties( get_frame( ) );
}
-FrameInstance::FrameInstance( Frame &frame ) :
- destroy( false ),
- instance( frame.get_frame( ) )
+uint8_t *Frame::get_image( mlt_image_format &format, int &w, int &h, int writable )
{
+ uint8_t *image = NULL;
+ mlt_frame_get_image( get_frame( ), &image, &format, &w, &h, writable );
+ return image;
}
-FrameInstance::~FrameInstance( )
+int16_t *Frame::get_audio( mlt_audio_format &format, int &frequency, int &channels, int &samples )
{
- if ( destroy )
- mlt_frame_close( instance );
+ int16_t *audio = NULL;
+ mlt_frame_get_audio( get_frame( ), &audio, &format, &frequency, &channels, &samples );
+ return audio;
}
namespace Mlt
{
+ class Properties;
+
class Frame : public Properties
{
- public:
- virtual mlt_frame get_frame( ) = 0;
- mlt_properties get_properties( );
- uint8_t *get_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 );
- };
-
- class FrameInstance : public Frame
- {
private:
bool destroy;
mlt_frame instance;
public:
- mlt_frame get_frame( );
- FrameInstance( mlt_frame frame );
- FrameInstance( Frame &frame );
- virtual ~FrameInstance( );
+ Frame( mlt_frame frame );
+ Frame( Frame &frame );
+ virtual ~Frame( );
+ virtual mlt_frame get_frame( );
+ mlt_properties get_properties( );
+ uint8_t *get_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 );
};
}
ClipInfo::ClipInfo( mlt_playlist_clip_info *info ) :
clip( info->clip ),
- producer( new ProducerInstance( info->producer ) ),
- service( new ServiceInstance( info->service ) ),
+ producer( new Producer( info->producer ) ),
+ service( new Service( info->service ) ),
start( info->start ),
resource( strdup( info->resource ) ),
frame_in( info->frame_in ),
{
}
+ClipInfo::ClipInfo( Playlist &playlist, int index )
+{
+ mlt_playlist_clip_info info;
+ mlt_playlist_get_clip_info( playlist.get_playlist( ), &info, index );
+ clip = info.clip;
+ producer = new Producer( info.producer );
+ service = new Service( info.service );
+ start = info.start;
+ resource = strdup( info.resource );
+ frame_in = info.frame_in;
+ frame_out = info.frame_out;
+ frame_count = info.frame_count;
+ length = info.length;
+ fps = info.fps;
+}
+
ClipInfo::~ClipInfo( )
{
delete producer;
free( resource );
}
-PlaylistInstance::PlaylistInstance( ) :
+Playlist::Playlist( ) :
destroy( true ),
instance( NULL )
{
instance = mlt_playlist_init( );
}
-PlaylistInstance::PlaylistInstance( Playlist &playlist ) :
+Playlist::Playlist( Playlist &playlist ) :
destroy( false ),
instance( playlist.get_playlist( ) )
{
}
-PlaylistInstance::PlaylistInstance( mlt_playlist playlist ) :
+Playlist::Playlist( mlt_playlist playlist ) :
destroy( false ),
instance( playlist )
{
}
-PlaylistInstance::~PlaylistInstance( )
+Playlist::~Playlist( )
{
if ( destroy )
mlt_playlist_close( instance );
}
-mlt_playlist PlaylistInstance::get_playlist( )
+mlt_playlist Playlist::get_playlist( )
{
return instance;
}
Producer *Playlist::current( )
{
- return new ProducerInstance( mlt_playlist_current( get_playlist( ) ) );
+ return new Producer( mlt_playlist_current( get_playlist( ) ) );
}
ClipInfo *Playlist::clip_info( int index )
namespace Mlt
{
+ class Producer;
+ class Service;
+ class Playlist;
+
class ClipInfo
{
public:
ClipInfo( mlt_playlist_clip_info *info );
+ ClipInfo( Playlist &playlist, int i );
~ClipInfo( );
int clip;
Producer *producer;
class Playlist : public Producer
{
+ private:
+ bool destroy;
+ mlt_playlist instance;
public:
- virtual mlt_playlist get_playlist( ) = 0;
+ Playlist( );
+ Playlist( Playlist &playlist );
+ Playlist( mlt_playlist playlist );
+ virtual ~Playlist( );
+ virtual mlt_playlist get_playlist( );
mlt_producer get_producer( );
int count( );
int clear( );
int move( int from, int to );
int resize_clip( int clip, mlt_position in, mlt_position out );
};
-
- class PlaylistInstance : public Playlist
- {
- private:
- bool destroy;
- mlt_playlist instance;
- public:
- mlt_playlist get_playlist( );
- PlaylistInstance( );
- PlaylistInstance( Playlist &playlist );
- PlaylistInstance( mlt_playlist playlist );
- virtual ~PlaylistInstance( );
- };
}
#endif
#include "MltProducer.h"
using namespace Mlt;
+Producer::Producer( ) :
+ destroy( false ),
+ instance( NULL )
+{
+}
+
+Producer::Producer( char *id, char *service ) :
+ destroy( true ),
+ instance( NULL )
+{
+ if ( id != NULL && service != NULL )
+ instance = mlt_factory_producer( id, service );
+ else
+ instance = mlt_factory_producer( "fezzik", id != NULL ? id : service );
+}
+
+Producer::Producer( mlt_producer producer ) :
+ destroy( false ),
+ instance( producer )
+{
+}
+
+Producer::Producer( Producer &producer ) :
+ destroy( false ),
+ instance( producer.get_producer( ) )
+{
+}
+
+Producer::~Producer( )
+{
+ if ( destroy )
+ mlt_producer_close( instance );
+}
mlt_service Producer::get_service( )
{
return mlt_producer_service( get_producer( ) );
return mlt_producer_get_playtime( get_producer( ) );
}
-mlt_producer ProducerInstance::get_producer( )
+mlt_producer Producer::get_producer( )
{
return instance;
}
-ProducerInstance::ProducerInstance( char *id, char *service ) :
- destroy( true ),
- instance( NULL )
-{
- if ( id != NULL && service != NULL )
- instance = mlt_factory_producer( id, service );
- else
- instance = mlt_factory_producer( "fezzik", id != NULL ? id : service );
-}
-
-ProducerInstance::ProducerInstance( mlt_producer producer ) :
- destroy( false ),
- instance( producer )
-{
-}
-
-ProducerInstance::ProducerInstance( Producer &producer ) :
- destroy( false ),
- instance( producer.get_producer( ) )
-{
-}
-
-ProducerInstance::~ProducerInstance( )
-{
- if ( destroy )
- mlt_producer_close( instance );
-}
namespace Mlt
{
+ class Service;
+
class Producer : public Service
{
+ private:
+ bool destroy;
+ mlt_producer instance;
public:
- virtual mlt_producer get_producer( ) = 0;
+ Producer( );
+ Producer( char *id, char *service = NULL );
+ Producer( mlt_producer producer );
+ Producer( Producer &producer );
+ virtual ~Producer( );
+ virtual mlt_producer get_producer( );
mlt_service get_service( );
int seek( mlt_position position );
mlt_position position( );
mlt_position get_length( );
mlt_position get_playtime( );
};
-
- class ProducerInstance : public Producer
- {
- private:
- bool destroy;
- mlt_producer instance;
- public:
- mlt_producer get_producer( );
- ProducerInstance( char *id, char *service = NULL );
- ProducerInstance( mlt_producer producer );
- ProducerInstance( Producer &producer );
- virtual ~ProducerInstance( );
- };
}
#endif
#include "MltProperties.h"
using namespace Mlt;
-PropertiesInstance::PropertiesInstance( ) :
+Properties::Properties( ) :
destroy( true ),
instance( NULL )
{
instance = mlt_properties_new( );
}
-PropertiesInstance::PropertiesInstance( Properties &properties ) :
+Properties::Properties( Properties &properties ) :
destroy( false ),
instance( properties.get_properties( ) )
{
}
-PropertiesInstance::PropertiesInstance( mlt_properties properties ) :
+Properties::Properties( mlt_properties properties ) :
destroy( false ),
instance( properties )
{
}
-PropertiesInstance::PropertiesInstance( char *file ) :
+Properties::Properties( char *file ) :
destroy( true ),
instance( NULL )
{
instance = mlt_properties_load( file );
}
-PropertiesInstance::~PropertiesInstance( )
+Properties::~Properties( )
{
if ( destroy )
mlt_properties_close( instance );
}
-mlt_properties PropertiesInstance::get_properties( )
+mlt_properties Properties::get_properties( )
{
return instance;
}
class Properties
{
+ private:
+ bool destroy;
+ mlt_properties instance;
public:
- virtual mlt_properties get_properties( ) = 0;
+ Properties( );
+ Properties( Properties &properties );
+ Properties( mlt_properties properties );
+ Properties( char *file );
+ virtual ~Properties( );
+ virtual mlt_properties get_properties( );
bool is_valid( );
int count( );
char *get( char *name );
int rename( char *source, char *dest );
void dump( FILE *output = stderr );
};
-
- /** Instance class.
- */
-
- class PropertiesInstance : public Properties
- {
- private:
- bool destroy;
- mlt_properties instance;
- public:
- mlt_properties get_properties( );
- PropertiesInstance( );
- PropertiesInstance( Properties &properties );
- PropertiesInstance( mlt_properties properties );
- PropertiesInstance( char *file );
- virtual ~PropertiesInstance( );
- };
}
#endif
#include "MltService.h"
using namespace Mlt;
+Service::Service( ) :
+ instance( NULL )
+{
+}
+
+Service::Service( Service &service ) :
+ instance( service.get_service( ) )
+{
+}
+
+Service::Service( mlt_service service ) :
+ instance( service )
+{
+}
+
+Service::~Service( )
+{
+}
+
+mlt_service Service::get_service( )
+{
+ return instance;
+}
+
mlt_properties Service::get_properties( )
{
return mlt_service_properties( get_service( ) );
Service *Service::producer( )
{
- return new ServiceInstance( mlt_service_producer( get_service( ) ) );
+ return new Service( mlt_service_producer( get_service( ) ) );
}
Service *Service::consumer( )
{
- return new ServiceInstance( mlt_service_consumer( get_service( ) ) );
+ return new Service( mlt_service_consumer( get_service( ) ) );
}
Frame *Service::get_frame( int index )
{
mlt_frame frame = NULL;
mlt_service_get_frame( get_service( ), &frame, index );
- return new FrameInstance( frame );
-}
-
-mlt_service ServiceInstance::get_service( )
-{
- return instance;
+ return new Frame( frame );
}
-ServiceInstance::ServiceInstance( Service &service ) :
- instance( service.get_service( ) )
-{
-}
-
-ServiceInstance::ServiceInstance( mlt_service service ) :
- instance( service )
-{
-}
namespace Mlt
{
+ class Properties;
+ class Frame;
+
class Service : public Properties
{
+ private:
+ mlt_service instance;
public:
- virtual mlt_service get_service( ) = 0;
+ Service( );
+ Service( Service &service );
+ Service( mlt_service service );
+ virtual ~Service( );
+ virtual mlt_service get_service( );
mlt_properties get_properties( );
int connect_producer( Service &producer, int index = 0 );
Service *consumer( );
Service *producer( );
Frame *get_frame( int index = 0 );
};
-
- class ServiceInstance : public Service
- {
- private:
- mlt_service instance;
- public:
- mlt_service get_service( );
- ServiceInstance( Service &service );
- ServiceInstance( mlt_service service );
- };
}
#endif
#include "MltTransition.h"
using namespace Mlt;
-mlt_service Transition::get_service( )
-{
- return mlt_transition_service( get_transition( ) );
-}
-
-mlt_transition TransitionInstance::get_transition( )
-{
- return instance;
-}
-
-TransitionInstance::TransitionInstance( char *id, char *arg ) :
+Transition::Transition( char *id, char *arg ) :
destroy( true ),
instance( NULL )
{
instance = mlt_factory_transition( id, arg );
}
-TransitionInstance::TransitionInstance( Transition &transition ) :
+Transition::Transition( Transition &transition ) :
destroy( false ),
instance( transition.get_transition( ) )
{
}
-TransitionInstance::TransitionInstance( mlt_transition transition ) :
+Transition::Transition( mlt_transition transition ) :
destroy( false ),
instance( transition )
{
}
-TransitionInstance::~TransitionInstance( )
+Transition::~Transition( )
{
if ( destroy )
mlt_transition_close( instance );
}
+mlt_transition Transition::get_transition( )
+{
+ return instance;
+}
+
+mlt_service Transition::get_service( )
+{
+ return mlt_transition_service( get_transition( ) );
+}
+
namespace Mlt
{
+ class Service;
+
class Transition : public Service
{
- public:
- virtual mlt_transition get_transition( ) = 0;
- mlt_service get_service( );
- };
-
- class TransitionInstance : public Transition
- {
private:
bool destroy;
mlt_transition instance;
public:
- mlt_transition get_transition( );
- TransitionInstance( char *id, char *arg = NULL );
- TransitionInstance( Transition &transition );
- TransitionInstance( mlt_transition transition );
- virtual ~TransitionInstance( );
+ Transition( char *id, char *arg = NULL );
+ Transition( Transition &transition );
+ Transition( mlt_transition transition );
+ virtual ~Transition( );
+ virtual mlt_transition get_transition( );
+ mlt_service get_service( );
};
}
int main( int argc, char **argv )
{
Factory::init( NULL );
- Producer *producer = Factory::producer( argv[ 1 ] );
+ Producer *producer = new Producer( argv[ 1 ] );
if ( !producer->is_valid( ) )
{
cerr << "Can't construct producer for " << argv[ 1 ] << endl;
return 0;
}
- Consumer *consumer = Factory::consumer( "sdl" );
+ Consumer *consumer = new Consumer( "sdl" );
consumer->set( "rescale", "none" );
- Filter *filter = Factory::filter( "greyscale" );
+ Filter *filter = new Filter( "greyscale" );
filter->connect( *producer );
consumer->connect( *filter );
consumer->start( );