]> git.sesse.net Git - mlt/blobdiff - src/modules/xml/consumer_xml.c
Do not serialize profile when consumer profile is null.
[mlt] / src / modules / xml / consumer_xml.c
index 9e85e6ecbc97979f125f7cf846558b837bf9217d..3b96cfef1fdc293cf5d60fc5d935991c1a10dbbf 100644 (file)
@@ -22,7 +22,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <pthread.h>
 #include <unistd.h>
 #include <libxml/tree.h>
 
@@ -192,8 +191,9 @@ static void serialise_properties( serialise_context context, mlt_properties prop
                         strcmp( name, "height" ) != 0 )
                {
                        char *value = mlt_properties_get_value( properties, i );
-                       if ( strcmp( context->root, "" ) && !strncmp( value, context->root, strlen( context->root ) ) )
-                               value += strlen( context->root ) + 1;
+                       int rootlen = strlen( context->root );
+                       if ( rootlen && !strncmp( value, context->root, rootlen ) && value[ rootlen ] == '/' )
+                               value += rootlen + 1;
                        p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
                        xmlNewProp( p, _x("name"), _x(name) );
                }
@@ -214,8 +214,9 @@ static void serialise_store_properties( serialise_context context, mlt_propertie
                        char *value = mlt_properties_get_value( properties, i );
                        if ( value != NULL )
                        {
-                               if ( strcmp( context->root, "" ) && !strncmp( value, context->root, strlen( context->root ) ) )
-                                       value += strlen( context->root ) + 1;
+                               int rootlen = strlen( context->root );
+                               if ( rootlen && !strncmp( value, context->root, rootlen ) && value[ rootlen ] == '/' )
+                                       value += rootlen + 1;
                                p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
                                xmlNewProp( p, _x("name"), _x(name) );
                        }
@@ -629,7 +630,9 @@ xmlDocPtr xml_make_doc( mlt_consumer consumer, mlt_service service )
        xmlDocPtr doc = xmlNewDoc( _x("1.0") );
        xmlNodePtr root = xmlNewNode( NULL, _x("mlt") );
        struct serialise_context_s *context = calloc( 1, sizeof( struct serialise_context_s ) );
-       
+       mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( consumer ) );
+       char tmpstr[ 32 ];
+
        xmlDocSetRootElement( doc, root );
 
        // If we have root, then deal with it now
@@ -651,6 +654,34 @@ xmlDocPtr xml_make_doc( mlt_consumer consumer, mlt_service service )
                xmlNewProp( root, _x("title"), _x(mlt_properties_get( properties, "title" )) );
        mlt_properties_set_int( properties, "global_feed", 1 );
 
+       // Add a profile child element
+       if ( profile )
+       {
+               xmlNodePtr profile_node = xmlNewChild( root, NULL, _x("profile"), NULL );
+               if ( profile->description )
+                       xmlNewProp( profile_node, _x("description"), _x(profile->description) );
+               sprintf( tmpstr, "%d", profile->width );
+               xmlNewProp( profile_node, _x("width"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->height );
+               xmlNewProp( profile_node, _x("height"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->progressive );
+               xmlNewProp( profile_node, _x("progressive"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->sample_aspect_num );
+               xmlNewProp( profile_node, _x("sample_aspect_num"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->sample_aspect_den );
+               xmlNewProp( profile_node, _x("sample_aspect_den"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->display_aspect_num );
+               xmlNewProp( profile_node, _x("display_aspect_num"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->display_aspect_den );
+               xmlNewProp( profile_node, _x("display_aspect_den"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->frame_rate_num );
+               xmlNewProp( profile_node, _x("frame_rate_num"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->frame_rate_den );
+               xmlNewProp( profile_node, _x("frame_rate_den"), _x(tmpstr) );
+               sprintf( tmpstr, "%d", profile->colorspace );
+               xmlNewProp( profile_node, _x("colorspace"), _x(tmpstr) );
+       }
+
        // Construct the context maps
        context->id_map = mlt_properties_new();
        context->hide_map = mlt_properties_new();