e56f097040560b29c945599db34cbaac13398dc5
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
25 static int on_invalid( mlt_parser
this, mlt_service object
)
30 static int on_unknown( mlt_parser
this, mlt_service object
)
35 static int on_start_producer( mlt_parser
this, mlt_producer object
)
40 static int on_end_producer( mlt_parser
this, mlt_producer object
)
45 static int on_start_playlist( mlt_parser
this, mlt_playlist object
)
50 static int on_end_playlist( mlt_parser
this, mlt_playlist object
)
55 static int on_start_tractor( mlt_parser
this, mlt_tractor object
)
60 static int on_end_tractor( mlt_parser
this, mlt_tractor object
)
65 static int on_start_multitrack( mlt_parser
this, mlt_multitrack object
)
70 static int on_end_multitrack( mlt_parser
this, mlt_multitrack object
)
75 static int on_start_track( mlt_parser
this )
80 static int on_end_track( mlt_parser
this )
85 static int on_start_filter( mlt_parser
this, mlt_filter object
)
90 static int on_end_filter( mlt_parser
this, mlt_filter object
)
95 static int on_start_transition( mlt_parser
this, mlt_transition object
)
100 static int on_end_transition( mlt_parser
this, mlt_transition object
)
105 mlt_parser
mlt_parser_new( )
107 mlt_parser
this = calloc( 1, sizeof( struct mlt_parser_s
) );
108 if ( this != NULL
&& mlt_properties_init( &this->parent
, this ) == 0 )
110 this->on_invalid
= on_invalid
;
111 this->on_unknown
= on_unknown
;
112 this->on_start_producer
= on_start_producer
;
113 this->on_end_producer
= on_end_producer
;
114 this->on_start_playlist
= on_start_playlist
;
115 this->on_end_playlist
= on_end_playlist
;
116 this->on_start_tractor
= on_start_tractor
;
117 this->on_end_tractor
= on_end_tractor
;
118 this->on_start_multitrack
= on_start_multitrack
;
119 this->on_end_multitrack
= on_end_multitrack
;
120 this->on_start_track
= on_start_track
;
121 this->on_end_track
= on_end_track
;
122 this->on_start_filter
= on_start_filter
;
123 this->on_end_filter
= on_end_filter
;
124 this->on_start_transition
= on_start_transition
;
125 this->on_end_transition
= on_end_transition
;
130 mlt_properties
mlt_parser_properties( mlt_parser
this )
132 return &this->parent
;
135 int mlt_parser_start( mlt_parser
this, mlt_service object
)
138 mlt_service_type type
= mlt_service_identify( object
);
142 error
= this->on_invalid( this, object
);
145 error
= this->on_unknown( this, object
);
148 if ( mlt_producer_is_cut( ( mlt_producer
)object
) )
149 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_cut_parent( ( mlt_producer
)object
) );
150 error
= this->on_start_producer( this, ( mlt_producer
)object
);
154 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
155 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
157 error
= this->on_end_producer( this, ( mlt_producer
)object
);
160 error
= this->on_start_playlist( this, ( mlt_playlist
)object
);
164 while ( error
== 0 && i
< mlt_playlist_count( ( mlt_playlist
)object
) )
165 mlt_parser_start( this, ( mlt_service
)mlt_playlist_get_clip( ( mlt_playlist
)object
, i
++ ) );
167 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
168 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
170 error
= this->on_end_playlist( this, ( mlt_playlist
)object
);
173 error
= this->on_start_tractor( this, ( mlt_tractor
)object
);
177 mlt_service next
= mlt_service_producer( object
);
178 mlt_parser_start( this, ( mlt_service
)mlt_tractor_multitrack( ( mlt_tractor
)object
) );
179 while ( next
!= ( mlt_service
)mlt_tractor_multitrack( ( mlt_tractor
)object
) )
181 mlt_parser_start( this, next
);
182 next
= mlt_service_producer( next
);
184 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
185 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
187 error
= this->on_end_tractor( this, ( mlt_tractor
)object
);
189 case multitrack_type
:
190 error
= this->on_start_multitrack( this, ( mlt_multitrack
)object
);
194 while ( i
< mlt_multitrack_count( ( mlt_multitrack
)object
) )
196 this->on_start_track( this );
197 mlt_parser_start( this, ( mlt_service
)mlt_multitrack_track( ( mlt_multitrack
)object
, i
++ ) );
198 this->on_end_track( this );
201 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
202 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
204 error
= this->on_end_multitrack( this, ( mlt_multitrack
)object
);
207 error
= this->on_start_filter( this, ( mlt_filter
)object
);
211 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
212 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
214 error
= this->on_end_filter( this, ( mlt_filter
)object
);
216 case transition_type
:
217 error
= this->on_start_transition( this, ( mlt_transition
)object
);
221 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
222 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
224 error
= this->on_end_transition( this, ( mlt_transition
)object
);
234 void mlt_parser_close( mlt_parser
this )
238 mlt_properties_close( &this->parent
);