Event and frame handling
[melted] / mlt++ / swig / mltpp.i
1 /**
2  * mltpp.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 mltpp
22 %include "carrays.i"
23 %array_class(unsigned char, unsignedCharArray);
24
25 %{
26 #include <mlt++/Mlt.h>
27 %}
28
29 /** These methods return objects which should be gc'd.
30  */
31
32 namespace Mlt {
33 %newobject Factory::producer( char *, char * );
34 %newobject Factory::filter( char *, char * );
35 %newobject Factory::transition( char *, char * );
36 %newobject Factory::consumer( char *, char * );
37 %newobject Properties::listen( char *, void *, mlt_listener );
38 %newobject Service::producer( );
39 %newobject Service::consumer( );
40 %newobject Service::get_frame( int );
41 %newobject Service::filter( int );
42 %newobject Producer::filter( int );
43 %newobject Playlist::current( );
44 %newobject Playlist::clip_info( int );
45 %newobject Multitrack::track( int );
46 %newobject Tractor::multitrack( );
47 %newobject Tractor::field( );
48 %newobject Tractor::track( int );
49 %newobject Miracle::execute( char * );
50 %newobject Miracle::push( char *, Service & );
51 }
52
53 /** Classes to wrap.
54  */
55
56 %include <framework/mlt_types.h>
57 %include <framework/mlt_factory.h>
58 %include <MltFactory.h>
59 %include <MltEvent.h>
60 %include <MltProperties.h>
61 %include <MltFrame.h>
62 %include <MltService.h>
63 %include <MltProducer.h>
64 %include <MltPlaylist.h>
65 %include <MltConsumer.h>
66 %include <MltFilter.h>
67 %include <MltTransition.h>
68 %include <MltMultitrack.h>
69 %include <MltField.h>
70 %include <MltTractor.h>
71 %include <MltFilteredConsumer.h>
72 %include <MltMiracle.h>
73 %include <MltResponse.h>
74
75 #if defined(SWIGRUBY)
76
77 %{
78
79 static void ruby_listener( mlt_properties owner, void *object );
80
81 class RubyListener
82 {
83         private:
84                 Mlt::Event *event;
85
86         public:
87                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback ) : 
88                         callback( callback ) 
89                 {
90                         event = properties.listen( id, this, ( mlt_listener )ruby_listener );
91                 }
92
93                 ~RubyList( )
94                 {
95                         delete event;
96                 }
97
98         void mark( ) 
99                 { 
100                         ((void (*)(VALUE))(rb_gc_mark))( callback ); 
101                 }
102
103         void doit( ) 
104                 {
105                 ID method = rb_intern( "call" );
106                 rb_funcall( callback, method, 0 );
107         }
108
109         private:
110                 VALUE callback;
111 };
112
113 static void ruby_listener( mlt_properties owner, void *object )
114 {
115         RubyListener *o = static_cast< RubyListener * >( object );
116         o->doit( );
117 }
118
119 void markRubyListener( void* p ) 
120 {
121     RubyListener *o = static_cast<RubyListener*>( p );
122     o->mark( );
123 }
124
125 %}
126
127 // Ruby wrapper
128 %rename( Listener )  RubyListener;
129 %markfunc RubyListener "markRubyListener";
130
131 class RubyListener 
132 {
133         public:
134                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback );
135 };
136
137 #endif
138