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