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