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