1 /**
2 * MltService.cpp - MLT Wrapper
3 * Copyright (C) 2004-2019 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 <string.h>
21 #include "MltService.h"
22 #include "MltFilter.h"
23 #include "MltProfile.h"
24 using namespace Mlt;
25
Service()26 Service::Service( ) :
27 Properties( false ),
28 instance( NULL )
29 {
30 }
31
Service(Service & service)32 Service::Service( Service &service ) :
33 Properties( false ),
34 instance( service.get_service( ) )
35 {
36 inc_ref( );
37 }
38
Service(const Service & service)39 Service::Service(const Service &service )
40 : Service(const_cast<Service&>(service))
41 {
42 }
43
Service(mlt_service service)44 Service::Service( mlt_service service ) :
45 Properties( false ),
46 instance( service )
47 {
48 inc_ref( );
49 }
50
~Service()51 Service::~Service( )
52 {
53 mlt_service_close( instance );
54 }
55
operator =(const Service & service)56 Service &Service::operator=(const Service &service)
57 {
58 if (this != &service)
59 {
60 mlt_service_close( instance );
61 instance = service.instance;
62 inc_ref( );
63 }
64 return *this;
65 }
66
get_service()67 mlt_service Service::get_service( )
68 {
69 return instance;
70 }
71
get_properties()72 mlt_properties Service::get_properties( )
73 {
74 return mlt_service_properties( get_service( ) );
75 }
76
lock()77 void Service::lock( )
78 {
79 mlt_service_lock( get_service( ) );
80 }
81
unlock()82 void Service::unlock( )
83 {
84 mlt_service_unlock( get_service( ) );
85 }
86
connect_producer(Service & producer,int index)87 int Service::connect_producer( Service &producer, int index )
88 {
89 return mlt_service_connect_producer( get_service( ), producer.get_service( ), index );
90 }
91
insert_producer(Mlt::Service & producer,int index)92 int Mlt::Service::insert_producer(Mlt::Service &producer, int index)
93 {
94 return mlt_service_insert_producer( get_service(), producer.get_service(), index );
95 }
96
disconnect_producer(int index)97 int Service::disconnect_producer( int index )
98 {
99 return mlt_service_disconnect_producer( get_service(), index );
100 }
101
disconnect_all_producers()102 int Service::disconnect_all_producers( )
103 {
104 return mlt_service_disconnect_all_producers( get_service() );
105 }
106
producer()107 Service *Service::producer( )
108 {
109 return new Service( mlt_service_producer( get_service( ) ) );
110 }
111
consumer()112 Service *Service::consumer( )
113 {
114 return new Service( mlt_service_consumer( get_service( ) ) );
115 }
116
profile()117 Profile *Service::profile( )
118 {
119 return new Profile( mlt_service_profile( get_service() ) );
120 }
121
get_profile()122 mlt_profile Service::get_profile()
123 {
124 return mlt_service_profile( get_service() );
125 }
126
get_frame(int index)127 Frame *Service::get_frame( int index )
128 {
129 mlt_frame frame = NULL;
130 mlt_service_get_frame( get_service( ), &frame, index );
131 Frame *result = new Frame( frame );
132 mlt_frame_close( frame );
133 return result;
134 }
135
type()136 mlt_service_type Service::type( )
137 {
138 return mlt_service_identify( get_service( ) );
139 }
140
attach(Filter & filter)141 int Service::attach( Filter &filter )
142 {
143 return mlt_service_attach( get_service( ), filter.get_filter( ) );
144 }
145
detach(Filter & filter)146 int Service::detach( Filter &filter )
147 {
148 return mlt_service_detach( get_service( ), filter.get_filter( ) );
149 }
150
filter_count()151 int Service::filter_count()
152 {
153 return mlt_service_filter_count( get_service() );
154 }
155
move_filter(int from,int to)156 int Service::move_filter(int from, int to)
157 {
158 return mlt_service_move_filter( get_service(), from, to );
159 }
160
filter(int index)161 Filter *Service::filter( int index )
162 {
163 mlt_filter result = mlt_service_filter( get_service( ), index );
164 return result == NULL ? NULL : new Filter( result );
165 }
166
set_profile(mlt_profile profile)167 void Service::set_profile( mlt_profile profile )
168 {
169 mlt_service_set_profile( get_service( ), profile );
170 }
171
set_profile(Profile & profile)172 void Service::set_profile( Profile &profile )
173 {
174 set_profile( profile.get_profile( ) );
175 }
176