]> git.sesse.net Git - mlt/blob - src/swig/mlt.i
Fix doc error for mlt_playlist_is_blank().
[mlt] / src / swig / mlt.i
1 /**
2  * mlt.i - Swig Bindings for mlt++
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 %module mlt
22 %include "carrays.i"
23 %array_class(unsigned char, unsignedCharArray);
24
25 %{
26 #include <mlt++/Mlt.h>
27 int mlt_log_get_level( void );
28 void mlt_log_set_level( int );
29 %}
30
31 /** These methods return objects which should be gc'd.
32  */
33
34 namespace Mlt {
35 %newobject Factory::init( const char * );
36 %newobject Factory::producer( Profile &, char *, char * );
37 %newobject Factory::filter( Profile &, char *, char * );
38 %newobject Factory::transition( Profile &, char *, char * );
39 %newobject Factory::consumer( Profile &, char *, char * );
40 %newobject Properties::listen( const char *, void *, mlt_listener );
41 %newobject Properties::setup_wait_for( const char * );
42 %newobject Properties::parse_yaml( const char * );
43 %newobject Service::producer( );
44 %newobject Service::consumer( );
45 %newobject Service::get_frame( int );
46 %newobject Service::filter( int );
47 %newobject Producer::filter( int );
48 %newobject Producer::cut( int, int );
49 %newobject Playlist::current( );
50 %newobject Playlist::clip_info( int );
51 %newobject Playlist::get_clip( int );
52 %newobject Multitrack::track( int );
53 %newobject Tractor::multitrack( );
54 %newobject Tractor::field( );
55 %newobject Tractor::track( int );
56 %newobject Frame::get_original_producer( );
57 %newobject Repository::consumers( );
58 %newobject Repository::filters( );
59 %newobject Repository::producers( );
60 %newobject Repository::transitions( );
61 %newobject Repository::metadata( mlt_service_type, const char * );
62 %newobject Repository::languages( );
63 %newobject Profile::list();
64 %newobject Repository::presets();
65
66 #if defined(SWIGPYTHON)
67 %feature("shadow") Frame::get_waveform(int, int) %{
68     def get_waveform(*args): return _mlt.frame_get_waveform(*args)
69 %}
70 %feature("shadow") Frame::get_image(mlt_image_format&, int&, int&) %{
71     def get_image(*args): return _mlt.frame_get_image(*args)
72 %}
73 #endif
74
75 }
76
77 /** Classes to wrap.
78  */
79
80 %include <framework/mlt_types.h>
81 %include <framework/mlt_factory.h>
82 %include <framework/mlt_version.h>
83 int mlt_log_get_level( void );
84 void mlt_log_set_level( int );
85 %include <MltFactory.h>
86 %include <MltRepository.h>
87 %include <MltEvent.h>
88 %include <MltProperties.h>
89 %include <MltFrame.h>
90 %include <MltGeometry.h>
91 %include <MltService.h>
92 %include <MltProducer.h>
93 %include <MltProfile.h>
94 %include <MltPlaylist.h>
95 %include <MltConsumer.h>
96 %include <MltFilter.h>
97 %include <MltTransition.h>
98 %include <MltMultitrack.h>
99 %include <MltField.h>
100 %include <MltTractor.h>
101 %include <MltParser.h>
102 %include <MltFilteredConsumer.h>
103
104
105
106 #if defined(SWIGRUBY)
107
108 %{
109
110 static void ruby_listener( mlt_properties owner, void *object );
111
112 class RubyListener
113 {
114         protected:
115                 VALUE callback;
116                 Mlt::Event *event;
117
118         public:
119                 RubyListener( VALUE callback ) : callback( callback )
120                 {}
121
122                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback ) :
123                         callback( callback ) 
124                 {
125                         event = properties.listen( id, this, ( mlt_listener )ruby_listener );
126                 }
127
128                 virtual ~RubyListener( )
129                 {
130                         delete event;
131                 }
132
133                 void mark( )
134                 { 
135                         ((void (*)(VALUE))(rb_gc_mark))( callback ); 
136                 }
137
138                 void doit( )
139                 {
140                 ID method = rb_intern( "call" );
141                 rb_funcall( callback, method, 0 );
142         }
143 };
144
145 static void ruby_listener( mlt_properties owner, void *object )
146 {
147         RubyListener *o = static_cast< RubyListener * >( object );
148         o->doit( );
149 }
150
151 void markRubyListener( void* p ) 
152 {
153     RubyListener *o = static_cast<RubyListener*>( p );
154     o->mark( );
155 }
156
157 static void on_playlist_next( mlt_properties owner, void *object, int i );
158
159 class PlaylistNextListener : RubyListener
160 {
161         private:
162                 Mlt::Event *event;
163
164         public:
165                 PlaylistNextListener( Mlt::Properties *properties, VALUE proc )
166                         : RubyListener( proc )
167                 {
168                         event = properties->listen( "playlist-next", this, ( mlt_listener )on_playlist_next );
169                 }
170
171                 ~PlaylistNextListener()
172                 {
173                         delete event;
174                 }
175
176                 void yield( int i )
177                 {
178                         ID method = rb_intern( "call" );
179                         rb_funcall( callback, method, 1, INT2FIX( i ) );
180                 }
181 };
182
183 static void on_playlist_next( mlt_properties owner, void *object, int i )
184 {
185         PlaylistNextListener *o = static_cast< PlaylistNextListener * >( object );
186         o->yield( i );
187 }
188
189 %}
190
191 // Ruby wrapper
192 %rename( Listener )  RubyListener;
193 %markfunc RubyListener "markRubyListener";
194 %markfunc PlaylistNextListener "markRubyListener";
195
196 class RubyListener
197 {
198         public:
199                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback );
200 };
201
202 class PlaylistNextListener
203 {
204         public:
205                 PlaylistNextListener( Mlt::Properties *properties, VALUE proc );
206 };
207
208 #endif // SWIGGRUBY
209
210
211
212 #if defined(SWIGPYTHON)
213 %{
214 typedef struct {
215         int size;
216         char* data;
217 } binary_data;
218
219 binary_data frame_get_waveform( Mlt::Frame &frame, int w, int h )
220 {
221         binary_data result = {
222                 w * h,
223                 (char*) frame.get_waveform( w, h )
224         };
225         return result;
226 }
227
228 binary_data frame_get_image( Mlt::Frame &frame, mlt_image_format format, int w, int h )
229 {
230         binary_data result = {
231                 mlt_image_format_size( format, w, h, NULL ),
232                 (char*) frame.get_image( format, w, h )
233         };
234         return result;
235 }
236
237 %}
238
239 %typemap(out) binary_data {
240         $result = PyString_FromStringAndSize( $1.data, $1.size );
241 }
242
243 binary_data frame_get_waveform(Mlt::Frame&, int, int);
244 binary_data frame_get_image(Mlt::Frame&, mlt_image_format, int, int);
245
246 #endif