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
this, mlt_service object
)
32 static int on_unknown( mlt_parser
this, mlt_service object
)
37 static int on_start_producer( mlt_parser
this, mlt_producer object
)
42 static int on_end_producer( mlt_parser
this, mlt_producer object
)
47 static int on_start_playlist( mlt_parser
this, mlt_playlist object
)
52 static int on_end_playlist( mlt_parser
this, mlt_playlist object
)
57 static int on_start_tractor( mlt_parser
this, mlt_tractor object
)
62 static int on_end_tractor( mlt_parser
this, mlt_tractor object
)
67 static int on_start_multitrack( mlt_parser
this, mlt_multitrack object
)
72 static int on_end_multitrack( mlt_parser
this, mlt_multitrack object
)
77 static int on_start_track( mlt_parser
this )
82 static int on_end_track( mlt_parser
this )
87 static int on_start_filter( mlt_parser
this, mlt_filter object
)
92 static int on_end_filter( mlt_parser
this, mlt_filter object
)
97 static int on_start_transition( mlt_parser
this, mlt_transition object
)
102 static int on_end_transition( mlt_parser
this, mlt_transition object
)
107 mlt_parser
mlt_parser_new( )
109 mlt_parser
this = calloc( 1, sizeof( struct mlt_parser_s
) );
110 if ( this != NULL
&& mlt_properties_init( &this->parent
, this ) == 0 )
112 this->on_invalid
= on_invalid
;
113 this->on_unknown
= on_unknown
;
114 this->on_start_producer
= on_start_producer
;
115 this->on_end_producer
= on_end_producer
;
116 this->on_start_playlist
= on_start_playlist
;
117 this->on_end_playlist
= on_end_playlist
;
118 this->on_start_tractor
= on_start_tractor
;
119 this->on_end_tractor
= on_end_tractor
;
120 this->on_start_multitrack
= on_start_multitrack
;
121 this->on_end_multitrack
= on_end_multitrack
;
122 this->on_start_track
= on_start_track
;
123 this->on_end_track
= on_end_track
;
124 this->on_start_filter
= on_start_filter
;
125 this->on_end_filter
= on_end_filter
;
126 this->on_start_transition
= on_start_transition
;
127 this->on_end_transition
= on_end_transition
;
132 mlt_properties
mlt_parser_properties( mlt_parser
this )
134 return &this->parent
;
137 int mlt_parser_start( mlt_parser
this, mlt_service object
)
140 mlt_service_type type
= mlt_service_identify( object
);
144 error
= this->on_invalid( this, object
);
147 error
= this->on_unknown( this, object
);
150 if ( mlt_producer_is_cut( ( mlt_producer
)object
) )
151 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_cut_parent( ( mlt_producer
)object
) );
152 error
= this->on_start_producer( this, ( mlt_producer
)object
);
156 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
157 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
159 error
= this->on_end_producer( this, ( mlt_producer
)object
);
162 error
= this->on_start_playlist( this, ( mlt_playlist
)object
);
166 while ( error
== 0 && i
< mlt_playlist_count( ( mlt_playlist
)object
) )
167 mlt_parser_start( this, ( 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( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
172 error
= this->on_end_playlist( this, ( mlt_playlist
)object
);
175 error
= this->on_start_tractor( this, ( mlt_tractor
)object
);
179 mlt_service next
= mlt_service_producer( object
);
180 mlt_parser_start( this, ( mlt_service
)mlt_tractor_multitrack( ( mlt_tractor
)object
) );
181 while ( next
!= ( mlt_service
)mlt_tractor_multitrack( ( mlt_tractor
)object
) )
183 mlt_parser_start( this, next
);
184 next
= mlt_service_producer( next
);
186 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
187 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
189 error
= this->on_end_tractor( this, ( mlt_tractor
)object
);
191 case multitrack_type
:
192 error
= this->on_start_multitrack( this, ( mlt_multitrack
)object
);
196 while ( i
< mlt_multitrack_count( ( mlt_multitrack
)object
) )
198 this->on_start_track( this );
199 mlt_parser_start( this, ( mlt_service
)mlt_multitrack_track( ( mlt_multitrack
)object
, i
++ ) );
200 this->on_end_track( this );
203 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
204 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
206 error
= this->on_end_multitrack( this, ( mlt_multitrack
)object
);
209 error
= this->on_start_filter( this, ( mlt_filter
)object
);
213 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
214 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
216 error
= this->on_end_filter( this, ( mlt_filter
)object
);
218 case transition_type
:
219 error
= this->on_start_transition( this, ( mlt_transition
)object
);
223 while ( error
== 0 && mlt_producer_filter( ( mlt_producer
)object
, i
) != NULL
)
224 error
= mlt_parser_start( this, ( mlt_service
)mlt_producer_filter( ( mlt_producer
)object
, i
++ ) );
226 error
= this->on_end_transition( this, ( mlt_transition
)object
);
236 void mlt_parser_close( mlt_parser
this )
240 mlt_properties_close( &this->parent
);