2 * mlt_parser.c -- service parsing functionality
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
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( mlt_parser this, mlt_service object )
29 static int on_unknown( mlt_parser this, mlt_service object )
34 static int on_start_producer( mlt_parser this, mlt_producer object )
39 static int on_end_producer( mlt_parser this, mlt_producer object )
44 static int on_start_playlist( mlt_parser this, mlt_playlist object )
49 static int on_end_playlist( mlt_parser this, mlt_playlist object )
54 static int on_start_tractor( mlt_parser this, mlt_tractor object )
59 static int on_end_tractor( mlt_parser this, mlt_tractor object )
64 static int on_start_multitrack( mlt_parser this, mlt_multitrack object )
69 static int on_end_multitrack( mlt_parser this, mlt_multitrack object )
74 static int on_start_track( mlt_parser this )
79 static int on_end_track( mlt_parser this )
84 static int on_start_filter( mlt_parser this, mlt_filter object )
89 static int on_end_filter( mlt_parser this, mlt_filter object )
94 static int on_start_transition( mlt_parser this, mlt_transition object )
99 static int on_end_transition( mlt_parser this, mlt_transition object )
104 mlt_parser mlt_parser_new( )
106 mlt_parser this = calloc( 1, sizeof( struct mlt_parser_s ) );
107 if ( this != NULL && mlt_properties_init( &this->parent, this ) == 0 )
109 this->on_invalid = on_invalid;
110 this->on_unknown = on_unknown;
111 this->on_start_producer = on_start_producer;
112 this->on_end_producer = on_end_producer;
113 this->on_start_playlist = on_start_playlist;
114 this->on_end_playlist = on_end_playlist;
115 this->on_start_tractor = on_start_tractor;
116 this->on_end_tractor = on_end_tractor;
117 this->on_start_multitrack = on_start_multitrack;
118 this->on_end_multitrack = on_end_multitrack;
119 this->on_start_track = on_start_track;
120 this->on_end_track = on_end_track;
121 this->on_start_filter = on_start_filter;
122 this->on_end_filter = on_end_filter;
123 this->on_start_transition = on_start_transition;
124 this->on_end_transition = on_end_transition;
129 mlt_properties mlt_parser_properties( mlt_parser this )
131 return &this->parent;
134 int mlt_parser_start( mlt_parser this, mlt_service object )
137 mlt_service_type type = mlt_service_identify( object );
141 error = this->on_invalid( this, object );
144 error = this->on_unknown( this, object );
147 if ( mlt_producer_is_cut( ( mlt_producer )object ) )
148 error = mlt_parser_start( this, ( mlt_service )mlt_producer_cut_parent( ( mlt_producer )object ) );
149 error = this->on_start_producer( this, ( mlt_producer )object );
153 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
154 error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
156 error = this->on_end_producer( this, ( mlt_producer )object );
159 error = this->on_start_playlist( this, ( mlt_playlist )object );
163 while ( error == 0 && i < mlt_playlist_count( ( mlt_playlist )object ) )
164 mlt_parser_start( this, ( mlt_service )mlt_playlist_get_clip( ( mlt_playlist )object, i ++ ) );
166 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
167 error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
169 error = this->on_end_playlist( this, ( mlt_playlist )object );
172 error = this->on_start_tractor( this, ( mlt_tractor )object );
176 mlt_service next = mlt_service_producer( object );
177 mlt_parser_start( this, ( mlt_service )mlt_tractor_multitrack( ( mlt_tractor )object ) );
178 while ( next != ( mlt_service )mlt_tractor_multitrack( ( mlt_tractor )object ) )
180 mlt_parser_start( this, next );
181 next = mlt_service_producer( next );
183 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
184 error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
186 error = this->on_end_tractor( this, ( mlt_tractor )object );
188 case multitrack_type:
189 error = this->on_start_multitrack( this, ( mlt_multitrack )object );
193 while ( i < mlt_multitrack_count( ( mlt_multitrack )object ) )
195 this->on_start_track( this );
196 mlt_parser_start( this, ( mlt_service )mlt_multitrack_track( ( mlt_multitrack )object , i ++ ) );
197 this->on_end_track( this );
200 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
201 error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
203 error = this->on_end_multitrack( this, ( mlt_multitrack )object );
206 error = this->on_start_filter( this, ( mlt_filter )object );
210 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
211 error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
213 error = this->on_end_filter( this, ( mlt_filter )object );
215 case transition_type:
216 error = this->on_start_transition( this, ( mlt_transition )object );
220 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
221 error = mlt_parser_start( this, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
223 error = this->on_end_transition( this, ( mlt_transition )object );
233 void mlt_parser_close( mlt_parser this )
237 mlt_properties_close( &this->parent );