Remove the old mlt++ dir.
[melted] / src / swig / mlt.i
1 /**
2  * melted.i - Swig Bindings for melted++
3  * Copyright (C) 2004-2009 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.h>
27 #include <MltMelted.h>
28 #include <MltResponse.h>
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( char *, void *, mlt_listener );
41 %newobject Service::producer( );
42 %newobject Service::consumer( );
43 %newobject Service::get_frame( int );
44 %newobject Service::filter( int );
45 %newobject Producer::filter( int );
46 %newobject Producer::cut( int, int );
47 %newobject Playlist::current( );
48 %newobject Playlist::clip_info( int );
49 %newobject Playlist::get_clip( int );
50 %newobject Multitrack::track( int );
51 %newobject Tractor::multitrack( );
52 %newobject Tractor::field( );
53 %newobject Tractor::track( int );
54 %newobject Frame::get_original_producer( );
55 %newobject Repository::consumers( );
56 %newobject Repository::filters( );
57 %newobject Repository::producers( );
58 %newobject Repository::transitions( );
59 %newobject Repository::metadata( mlt_service_type, const char * );
60 %newobject Melted::execute( char * );
61 %newobject Melted::received( char *, char * );
62 %newobject Melted::push( char *, Service & );
63 %newobject Melted::unit( int );
64 }
65
66 /** Classes to wrap.
67  */
68
69 %include <framework/mlt_types.h>
70 %include <framework/mlt_factory.h>
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 %include <MltMelted.h>
90 %include <MltResponse.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