From: Thiago Santos Date: Thu, 9 Jun 2011 03:02:07 +0000 (-0300) Subject: tag: xmp: Fix LocationShown syntax X-Git-Tag: 1.19.3~511^2~6555^2~807 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02580714de9245d3af2e20e8dadddcb081877b01;p=platform%2Fupstream%2Fgstreamer.git tag: xmp: Fix LocationShown syntax According to the specification, the LocationShown requires its struct fields to be inside a Bag type. --- diff --git a/gst-libs/gst/tag/gstxmptag.c b/gst-libs/gst/tag/gstxmptag.c index 89973e9..dd20fd3 100644 --- a/gst-libs/gst/tag/gstxmptag.c +++ b/gst-libs/gst/tag/gstxmptag.c @@ -115,7 +115,8 @@ xmp_serialization_data_use_schema (XmpSerializationData * serdata, typedef enum { - GstXmpTagTypeSimple = 0, + GstXmpTagTypeNone = 0, + GstXmpTagTypeSimple, GstXmpTagTypeBag, GstXmpTagTypeSeq, GstXmpTagTypeStruct, @@ -136,6 +137,13 @@ struct _XmpTag const gchar *tag_name; GstXmpTagType type; + /* some tags must be inside a Bag even + * if they are a single entry. Set it here so we know */ + GstXmpTagType supertype; + + /* For tags that need a rdf:parseType attribute */ + const gchar *parse_type; + /* Used for struct and compound types */ GSList *children; @@ -157,9 +165,9 @@ xmp_tag_get_merge_mode (XmpTag * xmptag) } static const gchar * -xmp_tag_get_type_name (XmpTag * xmptag) +xmp_tag_type_get_name (GstXmpTagType tagtype) { - switch (xmptag->type) { + switch (tagtype) { case GstXmpTagTypeSeq: return "rdf:Seq"; case GstXmpTagTypeBag: @@ -251,6 +259,8 @@ gst_xmp_tag_create (const gchar * gst_tag, const gchar * xmp_tag, xmpinfo->gst_tag = gst_tag; xmpinfo->tag_name = xmp_tag; xmpinfo->type = xmp_type; + xmpinfo->supertype = GstXmpTagTypeNone; + xmpinfo->parse_type = NULL; xmpinfo->serialize = serialization_func; xmpinfo->deserialize = deserialization_func; xmpinfo->children = NULL; @@ -1012,6 +1022,8 @@ _init_xmp_tag_map (gpointer user_data) schema = gst_xmp_schema_new (); xmpinfo = gst_xmp_tag_create (NULL, "Iptc4xmpExt:LocationShown", GstXmpTagTypeStruct, NULL, NULL); + xmpinfo->supertype = GstXmpTagTypeBag; + xmpinfo->parse_type = "Resource"; xmpinfo->children = g_slist_prepend (xmpinfo->children, gst_xmp_tag_create (GST_TAG_GEO_LOCATION_SUBLOCATION, "LocationDetails:Sublocation", GstXmpTagTypeSimple, NULL, NULL)); @@ -1667,10 +1679,29 @@ write_one_tag (const GstTagList * list, XmpTag * xmp_tag, gpointer user_data) if (use_it) { if (xmp_tag->tag_name) string_open_tag (data, xmp_tag->tag_name); + + if (xmp_tag->supertype) { + string_open_tag (data, xmp_tag_type_get_name (xmp_tag->supertype)); + if (xmp_tag->parse_type) { + g_string_append (data, "parse_type); + g_string_append_c (data, '"'); + g_string_append_c (data, '>'); + } else { + string_open_tag (data, "rdf:li"); + } + } + /* now write it */ for (iter = xmp_tag->children; iter; iter = g_slist_next (iter)) { write_one_tag (list, iter->data, user_data); } + + if (xmp_tag->supertype) { + string_close_tag (data, "rdf:li"); + string_close_tag (data, xmp_tag_type_get_name (xmp_tag->supertype)); + } + if (xmp_tag->tag_name) string_close_tag (data, xmp_tag->tag_name); } @@ -1703,7 +1734,7 @@ write_one_tag (const GstTagList * list, XmpTag * xmp_tag, gpointer user_data) } else { const gchar *typename; - typename = xmp_tag_get_type_name (xmp_tag); + typename = xmp_tag_type_get_name (xmp_tag->type); string_open_tag (data, typename); for (i = 0; i < ct; i++) {