2 * MltParser.cpp - MLT Wrapper
3 * Copyright (C) 2004-2005 Charles Yates
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 static int on_invalid_cb( mlt_parser self, mlt_service object )
26 mlt_properties properties = mlt_parser_properties( self );
27 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
28 Service service( object );
29 return parser->on_invalid( &service );
32 static int on_unknown_cb( mlt_parser self, mlt_service object )
34 mlt_properties properties = mlt_parser_properties( self );
35 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
36 Service service( object );
37 return parser->on_unknown( &service );
40 static int on_start_producer_cb( mlt_parser self, mlt_producer object )
42 mlt_properties properties = mlt_parser_properties( self );
43 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
44 Producer producer( object );
45 return parser->on_start_producer( &producer );
48 static int on_end_producer_cb( mlt_parser self, mlt_producer object )
50 mlt_properties properties = mlt_parser_properties( self );
51 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
52 Producer producer( object );
53 return parser->on_end_producer( &producer );
56 static int on_start_playlist_cb( mlt_parser self, mlt_playlist object )
58 mlt_properties properties = mlt_parser_properties( self );
59 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
60 Playlist playlist( object );
61 return parser->on_start_playlist( &playlist );
64 static int on_end_playlist_cb( mlt_parser self, mlt_playlist object )
66 mlt_properties properties = mlt_parser_properties( self );
67 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
68 Playlist playlist( object );
69 return parser->on_end_playlist( &playlist );
72 static int on_start_tractor_cb( mlt_parser self, mlt_tractor object )
74 mlt_properties properties = mlt_parser_properties( self );
75 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
76 Tractor tractor( object );
77 return parser->on_start_tractor( &tractor );
80 static int on_end_tractor_cb( mlt_parser self, mlt_tractor object )
82 mlt_properties properties = mlt_parser_properties( self );
83 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
84 Tractor tractor( object );
85 return parser->on_end_tractor( &tractor );
88 static int on_start_multitrack_cb( mlt_parser self, mlt_multitrack object )
90 mlt_properties properties = mlt_parser_properties( self );
91 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
92 Multitrack multitrack( object );
93 return parser->on_start_multitrack( &multitrack );
96 static int on_end_multitrack_cb( mlt_parser self, mlt_multitrack object )
98 mlt_properties properties = mlt_parser_properties( self );
99 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
100 Multitrack multitrack( object );
101 return parser->on_end_multitrack( &multitrack );
104 static int on_start_track_cb( mlt_parser self )
106 mlt_properties properties = mlt_parser_properties( self );
107 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
108 return parser->on_start_track( );
111 static int on_end_track_cb( mlt_parser self )
113 mlt_properties properties = mlt_parser_properties( self );
114 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
115 return parser->on_end_track( );
118 static int on_start_filter_cb( mlt_parser self, mlt_filter object )
120 mlt_properties properties = mlt_parser_properties( self );
121 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
122 Filter filter( object );
123 return parser->on_start_filter( &filter );
126 static int on_end_filter_cb( mlt_parser self, mlt_filter object )
128 mlt_properties properties = mlt_parser_properties( self );
129 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
130 Filter filter( object );
131 return parser->on_end_filter( &filter );
134 static int on_start_transition_cb( mlt_parser self, mlt_transition object )
136 mlt_properties properties = mlt_parser_properties( self );
137 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
138 Transition transition( object );
139 return parser->on_start_transition( &transition );
142 static int on_end_transition_cb( mlt_parser self, mlt_transition object )
144 mlt_properties properties = mlt_parser_properties( self );
145 Parser *parser = ( Parser * )mlt_properties_get_data( properties, "_parser_object", NULL );
146 Transition transition( object );
147 return parser->on_end_transition( &transition );
153 parser = mlt_parser_new( );
154 set( "_parser_object", this, 0 );
155 parser->on_invalid = on_invalid_cb;
156 parser->on_unknown = on_unknown_cb;
157 parser->on_start_producer = on_start_producer_cb;
158 parser->on_end_producer = on_end_producer_cb;
159 parser->on_start_playlist = on_start_playlist_cb;
160 parser->on_end_playlist = on_end_playlist_cb;
161 parser->on_start_tractor = on_start_tractor_cb;
162 parser->on_end_tractor = on_end_tractor_cb;
163 parser->on_start_multitrack = on_start_multitrack_cb;
164 parser->on_end_multitrack = on_end_multitrack_cb;
165 parser->on_start_track = on_start_track_cb;
166 parser->on_end_track = on_end_track_cb;
167 parser->on_start_filter = on_start_filter_cb;
168 parser->on_end_filter = on_end_filter_cb;
169 parser->on_start_transition = on_start_transition_cb;
170 parser->on_end_transition = on_end_transition_cb;
175 mlt_parser_close( parser );
178 mlt_properties Parser::get_properties( )
180 return mlt_parser_properties( parser );
183 int Parser::start( Service &service )
185 return mlt_parser_start( parser, service.get_service( ) );
188 int Parser::on_invalid( Service *object )
190 object->debug( "Invalid" );
194 int Parser::on_unknown( Service *object )
196 object->debug( "Unknown" );
200 int Parser::on_start_producer( Producer *object )
202 object->debug( "on_start_producer" );
206 int Parser::on_end_producer( Producer *object )
208 object->debug( "on_end_producer" );
212 int Parser::on_start_playlist( Playlist *object )
214 object->debug( "on_start_playlist" );
218 int Parser::on_end_playlist( Playlist *object )
220 object->debug( "on_end_playlist" );
224 int Parser::on_start_tractor( Tractor *object )
226 object->debug( "on_start_tractor" );
230 int Parser::on_end_tractor( Tractor *object )
232 object->debug( "on_end_tractor" );
236 int Parser::on_start_multitrack( Multitrack *object )
238 object->debug( "on_start_multitrack" );
242 int Parser::on_end_multitrack( Multitrack *object )
244 object->debug( "on_end_multitrack" );
248 int Parser::on_start_track( )
250 fprintf( stderr, "on_start_track\n" );
254 int Parser::on_end_track( )
256 fprintf( stderr, "on_end_track\n" );
260 int Parser::on_start_filter( Filter *object )
262 object->debug( "on_start_filter" );
266 int Parser::on_end_filter( Filter *object )
268 object->debug( "on_end_filter" );
272 int Parser::on_start_transition( Transition *object )
274 object->debug( "on_start_transition" );
278 int Parser::on_end_transition( Transition *object )
280 object->debug( "on_end_transition" );