X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmodules%2Fxml%2Fconsumer_xml.c;h=92988f142f61f28fc17f747d0b240c989e0b3f45;hb=236717e4ecc23e458e191b6c9a2ba70915b80937;hp=8ed27204d293cb5a4d25c5958b4bbab0788e93f8;hpb=93405b38f839546b1c661ca1ee12814e0f6214a8;p=mlt diff --git a/src/modules/xml/consumer_xml.c b/src/modules/xml/consumer_xml.c index 8ed27204..92988f14 100644 --- a/src/modules/xml/consumer_xml.c +++ b/src/modules/xml/consumer_xml.c @@ -186,7 +186,7 @@ static char *xml_get_id( serialise_context context, mlt_service service, xml_typ mlt_consumer consumer_xml_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg ) { // Create the consumer object - mlt_consumer this = calloc( sizeof( struct mlt_consumer_s ), 1 ); + mlt_consumer this = calloc( 1, sizeof( struct mlt_consumer_s ) ); // If no malloc'd and consumer init ok if ( this != NULL && mlt_consumer_init( this, NULL, profile ) == 0 ) @@ -234,9 +234,13 @@ static void serialise_properties( serialise_context context, mlt_properties prop strcmp( name, "width" ) && strcmp( name, "height" ) ) { - char *value; + char *value = NULL; if ( !strcmp( name, "length" ) ) - value = strdup( mlt_properties_get_time( properties, name, context->time_format ) ); + { + char *time = mlt_properties_get_time( properties, name, context->time_format ); + if ( time ) + value = strdup( time ); + } else value = filter_restricted( mlt_properties_get_value( properties, i ) ); if ( value ) @@ -388,6 +392,7 @@ static void serialise_multitrack( serialise_context context, mlt_service service 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 ); @@ -442,6 +447,7 @@ static void serialise_playlist( serialise_context context, mlt_service service, // 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." ); @@ -481,6 +487,7 @@ static void serialise_playlist( serialise_context context, mlt_service service, 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 ); @@ -523,11 +530,14 @@ static void serialise_tractor( serialise_context context, mlt_service service, x xmlNewProp( child, _x("title"), _x(mlt_properties_get( properties, "title" )) ); if ( mlt_properties_get( properties, "global_feed" ) ) xmlNewProp( child, _x("global_feed"), _x(mlt_properties_get( properties, "global_feed" )) ); - xmlNewProp( child, _x("in"), _x(mlt_properties_get_time( properties, "in", context->time_format )) ); - xmlNewProp( child, _x("out"), _x(mlt_properties_get_time( properties, "out", context->time_format )) ); + if ( mlt_properties_get_position( properties, "in" ) >= 0 ) + xmlNewProp( child, _x("in"), _x(mlt_properties_get_time( properties, "in", context->time_format )) ); + if ( mlt_properties_get_position( properties, "out" ) >= 0 ) + xmlNewProp( child, _x("out"), _x(mlt_properties_get_time( properties, "out", context->time_format )) ); // 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." ); @@ -661,6 +671,8 @@ static void serialise_service( serialise_context context, mlt_service service, x else { serialise_producer( context, service, node ); + if ( mlt_properties_get( properties, "xml" ) != NULL ) + break; } } @@ -683,6 +695,25 @@ static void serialise_service( serialise_context context, mlt_service service, x } } +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 ); @@ -764,11 +795,13 @@ xmlDocPtr xml_make_doc( mlt_consumer consumer, mlt_service 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 @@ -914,6 +947,9 @@ static void *consumer_thread( void *arg ) // Frame and size mlt_frame frame = NULL; + int video_off = mlt_properties_get_int( properties, "video_off" ); + int audio_off = mlt_properties_get_int( properties, "audio_off" ); + // Loop while running while( !terminated && mlt_properties_get_int( properties, "running" ) ) { @@ -935,8 +971,10 @@ static void *consumer_thread( void *arg ) mlt_audio_format aformat = mlt_audio_s16; uint8_t *buffer; - mlt_frame_get_image( frame, &buffer, &iformat, &width, &height, 0 ); - mlt_frame_get_audio( frame, (void**) &buffer, &aformat, &frequency, &channels, &samples ); + if ( !video_off ) + mlt_frame_get_image( frame, &buffer, &iformat, &width, &height, 0 ); + if ( !audio_off ) + mlt_frame_get_audio( frame, (void**) &buffer, &aformat, &frequency, &channels, &samples ); // Close the frame mlt_events_fire( properties, "consumer-frame-show", frame, NULL );