add MltProfile and update examples
[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( Profile &, char *, char * );
34 %newobject Factory::filter( Profile &, char *, char * );
35 %newobject Factory::transition( Profile &, char *, char * );
36 %newobject Factory::consumer( Profile &, 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 Producer::cut( int, int );
44 %newobject Playlist::current( );
45 %newobject Playlist::clip_info( int );
46 %newobject Playlist::get_clip( int );
47 %newobject Multitrack::track( int );
48 %newobject Tractor::multitrack( );
49 %newobject Tractor::field( );
50 %newobject Tractor::track( int );
51 %newobject Frame::get_original_producer( );
52 %newobject Miracle::execute( char * );
53 %newobject Miracle::push( char *, Service & );
54 %newobject Miracle::unit( int );
55 }
56
57 /** Classes to wrap.
58  */
59
60 %include <framework/mlt_types.h>
61 %include <framework/mlt_factory.h>
62 %include <MltFactory.h>
63 %include <MltEvent.h>
64 %include <MltProperties.h>
65 %include <MltFrame.h>
66 %include <MltGeometry.h>
67 %include <MltService.h>
68 %include <MltProducer.h>
69 %include <MltProfile.h>
70 %include <MltPlaylist.h>
71 %include <MltConsumer.h>
72 %include <MltFilter.h>
73 %include <MltTransition.h>
74 %include <MltMultitrack.h>
75 %include <MltField.h>
76 %include <MltTractor.h>
77 %include <MltParser.h>
78 %include <MltFilteredConsumer.h>
79 %include <MltMiracle.h>
80 %include <MltResponse.h>
81
82 #if defined(SWIGRUBY)
83
84 %{
85
86 static void ruby_listener( mlt_properties owner, void *object );
87
88 class RubyListener
89 {
90         private:
91                 VALUE callback;
92                 Mlt::Event *event;
93
94         public:
95                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback ) : 
96                         callback( callback ) 
97                 {
98                         event = properties.listen( id, this, ( mlt_listener )ruby_listener );
99                 }
100
101                 ~RubyListener( )
102                 {
103                         delete event;
104                 }
105
106         void mark( ) 
107                 { 
108                         ((void (*)(VALUE))(rb_gc_mark))( callback ); 
109                 }
110
111         void doit( ) 
112                 {
113                 ID method = rb_intern( "call" );
114                 rb_funcall( callback, method, 0 );
115         }
116 };
117
118 static void ruby_listener( mlt_properties owner, void *object )
119 {
120         RubyListener *o = static_cast< RubyListener * >( object );
121         o->doit( );
122 }
123
124 void markRubyListener( void* p ) 
125 {
126     RubyListener *o = static_cast<RubyListener*>( p );
127     o->mark( );
128 }
129
130 %}
131
132 // Ruby wrapper
133 %rename( Listener )  RubyListener;
134 %markfunc RubyListener "markRubyListener";
135
136 class RubyListener 
137 {
138         public:
139                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback );
140 };
141
142 #endif
143