5473aff1e926cec899dfc5116a88e1f31ac6e1d9
3 * \brief service parsing functionality
5 * Copyright (C) 2003-2008 Ushodaya Enterprises Limited
6 * \author Charles Yates <charles.yates@pandora.be>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 static int on_invalid( mlt_parser
this, mlt_service object
)
31 static int on_unknown( mlt_parser
this, mlt_service object
)
36 static int on_start_producer( mlt_parser
this, mlt_producer object
)
41 static int on_end_producer( mlt_parser
this, mlt_producer object
)
46 static int on_start_playlist( mlt_parser
this, mlt_playlist object
)
51 static int on_end_playlist( mlt_parser
this, mlt_playlist object
)
56 static int on_start_tractor( mlt_parser
this, mlt_tractor object
)
61 static int on_end_tractor( mlt_parser
this, mlt_tractor object
)
66 static int on_start_multitrack( mlt_parser
this, mlt_multitrack object
)
71 static int on_end_multitrack( mlt_parser
this, mlt_multitrack object
)
76 static int on_start_track( mlt_parser
this )
81 static int on_end_track( mlt_parser
this )
86 static int on_start_filter( mlt_parser
this, mlt_filter object
)
91 static int on_end_filter( mlt_parser
this, mlt_filter object
)
96 static int on_start_transition( mlt_parser
this, mlt_transition object
)
101 static int on_end_transition( mlt_parser
this, mlt_transition object
)
106 mlt_parser
mlt_parser_new( )
108 mlt_parser
this = calloc( 1, sizeof( struct mlt_parser_s
) );
109 if ( this != NULL
&& mlt_properties_init( &this->parent
, this ) == 0 )
111 this->on_invalid
= on_invalid
;
112 this->on_unknown
= on_unknown
;
113 this->on_start_producer
= on_start_producer
;
114 this->on_end_producer
= on_end_producer
;
115 this->on_start_playlist
= on_start_playlist
;
116 this->on_end_playlist
= on_end_playlist
;
117 this->on_start_tractor
= on_start_tractor
;
118 this->on_end_tractor
= on_end_tractor
;
119 this->on_start_multitrack
= on_start_multitrack
;
120 this->on_end_multitrack
= on_end_multitrack
;
121 this->on_start_track
= on_start_track
;
122 this->on_end_track
= on_end_track
;
123 this->on_start_filter
= on_start_filter
;
124 this->on_end_filter
= on_end_filter
;
125 this->on_start_transition
= on_start_transition
;
126 this->on_end_transition
= on_end_transition
;
131 mlt_properties
mlt_parser_properties( mlt_parser
this )
133 return &this->parent
;
136 int mlt_parser_start( mlt_parser
this, mlt_service object
)
139 mlt_service_type type
= mlt_service_identify( object
);
143 error
= this->on_invalid( this, object
);
146 error
= this->on_unknown( this, object
);
149 if ( mlt_producer_is_cut( ( mlt_producer
)object
) )
150 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_cut_parent( ( mlt_producer
)object
) );
151 error
= this->on_start_producer( this, ( mlt_producer
)object
);
155 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
156 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
158 error
= this->on_end_producer( this, ( mlt_producer
)object
);
161 error
= this->on_start_playlist( this, ( mlt_playlist
)object
);
165 while ( error
== 0 && i
< mlt_playlist_count( ( mlt_playlist
)object
) )
166 mlt_parser_start( this, ( mlt_service
)mlt_playlist_get_clip( ( mlt_playlist
)object
, i
++ ) );
168 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
169 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
171 error
= this->on_end_playlist( this, ( mlt_playlist
)object
);
174 error
= this->on_start_tractor( this, ( mlt_tractor
)object
);
178 mlt_service next
= mlt_service_producer( object
);
179 mlt_parser_start( this, ( mlt_service
)mlt_tractor_multitrack( ( mlt_tractor
)object
) );
180 while ( next
!= ( mlt_service
)mlt_tractor_multitrack( ( mlt_tractor
)object
) )
182 mlt_parser_start( this, next
);
183 next
= mlt_service_producer( next
);
185 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
186 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
188 error
= this->on_end_tractor( this, ( mlt_tractor
)object
);
190 case multitrack_type
:
191 error
= this->on_start_multitrack( this, ( mlt_multitrack
)object
);
195 while ( i
< mlt_multitrack_count( ( mlt_multitrack
)object
) )
197 this->on_start_track( this );
198 mlt_parser_start( this, ( mlt_service
)mlt_multitrack_track( ( mlt_multitrack
)object
, i
++ ) );
199 this->on_end_track( this );
202 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
203 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
205 error
= this->on_end_multitrack( this, ( mlt_multitrack
)object
);
208 error
= this->on_start_filter( this, ( mlt_filter
)object
);
212 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
213 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
215 error
= this->on_end_filter( this, ( mlt_filter
)object
);
217 case transition_type
:
218 error
= this->on_start_transition( this, ( mlt_transition
)object
);
222 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
223 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
225 error
= this->on_end_transition( this, ( mlt_transition
)object
);
235 void mlt_parser_close( mlt_parser
this )
239 mlt_properties_close( &this->parent
);