2 * consumer_xml.c -- a libxml2 serialiser of mlt service networks
3 * Copyright (C) 2003-2009 Ushodaya Enterprises Limited
4 * Author: Dan Dennedy <dan@dennedy.org>
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
21 #include <framework/mlt.h>
26 #include <libxml/tree.h>
30 #define _x (const xmlChar*)
31 #define _s (const char*)
33 // This maintains counters for adding ids to elements
34 struct serialise_context_s
36 mlt_properties id_map;
44 mlt_properties hide_map;
48 typedef struct serialise_context_s* serialise_context;
50 /** Forward references to static functions.
53 static int consumer_start( mlt_consumer parent );
54 static int consumer_is_stopped( mlt_consumer this );
55 static void serialise_service( serialise_context context, mlt_service service, xmlNode *node );
69 /** Create or retrieve an id associated to this service.
72 static char *xml_get_id( serialise_context context, mlt_service service, xml_type type )
76 mlt_properties map = context->id_map;
78 // Search the map for the service
79 for ( i = 0; i < mlt_properties_count( map ); i ++ )
80 if ( mlt_properties_get_data_at( map, i, NULL ) == service )
83 // If the service is not in the map, and the type indicates a new id is needed...
84 if ( i >= mlt_properties_count( map ) && type != xml_existing )
86 // Attempt to reuse existing id
87 id = mlt_properties_get( MLT_SERVICE_PROPERTIES( service ), "id" );
89 // If no id, or the id is used in the map (for another service), then
91 if ( id == NULL || mlt_properties_get_data( map, id, NULL ) != NULL )
99 sprintf( temp, "producer%d", context->producer_count ++ );
102 sprintf( temp, "multitrack%d", context->multitrack_count ++ );
105 sprintf( temp, "playlist%d", context->playlist_count ++ );
108 sprintf( temp, "tractor%d", context->tractor_count ++ );
111 sprintf( temp, "filter%d", context->filter_count ++ );
114 sprintf( temp, "transition%d", context->transition_count ++ );
121 while( mlt_properties_get_data( map, temp, NULL ) != NULL );
123 // Set the data at the generated name
124 mlt_properties_set_data( map, temp, service, 0, NULL, NULL );
126 // Get the pointer to the name (i is the end of the list)
127 id = mlt_properties_get_name( map, i );
131 // Store the existing id in the map
132 mlt_properties_set_data( map, id, service, 0, NULL, NULL );
135 else if ( type == xml_existing )
137 id = mlt_properties_get_name( map, i );
143 /** This is what will be called by the factory - anything can be passed in
144 via the argument, but keep it simple.
147 mlt_consumer consumer_xml_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
149 // Create the consumer object
150 mlt_consumer this = calloc( sizeof( struct mlt_consumer_s ), 1 );
152 // If no malloc'd and consumer init ok
153 if ( this != NULL && mlt_consumer_init( this, NULL, profile ) == 0 )
155 // Allow thread to be started/stopped
156 this->start = consumer_start;
157 this->is_stopped = consumer_is_stopped;
159 mlt_properties_set( MLT_CONSUMER_PROPERTIES( this ), "resource", arg );
161 // Return the consumer produced
165 // malloc or consumer init failed
172 static void serialise_properties( serialise_context context, mlt_properties properties, xmlNode *node )
177 // Enumerate the properties
178 for ( i = 0; i < mlt_properties_count( properties ); i++ )
180 char *name = mlt_properties_get_name( properties, i );
183 mlt_properties_get_value( properties, i ) != NULL &&
184 strcmp( name, "mlt" ) != 0 &&
185 strcmp( name, "in" ) != 0 &&
186 strcmp( name, "out" ) != 0 &&
187 strcmp( name, "id" ) != 0 &&
188 strcmp( name, "title" ) != 0 &&
189 strcmp( name, "root" ) != 0 &&
190 strcmp( name, "width" ) != 0 &&
191 strcmp( name, "height" ) != 0 )
193 char *value = mlt_properties_get_value( properties, i );
194 int rootlen = strlen( context->root );
195 if ( rootlen && !strncmp( value, context->root, rootlen ) && value[ rootlen ] == '/' )
196 value += rootlen + 1;
197 p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
198 xmlNewProp( p, _x("name"), _x(name) );
203 static void serialise_store_properties( serialise_context context, mlt_properties properties, xmlNode *node, const char *store )
208 // Enumerate the properties
209 for ( i = 0; store != NULL && i < mlt_properties_count( properties ); i++ )
211 char *name = mlt_properties_get_name( properties, i );
212 if ( !strncmp( name, store, strlen( store ) ) )
214 char *value = mlt_properties_get_value( properties, i );
217 int rootlen = strlen( context->root );
218 if ( rootlen && !strncmp( value, context->root, rootlen ) && value[ rootlen ] == '/' )
219 value += rootlen + 1;
220 p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
221 xmlNewProp( p, _x("name"), _x(name) );
227 static inline void serialise_service_filters( serialise_context context, mlt_service service, xmlNode *node )
231 mlt_filter filter = NULL;
233 // Enumerate the filters
234 for ( i = 0; ( filter = mlt_producer_filter( MLT_PRODUCER( service ), i ) ) != NULL; i ++ )
236 mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
237 if ( mlt_properties_get_int( properties, "_loader" ) == 0 )
239 // Get a new id - if already allocated, do nothing
240 char *id = xml_get_id( context, MLT_FILTER_SERVICE( filter ), xml_filter );
243 int in = mlt_properties_get_position( properties, "in" );
244 int out = mlt_properties_get_position( properties, "out" );
245 p = xmlNewChild( node, NULL, _x("filter"), NULL );
246 xmlNewProp( p, _x("id"), _x(id) );
247 if ( mlt_properties_get( properties, "title" ) )
248 xmlNewProp( p, _x("title"), _x(mlt_properties_get( properties, "title" )) );
249 if ( in != 0 || out != 0 )
252 sprintf( temp, "%d", in );
253 xmlNewProp( p, _x("in"), _x(temp) );
254 sprintf( temp, "%d", out );
255 xmlNewProp( p, _x("out"), _x(temp) );
257 serialise_properties( context, properties, p );
258 serialise_service_filters( context, MLT_FILTER_SERVICE( filter ), p );
264 static void serialise_producer( serialise_context context, mlt_service service, xmlNode *node )
266 xmlNode *child = node;
267 mlt_service parent = MLT_SERVICE( mlt_producer_cut_parent( MLT_PRODUCER( service ) ) );
269 if ( context->pass == 0 )
271 mlt_properties properties = MLT_SERVICE_PROPERTIES( parent );
272 // Get a new id - if already allocated, do nothing
273 char *id = xml_get_id( context, parent, xml_producer );
277 child = xmlNewChild( node, NULL, _x("producer"), NULL );
280 xmlNewProp( child, _x("id"), _x(id) );
281 if ( mlt_properties_get( properties, "title" ) )
282 xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
283 xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
284 xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
285 serialise_properties( context, properties, child );
286 serialise_service_filters( context, service, child );
288 // Add producer to the map
289 mlt_properties_set_int( context->hide_map, id, mlt_properties_get_int( properties, "hide" ) );
293 char *id = xml_get_id( context, parent, xml_existing );
294 mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
295 xmlNewProp( node, _x("parent"), _x(id) );
296 xmlNewProp( node, _x("in"), _x(mlt_properties_get( properties, "in" )) );
297 xmlNewProp( node, _x("out"), _x(mlt_properties_get( properties, "out" )) );
301 static void serialise_tractor( serialise_context context, mlt_service service, xmlNode *node );
303 static void serialise_multitrack( serialise_context context, mlt_service service, xmlNode *node )
307 if ( context->pass == 0 )
309 // Iterate over the tracks to collect the producers
310 for ( i = 0; i < mlt_multitrack_count( MLT_MULTITRACK( service ) ); i++ )
312 mlt_producer producer = mlt_producer_cut_parent( mlt_multitrack_track( MLT_MULTITRACK( service ), i ) );
313 serialise_service( context, MLT_SERVICE( producer ), node );
318 // Get a new id - if already allocated, do nothing
319 char *id = xml_get_id( context, service, xml_multitrack );
323 // Serialise the tracks
324 for ( i = 0; i < mlt_multitrack_count( MLT_MULTITRACK( service ) ); i++ )
326 xmlNode *track = xmlNewChild( node, NULL, _x("track"), NULL );
328 mlt_producer producer = mlt_multitrack_track( MLT_MULTITRACK( service ), i );
329 mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
331 mlt_service parent = MLT_SERVICE( mlt_producer_cut_parent( producer ) );
333 char *id = xml_get_id( context, MLT_SERVICE( parent ), xml_existing );
334 xmlNewProp( track, _x("producer"), _x(id) );
335 if ( mlt_producer_is_cut( producer ) )
337 xmlNewProp( track, _x("in"), _x(mlt_properties_get( properties, "in" )) );
338 xmlNewProp( track, _x("out"), _x(mlt_properties_get( properties, "out" )) );
339 serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( producer ), track, context->store );
340 serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( producer ), track, "meta." );
341 serialise_service_filters( context, MLT_PRODUCER_SERVICE( producer ), track );
344 hide = mlt_properties_get_int( context->hide_map, id );
346 xmlNewProp( track, _x("hide"), _x( hide == 1 ? "video" : ( hide == 2 ? "audio" : "both" ) ) );
348 serialise_service_filters( context, service, node );
352 static void serialise_playlist( serialise_context context, mlt_service service, xmlNode *node )
355 xmlNode *child = node;
356 mlt_playlist_clip_info info;
357 mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
359 if ( context->pass == 0 )
361 // Get a new id - if already allocated, do nothing
362 char *id = xml_get_id( context, service, xml_playlist );
366 // Iterate over the playlist entries to collect the producers
367 for ( i = 0; i < mlt_playlist_count( MLT_PLAYLIST( service ) ); i++ )
369 if ( ! mlt_playlist_get_clip_info( MLT_PLAYLIST( service ), &info, i ) )
371 if ( info.producer != NULL )
373 mlt_producer producer = mlt_producer_cut_parent( info.producer );
374 char *service_s = mlt_properties_get( MLT_PRODUCER_PROPERTIES( producer ), "mlt_service" );
375 char *resource_s = mlt_properties_get( MLT_PRODUCER_PROPERTIES( producer ), "resource" );
376 if ( resource_s != NULL && !strcmp( resource_s, "<playlist>" ) )
377 serialise_playlist( context, MLT_SERVICE( producer ), node );
378 else if ( service_s != NULL && strcmp( service_s, "blank" ) != 0 )
379 serialise_service( context, MLT_SERVICE( producer ), node );
384 child = xmlNewChild( node, NULL, _x("playlist"), NULL );
387 xmlNewProp( child, _x("id"), _x(id) );
388 if ( mlt_properties_get( properties, "title" ) )
389 xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
391 // Store application specific properties
392 serialise_store_properties( context, properties, child, context->store );
393 serialise_store_properties( context, properties, child, "meta." );
395 // Add producer to the map
396 mlt_properties_set_int( context->hide_map, id, mlt_properties_get_int( properties, "hide" ) );
398 // Iterate over the playlist entries
399 for ( i = 0; i < mlt_playlist_count( MLT_PLAYLIST( service ) ); i++ )
401 if ( ! mlt_playlist_get_clip_info( MLT_PLAYLIST( service ), &info, i ) )
403 mlt_producer producer = mlt_producer_cut_parent( info.producer );
404 char *service_s = mlt_properties_get( MLT_PRODUCER_PROPERTIES( producer ), "mlt_service" );
405 if ( service_s != NULL && strcmp( service_s, "blank" ) == 0 )
409 xmlNode *entry = xmlNewChild( child, NULL, _x("blank"), NULL );
410 snprintf( length, 19, "%d", (int)info.frame_count );
411 xmlNewProp( entry, _x("length"), _x(length) );
416 xmlNode *entry = xmlNewChild( child, NULL, _x("entry"), NULL );
417 id = xml_get_id( context, MLT_SERVICE( producer ), xml_existing );
418 xmlNewProp( entry, _x("producer"), _x(id) );
419 sprintf( temp, "%d", (int)info.frame_in );
420 xmlNewProp( entry, _x("in"), _x(temp) );
421 sprintf( temp, "%d", (int)info.frame_out );
422 xmlNewProp( entry, _x("out"), _x(temp) );
423 if ( info.repeat > 1 )
425 sprintf( temp, "%d", info.repeat );
426 xmlNewProp( entry, _x("repeat"), _x(temp) );
428 if ( mlt_producer_is_cut( info.cut ) )
430 serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( info.cut ), entry, context->store );
431 serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( info.cut ), entry, "meta." );
432 serialise_service_filters( context, MLT_PRODUCER_SERVICE( info.cut ), entry );
438 serialise_service_filters( context, service, child );
440 else if ( xmlStrcmp( node->name, _x("tractor") ) != 0 )
442 char *id = xml_get_id( context, service, xml_existing );
443 xmlNewProp( node, _x("producer"), _x(id) );
447 static void serialise_tractor( serialise_context context, mlt_service service, xmlNode *node )
449 xmlNode *child = node;
450 mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
452 if ( context->pass == 0 )
454 // Recurse on connected producer
455 serialise_service( context, mlt_service_producer( service ), node );
459 // Get a new id - if already allocated, do nothing
460 char *id = xml_get_id( context, service, xml_tractor );
464 child = xmlNewChild( node, NULL, _x("tractor"), NULL );
467 xmlNewProp( child, _x("id"), _x(id) );
468 if ( mlt_properties_get( properties, "title" ) )
469 xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
470 if ( mlt_properties_get( properties, "global_feed" ) )
471 xmlNewProp( child, _x("global_feed"), _x(mlt_properties_get( properties, "global_feed" )) );
472 xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
473 xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
475 // Store application specific properties
476 serialise_store_properties( context, MLT_SERVICE_PROPERTIES( service ), child, context->store );
477 serialise_store_properties( context, MLT_SERVICE_PROPERTIES( service ), child, "meta." );
479 // Recurse on connected producer
480 serialise_service( context, mlt_service_producer( service ), child );
481 serialise_service_filters( context, service, child );
485 static void serialise_filter( serialise_context context, mlt_service service, xmlNode *node )
487 xmlNode *child = node;
488 mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
490 // Recurse on connected producer
491 serialise_service( context, mlt_service_producer( service ), node );
493 if ( context->pass == 1 )
495 // Get a new id - if already allocated, do nothing
496 char *id = xml_get_id( context, service, xml_filter );
500 child = xmlNewChild( node, NULL, _x("filter"), NULL );
503 xmlNewProp( child, _x("id"), _x(id) );
504 if ( mlt_properties_get( properties, "title" ) )
505 xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
506 xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
507 xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
509 serialise_properties( context, properties, child );
510 serialise_service_filters( context, service, child );
514 static void serialise_transition( serialise_context context, mlt_service service, xmlNode *node )
516 xmlNode *child = node;
517 mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
519 // Recurse on connected producer
520 serialise_service( context, MLT_SERVICE( MLT_TRANSITION( service )->producer ), node );
522 if ( context->pass == 1 )
524 // Get a new id - if already allocated, do nothing
525 char *id = xml_get_id( context, service, xml_transition );
529 child = xmlNewChild( node, NULL, _x("transition"), NULL );
532 xmlNewProp( child, _x("id"), _x(id) );
533 if ( mlt_properties_get( properties, "title" ) )
534 xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) );
535 xmlNewProp( child, _x("in"), _x(mlt_properties_get( properties, "in" )) );
536 xmlNewProp( child, _x("out"), _x(mlt_properties_get( properties, "out" )) );
538 serialise_properties( context, properties, child );
539 serialise_service_filters( context, service, child );
543 static void serialise_service( serialise_context context, mlt_service service, xmlNode *node )
545 // Iterate over consumer/producer connections
546 while ( service != NULL )
548 mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
549 char *mlt_type = mlt_properties_get( properties, "mlt_type" );
551 // Tell about the producer
552 if ( strcmp( mlt_type, "producer" ) == 0 )
554 char *mlt_service = mlt_properties_get( properties, "mlt_service" );
555 if ( mlt_properties_get( properties, "xml" ) == NULL && ( mlt_service != NULL && !strcmp( mlt_service, "tractor" ) ) )
558 serialise_tractor( context, service, node );
560 serialise_tractor( context, service, node );
566 serialise_producer( context, service, node );
568 if ( mlt_properties_get( properties, "xml" ) != NULL )
572 // Tell about the framework container producers
573 else if ( strcmp( mlt_type, "mlt_producer" ) == 0 )
575 char *resource = mlt_properties_get( properties, "resource" );
577 // Recurse on multitrack's tracks
578 if ( strcmp( resource, "<multitrack>" ) == 0 )
580 serialise_multitrack( context, service, node );
584 // Recurse on playlist's clips
585 else if ( strcmp( resource, "<playlist>" ) == 0 )
587 serialise_playlist( context, service, node );
590 // Recurse on tractor's producer
591 else if ( strcmp( resource, "<tractor>" ) == 0 )
594 serialise_tractor( context, service, node );
596 serialise_tractor( context, service, node );
601 // Treat it as a normal producer
604 serialise_producer( context, service, node );
608 // Tell about a filter
609 else if ( strcmp( mlt_type, "filter" ) == 0 )
611 serialise_filter( context, service, node );
615 // Tell about a transition
616 else if ( strcmp( mlt_type, "transition" ) == 0 )
618 serialise_transition( context, service, node );
622 // Get the next connected service
623 service = mlt_service_producer( service );
627 xmlDocPtr xml_make_doc( mlt_consumer consumer, mlt_service service )
629 mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
630 xmlDocPtr doc = xmlNewDoc( _x("1.0") );
631 xmlNodePtr root = xmlNewNode( NULL, _x("mlt") );
632 struct serialise_context_s *context = calloc( 1, sizeof( struct serialise_context_s ) );
633 xmlNodePtr profile_node = xmlNewChild( root, NULL, _x("profile"), NULL );
634 mlt_profile profile = mlt_service_profile( service );
637 xmlDocSetRootElement( doc, root );
639 // If we have root, then deal with it now
640 if ( mlt_properties_get( properties, "root" ) != NULL )
642 xmlNewProp( root, _x("root"), _x(mlt_properties_get( properties, "root" )) );
643 context->root = strdup( mlt_properties_get( properties, "root" ) );
647 context->root = strdup( "" );
650 // Assign the additional 'storage' pattern for properties
651 context->store = mlt_properties_get( MLT_CONSUMER_PROPERTIES( consumer ), "store" );
653 // Assign a title property
654 if ( mlt_properties_get( properties, "title" ) != NULL )
655 xmlNewProp( root, _x("title"), _x(mlt_properties_get( properties, "title" )) );
656 mlt_properties_set_int( properties, "global_feed", 1 );
658 // Add a profile child element
659 xmlNewProp( profile_node, _x("description"), _x(profile->description) );
660 sprintf( tmpstr, "%d", profile->width );
661 xmlNewProp( profile_node, _x("width"), _x(tmpstr) );
662 sprintf( tmpstr, "%d", profile->height );
663 xmlNewProp( profile_node, _x("height"), _x(tmpstr) );
664 sprintf( tmpstr, "%d", profile->progressive );
665 xmlNewProp( profile_node, _x("progressive"), _x(tmpstr) );
666 sprintf( tmpstr, "%d", profile->sample_aspect_num );
667 xmlNewProp( profile_node, _x("sample_aspect_num"), _x(tmpstr) );
668 sprintf( tmpstr, "%d", profile->sample_aspect_den );
669 xmlNewProp( profile_node, _x("sample_aspect_den"), _x(tmpstr) );
670 sprintf( tmpstr, "%d", profile->display_aspect_num );
671 xmlNewProp( profile_node, _x("display_aspect_num"), _x(tmpstr) );
672 sprintf( tmpstr, "%d", profile->display_aspect_den );
673 xmlNewProp( profile_node, _x("display_aspect_den"), _x(tmpstr) );
674 sprintf( tmpstr, "%d", profile->frame_rate_num );
675 xmlNewProp( profile_node, _x("frame_rate_num"), _x(tmpstr) );
676 sprintf( tmpstr, "%d", profile->frame_rate_den );
677 xmlNewProp( profile_node, _x("frame_rate_den"), _x(tmpstr) );
678 sprintf( tmpstr, "%d", profile->colorspace );
679 xmlNewProp( profile_node, _x("colorspace"), _x(tmpstr) );
681 // Construct the context maps
682 context->id_map = mlt_properties_new();
683 context->hide_map = mlt_properties_new();
685 // Ensure producer is a framework producer
686 mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), "mlt_type", "mlt_producer" );
688 // In pass one, we serialise the end producers and playlists,
689 // adding them to a map keyed by address.
690 serialise_service( context, service, root );
692 // In pass two, we serialise the tractor and reference the
693 // producers and playlists
695 serialise_service( context, service, root );
698 mlt_properties_close( context->id_map );
699 mlt_properties_close( context->hide_map );
700 free( context->root );
706 static int consumer_start( mlt_consumer this )
708 xmlDocPtr doc = NULL;
710 // Get the producer service
711 mlt_service service = mlt_service_producer( MLT_CONSUMER_SERVICE( this ) );
712 if ( service != NULL )
714 mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
715 char *resource = mlt_properties_get( properties, "resource" );
717 // Set the title if provided
718 if ( mlt_properties_get( properties, "title" ) )
719 mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), "title", mlt_properties_get( properties, "title" ) );
720 else if ( mlt_properties_get( MLT_SERVICE_PROPERTIES( service ), "title" ) == NULL )
721 mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), "title", "Anonymous Submission" );
723 // Check for a root on the consumer properties and pass to service
724 if ( mlt_properties_get( properties, "root" ) )
725 mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), "root", mlt_properties_get( properties, "root" ) );
727 // Specify roots in other cases...
728 if ( resource != NULL && mlt_properties_get( properties, "root" ) == NULL )
730 // Get the current working directory
731 char *cwd = getcwd( NULL, 0 );
732 mlt_properties_set( MLT_SERVICE_PROPERTIES( service ), "root", cwd );
737 doc = xml_make_doc( this, service );
740 if ( resource == NULL || !strcmp( resource, "" ) )
742 xmlDocFormatDump( stdout, doc, 1 );
744 else if ( strchr( resource, '.' ) == NULL )
746 xmlChar *buffer = NULL;
748 xmlDocDumpMemoryEnc( doc, &buffer, &length, "utf-8" );
749 mlt_properties_set( properties, resource, _s(buffer) );
754 xmlSaveFormatFileEnc( resource, doc, "utf-8", 1 );
757 // Close the document
761 mlt_consumer_stop( this );
763 mlt_consumer_stopped( this );
768 static int consumer_is_stopped( mlt_consumer this )