Run time type identification
[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 using namespace Mlt;
25
26 ClipInfo::ClipInfo( mlt_playlist_clip_info *info ) :
27 clip( info->clip ),
28 producer( new Producer( info->producer ) ),
29 service( new Service( info->service ) ),
30 start( info->start ),
31 resource( strdup( info->resource ) ),
32 frame_in( info->frame_in ),
33 frame_out( info->frame_out ),
34 frame_count( info->frame_count ),
35 length( info->length ),
36 fps( info->fps )
37 {
38 }
39
40 ClipInfo::~ClipInfo( )
41 {
42 delete producer;
43 delete service;
44 free( resource );
45 }
46
47 Playlist::Playlist( ) :
48 instance( NULL )
49 {
50 instance = mlt_playlist_init( );
51 }
52
53 Playlist::Playlist( Service &producer ) :
54 instance( NULL )
55 {
56 if ( producer.type( ) == playlist_type )
57 {
58 instance = ( mlt_playlist )producer.get_service( );
59 inc_ref( );
60 }
61 }
62
63 Playlist::Playlist( Playlist &playlist ) :
64 instance( playlist.get_playlist( ) )
65 {
66 inc_ref( );
67 }
68
69 Playlist::Playlist( mlt_playlist playlist ) :
70 instance( playlist )
71 {
72 inc_ref( );
73 }
74
75 Playlist::~Playlist( )
76 {
77 mlt_playlist_close( instance );
78 }
79
80 mlt_playlist Playlist::get_playlist( )
81 {
82 return instance;
83 }
84
85 mlt_producer Playlist::get_producer( )
86 {
87 return mlt_playlist_producer( get_playlist( ) );
88 }
89
90 int Playlist::count( )
91 {
92 return mlt_playlist_count( get_playlist( ) );
93 }
94
95 int Playlist::clear( )
96 {
97 return mlt_playlist_clear( get_playlist( ) );
98 }
99
100 int Playlist::append( Producer &producer, int in, int out )
101 {
102 return mlt_playlist_append_io( get_playlist( ), producer.get_producer( ), in, out );
103 }
104
105 int Playlist::blank( int length )
106 {
107 return mlt_playlist_blank( get_playlist( ), length );
108 }
109
110 int Playlist::clip( mlt_whence whence, int index )
111 {
112 return mlt_playlist_clip( get_playlist( ), whence, index );
113 }
114
115 int Playlist::current_clip( )
116 {
117 return mlt_playlist_current_clip( get_playlist( ) );
118 }
119
120 Producer *Playlist::current( )
121 {
122 return new Producer( mlt_playlist_current( get_playlist( ) ) );
123 }
124
125 ClipInfo *Playlist::clip_info( int index )
126 {
127 mlt_playlist_clip_info info;
128 mlt_playlist_get_clip_info( get_playlist( ), &info, index );
129 return new ClipInfo( &info );
130 }
131
132 int Playlist::insert( Producer &producer, int where, int in, int out )
133 {
134 return mlt_playlist_insert( get_playlist( ), producer.get_producer( ), where, in, out );
135 }
136
137 int Playlist::remove( int where )
138 {
139 return mlt_playlist_remove( get_playlist( ), where );
140 }
141
142 int Playlist::move( int from, int to )
143 {
144 return mlt_playlist_move( get_playlist( ), from, to );
145 }
146
147 int Playlist::resize_clip( int clip, int in, int out )
148 {
149 return mlt_playlist_resize_clip( get_playlist( ), clip, in, out );
150 }
151
152 int Playlist::split( int clip, int position )
153 {
154 return mlt_playlist_split( get_playlist( ), clip, position );
155 }
156
157 int Playlist::join( int clip, int count, int merge )
158 {
159 return mlt_playlist_join( get_playlist( ), clip, count, merge );
160 }