using namespace Mlt;
Consumer::Consumer( char *id, char *arg ) :
- destroy( true ),
instance( NULL )
{
if ( arg != NULL )
}
Consumer::Consumer( Consumer &consumer ) :
- destroy( false ),
instance( consumer.get_consumer( ) )
{
+ inc_ref( );
}
Consumer::Consumer( mlt_consumer consumer ) :
- destroy( false ),
instance( consumer )
{
+ inc_ref( );
}
Consumer::~Consumer( )
{
- if ( destroy )
- {
- stop( );
- mlt_consumer_close( instance );
- }
+ mlt_consumer_close( instance );
}
mlt_consumer Consumer::get_consumer( )
class Consumer : public Service
{
private:
- bool destroy;
mlt_consumer instance;
public:
Consumer( char *id, char *service = NULL );
using namespace Mlt;
Filter::Filter( char *id, char *arg ) :
- destroy( true ),
instance( NULL )
{
if ( arg != NULL )
}
Filter::Filter( Filter &filter ) :
- destroy( false ),
instance( filter.get_filter( ) )
{
+ inc_ref( );
}
Filter::Filter( mlt_filter filter ) :
- destroy( false ),
instance( filter )
{
+ inc_ref( );
}
Filter::~Filter( )
{
- if ( destroy )
- mlt_filter_close( instance );
+ mlt_filter_close( instance );
}
mlt_filter Filter::get_filter( )
class Filter : public Service
{
private:
- bool destroy;
mlt_filter instance;
public:
Filter( char *id, char *service = NULL );
first = new Service( *this );
}
+FilteredConsumer::FilteredConsumer( Consumer &consumer ) :
+ Consumer( consumer )
+{
+ // Create a reference to the first service
+ first = new Service( *this );
+}
+
FilteredConsumer::~FilteredConsumer( )
{
// Delete the reference to the first service
Service *first;
public:
FilteredConsumer( char *id, char *arg = NULL );
+ FilteredConsumer( Consumer &consumer );
virtual ~FilteredConsumer( );
int connect( Service &service );
int attach( Filter &filter );
using namespace Mlt;
Frame::Frame( mlt_frame frame ) :
- destroy( true ),
instance( frame )
{
}
Frame::Frame( Frame &frame ) :
- destroy( false ),
instance( frame.get_frame( ) )
{
+ inc_ref( );
}
Frame::~Frame( )
{
- if ( destroy )
- mlt_frame_close( instance );
+ mlt_frame_close( instance );
}
mlt_frame Frame::get_frame( )
class Frame : public Properties
{
private:
- bool destroy;
mlt_frame instance;
public:
Frame( mlt_frame frame );
}
Playlist::Playlist( ) :
- destroy( true ),
instance( NULL )
{
instance = mlt_playlist_init( );
}
Playlist::Playlist( Playlist &playlist ) :
- destroy( false ),
instance( playlist.get_playlist( ) )
{
+ inc_ref( );
}
Playlist::Playlist( mlt_playlist playlist ) :
- destroy( false ),
instance( playlist )
{
+ inc_ref( );
}
Playlist::~Playlist( )
{
- if ( destroy )
- mlt_playlist_close( instance );
+ mlt_playlist_close( instance );
}
mlt_playlist Playlist::get_playlist( )
return mlt_playlist_resize_clip( get_playlist( ), clip, in, out );
}
+int Playlist::split( int clip, int position )
+{
+ return mlt_playlist_split( get_playlist( ), clip, position );
+}
+
+int Playlist::join( int clip, int count, int merge )
+{
+ return mlt_playlist_join( get_playlist( ), clip, count, merge );
+}
class Playlist : public Producer
{
private:
- bool destroy;
mlt_playlist instance;
public:
Playlist( );
int remove( int where );
int move( int from, int to );
int resize_clip( int clip, int in, int out );
+ int split( int clip, int position );
+ int join( int clip, int count = 1, int merge = 1 );
};
}
using namespace Mlt;
Producer::Producer( ) :
- destroy( false ),
instance( NULL )
{
}
Producer::Producer( char *id, char *service ) :
- destroy( true ),
instance( NULL )
{
if ( id != NULL && service != NULL )
}
Producer::Producer( mlt_producer producer ) :
- destroy( false ),
instance( producer )
{
+ inc_ref( );
}
Producer::Producer( Producer &producer ) :
- destroy( false ),
instance( producer.get_producer( ) )
{
+ inc_ref( );
}
Producer::~Producer( )
{
- if ( destroy )
- mlt_producer_close( instance );
+ mlt_producer_close( instance );
}
mlt_producer Producer::get_producer( )
class Producer : public Service
{
private:
- bool destroy;
mlt_producer instance;
public:
Producer( );
using namespace Mlt;
Properties::Properties( ) :
- destroy( true ),
instance( NULL )
{
instance = mlt_properties_new( );
}
+Properties::Properties( bool dummy ) :
+ instance( NULL )
+{
+}
+
Properties::Properties( Properties &properties ) :
- destroy( false ),
instance( properties.get_properties( ) )
{
+ fprintf( stderr, "Incrementing ref count on properties #1\n" );
+ inc_ref( );
}
Properties::Properties( mlt_properties properties ) :
- destroy( false ),
instance( properties )
{
+ fprintf( stderr, "Incrementing ref count on properties #2\n" );
+ inc_ref( );
}
Properties::Properties( char *file ) :
- destroy( true ),
instance( NULL )
{
instance = mlt_properties_load( file );
Properties::~Properties( )
{
- if ( destroy )
- mlt_properties_close( instance );
+ mlt_properties_close( instance );
}
mlt_properties Properties::get_properties( )
return instance;
}
+int Properties::inc_ref( )
+{
+ return mlt_properties_inc_ref( get_properties( ) );
+}
+
+int Properties::dec_ref( )
+{
+ return mlt_properties_dec_ref( get_properties( ) );
+}
+
bool Properties::is_valid( )
{
return get_properties( ) != NULL;
mlt_properties_dump( get_properties( ), output );
}
+void Properties::debug( char *title, FILE *output )
+{
+ mlt_properties_debug( get_properties( ), title, output );
+}
+
int Properties::save( char *file )
{
int error = 0;
class Properties
{
private:
- bool destroy;
mlt_properties instance;
protected:
virtual mlt_properties get_properties( );
public:
Properties( );
+ Properties( bool dummy );
Properties( Properties &properties );
Properties( mlt_properties properties );
Properties( char *file );
virtual ~Properties( );
+ int inc_ref( );
+ int dec_ref( );
bool is_valid( );
int count( );
char *get( char *name );
int inherit( Properties &that );
int rename( char *source, char *dest );
void dump( FILE *output = stderr );
+ void debug( char *title = "Object", FILE *output = stderr );
int save( char *file );
};
}
using namespace Mlt;
Service::Service( ) :
+ Properties( false ),
instance( NULL )
{
}
Service::Service( Service &service ) :
+ Properties( false ),
instance( service.get_service( ) )
{
+ inc_ref( );
}
Service::Service( mlt_service service ) :
+ Properties( false ),
instance( service )
{
+ inc_ref( );
+}
+
+Service::~Service( )
+{
+ mlt_service_close( instance );
}
mlt_service Service::get_service( )
Service( );
Service( Service &service );
Service( mlt_service service );
+ virtual ~Service( );
virtual mlt_service get_service( );
virtual mlt_service get_connection( );
mlt_properties get_properties( );
using namespace Mlt;
Transition::Transition( char *id, char *arg ) :
- destroy( true ),
instance( NULL )
{
if ( arg != NULL )
}
Transition::Transition( Transition &transition ) :
- destroy( false ),
instance( transition.get_transition( ) )
{
+ inc_ref( );
}
Transition::Transition( mlt_transition transition ) :
- destroy( false ),
instance( transition )
{
+ inc_ref( );
}
Transition::~Transition( )
{
- if ( destroy )
- mlt_transition_close( instance );
+ mlt_transition_close( instance );
}
mlt_transition Transition::get_transition( )
class Transition : public Service
{
private:
- bool destroy;
mlt_transition instance;
public:
Transition( char *id, char *arg = NULL );
$p->set( "eof", "loop" );
# Create the consumer
- $c = new mltpp::Consumer( "sdl" );
+ $c = new mltpp::FilteredConsumer( "sdl" );
+ $c->attach( new mltpp::Filter( "greyscale" ) );
# Turn of the default rescaling
$c->set( "rescale", "none" );
while ( !$c->is_stopped ) {
sleep( 1 );
}
+
+ $c->stop( );
+ $c = undef;
+ $p = undef;
}
else
{
print "Unable to open $ARGV[0]\n";
}
+mltpp::mlt_factory_close( );