xmlNewProp( track, _x("in"), _x( mlt_properties_get_time( properties, "in", context->time_format ) ) );
xmlNewProp( track, _x("out"), _x( mlt_properties_get_time( properties, "out", context->time_format ) ) );
serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( producer ), track, context->store );
+ serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( producer ), track, "xml_" );
if ( !context->no_meta )
serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( producer ), track, "meta." );
serialise_service_filters( context, MLT_PRODUCER_SERVICE( producer ), track );
// Store application specific properties
serialise_store_properties( context, properties, child, context->store );
+ serialise_store_properties( context, properties, child, "xml_" );
if ( !context->no_meta )
serialise_store_properties( context, properties, child, "meta." );
if ( mlt_producer_is_cut( info.cut ) )
{
serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( info.cut ), entry, context->store );
+ serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( info.cut ), entry, "xml_" );
if ( !context->no_meta )
serialise_store_properties( context, MLT_PRODUCER_PROPERTIES( info.cut ), entry, "meta." );
serialise_service_filters( context, MLT_PRODUCER_SERVICE( info.cut ), entry );
// Store application specific properties
serialise_store_properties( context, MLT_SERVICE_PROPERTIES( service ), child, context->store );
+ serialise_store_properties( context, MLT_SERVICE_PROPERTIES( service ), child, "xml_" );
if ( !context->no_meta )
serialise_store_properties( context, MLT_SERVICE_PROPERTIES( service ), child, "meta." );
}
}
+static void serialise_other( mlt_properties properties, struct serialise_context_s *context, xmlNodePtr root )
+{
+ int i;
+ mlt_properties_debug( properties, __FUNCTION__, stderr );
+ for ( i = 0; i < mlt_properties_count( properties ); i++ )
+ {
+ const char* name = mlt_properties_get_name( properties, i );
+ if ( strlen(name) > 10 && !strncmp( name, "xml_retain", 10 ) )
+ {
+ mlt_service service = mlt_properties_get_data_at( properties, i, NULL );
+ if ( service )
+ {
+ mlt_properties_set_int( MLT_SERVICE_PROPERTIES( service ), "xml_retain", 1 );
+ serialise_service( context, service, root );
+ }
+ }
+ }
+}
+
xmlDocPtr xml_make_doc( mlt_consumer consumer, mlt_service service )
{
mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
// In pass one, we serialise the end producers and playlists,
// adding them to a map keyed by address.
+ serialise_other( MLT_SERVICE_PROPERTIES( service ), context, root );
serialise_service( context, service, root );
// In pass two, we serialise the tractor and reference the
// producers and playlists
context->pass++;
+ serialise_other( MLT_SERVICE_PROPERTIES( service ), context, root );
serialise_service( context, service, root );
// Cleanup resource
description: >
Serialise the service network to XML.
See docs/mlt-xml.txt for more information.
+
+notes: >
+ If you set a data property beginning with (and longer than) "xml_retain" on
+ the service connected to this consumer where the data is a mlt_service
+ pointer, then the pointed at service will also be serialized before the
+ connected service. This can be useful, for example, to save a playlist as
+ a media bin along with a multitrack. You can serialize more than one of these
+ additional services by setting more than property, each with a unique key
+ beginning with "xml_retain".
+
bugs:
- Untested arbitrary nesting of multitracks and playlists.
- >
Property "id" is generated as service type followed by number if no
property named "id" exists, but it fails to guarantee uniqueness.
+
parameters:
- identifier: resource
argument: yes
return exists;
}
+// This function will add remaing services in the context service stack marked
+// with a "xml_retain" property to a property named "xml_retain" on the returned
+// service. The property is a mlt_properties data property.
+
+static void retain_services( struct deserialise_context_s *context, mlt_service service )
+{
+ mlt_properties retain_list = mlt_properties_new();
+ enum service_type type;
+ mlt_service retain_service = context_pop_service( context, &type );
+
+ while ( retain_service )
+ {
+ mlt_properties retain_properties = MLT_SERVICE_PROPERTIES( retain_service );
+
+ if ( mlt_properties_get_int( retain_properties, "xml_retain" ) )
+ {
+ // Remove the retained service from the destructors list.
+ int i;
+ for ( i = mlt_properties_count( context->destructors ) - 1; i >= 1; i -- )
+ {
+ const char *name = mlt_properties_get_name( context->destructors, i );
+ if ( mlt_properties_get_data_at( context->destructors, i, NULL ) == retain_service )
+ {
+ mlt_properties_set_data( context->destructors, name, retain_service, 0, NULL, NULL );
+ break;
+ }
+ }
+ const char *name = mlt_properties_get( retain_properties, "id" );
+ if ( name )
+ mlt_properties_set_data( retain_list, name, retain_service, 0,
+ (mlt_destructor) mlt_service_close, NULL );
+ }
+ retain_service = context_pop_service( context, &type );
+ }
+ if ( mlt_properties_count( retain_list ) > 0 )
+ {
+ mlt_properties_set_data( MLT_SERVICE_PROPERTIES(service), "xml_retain", retain_list, 0,
+ (mlt_destructor) mlt_properties_close, NULL );
+ }
+}
+
mlt_producer producer_xml_init( mlt_profile profile, mlt_service_type servtype, const char *id, char *data )
{
xmlSAXHandler *sax, *sax_orig;
(mlt_destructor) mlt_consumer_close, NULL );
mlt_properties_set_int( properties, "seekable", context->seekable );
+
+ retain_services( context, service );
}
else
{