]> git.sesse.net Git - mlt/blob - src/swig/mlt.i
cb57ad6c0f63af3dab58d0d113bac90a41b90e2a
[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 }
64
65 /** Classes to wrap.
66  */
67
68 %include <framework/mlt_types.h>
69 %include <framework/mlt_factory.h>
70 %include <framework/mlt_version.h>
71 int mlt_log_get_level( void );
72 void mlt_log_set_level( int );
73 %include <MltFactory.h>
74 %include <MltRepository.h>
75 %include <MltEvent.h>
76 %include <MltProperties.h>
77 %include <MltFrame.h>
78 %include <MltGeometry.h>
79 %include <MltService.h>
80 %include <MltProducer.h>
81 %include <MltProfile.h>
82 %include <MltPlaylist.h>
83 %include <MltConsumer.h>
84 %include <MltFilter.h>
85 %include <MltTransition.h>
86 %include <MltMultitrack.h>
87 %include <MltField.h>
88 %include <MltTractor.h>
89 %include <MltParser.h>
90 %include <MltFilteredConsumer.h>
91
92 #if defined(SWIGRUBY)
93
94 %{
95
96 static void ruby_listener( mlt_properties owner, void *object );
97
98 class RubyListener
99 {
100         private:
101                 VALUE callback;
102                 Mlt::Event *event;
103
104         public:
105                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback ) : 
106                         callback( callback ) 
107                 {
108                         event = properties.listen( id, this, ( mlt_listener )ruby_listener );
109                 }
110
111                 ~RubyListener( )
112                 {
113                         delete event;
114                 }
115
116         void mark( ) 
117                 { 
118                         ((void (*)(VALUE))(rb_gc_mark))( callback ); 
119                 }
120
121         void doit( ) 
122                 {
123                 ID method = rb_intern( "call" );
124                 rb_funcall( callback, method, 0 );
125         }
126 };
127
128 static void ruby_listener( mlt_properties owner, void *object )
129 {
130         RubyListener *o = static_cast< RubyListener * >( object );
131         o->doit( );
132 }
133
134 void markRubyListener( void* p ) 
135 {
136     RubyListener *o = static_cast<RubyListener*>( p );
137     o->mark( );
138 }
139
140 %}
141
142 // Ruby wrapper
143 %rename( Listener )  RubyListener;
144 %markfunc RubyListener "markRubyListener";
145
146 class RubyListener 
147 {
148         public:
149                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback );
150 };
151
152 #endif
153
154 #if defined(SWIGPYTHON)
155 %{
156 typedef struct {
157         int size;
158         char* data;
159 } binary_data;
160
161 binary_data frame_get_waveform( Mlt::Frame &frame, int w, int h )
162 {
163         binary_data result = {
164                 w * h,
165                 (char*) frame.get_waveform( w, h )
166         };
167         return result;
168 }
169
170 %}
171
172 %typemap(out) binary_data {
173         $result = PyString_FromStringAndSize( $1.data, $1.size );
174 }
175
176 binary_data frame_get_waveform(Mlt::Frame&, int, int);
177
178 #endif