* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <string.h>
#include "MltService.h"
+#include "MltFilter.h"
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( );
}
-mlt_service Service::get_service( )
+Service::~Service( )
{
- return instance;
+ mlt_service_close( instance );
}
-mlt_service Service::get_connection( )
+mlt_service Service::get_service( )
{
- return get_service( );
+ return instance;
}
mlt_properties Service::get_properties( )
int Service::connect_producer( Service &producer, int index )
{
- return mlt_service_connect_producer( get_service( ), producer.get_connection( ), index );
+ return mlt_service_connect_producer( get_service( ), producer.get_service( ), index );
}
Service *Service::producer( )
{
mlt_frame frame = NULL;
mlt_service_get_frame( get_service( ), &frame, index );
- return new Frame( frame );
+ Frame *result = new Frame( frame );
+ mlt_frame_close( frame );
+ return result;
+}
+
+service_type Service::type( )
+{
+ service_type type = invalid_type;
+ if ( is_valid( ) )
+ {
+ char *mlt_type = get( "mlt_type" );
+ char *resource = get( "resource" );
+ if ( mlt_type == NULL )
+ type = unknown_type;
+ else if ( !strcmp( mlt_type, "producer" ) )
+ type = producer_type;
+ else if ( !strcmp( mlt_type, "mlt_producer" ) )
+ {
+ if ( resource == NULL )
+ type = producer_type;
+ else if ( !strcmp( resource, "<playlist>" ) )
+ type = playlist_type;
+ else if ( !strcmp( resource, "<tractor>" ) )
+ type = tractor_type;
+ else if ( !strcmp( resource, "<multitrack>" ) )
+ type = multitrack_type;
+ }
+ else if ( !strcmp( mlt_type, "filter" ) )
+ type = filter_type;
+ else if ( !strcmp( mlt_type, "transition" ) )
+ type = transition_type;
+ else if ( !strcmp( mlt_type, "consumer" ) )
+ type = consumer_type;
+ else
+ type = unknown_type;
+ }
+ return type;
+}
+
+int Service::attach( Filter &filter )
+{
+ return mlt_service_attach( get_service( ), filter.get_filter( ) );
+}
+
+int Service::detach( Filter &filter )
+{
+ return mlt_service_detach( get_service( ), filter.get_filter( ) );
+}
+
+Filter *Service::filter( int index )
+{
+ return new Filter( mlt_service_filter( get_service( ), index ) );
}