OBJS = MltConsumer.o \
MltFactory.o \
MltFilter.o \
+ MltFilteredConsumer.o \
+ MltFilteredProducer.o \
MltFrame.o \
MltPlaylist.o \
MltProducer.o \
#include "MltConsumer.h"
#include "MltFactory.h"
#include "MltFilter.h"
+#include "MltFilteredConsumer.h"
+#include "MltFilteredProducer.h"
#include "MltFrame.h"
#include "MltPlaylist.h"
#include "MltProducer.h"
Consumer::~Consumer( )
{
if ( destroy )
+ {
+ stop( );
mlt_consumer_close( instance );
+ }
}
mlt_consumer Consumer::get_consumer( )
int Consumer::connect( Service &service )
{
- return mlt_consumer_connect( get_consumer( ), service.get_service( ) );
+ return connect_producer( service );
}
int Consumer::start( )
return mlt_consumer_stop( get_consumer( ) );
}
-int Consumer::is_stopped( )
+bool Consumer::is_stopped( )
{
- return mlt_consumer_is_stopped( get_consumer( ) );
+ return mlt_consumer_is_stopped( get_consumer( ) ) != 0;
}
-
virtual ~Consumer( );
virtual mlt_consumer get_consumer( );
mlt_service get_service( );
- int connect( Service &service );
+ virtual int connect( Service &service );
int start( );
int stop( );
- int is_stopped( );
+ bool is_stopped( );
};
}
--- /dev/null
+/**
+ * MltFilteredConsumer.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 "MltFilteredConsumer.h"
+using namespace Mlt;
+
+FilteredConsumer::FilteredConsumer( char *id, char *arg ) :
+ Consumer( id, arg )
+{
+ // Create a reference to the first service
+ first = new Service( *this );
+}
+
+FilteredConsumer::~FilteredConsumer( )
+{
+ // Delete the reference to the first service
+ delete first;
+}
+
+int FilteredConsumer::connect( Service &service )
+{
+ // All producers must connect to the first service, hence the use of the virtual here
+ return first->connect_producer( service );
+}
+
+int FilteredConsumer::attach( Filter &filter )
+{
+ int error = 0;
+ if ( filter.is_valid( ) )
+ {
+ Service *producer = first->producer( );
+ error = filter.connect( *producer );
+ if ( error == 0 )
+ {
+ first->connect_producer( filter );
+ delete first;
+ first = new Service( filter );
+ }
+ delete producer;
+ }
+ else
+ {
+ error = 1;
+ }
+ return error;
+}
+
+int FilteredConsumer::detach( Filter &filter )
+{
+ if ( filter.is_valid( ) )
+ {
+ Service *it = new Service( *first );
+ while ( it->is_valid( ) && it->get_service( ) != filter.get_service( ) )
+ {
+ Service *consumer = it->consumer( );
+ delete it;
+ it = consumer;
+ }
+ if ( it->get_service( ) == filter.get_service( ) )
+ {
+ Service *producer = it->producer( );
+ Service *consumer = it->consumer( );
+ consumer->connect_producer( *producer );
+ Service dummy( NULL );
+ it->connect_producer( dummy );
+ if ( first->get_service( ) == it->get_service( ) )
+ {
+ delete first;
+ first = new Service( *consumer );
+ }
+ }
+ delete it;
+ }
+ return 0;
+}
+
--- /dev/null
+/**
+ * MltFilteredConsumer.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_FILTERED_CONSUMER_H_
+#define _MLTPP_FILTERED_CONSUMER_H_
+
+#include "MltConsumer.h"
+#include "MltFilter.h"
+#include "MltService.h"
+
+namespace Mlt
+{
+ class Consumer;
+ class Service;
+ class Filter;
+
+ class FilteredConsumer : public Consumer
+ {
+ private:
+ Service *first;
+ public:
+ FilteredConsumer( char *id, char *arg = NULL );
+ virtual ~FilteredConsumer( );
+ int connect( Service &service );
+ int attach( Filter &filter );
+ int detach( Filter &filter );
+ };
+}
+
+#endif
+
--- /dev/null
+/**
+ * MltFilteredProducer.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 "MltFilteredProducer.h"
+using namespace Mlt;
+
+FilteredProducer::FilteredProducer( char *id, char *arg ) :
+ Producer( id, arg )
+{
+ // Create a reference to the last service
+ last = new Service( *this );
+}
+
+FilteredProducer::~FilteredProducer( )
+{
+ // Delete the reference to the last service
+ delete last;
+}
+
+mlt_service FilteredProducer::get_connection( )
+{
+ return last->get_service( );
+}
+
+int FilteredProducer::attach( Filter &filter )
+{
+ int error = 0;
+ if ( filter.is_valid( ) )
+ {
+ Service *consumer = last->consumer( );
+ filter.connect_producer( *last );
+ if ( consumer->is_valid( ) )
+ consumer->connect_producer( filter );
+ delete consumer;
+ delete last;
+ last = new Service( filter );
+ }
+ else
+ {
+ error = 1;
+ }
+ return error;
+}
+
+int FilteredProducer::detach( Filter &filter )
+{
+ if ( filter.is_valid( ) )
+ {
+ Service *it = new Service( *last );
+ while ( it->is_valid( ) && it->get_service( ) != filter.get_service( ) )
+ {
+ Service *producer = it->producer( );
+ delete it;
+ it = producer;
+ }
+ if ( it->get_service( ) == filter.get_service( ) )
+ {
+ Service *producer = it->producer( );
+ Service *consumer = it->consumer( );
+ if ( consumer->is_valid( ) )
+ consumer->connect_producer( *producer );
+ Producer dummy( "colour" );
+ dummy.connect_producer( *it );
+ if ( last->get_service( ) == it->get_service( ) )
+ {
+ delete last;
+ last = new Service( *producer );
+ }
+ }
+ delete it;
+ }
+ return 0;
+}
+
--- /dev/null
+/**
+ * MltFilteredProducer.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_FILTERED_PRODUCER_H_
+#define _MLTPP_FILTERED_PRODUCER_H_
+
+#include "MltProducer.h"
+#include "MltFilter.h"
+#include "MltService.h"
+
+namespace Mlt
+{
+ class Producer;
+ class Service;
+ class Filter;
+
+ class FilteredProducer : public Producer
+ {
+ private:
+ Service *last;
+ public:
+ FilteredProducer( char *id, char *arg = NULL );
+ virtual ~FilteredProducer( );
+ mlt_service get_connection( );
+ int attach( Filter &filter );
+ int detach( Filter &filter );
+ };
+}
+
+#endif
+
return instance;
}
+mlt_service Service::get_connection( )
+{
+ return get_service( );
+}
+
mlt_properties Service::get_properties( )
{
return mlt_service_properties( get_service( ) );
int Service::connect_producer( Service &producer, int index )
{
- return mlt_service_connect_producer( get_service( ), producer.get_service( ), index );
+ return mlt_service_connect_producer( get_service( ), producer.get_connection( ), index );
}
Service *Service::producer( )
Service( Service &service );
Service( mlt_service service );
virtual mlt_service get_service( );
+ virtual mlt_service get_connection( );
mlt_properties get_properties( );
int connect_producer( Service &producer, int index = 0 );
Service *consumer( );
#include <mlt++/Mlt.h>
%}
-%typedef int mlt_position;
-
/** These methods return objects which should be gc'd.
*/
/** Classes to wrap.
*/
+%include <framework/mlt_types.h>
+%include <MltFactory.h>
%include <MltProperties.h>
%include <MltFrame.h>
%include <MltService.h>
%include <MltPlaylist.h>
%include <MltConsumer.h>
%include <MltFilter.h>
-%include <MltFactory.h>
+%include <MltFilteredConsumer.h>
+%include <MltFilteredProducer.h>