2 * MltPlaylist.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.
23 #include "MltPlaylist.h"
24 #include "MltTransition.h"
27 ClipInfo
::ClipInfo( ) :
42 ClipInfo
::ClipInfo( mlt_playlist_clip_info
*info
) :
44 producer( new Producer( info
->producer
) ),
45 cut( new Producer( info
->cut
) ),
47 resource( info
->resource?
strdup( info
->resource
) : 0 ),
48 frame_in( info
->frame_in
),
49 frame_out( info
->frame_out
),
50 frame_count( info
->frame_count
),
51 length( info
->length
),
53 repeat( info
->repeat
)
57 ClipInfo
::~ClipInfo( )
64 void ClipInfo
::update( mlt_playlist_clip_info
*info
)
70 producer
= new Producer( info
->producer
);
71 cut
= new Producer( info
->cut
);
73 resource
= strdup( info
->resource
);
74 frame_in
= info
->frame_in
;
75 frame_out
= info
->frame_out
;
76 frame_count
= info
->frame_count
;
77 length
= info
->length
;
79 repeat
= info
->repeat
;
82 Playlist
::Playlist( ) :
85 instance
= mlt_playlist_init( );
88 Playlist
::Playlist( Service
&producer
) :
91 if ( producer
.type( ) == playlist_type
)
93 instance
= ( mlt_playlist
)producer
.get_service( );
98 Playlist
::Playlist( Playlist
&playlist
) :
99 Mlt
::Producer( playlist
),
100 instance( playlist
.get_playlist( ) )
105 Playlist
::Playlist( mlt_playlist playlist
) :
111 Playlist
::~Playlist( )
113 mlt_playlist_close( instance
);
116 mlt_playlist Playlist
::get_playlist( )
121 mlt_producer Playlist
::get_producer( )
123 return mlt_playlist_producer( get_playlist( ) );
126 int Playlist
::count( )
128 return mlt_playlist_count( get_playlist( ) );
131 int Playlist
::clear( )
133 return mlt_playlist_clear( get_playlist( ) );
136 int Playlist
::append( Producer
&producer
, int in
, int out
)
138 return mlt_playlist_append_io( get_playlist( ), producer
.get_producer( ), in
, out
);
141 int Playlist
::blank( int length
)
143 return mlt_playlist_blank( get_playlist( ), length
);
146 int Playlist
::clip( mlt_whence whence
, int index
)
148 return mlt_playlist_clip( get_playlist( ), whence
, index
);
151 int Playlist
::current_clip( )
153 return mlt_playlist_current_clip( get_playlist( ) );
156 Producer
*Playlist
::current( )
158 return new Producer( mlt_playlist_current( get_playlist( ) ) );
161 ClipInfo
*Playlist
::clip_info( int index
, ClipInfo
*info
)
163 mlt_playlist_clip_info clip_info
;
164 if ( mlt_playlist_get_clip_info( get_playlist( ), &clip_info
, index
) )
167 return new ClipInfo( &clip_info
);
168 info
->update( &clip_info
);
172 void Playlist
::delete_clip_info( ClipInfo
*info
)
177 int Playlist
::insert( Producer
&producer
, int where
, int in
, int out
)
179 return mlt_playlist_insert( get_playlist( ), producer
.get_producer( ), where
, in
, out
);
182 int Playlist
::remove( int where
)
184 return mlt_playlist_remove( get_playlist( ), where
);
187 int Playlist
::move( int from
, int to
)
189 return mlt_playlist_move( get_playlist( ), from
, to
);
192 int Playlist
::resize_clip( int clip
, int in
, int out
)
194 return mlt_playlist_resize_clip( get_playlist( ), clip
, in
, out
);
197 int Playlist
::split( int clip
, int position
)
199 return mlt_playlist_split( get_playlist( ), clip
, position
);
202 int Playlist
::split_at( int position
, bool left
)
204 return mlt_playlist_split_at( get_playlist( ), position
, left
);
207 int Playlist
::join( int clip
, int count
, int merge
)
209 return mlt_playlist_join( get_playlist( ), clip
, count
, merge
);
212 int Playlist
::mix( int clip
, int length
, Transition
*transition
)
214 return mlt_playlist_mix( get_playlist( ), clip
, length
, transition
== NULL ? NULL
: transition
->get_transition( ) );
217 int Playlist
::mix_add( int clip
, Transition
*transition
)
219 return mlt_playlist_mix_add( get_playlist( ), clip
, transition
== NULL ? NULL
: transition
->get_transition( ) );
222 int Playlist
::repeat( int clip
, int count
)
224 return mlt_playlist_repeat_clip( get_playlist( ), clip
, count
);
227 Producer
*Playlist
::get_clip( int clip
)
229 mlt_producer producer
= mlt_playlist_get_clip( get_playlist( ), clip
);
230 return producer
!= NULL ?
new Producer( producer
) : NULL
;
233 Producer
*Playlist
::get_clip_at( int position
)
235 mlt_producer producer
= mlt_playlist_get_clip_at( get_playlist( ), position
);
236 return producer
!= NULL ?
new Producer( producer
) : NULL
;
239 int Playlist
::get_clip_index_at( int position
)
241 return mlt_playlist_get_clip_index_at( get_playlist( ), position
);
244 bool Playlist
::is_mix( int clip
)
246 return mlt_playlist_clip_is_mix( get_playlist( ), clip
) != 0;
249 bool Playlist
::is_blank( int clip
)
251 return mlt_playlist_is_blank( get_playlist( ), clip
) != 0;
254 bool Playlist
::is_blank_at( int position
)
256 return mlt_playlist_is_blank_at( get_playlist( ), position
) != 0;
259 Producer
*Playlist
::replace_with_blank( int clip
)
261 mlt_producer producer
= mlt_playlist_replace_with_blank( get_playlist( ), clip
);
262 Producer
*object
= producer
!= NULL ?
new Producer( producer
) : NULL
;
263 mlt_producer_close( producer
);
267 void Playlist
::consolidate_blanks( int keep_length
)
269 return mlt_playlist_consolidate_blanks( get_playlist( ), keep_length
);
272 void Playlist
::insert_blank( int clip
, int length
)
274 mlt_playlist_insert_blank( get_playlist( ), clip
, length
);
277 void Playlist
::pad_blanks( int position
, int length
, int find
)
279 mlt_playlist_pad_blanks( get_playlist( ), position
, length
, find
);
282 int Playlist
::insert_at( int position
, Producer
*producer
, int mode
)
284 return mlt_playlist_insert_at( get_playlist( ), position
, producer
->get_producer( ), mode
);
287 int Playlist
::insert_at( int position
, Producer
&producer
, int mode
)
289 return mlt_playlist_insert_at( get_playlist( ), position
, producer
.get_producer( ), mode
);
292 int Playlist
::clip_start( int clip
)
294 return mlt_playlist_clip_start( get_playlist( ), clip
);
297 int Playlist
::blanks_from( int clip
, int bounded
)
299 return mlt_playlist_blanks_from( get_playlist( ), clip
, bounded
);
302 int Playlist
::clip_length( int clip
)
304 return mlt_playlist_clip_length( get_playlist( ), clip
);
307 int Playlist
::remove_region( int position
, int length
)
309 return mlt_playlist_remove_region( get_playlist( ), position
, length
);
312 int Playlist
::move_region( int position
, int length
, int new_position
)
314 return mlt_playlist_move_region( get_playlist( ), position
, length
, new_position
);