new mix related methods
[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 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 Miracle::execute( char * );
52 %newobject Miracle::push( char *, Service & );
53 }
54
55 /** Classes to wrap.
56  */
57
58 %include <framework/mlt_types.h>
59 %include <framework/mlt_factory.h>
60 %include <MltFactory.h>
61 %include <MltEvent.h>
62 %include <MltProperties.h>
63 %include <MltFrame.h>
64 %include <MltService.h>
65 %include <MltProducer.h>
66 %include <MltPlaylist.h>
67 %include <MltConsumer.h>
68 %include <MltFilter.h>
69 %include <MltTransition.h>
70 %include <MltMultitrack.h>
71 %include <MltField.h>
72 %include <MltTractor.h>
73 %include <MltFilteredConsumer.h>
74 %include <MltMiracle.h>
75 %include <MltResponse.h>
76
77 #if defined(SWIGRUBY)
78
79 %{
80
81 static void ruby_listener( mlt_properties owner, void *object );
82
83 class RubyListener
84 {
85         private:
86                 VALUE callback;
87                 Mlt::Event *event;
88
89         public:
90                 RubyListener( Mlt::Properties &properties, char *id, VALUE callback ) : 
91                         callback( callback ) 
92                 {
93                         event = properties.listen( id, this, ( mlt_listener )ruby_listener );
94                 }
95
96                 ~RubyListener( )
97                 {
98                         delete event;
99                 }
100
101         void mark( ) 
102                 { 
103                         ((void (*)(VALUE))(rb_gc_mark))( callback ); 
104                 }
105
106         void doit( ) 
107                 {
108                 ID method = rb_intern( "call" );
109                 rb_funcall( callback, method, 0 );
110         }
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