1 /**
2  * MltLink.cpp - MLT Wrapper
3  * Copyright (C) 2020 Meltytech, LLC
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #include "MltLink.h"
21 #include "MltProfile.h"
22 
23 #include <stdlib.h>
24 #include <string.h>
25 
26 using namespace Mlt;
27 
Link()28 Link::Link( ) :
29 	instance( nullptr )
30 {
31 }
32 
Link(mlt_link link)33 Link::Link( mlt_link link )
34  : instance( link )
35 {
36 	inc_ref( );
37 }
38 
Link(const char * id,const char * arg)39 Link::Link( const char *id, const char *arg ) :
40 	instance( NULL )
41 {
42 	if ( arg != NULL )
43 	{
44 		instance = mlt_factory_link( id, arg );
45 	}
46 	else
47 	{
48 		if ( strchr( id, ':' ) )
49 		{
50 			char *temp = strdup( id );
51 			char *arg = strchr( temp, ':' ) + 1;
52 			*( arg - 1 ) = '\0';
53 			instance = mlt_factory_link( temp, arg );
54 			free( temp );
55 		}
56 		else
57 		{
58 			instance = mlt_factory_link( id, NULL );
59 		}
60 	}
61 }
62 
~Link()63 Link::~Link( )
64 {
65 	mlt_link_close( instance );
66 }
67 
get_link()68 mlt_link Link::get_link( )
69 {
70 	return instance;
71 }
72 
get_producer()73 mlt_producer Link::get_producer( )
74 {
75 	return MLT_LINK_PRODUCER( instance );
76 }
77 
connect_next(Mlt::Producer & next,Mlt::Profile & default_profile)78 int Link::connect_next( Mlt::Producer& next, Mlt::Profile& default_profile )
79 {
80 	return mlt_link_connect_next( instance, next.get_producer(), default_profile.get_profile() );
81 }
82 
83