Adding the mix part 1
[melted] / mlt++ / src / MltPlaylist.cpp
1 /**
2 * MltPlaylist.cpp - MLT Wrapper
3 * Copyright (C) 2004-2005 Charles Yates
4 * Author: Charles Yates <charles.yates@pandora.be>
5 *
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.
10 *
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.
15 *
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.
19 */
20
21 #include <string.h>
22 #include <stdlib.h>
23 #include "MltPlaylist.h"
24 #include "MltTransition.h"
25 using namespace Mlt;
26
27 ClipInfo::ClipInfo( mlt_playlist_clip_info *info ) :
28 clip( info->clip ),
29 producer( new Producer( info->producer ) ),
30 service( new Service( info->service ) ),
31 start( info->start ),
32 resource( strdup( info->resource ) ),
33 frame_in( info->frame_in ),
34 frame_out( info->frame_out ),
35 frame_count( info->frame_count ),
36 length( info->length ),
37 fps( info->fps )
38 {
39 }
40
41 ClipInfo::~ClipInfo( )
42 {
43 delete producer;
44 delete service;
45 free( resource );
46 }
47
48 Playlist::Playlist( ) :
49 instance( NULL )
50 {
51 instance = mlt_playlist_init( );
52 }
53
54 Playlist::Playlist( Service &producer ) :
55 instance( NULL )
56 {
57 if ( producer.type( ) == playlist_type )
58 {
59 instance = ( mlt_playlist )producer.get_service( );
60 inc_ref( );
61 }
62 }
63
64 Playlist::Playlist( Playlist &playlist ) :
65 instance( playlist.get_playlist( ) )
66 {
67 inc_ref( );
68 }
69
70 Playlist::Playlist( mlt_playlist playlist ) :
71 instance( playlist )
72 {
73 inc_ref( );
74 }
75
76 Playlist::~Playlist( )
77 {
78 mlt_playlist_close( instance );
79 }
80
81 mlt_playlist Playlist::get_playlist( )
82 {
83 return instance;
84 }
85
86 mlt_producer Playlist::get_producer( )
87 {
88 return mlt_playlist_producer( get_playlist( ) );
89 }
90
91 int Playlist::count( )
92 {
93 return mlt_playlist_count( get_playlist( ) );
94 }
95
96 int Playlist::clear( )
97 {
98 return mlt_playlist_clear( get_playlist( ) );
99 }
100
101 int Playlist::append( Producer &producer, int in, int out )
102 {
103 return mlt_playlist_append_io( get_playlist( ), producer.get_producer( ), in, out );
104 }
105
106 int Playlist::blank( int length )
107 {
108 return mlt_playlist_blank( get_playlist( ), length );
109 }
110
111 int Playlist::clip( mlt_whence whence, int index )
112 {
113 return mlt_playlist_clip( get_playlist( ), whence, index );
114 }
115
116 int Playlist::current_clip( )
117 {
118 return mlt_playlist_current_clip( get_playlist( ) );
119 }
120
121 Producer *Playlist::current( )
122 {
123 return new Producer( mlt_playlist_current( get_playlist( ) ) );
124 }
125
126 ClipInfo *Playlist::clip_info( int index )
127 {
128 mlt_playlist_clip_info info;
129 mlt_playlist_get_clip_info( get_playlist( ), &info, index );
130 return new ClipInfo( &info );
131 }
132
133 int Playlist::insert( Producer &producer, int where, int in, int out )
134 {
135 return mlt_playlist_insert( get_playlist( ), producer.get_producer( ), where, in, out );
136 }
137
138 int Playlist::remove( int where )
139 {
140 return mlt_playlist_remove( get_playlist( ), where );
141 }
142
143 int Playlist::move( int from, int to )
144 {
145 return mlt_playlist_move( get_playlist( ), from, to );
146 }
147
148 int Playlist::resize_clip( int clip, int in, int out )
149 {
150 return mlt_playlist_resize_clip( get_playlist( ), clip, in, out );
151 }
152
153 int Playlist::split( int clip, int position )
154 {
155 return mlt_playlist_split( get_playlist( ), clip, position );
156 }
157
158 int Playlist::join( int clip, int count, int merge )
159 {
160 return mlt_playlist_join( get_playlist( ), clip, count, merge );
161 }
162
163 int Playlist::mix( int clip, int length, Transition *transition )
164 {
165 return mlt_playlist_mix( get_playlist( ), clip, length, transition == NULL ? NULL : transition->get_transition( ) );
166 }