2 * MltProducer.cpp - MLT Wrapper
3 * Copyright (C) 2004-2005 Charles Yates
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "MltProducer.h"
22 #include "MltFilter.h"
23 #include "MltProfile.h"
26 Producer
::Producer( ) :
32 Producer
::Producer( Profile
& profile
, char *id
, char *service
) :
36 if ( id
!= NULL
&& service
!= NULL
)
37 instance
= mlt_factory_producer( profile
.get_profile(), id
, service
);
39 instance
= mlt_factory_producer( profile
.get_profile(), "fezzik", id
!= NULL ? id
: service
);
42 Producer
::Producer( Service
&producer
) :
46 mlt_service_type type
= producer
.type( );
47 if ( type
== producer_type
|| type
== playlist_type
||
48 type
== tractor_type
|| type
== multitrack_type
)
50 instance
= ( mlt_producer
)producer
.get_service( );
55 Producer
::Producer( mlt_producer producer
) :
62 Producer
::Producer( Producer
&producer
) :
63 instance( producer
.get_producer( ) ),
69 Producer
::Producer( Producer
*producer
) :
70 instance( producer
!= NULL ? producer
->get_producer( ) : NULL
),
77 Producer
::~Producer( )
80 mlt_producer_close( instance
);
84 mlt_producer Producer
::get_producer( )
89 mlt_producer Producer
::get_parent( )
91 return get_producer( ) != NULL
&& mlt_producer_cut_parent( get_producer( ) ) != NULL ?
mlt_producer_cut_parent( get_producer( ) ) : get_producer( );
94 Producer
&Producer
::parent( )
96 if ( is_cut( ) && parent_
== NULL
)
97 parent_
= new Producer( get_parent( ) );
98 return parent_
== NULL ?
*this : *parent_
;
101 mlt_service Producer
::get_service( )
103 return mlt_producer_service( get_producer( ) );
106 int Producer
::seek( int position
)
108 return mlt_producer_seek( get_producer( ), position
);
111 int Producer
::position( )
113 return mlt_producer_position( get_producer( ) );
116 int Producer
::frame( )
118 return mlt_producer_frame( get_producer( ) );
121 int Producer
::set_speed( double speed
)
123 return mlt_producer_set_speed( get_producer( ), speed
);
126 double Producer
::get_speed( )
128 return mlt_producer_get_speed( get_producer( ) );
131 double Producer
::get_fps( )
133 return mlt_producer_get_fps( get_producer( ) );
136 int Producer
::set_in_and_out( int in
, int out
)
138 return mlt_producer_set_in_and_out( get_producer( ), in
, out
);
141 int Producer
::get_in( )
143 return mlt_producer_get_in( get_producer( ) );
146 int Producer
::get_out( )
148 return mlt_producer_get_out( get_producer( ) );
151 int Producer
::get_length( )
153 return mlt_producer_get_length( get_producer( ) );
156 int Producer
::get_playtime( )
158 return mlt_producer_get_playtime( get_producer( ) );
161 Producer
*Producer
::cut( int in
, int out
)
163 mlt_producer producer
= mlt_producer_cut( get_producer( ), in
, out
);
164 Producer
*result
= new Producer( producer
);
165 mlt_producer_close( producer
);
169 bool Producer
::is_cut( )
171 return mlt_producer_is_cut( get_producer( ) ) != 0;
174 bool Producer
::is_blank( )
176 return mlt_producer_is_blank( get_producer( ) ) != 0;
179 bool Producer
::same_clip( Producer
&that
)
181 return mlt_producer_cut_parent( get_producer( ) ) == mlt_producer_cut_parent( that
.get_producer( ) );
184 bool Producer
::runs_into( Producer
&that
)
186 return same_clip( that
) && get_out( ) == ( that
.get_in( ) - 1 );
189 void Producer
::optimise( )
191 mlt_producer_optimise( get_producer( ) );