3 * \brief service parsing functionality
6 * Copyright (C) 2003-2009 Ushodaya Enterprises Limited
7 * \author Charles Yates <charles.yates@pandora.be>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 static int on_invalid( mlt_parser self, mlt_service object )
32 static int on_unknown( mlt_parser self, mlt_service object )
37 static int on_start_producer( mlt_parser self, mlt_producer object )
42 static int on_end_producer( mlt_parser self, mlt_producer object )
47 static int on_start_playlist( mlt_parser self, mlt_playlist object )
52 static int on_end_playlist( mlt_parser self, mlt_playlist object )
57 static int on_start_tractor( mlt_parser self, mlt_tractor object )
62 static int on_end_tractor( mlt_parser self, mlt_tractor object )
67 static int on_start_multitrack( mlt_parser self, mlt_multitrack object )
72 static int on_end_multitrack( mlt_parser self, mlt_multitrack object )
77 static int on_start_track( mlt_parser self )
82 static int on_end_track( mlt_parser self )
87 static int on_start_filter( mlt_parser self, mlt_filter object )
92 static int on_end_filter( mlt_parser self, mlt_filter object )
97 static int on_start_transition( mlt_parser self, mlt_transition object )
102 static int on_end_transition( mlt_parser self, mlt_transition object )
107 mlt_parser mlt_parser_new( )
109 mlt_parser self = calloc( 1, sizeof( struct mlt_parser_s ) );
110 if ( self != NULL && mlt_properties_init( &self->parent, self ) == 0 )
112 self->on_invalid = on_invalid;
113 self->on_unknown = on_unknown;
114 self->on_start_producer = on_start_producer;
115 self->on_end_producer = on_end_producer;
116 self->on_start_playlist = on_start_playlist;
117 self->on_end_playlist = on_end_playlist;
118 self->on_start_tractor = on_start_tractor;
119 self->on_end_tractor = on_end_tractor;
120 self->on_start_multitrack = on_start_multitrack;
121 self->on_end_multitrack = on_end_multitrack;
122 self->on_start_track = on_start_track;
123 self->on_end_track = on_end_track;
124 self->on_start_filter = on_start_filter;
125 self->on_end_filter = on_end_filter;
126 self->on_start_transition = on_start_transition;
127 self->on_end_transition = on_end_transition;
132 mlt_properties mlt_parser_properties( mlt_parser self )
134 return &self->parent;
137 int mlt_parser_start( mlt_parser self, mlt_service object )
140 mlt_service_type type = mlt_service_identify( object );
144 error = self->on_invalid( self, object );
147 error = self->on_unknown( self, object );
150 if ( mlt_producer_is_cut( ( mlt_producer )object ) )
151 error = mlt_parser_start( self, ( mlt_service )mlt_producer_cut_parent( ( mlt_producer )object ) );
152 error = self->on_start_producer( self, ( mlt_producer )object );
156 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
157 error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
159 error = self->on_end_producer( self, ( mlt_producer )object );
162 error = self->on_start_playlist( self, ( mlt_playlist )object );
166 while ( error == 0 && i < mlt_playlist_count( ( mlt_playlist )object ) )
167 mlt_parser_start( self, ( mlt_service )mlt_playlist_get_clip( ( mlt_playlist )object, i ++ ) );
169 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
170 error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
172 error = self->on_end_playlist( self, ( mlt_playlist )object );
175 error = self->on_start_tractor( self, ( mlt_tractor )object );
179 mlt_service next = mlt_service_producer( object );
180 mlt_parser_start( self, ( mlt_service )mlt_tractor_multitrack( ( mlt_tractor )object ) );
181 while ( next != ( mlt_service )mlt_tractor_multitrack( ( mlt_tractor )object ) )
183 mlt_parser_start( self, next );
184 next = mlt_service_producer( next );
186 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
187 error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
189 error = self->on_end_tractor( self, ( mlt_tractor )object );
191 case multitrack_type:
192 error = self->on_start_multitrack( self, ( mlt_multitrack )object );
196 while ( i < mlt_multitrack_count( ( mlt_multitrack )object ) )
198 self->on_start_track( self );
199 mlt_parser_start( self, ( mlt_service )mlt_multitrack_track( ( mlt_multitrack )object , i ++ ) );
200 self->on_end_track( self );
203 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
204 error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
206 error = self->on_end_multitrack( self, ( mlt_multitrack )object );
209 error = self->on_start_filter( self, ( mlt_filter )object );
213 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
214 error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
216 error = self->on_end_filter( self, ( mlt_filter )object );
218 case transition_type:
219 error = self->on_start_transition( self, ( mlt_transition )object );
223 while ( error == 0 && mlt_producer_filter( ( mlt_producer )object, i ) != NULL )
224 error = mlt_parser_start( self, ( mlt_service )mlt_producer_filter( ( mlt_producer )object, i ++ ) );
226 error = self->on_end_transition( self, ( mlt_transition )object );
236 void mlt_parser_close( mlt_parser self )
240 mlt_properties_close( &self->parent );