2 * producer_westley.c -- a libxml2 parser of mlt service networks
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Dan Dennedy <dan@dennedy.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 // TODO: destroy unreferenced producers (they are currently destroyed
22 // when the returned producer is closed).
24 #include "producer_westley.h"
25 #include <framework/mlt.h>
32 #include <libxml/parser.h>
33 #include <libxml/parserInternals.h> // for xmlCreateFileParserCtxt
34 #include <libxml/tree.h>
36 #define STACK_SIZE 1000
37 #define BRANCH_SIG_LEN 4000
41 extern xmlDocPtr
westley_make_doc( mlt_service service
);
58 mlt_dummy_filter_type
,
59 mlt_dummy_transition_type
,
60 mlt_dummy_producer_type
,
63 struct deserialise_context_s
65 enum service_type stack_types
[ STACK_SIZE
];
66 mlt_service stack_service
[ STACK_SIZE
];
67 int stack_service_size
;
68 mlt_properties producer_map
;
69 mlt_properties destructors
;
73 xmlNodePtr stack_node
[ STACK_SIZE
];
76 int entity_is_replace
;
78 int branch
[ STACK_SIZE
];
79 const xmlChar
*publicId
;
80 const xmlChar
*systemId
;
81 mlt_properties params
;
83 typedef struct deserialise_context_s
*deserialise_context
;
85 /** Convert the numerical current branch address to a dot-delimited string.
87 static char *serialise_branch( deserialise_context
this, char *s
)
92 for ( i
= 0; i
< this->depth
; i
++ )
94 int len
= strlen( s
);
95 snprintf( s
+ len
, BRANCH_SIG_LEN
- len
, "%d.", this->branch
[ i
] );
103 static int context_push_service( deserialise_context
this, mlt_service that
, enum service_type type
)
105 int ret
= this->stack_service_size
>= STACK_SIZE
- 1;
108 this->stack_service
[ this->stack_service_size
] = that
;
109 this->stack_types
[ this->stack_service_size
++ ] = type
;
111 // Record the tree branch on which this service lives
112 if ( that
!= NULL
&& mlt_properties_get( MLT_SERVICE_PROPERTIES( that
), "_westley_branch" ) == NULL
)
114 char s
[ BRANCH_SIG_LEN
];
115 mlt_properties_set( MLT_SERVICE_PROPERTIES( that
), "_westley_branch", serialise_branch( this, s
) );
124 static mlt_service
context_pop_service( deserialise_context
this, enum service_type
*type
)
126 mlt_service result
= NULL
;
127 if ( this->stack_service_size
> 0 )
129 result
= this->stack_service
[ -- this->stack_service_size
];
131 *type
= this->stack_types
[ this->stack_service_size
];
139 static int context_push_node( deserialise_context
this, xmlNodePtr node
)
141 int ret
= this->stack_node_size
>= STACK_SIZE
- 1;
143 this->stack_node
[ this->stack_node_size
++ ] = node
;
150 static xmlNodePtr
context_pop_node( deserialise_context
this )
152 xmlNodePtr result
= NULL
;
153 if ( this->stack_node_size
> 0 )
154 result
= this->stack_node
[ -- this->stack_node_size
];
159 // Set the destructor on a new service
160 static void track_service( mlt_properties properties
, void *service
, mlt_destructor destructor
)
162 int registered
= mlt_properties_get_int( properties
, "registered" );
163 char *key
= mlt_properties_get( properties
, "registered" );
164 mlt_properties_set_data( properties
, key
, service
, 0, destructor
, NULL
);
165 mlt_properties_set_int( properties
, "registered", ++ registered
);
169 // Prepend the property value with the document root
170 static inline void qualify_property( deserialise_context context
, mlt_properties properties
, char *name
)
172 char *resource
= mlt_properties_get( properties
, name
);
173 if ( resource
!= NULL
)
175 // Qualify file name properties
176 char *root
= mlt_properties_get( context
->producer_map
, "root" );
177 if ( root
!= NULL
&& strcmp( root
, "" ) )
179 char *full_resource
= malloc( strlen( root
) + strlen( resource
) + 2 );
180 if ( resource
[ 0 ] != '/' && strchr( resource
, ':' ) == NULL
)
182 strcpy( full_resource
, root
);
183 strcat( full_resource
, "/" );
184 strcat( full_resource
, resource
);
188 strcpy( full_resource
, resource
);
190 mlt_properties_set( properties
, name
, full_resource
);
191 free( full_resource
);
197 /** This function adds a producer to a playlist or multitrack when
198 there is no entry or track element.
201 static int add_producer( deserialise_context context
, mlt_service service
, mlt_position in
, mlt_position out
)
203 // Return value (0 = service remains top of stack, 1 means it can be removed)
206 // Get the parent producer
207 enum service_type type
;
208 mlt_service container
= context_pop_service( context
, &type
);
211 if ( service
!= NULL
&& container
!= NULL
)
213 char *container_branch
= mlt_properties_get( MLT_SERVICE_PROPERTIES( container
), "_westley_branch" );
214 char *service_branch
= mlt_properties_get( MLT_SERVICE_PROPERTIES( service
), "_westley_branch" );
215 contained
= !strncmp( container_branch
, service_branch
, strlen( container_branch
) );
220 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
221 char *hide_s
= mlt_properties_get( properties
, "hide" );
223 // Indicate that this service is no longer top of stack
228 case mlt_tractor_type
:
230 mlt_multitrack multitrack
= mlt_tractor_multitrack( MLT_TRACTOR( container
) );
231 mlt_multitrack_connect( multitrack
, MLT_PRODUCER( service
), mlt_multitrack_count( multitrack
) );
234 case mlt_multitrack_type
:
236 mlt_multitrack_connect( MLT_MULTITRACK( container
),
237 MLT_PRODUCER( service
),
238 mlt_multitrack_count( MLT_MULTITRACK( container
) ) );
241 case mlt_playlist_type
:
243 mlt_playlist_append_io( MLT_PLAYLIST( container
), MLT_PRODUCER( service
), in
, out
);
248 fprintf( stderr
, "Producer defined inside something that isn't a container\n" );
252 // Set the hide state of the track producer
253 if ( hide_s
!= NULL
)
255 if ( strcmp( hide_s
, "video" ) == 0 )
256 mlt_properties_set_int( properties
, "hide", 1 );
257 else if ( strcmp( hide_s
, "audio" ) == 0 )
258 mlt_properties_set_int( properties
, "hide", 2 );
259 else if ( strcmp( hide_s
, "both" ) == 0 )
260 mlt_properties_set_int( properties
, "hide", 3 );
264 // Put the parent producer back
265 if ( container
!= NULL
)
266 context_push_service( context
, container
, type
);
271 /** Attach filters defined on that to this.
274 static void attach_filters( mlt_service
this, mlt_service that
)
279 mlt_filter filter
= NULL
;
280 for ( i
= 0; ( filter
= mlt_service_filter( that
, i
) ) != NULL
; i
++ )
282 mlt_service_attach( this, filter
);
283 attach_filters( MLT_FILTER_SERVICE( filter
), MLT_FILTER_SERVICE( filter
) );
288 static void on_start_tractor( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
290 mlt_tractor tractor
= mlt_tractor_new( );
291 mlt_service service
= MLT_TRACTOR_SERVICE( tractor
);
292 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
294 track_service( context
->destructors
, service
, (mlt_destructor
) mlt_tractor_close
);
296 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
297 mlt_properties_set( MLT_SERVICE_PROPERTIES( service
), (char*) atts
[0], atts
[1] == NULL ?
"" : (char*) atts
[1] );
299 mlt_properties_set_int( MLT_TRACTOR_PROPERTIES( tractor
), "global_feed", 1 );
301 if ( mlt_properties_get( properties
, "id" ) != NULL
)
302 mlt_properties_set_data( context
->producer_map
, mlt_properties_get( properties
, "id" ), service
, 0, NULL
, NULL
);
304 context_push_service( context
, service
, mlt_tractor_type
);
307 static void on_end_tractor( deserialise_context context
, const xmlChar
*name
)
310 enum service_type type
;
311 mlt_service tractor
= context_pop_service( context
, &type
);
313 if ( tractor
!= NULL
&& type
== mlt_tractor_type
)
315 // See if the tractor should be added to a playlist or multitrack
316 if ( add_producer( context
, tractor
, 0, mlt_producer_get_out( MLT_PRODUCER( tractor
) ) ) == 0 )
317 context_push_service( context
, tractor
, type
);
321 fprintf( stderr
, "Invalid state for tractor\n" );
325 static void on_start_multitrack( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
327 enum service_type type
;
328 mlt_service parent
= context_pop_service( context
, &type
);
330 // If we don't have a parent, then create one now, providing we're in a state where we can
331 if ( parent
== NULL
|| ( type
== mlt_playlist_type
|| type
== mlt_multitrack_type
) )
333 mlt_tractor tractor
= NULL
;
334 // Push the parent back
335 if ( parent
!= NULL
)
336 context_push_service( context
, parent
, type
);
338 // Create a tractor to contain the multitrack
339 tractor
= mlt_tractor_new( );
340 parent
= MLT_TRACTOR_SERVICE( tractor
);
341 track_service( context
->destructors
, parent
, (mlt_destructor
) mlt_tractor_close
);
342 type
= mlt_tractor_type
;
344 // Flag it as a synthesised tractor for clean up later
345 mlt_properties_set_int( MLT_SERVICE_PROPERTIES( parent
), "fezzik_synth", 1 );
348 if ( type
== mlt_tractor_type
)
350 mlt_service service
= MLT_SERVICE( mlt_tractor_multitrack( MLT_TRACTOR( parent
) ) );
351 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
352 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
353 mlt_properties_set( properties
, (char*) atts
[0], atts
[1] == NULL ?
"" : (char*) atts
[1] );
355 if ( mlt_properties_get( properties
, "id" ) != NULL
)
356 mlt_properties_set_data( context
->producer_map
, mlt_properties_get( properties
,"id" ), service
, 0, NULL
, NULL
);
358 context_push_service( context
, parent
, type
);
359 context_push_service( context
, service
, mlt_multitrack_type
);
363 fprintf( stderr
, "Invalid multitrack position\n" );
367 static void on_end_multitrack( deserialise_context context
, const xmlChar
*name
)
369 // Get the multitrack from the stack
370 enum service_type type
;
371 mlt_service service
= context_pop_service( context
, &type
);
373 if ( service
== NULL
|| type
!= mlt_multitrack_type
)
374 fprintf( stderr
, "End multitrack in the wrong state...\n" );
377 static void on_start_playlist( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
379 mlt_playlist playlist
= mlt_playlist_init( );
380 mlt_service service
= MLT_PLAYLIST_SERVICE( playlist
);
381 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
383 track_service( context
->destructors
, service
, (mlt_destructor
) mlt_playlist_close
);
385 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
387 mlt_properties_set( properties
, (char*) atts
[0], atts
[1] == NULL ?
"" : (char*) atts
[1] );
389 // Out will be overwritten later as we append, so we need to save it
390 if ( strcmp( atts
[ 0 ], "out" ) == 0 )
391 mlt_properties_set( properties
, "_westley.out", ( char* )atts
[ 1 ] );
394 if ( mlt_properties_get( properties
, "id" ) != NULL
)
395 mlt_properties_set_data( context
->producer_map
, mlt_properties_get( properties
, "id" ), service
, 0, NULL
, NULL
);
397 context_push_service( context
, service
, mlt_playlist_type
);
400 static void on_end_playlist( deserialise_context context
, const xmlChar
*name
)
402 // Get the playlist from the stack
403 enum service_type type
;
404 mlt_service service
= context_pop_service( context
, &type
);
406 if ( service
!= NULL
&& type
== mlt_playlist_type
)
408 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
409 mlt_position in
= mlt_properties_get_position( properties
, "in" );
410 mlt_position out
= mlt_properties_get_position( properties
, "out" );
412 // See if the playlist should be added to a playlist or multitrack
413 if ( add_producer( context
, service
, in
, out
) == 0 )
414 context_push_service( context
, service
, type
);
418 fprintf( stderr
, "Invalid state of playlist end\n" );
422 static void on_start_producer( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
424 // use a dummy service to hold properties to allow arbitrary nesting
425 mlt_service service
= calloc( 1, sizeof( struct mlt_service_s
) );
426 mlt_service_init( service
, NULL
);
428 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
430 context_push_service( context
, service
, mlt_dummy_producer_type
);
432 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
433 mlt_properties_set( properties
, (char*) atts
[0], atts
[1] == NULL ?
"" : (char*) atts
[1] );
436 static void on_end_producer( deserialise_context context
, const xmlChar
*name
)
438 enum service_type type
;
439 mlt_service service
= context_pop_service( context
, &type
);
440 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
442 if ( service
!= NULL
&& type
== mlt_dummy_producer_type
)
444 mlt_service producer
= NULL
;
446 qualify_property( context
, properties
, "resource" );
447 char *resource
= mlt_properties_get( properties
, "resource" );
449 // Let Kino-SMIL src be a synonym for resource
450 if ( resource
== NULL
)
452 qualify_property( context
, properties
, "src" );
453 resource
= mlt_properties_get( properties
, "src" );
456 // Instantiate the producer
457 if ( mlt_properties_get( properties
, "mlt_service" ) != NULL
)
460 strncpy( temp
, mlt_properties_get( properties
, "mlt_service" ), 1024 );
461 if ( resource
!= NULL
)
464 strncat( temp
, resource
, 1023 - strlen( temp
) );
466 producer
= MLT_SERVICE( mlt_factory_producer( "fezzik", temp
) );
469 // Just in case the plugin requested doesn't exist...
470 if ( producer
== NULL
&& resource
!= NULL
)
471 producer
= MLT_SERVICE( mlt_factory_producer( "fezzik", resource
) );
473 if ( producer
== NULL
)
474 producer
= MLT_SERVICE( mlt_factory_producer( "fezzik", "+INVALID.txt" ) );
476 if ( producer
== NULL
)
477 producer
= MLT_SERVICE( mlt_factory_producer( "fezzik", "colour:red" ) );
479 // Track this producer
480 track_service( context
->destructors
, producer
, (mlt_destructor
) mlt_producer_close
);
482 // Propogate the properties
483 qualify_property( context
, properties
, "resource" );
484 qualify_property( context
, properties
, "luma" );
485 qualify_property( context
, properties
, "luma.resource" );
486 qualify_property( context
, properties
, "composite.luma" );
487 qualify_property( context
, properties
, "producer.resource" );
489 // Handle in/out properties separately
490 mlt_position in
= -1;
491 mlt_position out
= -1;
494 if ( mlt_properties_get( properties
, "in" ) != NULL
)
495 in
= mlt_properties_get_position( properties
, "in" );
496 // Let Kino-SMIL clipBegin be a synonym for in
497 if ( mlt_properties_get( properties
, "clipBegin" ) != NULL
)
498 in
= mlt_properties_get_position( properties
, "clipBegin" );
500 if ( mlt_properties_get( properties
, "out" ) != NULL
)
501 out
= mlt_properties_get_position( properties
, "out" );
502 // Let Kino-SMIL clipEnd be a synonym for out
503 if ( mlt_properties_get( properties
, "clipEnd" ) != NULL
)
504 out
= mlt_properties_get_position( properties
, "clipEnd" );
507 mlt_properties_set( properties
, "in", NULL
);
508 mlt_properties_set( properties
, "out", NULL
);
510 // Inherit the properties
511 mlt_properties_inherit( MLT_SERVICE_PROPERTIES( producer
), properties
);
513 // Attach all filters from service onto producer
514 attach_filters( producer
, service
);
516 // Add the producer to the producer map
517 if ( mlt_properties_get( properties
, "id" ) != NULL
)
518 mlt_properties_set_data( context
->producer_map
, mlt_properties_get(properties
, "id"), producer
, 0, NULL
, NULL
);
520 // See if the producer should be added to a playlist or multitrack
521 if ( add_producer( context
, producer
, in
, out
) == 0 )
523 // Otherwise, set in and out on...
524 if ( in
!= -1 || out
!= -1 )
526 // Get the parent service
527 enum service_type type
;
528 mlt_service parent
= context_pop_service( context
, &type
);
529 if ( parent
!= NULL
)
531 // Get the parent properties
532 properties
= MLT_SERVICE_PROPERTIES( parent
);
534 char *resource
= mlt_properties_get( properties
, "resource" );
536 // Put the parent producer back
537 context_push_service( context
, parent
, type
);
539 // If the parent is a track or entry
540 if ( resource
&& ( strcmp( resource
, "<entry>" ) == 0 ) )
542 mlt_properties_set_position( properties
, "in", in
);
543 mlt_properties_set_position( properties
, "out", out
);
547 // Otherwise, set in and out on producer directly
548 mlt_producer_set_in_and_out( MLT_PRODUCER( producer
), in
, out
);
553 // Otherwise, set in and out on producer directly
554 mlt_producer_set_in_and_out( MLT_PRODUCER( producer
), in
, out
);
558 // Push the producer onto the stack
559 context_push_service( context
, producer
, mlt_producer_type
);
562 mlt_service_close( service
);
566 static void on_start_blank( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
568 // Get the playlist from the stack
569 enum service_type type
;
570 mlt_service service
= context_pop_service( context
, &type
);
571 mlt_position length
= 0;
573 if ( type
== mlt_playlist_type
&& service
!= NULL
)
575 // Look for the length attribute
576 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
578 if ( strcmp( atts
[0], "length" ) == 0 )
580 length
= atoll( atts
[1] );
585 // Append a blank to the playlist
586 mlt_playlist_blank( MLT_PLAYLIST( service
), length
- 1 );
588 // Push the playlist back onto the stack
589 context_push_service( context
, service
, type
);
593 fprintf( stderr
, "blank without a playlist - a definite no no\n" );
597 static void on_start_entry( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
599 mlt_producer entry
= NULL
;
600 mlt_properties temp
= mlt_properties_new( );
602 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
604 mlt_properties_set( temp
, (char*) atts
[0], atts
[1] == NULL ?
"" : (char*) atts
[1] );
606 // Look for the producer attribute
607 if ( strcmp( atts
[ 0 ], "producer" ) == 0 )
609 mlt_producer producer
= mlt_properties_get_data( context
->producer_map
, (char*) atts
[1], NULL
);
610 if ( producer
!= NULL
)
611 mlt_properties_set_data( temp
, "producer", producer
, 0, NULL
, NULL
);
615 // If we have a valid entry
616 if ( mlt_properties_get_data( temp
, "producer", NULL
) != NULL
)
618 mlt_playlist_clip_info info
;
619 enum service_type parent_type
;
620 mlt_service parent
= context_pop_service( context
, &parent_type
);
621 mlt_producer producer
= mlt_properties_get_data( temp
, "producer", NULL
);
623 if ( parent_type
== mlt_playlist_type
)
625 // Append the producer to the playlist
626 if ( mlt_properties_get( temp
, "in" ) != NULL
|| mlt_properties_get( temp
, "out" ) != NULL
)
628 mlt_playlist_append_io( MLT_PLAYLIST( parent
), producer
,
629 mlt_properties_get_position( temp
, "in" ),
630 mlt_properties_get_position( temp
, "out" ) );
634 mlt_playlist_append( MLT_PLAYLIST( parent
), producer
);
637 // Handle the repeat property
638 if ( mlt_properties_get_int( temp
, "repeat" ) > 0 )
640 mlt_playlist_repeat_clip( MLT_PLAYLIST( parent
),
641 mlt_playlist_count( MLT_PLAYLIST( parent
) ) - 1,
642 mlt_properties_get_int( temp
, "repeat" ) );
645 mlt_playlist_get_clip_info( MLT_PLAYLIST( parent
), &info
, mlt_playlist_count( MLT_PLAYLIST( parent
) ) - 1 );
650 fprintf( stderr
, "Entry not part of a playlist...\n" );
653 context_push_service( context
, parent
, parent_type
);
656 // Push the cut onto the stack
657 context_push_service( context
, MLT_PRODUCER_SERVICE( entry
), mlt_entry_type
);
659 mlt_properties_close( temp
);
662 static void on_end_entry( deserialise_context context
, const xmlChar
*name
)
664 // Get the entry from the stack
665 enum service_type entry_type
;
666 mlt_service entry
= context_pop_service( context
, &entry_type
);
668 if ( entry
== NULL
&& entry_type
!= mlt_entry_type
)
670 fprintf( stderr
, "Invalid state at end of entry\n" );
674 static void on_start_track( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
676 // use a dummy service to hold properties to allow arbitrary nesting
677 mlt_service service
= calloc( 1, sizeof( struct mlt_service_s
) );
678 mlt_service_init( service
, NULL
);
680 // Push the dummy service onto the stack
681 context_push_service( context
, service
, mlt_entry_type
);
683 mlt_properties_set( MLT_SERVICE_PROPERTIES( service
), "resource", "<track>" );
685 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
687 mlt_properties_set( MLT_SERVICE_PROPERTIES( service
), (char*) atts
[0], atts
[1] == NULL ?
"" : (char*) atts
[1] );
689 // Look for the producer attribute
690 if ( strcmp( atts
[ 0 ], "producer" ) == 0 )
692 mlt_producer producer
= mlt_properties_get_data( context
->producer_map
, (char*) atts
[1], NULL
);
693 if ( producer
!= NULL
)
694 mlt_properties_set_data( MLT_SERVICE_PROPERTIES( service
), "producer", producer
, 0, NULL
, NULL
);
699 static void on_end_track( deserialise_context context
, const xmlChar
*name
)
701 // Get the track from the stack
702 enum service_type track_type
;
703 mlt_service track
= context_pop_service( context
, &track_type
);
705 if ( track
!= NULL
&& track_type
== mlt_entry_type
)
707 mlt_properties track_props
= MLT_SERVICE_PROPERTIES( track
);
708 enum service_type parent_type
;
709 mlt_service parent
= context_pop_service( context
, &parent_type
);
710 mlt_multitrack multitrack
= NULL
;
712 mlt_producer producer
= mlt_properties_get_data( track_props
, "producer", NULL
);
713 mlt_properties producer_props
= MLT_PRODUCER_PROPERTIES( producer
);
715 if ( parent_type
== mlt_tractor_type
)
716 multitrack
= mlt_tractor_multitrack( MLT_TRACTOR( parent
) );
717 else if ( parent_type
== mlt_multitrack_type
)
718 multitrack
= MLT_MULTITRACK( parent
);
720 fprintf( stderr
, "track contained in an invalid container\n" );
722 if ( multitrack
!= NULL
)
724 // Set producer i/o if specified
725 if ( mlt_properties_get( track_props
, "in" ) != NULL
||
726 mlt_properties_get( track_props
, "out" ) != NULL
)
728 mlt_producer cut
= mlt_producer_cut( MLT_PRODUCER( producer
),
729 mlt_properties_get_position( track_props
, "in" ),
730 mlt_properties_get_position( track_props
, "out" ) );
731 mlt_multitrack_connect( multitrack
, cut
, mlt_multitrack_count( multitrack
) );
732 mlt_properties_inherit( MLT_PRODUCER_PROPERTIES( cut
), track_props
);
733 track_props
= MLT_PRODUCER_PROPERTIES( cut
);
734 mlt_producer_close( cut
);
738 mlt_multitrack_connect( multitrack
, producer
, mlt_multitrack_count( multitrack
) );
741 // Set the hide state of the track producer
742 char *hide_s
= mlt_properties_get( track_props
, "hide" );
743 if ( hide_s
!= NULL
)
745 if ( strcmp( hide_s
, "video" ) == 0 )
746 mlt_properties_set_int( producer_props
, "hide", 1 );
747 else if ( strcmp( hide_s
, "audio" ) == 0 )
748 mlt_properties_set_int( producer_props
, "hide", 2 );
749 else if ( strcmp( hide_s
, "both" ) == 0 )
750 mlt_properties_set_int( producer_props
, "hide", 3 );
754 if ( parent
!= NULL
)
755 context_push_service( context
, parent
, parent_type
);
757 mlt_service_close( track
);
761 fprintf( stderr
, "Invalid state at end of track\n" );
765 static void on_start_filter( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
767 // use a dummy service to hold properties to allow arbitrary nesting
768 mlt_service service
= calloc( 1, sizeof( struct mlt_service_s
) );
769 mlt_service_init( service
, NULL
);
771 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
773 context_push_service( context
, service
, mlt_dummy_filter_type
);
775 // Set the properties
776 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
777 mlt_properties_set( properties
, (char*) atts
[0], (char*) atts
[1] );
780 static void on_end_filter( deserialise_context context
, const xmlChar
*name
)
782 enum service_type type
;
783 mlt_service service
= context_pop_service( context
, &type
);
784 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
786 enum service_type parent_type
;
787 mlt_service parent
= context_pop_service( context
, &parent_type
);
789 if ( service
!= NULL
&& type
== mlt_dummy_filter_type
)
791 mlt_service filter
= MLT_SERVICE( mlt_factory_filter( mlt_properties_get( properties
, "mlt_service" ), NULL
) );
792 mlt_properties filter_props
= MLT_SERVICE_PROPERTIES( filter
);
794 track_service( context
->destructors
, filter
, (mlt_destructor
) mlt_filter_close
);
796 // Propogate the properties
797 qualify_property( context
, properties
, "resource" );
798 qualify_property( context
, properties
, "luma" );
799 qualify_property( context
, properties
, "luma.resource" );
800 qualify_property( context
, properties
, "composite.luma" );
801 qualify_property( context
, properties
, "producer.resource" );
802 mlt_properties_inherit( filter_props
, properties
);
804 // Attach all filters from service onto filter
805 attach_filters( filter
, service
);
807 // Associate the filter with the parent
808 if ( parent
!= NULL
)
810 if ( parent_type
== mlt_tractor_type
)
812 mlt_field field
= mlt_tractor_field( MLT_TRACTOR( parent
) );
813 mlt_field_plant_filter( field
, MLT_FILTER( filter
), mlt_properties_get_int( properties
, "track" ) );
814 mlt_filter_set_in_and_out( MLT_FILTER( filter
),
815 mlt_properties_get_int( properties
, "in" ),
816 mlt_properties_get_int( properties
, "out" ) );
820 mlt_service_attach( parent
, MLT_FILTER( filter
) );
823 // Put the parent back on the stack
824 context_push_service( context
, parent
, parent_type
);
828 fprintf( stderr
, "filter closed with invalid parent...\n" );
831 // Close the dummy filter service
832 mlt_service_close( service
);
836 fprintf( stderr
, "Invalid top of stack on filter close\n" );
840 static void on_start_transition( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
842 // use a dummy service to hold properties to allow arbitrary nesting
843 mlt_service service
= calloc( 1, sizeof( struct mlt_service_s
) );
844 mlt_service_init( service
, NULL
);
846 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
848 context_push_service( context
, service
, mlt_dummy_transition_type
);
850 // Set the properties
851 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
852 mlt_properties_set( properties
, (char*) atts
[0], (char*) atts
[1] );
855 static void on_end_transition( deserialise_context context
, const xmlChar
*name
)
857 enum service_type type
;
858 mlt_service service
= context_pop_service( context
, &type
);
859 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
861 enum service_type parent_type
;
862 mlt_service parent
= context_pop_service( context
, &parent_type
);
864 if ( service
!= NULL
&& type
== mlt_dummy_transition_type
)
866 mlt_service effect
= MLT_SERVICE( mlt_factory_transition(mlt_properties_get(properties
,"mlt_service"), NULL
) );
867 mlt_properties effect_props
= MLT_SERVICE_PROPERTIES( effect
);
869 track_service( context
->destructors
, effect
, (mlt_destructor
) mlt_transition_close
);
871 // Propogate the properties
872 qualify_property( context
, properties
, "resource" );
873 qualify_property( context
, properties
, "luma" );
874 qualify_property( context
, properties
, "luma.resource" );
875 qualify_property( context
, properties
, "composite.luma" );
876 qualify_property( context
, properties
, "producer.resource" );
877 mlt_properties_inherit( effect_props
, properties
);
879 // Attach all filters from service onto effect
880 attach_filters( effect
, service
);
882 // Associate the filter with the parent
883 if ( parent
!= NULL
)
885 if ( parent_type
== mlt_tractor_type
)
887 mlt_field field
= mlt_tractor_field( MLT_TRACTOR( parent
) );
888 if ( mlt_properties_get_int( properties
, "a_track" ) == mlt_properties_get_int( properties
, "b_track" ) )
889 mlt_properties_set_int( properties
, "b_track", mlt_properties_get_int( properties
, "a_track" ) + 1 );
890 mlt_field_plant_transition( field
, MLT_TRANSITION( effect
),
891 mlt_properties_get_int( properties
, "a_track" ),
892 mlt_properties_get_int( properties
, "b_track" ) );
893 mlt_transition_set_in_and_out( MLT_TRANSITION( effect
),
894 mlt_properties_get_int( properties
, "in" ),
895 mlt_properties_get_int( properties
, "out" ) );
899 fprintf( stderr
, "Misplaced transition - ignoring\n" );
902 // Put the parent back on the stack
903 context_push_service( context
, parent
, parent_type
);
907 fprintf( stderr
, "transition closed with invalid parent...\n" );
910 // Close the dummy filter service
911 mlt_service_close( service
);
915 fprintf( stderr
, "Invalid top of stack on transition close\n" );
919 static void on_start_property( deserialise_context context
, const xmlChar
*name
, const xmlChar
**atts
)
921 enum service_type type
;
922 mlt_service service
= context_pop_service( context
, &type
);
923 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
926 if ( service
!= NULL
)
928 // Set the properties
929 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
931 if ( strcmp( atts
[ 0 ], "name" ) == 0 )
932 context
->property
= strdup( atts
[ 1 ] );
933 else if ( strcmp( atts
[ 0 ], "value" ) == 0 )
934 value
= (char*) atts
[ 1 ];
937 if ( context
->property
!= NULL
)
938 mlt_properties_set( properties
, context
->property
, value
== NULL ?
"" : value
);
940 // Tell parser to collect any further nodes for serialisation
941 context
->is_value
= 1;
943 context_push_service( context
, service
, type
);
947 fprintf( stderr
, "Property without a service '%s'?\n", ( char * )name
);
951 static void on_end_property( deserialise_context context
, const xmlChar
*name
)
953 enum service_type type
;
954 mlt_service service
= context_pop_service( context
, &type
);
955 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
957 if ( service
!= NULL
)
959 // Tell parser to stop building a tree
960 context
->is_value
= 0;
962 // See if there is a xml tree for the value
963 if ( context
->property
!= NULL
&& context
->value_doc
!= NULL
)
968 // Serialise the tree to get value
969 xmlDocDumpMemory( context
->value_doc
, &value
, &size
);
970 mlt_properties_set( properties
, context
->property
, value
);
972 xmlFreeDoc( context
->value_doc
);
973 context
->value_doc
= NULL
;
976 // Close this property handling
977 free( context
->property
);
978 context
->property
= NULL
;
980 context_push_service( context
, service
, type
);
984 fprintf( stderr
, "Property without a service '%s'??\n", (char *)name
);
988 static void on_start_element( void *ctx
, const xmlChar
*name
, const xmlChar
**atts
)
990 struct _xmlParserCtxt
*xmlcontext
= ( struct _xmlParserCtxt
* )ctx
;
991 deserialise_context context
= ( deserialise_context
)( xmlcontext
->_private
);
993 //printf("on_start_element: %s\n", name );
994 context
->branch
[ context
->depth
] ++;
997 // Build a tree from nodes within a property value
998 if ( context
->is_value
== 1 )
1000 xmlNodePtr node
= xmlNewNode( NULL
, name
);
1002 if ( context
->value_doc
== NULL
)
1005 context
->value_doc
= xmlNewDoc( "1.0" );
1006 xmlDocSetRootElement( context
->value_doc
, node
);
1010 // Append child to tree
1011 xmlAddChild( context
->stack_node
[ context
->stack_node_size
- 1 ], node
);
1013 context_push_node( context
, node
);
1015 // Set the attributes
1016 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
1017 xmlSetProp( node
, atts
[ 0 ], atts
[ 1 ] );
1019 else if ( strcmp( name
, "tractor" ) == 0 )
1020 on_start_tractor( context
, name
, atts
);
1021 else if ( strcmp( name
, "multitrack" ) == 0 )
1022 on_start_multitrack( context
, name
, atts
);
1023 else if ( strcmp( name
, "playlist" ) == 0 || strcmp( name
, "seq" ) == 0 || strcmp( name
, "smil" ) == 0 )
1024 on_start_playlist( context
, name
, atts
);
1025 else if ( strcmp( name
, "producer" ) == 0 || strcmp( name
, "video" ) == 0 )
1026 on_start_producer( context
, name
, atts
);
1027 else if ( strcmp( name
, "blank" ) == 0 )
1028 on_start_blank( context
, name
, atts
);
1029 else if ( strcmp( name
, "entry" ) == 0 )
1030 on_start_entry( context
, name
, atts
);
1031 else if ( strcmp( name
, "track" ) == 0 )
1032 on_start_track( context
, name
, atts
);
1033 else if ( strcmp( name
, "filter" ) == 0 )
1034 on_start_filter( context
, name
, atts
);
1035 else if ( strcmp( name
, "transition" ) == 0 )
1036 on_start_transition( context
, name
, atts
);
1037 else if ( strcmp( name
, "property" ) == 0 )
1038 on_start_property( context
, name
, atts
);
1039 else if ( strcmp( name
, "westley" ) == 0 )
1040 for ( ; atts
!= NULL
&& *atts
!= NULL
; atts
+= 2 )
1041 mlt_properties_set( context
->producer_map
, ( char * )atts
[ 0 ], ( char * )atts
[ 1 ] );
1044 static void on_end_element( void *ctx
, const xmlChar
*name
)
1046 struct _xmlParserCtxt
*xmlcontext
= ( struct _xmlParserCtxt
* )ctx
;
1047 deserialise_context context
= ( deserialise_context
)( xmlcontext
->_private
);
1049 //printf("on_end_element: %s\n", name );
1050 if ( context
->is_value
== 1 && strcmp( name
, "property" ) != 0 )
1051 context_pop_node( context
);
1052 else if ( strcmp( name
, "multitrack" ) == 0 )
1053 on_end_multitrack( context
, name
);
1054 else if ( strcmp( name
, "playlist" ) == 0 || strcmp( name
, "seq" ) == 0 || strcmp( name
, "smil" ) == 0 )
1055 on_end_playlist( context
, name
);
1056 else if ( strcmp( name
, "track" ) == 0 )
1057 on_end_track( context
, name
);
1058 else if ( strcmp( name
, "entry" ) == 0 )
1059 on_end_entry( context
, name
);
1060 else if ( strcmp( name
, "tractor" ) == 0 )
1061 on_end_tractor( context
, name
);
1062 else if ( strcmp( name
, "property" ) == 0 )
1063 on_end_property( context
, name
);
1064 else if ( strcmp( name
, "producer" ) == 0 || strcmp( name
, "video" ) == 0 )
1065 on_end_producer( context
, name
);
1066 else if ( strcmp( name
, "filter" ) == 0 )
1067 on_end_filter( context
, name
);
1068 else if ( strcmp( name
, "transition" ) == 0 )
1069 on_end_transition( context
, name
);
1071 context
->branch
[ context
->depth
] = 0;
1075 static void on_characters( void *ctx
, const xmlChar
*ch
, int len
)
1077 struct _xmlParserCtxt
*xmlcontext
= ( struct _xmlParserCtxt
* )ctx
;
1078 deserialise_context context
= ( deserialise_context
)( xmlcontext
->_private
);
1079 char *value
= calloc( len
+ 1, 1 );
1080 enum service_type type
;
1081 mlt_service service
= context_pop_service( context
, &type
);
1082 mlt_properties properties
= MLT_SERVICE_PROPERTIES( service
);
1084 if ( service
!= NULL
)
1085 context_push_service( context
, service
, type
);
1088 strncpy( value
, (const char*) ch
, len
);
1090 if ( context
->stack_node_size
> 0 )
1091 xmlNodeAddContent( context
->stack_node
[ context
->stack_node_size
- 1 ], ( xmlChar
* )value
);
1093 // libxml2 generates an on_characters immediately after a get_entity within
1094 // an element value, and we ignore it because it is called again during
1095 // actual substitution.
1096 else if ( context
->property
!= NULL
&& context
->entity_is_replace
== 0 )
1098 char *s
= mlt_properties_get( properties
, context
->property
);
1101 // Append new text to existing content
1102 char *new = calloc( strlen( s
) + len
+ 1, 1 );
1104 strcat( new, value
);
1105 mlt_properties_set( properties
, context
->property
, new );
1109 mlt_properties_set( properties
, context
->property
, value
);
1111 context
->entity_is_replace
= 0;
1116 /** Convert parameters parsed from resource into entity declarations.
1118 static void params_to_entities( deserialise_context context
)
1120 if ( context
->params
!= NULL
)
1124 // Add our params as entitiy declarations
1125 for ( i
= 0; i
< mlt_properties_count( context
->params
); i
++ )
1127 xmlChar
*name
= ( xmlChar
* )mlt_properties_get_name( context
->params
, i
);
1128 xmlAddDocEntity( context
->entity_doc
, name
, XML_INTERNAL_GENERAL_ENTITY
,
1129 context
->publicId
, context
->systemId
, ( xmlChar
* )mlt_properties_get( context
->params
, name
) );
1133 mlt_properties_close( context
->params
);
1134 context
->params
= NULL
;
1138 // The following 3 facilitate entity substitution in the SAX parser
1139 static void on_internal_subset( void *ctx
, const xmlChar
* name
,
1140 const xmlChar
* publicId
, const xmlChar
* systemId
)
1142 struct _xmlParserCtxt
*xmlcontext
= ( struct _xmlParserCtxt
* )ctx
;
1143 deserialise_context context
= ( deserialise_context
)( xmlcontext
->_private
);
1145 context
->publicId
= publicId
;
1146 context
->systemId
= systemId
;
1147 xmlCreateIntSubset( context
->entity_doc
, name
, publicId
, systemId
);
1149 // Override default entities with our parameters
1150 params_to_entities( context
);
1153 // TODO: Check this with Dan... I think this is for westley parameterisation
1154 // but it's breaking standard escaped entities (like < etc).
1155 static void on_entity_declaration( void *ctx
, const xmlChar
* name
, int type
,
1156 const xmlChar
* publicId
, const xmlChar
* systemId
, xmlChar
* content
)
1158 struct _xmlParserCtxt
*xmlcontext
= ( struct _xmlParserCtxt
* )ctx
;
1159 deserialise_context context
= ( deserialise_context
)( xmlcontext
->_private
);
1161 xmlAddDocEntity( context
->entity_doc
, name
, type
, publicId
, systemId
, content
);
1164 // TODO: Check this functionality (see on_entity_declaration)
1165 static xmlEntityPtr
on_get_entity( void *ctx
, const xmlChar
* name
)
1167 struct _xmlParserCtxt
*xmlcontext
= ( struct _xmlParserCtxt
* )ctx
;
1168 deserialise_context context
= ( deserialise_context
)( xmlcontext
->_private
);
1169 xmlEntityPtr e
= NULL
;
1171 // Setup for entity declarations if not ready
1172 if ( xmlGetIntSubset( context
->entity_doc
) == NULL
)
1174 xmlCreateIntSubset( context
->entity_doc
, "westley", "", "" );
1175 context
->publicId
= "";
1176 context
->systemId
= "";
1179 // Add our parameters if not already
1180 params_to_entities( context
);
1182 e
= xmlGetPredefinedEntity( name
);
1184 // Send signal to on_characters that an entity substitutin is pending
1187 e
= xmlGetDocEntity( context
->entity_doc
, name
);
1189 context
->entity_is_replace
= 1;
1195 /** Convert a hexadecimal character to its value.
1197 static int tohex( char p
)
1199 return isdigit( p
) ? p
- '0' : tolower( p
) - 'a' + 10;
1202 /** Decode a url-encoded string containing hexadecimal character sequences.
1204 static char *url_decode( char *dest
, char *src
)
1212 *p
++ = ( tohex( *( src
+ 1 ) ) << 4 ) | tohex( *( src
+ 2 ) );
1225 /** Extract the filename from a URL attaching parameters to a properties list.
1227 static void parse_url( mlt_properties properties
, char *url
)
1230 int n
= strlen( url
);
1234 for ( i
= 0; i
< n
; i
++ )
1251 if ( name
!= NULL
&& value
!= NULL
)
1252 mlt_properties_set( properties
, name
, value
);
1258 if ( name
!= NULL
&& value
!= NULL
)
1259 mlt_properties_set( properties
, name
, value
);
1262 // Quick workaround to avoid unecessary libxml2 warnings
1263 static int file_exists( char *file
)
1265 char *name
= strdup( file
);
1267 if ( name
!= NULL
&& strchr( name
, '?' ) )
1268 *( strchr( name
, '?' ) ) = '\0';
1271 FILE *f
= fopen( name
, "r" );
1273 if ( exists
) fclose( f
);
1279 mlt_producer
producer_westley_init( int info
, char *data
)
1281 xmlSAXHandler
*sax
= calloc( 1, sizeof( xmlSAXHandler
) );
1282 struct deserialise_context_s
*context
= calloc( 1, sizeof( struct deserialise_context_s
) );
1283 mlt_properties properties
= NULL
;
1285 struct _xmlParserCtxt
*xmlcontext
;
1286 int well_formed
= 0;
1287 char *filename
= NULL
;
1289 if ( data
== NULL
|| !strcmp( data
, "" ) || ( info
== 0 && !file_exists( data
) ) )
1292 context
= calloc( 1, sizeof( struct deserialise_context_s
) );
1293 if ( context
== NULL
)
1296 context
->producer_map
= mlt_properties_new();
1297 context
->destructors
= mlt_properties_new();
1298 context
->params
= mlt_properties_new();
1300 // Decode URL and parse parameters
1301 mlt_properties_set( context
->producer_map
, "root", "" );
1304 filename
= strdup( data
);
1305 parse_url( context
->params
, url_decode( filename
, data
) );
1307 // We need the directory prefix which was used for the westley
1308 if ( strchr( filename
, '/' ) )
1311 mlt_properties_set( context
->producer_map
, "root", filename
);
1312 root
= mlt_properties_get( context
->producer_map
, "root" );
1313 *( strrchr( root
, '/' ) ) = '\0';
1315 // If we don't have an absolute path here, we're heading for disaster...
1316 if ( root
[ 0 ] != '/' )
1318 char *cwd
= getcwd( NULL
, 0 );
1319 char *real
= malloc( strlen( cwd
) + strlen( root
) + 2 );
1320 sprintf( real
, "%s/%s", cwd
, root
);
1321 mlt_properties_set( context
->producer_map
, "root", real
);
1328 // We need to track the number of registered filters
1329 mlt_properties_set_int( context
->destructors
, "registered", 0 );
1331 // Setup SAX callbacks
1332 sax
->startElement
= on_start_element
;
1333 sax
->endElement
= on_end_element
;
1334 sax
->characters
= on_characters
;
1335 sax
->cdataBlock
= on_characters
;
1336 sax
->internalSubset
= on_internal_subset
;
1337 sax
->entityDecl
= on_entity_declaration
;
1338 sax
->getEntity
= on_get_entity
;
1340 // Setup libxml2 SAX parsing
1342 xmlSubstituteEntitiesDefault( 1 );
1343 // This is used to facilitate entity substitution in the SAX parser
1344 context
->entity_doc
= xmlNewDoc( "1.0" );
1346 xmlcontext
= xmlCreateFileParserCtxt( filename
);
1348 xmlcontext
= xmlCreateMemoryParserCtxt( data
, strlen( data
) );
1350 // Invalid context - clean up and return NULL
1351 if ( xmlcontext
== NULL
)
1353 mlt_properties_close( context
->producer_map
);
1354 mlt_properties_close( context
->destructors
);
1355 mlt_properties_close( context
->params
);
1362 xmlcontext
->sax
= sax
;
1363 xmlcontext
->_private
= ( void* )context
;
1366 xmlParseDocument( xmlcontext
);
1367 well_formed
= xmlcontext
->wellFormed
;
1369 // Cleanup after parsing
1370 xmlFreeDoc( context
->entity_doc
);
1372 xmlcontext
->sax
= NULL
;
1373 xmlcontext
->_private
= NULL
;
1374 xmlFreeParserCtxt( xmlcontext
);
1375 xmlMemoryDump( ); // for debugging
1377 // Get the last producer on the stack
1378 enum service_type type
;
1379 mlt_service service
= context_pop_service( context
, &type
);
1380 if ( well_formed
&& service
!= NULL
)
1382 // Verify it is a producer service (mlt_type="mlt_producer")
1383 // (producer, playlist, multitrack)
1384 char *type
= mlt_properties_get( MLT_SERVICE_PROPERTIES( service
), "mlt_type" );
1385 if ( type
== NULL
|| ( strcmp( type
, "mlt_producer" ) != 0 && strcmp( type
, "producer" ) != 0 ) )
1390 xmlDocPtr doc
= westley_make_doc( service
);
1391 xmlDocFormatDump( stdout
, doc
, 1 );
1396 if ( well_formed
&& service
!= NULL
)
1398 char *title
= mlt_properties_get( context
->producer_map
, "title" );
1400 // Need the complete producer list for various reasons
1401 properties
= context
->destructors
;
1403 // Now make sure we don't have a reference to the service in the properties
1404 for ( i
= mlt_properties_count( properties
) - 1; i
>= 1; i
-- )
1406 char *name
= mlt_properties_get_name( properties
, i
);
1407 if ( mlt_properties_get_data( properties
, name
, NULL
) == service
)
1409 mlt_properties_set_data( properties
, name
, service
, 0, NULL
, NULL
);
1414 // We are done referencing destructor property list
1415 // Set this var to service properties for convenience
1416 properties
= MLT_SERVICE_PROPERTIES( service
);
1419 mlt_properties_set( properties
, "title", title
);
1421 // Optimise for overlapping producers
1422 mlt_producer_optimise( MLT_PRODUCER( service
) );
1424 // Handle deep copies
1425 if ( getenv( "MLT_WESTLEY_DEEP" ) == NULL
)
1427 // Now assign additional properties
1429 mlt_properties_set( properties
, "resource", data
);
1431 // This tells consumer_westley not to deep copy
1432 mlt_properties_set( properties
, "westley", "was here" );
1436 // Allow the project to be edited
1437 mlt_properties_set( properties
, "_westley", "was here" );
1438 mlt_properties_set_int( properties
, "_mlt_service_hidden", 1 );
1443 // Return null if not well formed
1448 mlt_properties_close( context
->producer_map
);
1449 if ( context
->params
!= NULL
)
1450 mlt_properties_close( context
->params
);
1451 mlt_properties_close( context
->destructors
);
1455 return MLT_PRODUCER( service
);