Commit 02580714 authored by Thiago Santos's avatar Thiago Santos
Browse files

tag: xmp: Fix LocationShown syntax

According to the specification, the LocationShown requires its
struct fields to be inside a Bag type.
parent 9e6d3214
...@@ -115,7 +115,8 @@ xmp_serialization_data_use_schema (XmpSerializationData * serdata, ...@@ -115,7 +115,8 @@ xmp_serialization_data_use_schema (XmpSerializationData * serdata,
typedef enum typedef enum
{ {
GstXmpTagTypeSimple = 0, GstXmpTagTypeNone = 0,
GstXmpTagTypeSimple,
GstXmpTagTypeBag, GstXmpTagTypeBag,
GstXmpTagTypeSeq, GstXmpTagTypeSeq,
GstXmpTagTypeStruct, GstXmpTagTypeStruct,
...@@ -136,6 +137,13 @@ struct _XmpTag ...@@ -136,6 +137,13 @@ struct _XmpTag
const gchar *tag_name; const gchar *tag_name;
GstXmpTagType type; 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 */ /* Used for struct and compound types */
GSList *children; GSList *children;
...@@ -157,9 +165,9 @@ xmp_tag_get_merge_mode (XmpTag * xmptag) ...@@ -157,9 +165,9 @@ xmp_tag_get_merge_mode (XmpTag * xmptag)
} }
static const gchar * static const gchar *
xmp_tag_get_type_name (XmpTag * xmptag) xmp_tag_type_get_name (GstXmpTagType tagtype)
{ {
switch (xmptag->type) { switch (tagtype) {
case GstXmpTagTypeSeq: case GstXmpTagTypeSeq:
return "rdf:Seq"; return "rdf:Seq";
case GstXmpTagTypeBag: case GstXmpTagTypeBag:
...@@ -251,6 +259,8 @@ gst_xmp_tag_create (const gchar * gst_tag, const gchar * xmp_tag, ...@@ -251,6 +259,8 @@ gst_xmp_tag_create (const gchar * gst_tag, const gchar * xmp_tag,
xmpinfo->gst_tag = gst_tag; xmpinfo->gst_tag = gst_tag;
xmpinfo->tag_name = xmp_tag; xmpinfo->tag_name = xmp_tag;
xmpinfo->type = xmp_type; xmpinfo->type = xmp_type;
xmpinfo->supertype = GstXmpTagTypeNone;
xmpinfo->parse_type = NULL;
xmpinfo->serialize = serialization_func; xmpinfo->serialize = serialization_func;
xmpinfo->deserialize = deserialization_func; xmpinfo->deserialize = deserialization_func;
xmpinfo->children = NULL; xmpinfo->children = NULL;
...@@ -1012,6 +1022,8 @@ _init_xmp_tag_map (gpointer user_data) ...@@ -1012,6 +1022,8 @@ _init_xmp_tag_map (gpointer user_data)
schema = gst_xmp_schema_new (); schema = gst_xmp_schema_new ();
xmpinfo = gst_xmp_tag_create (NULL, "Iptc4xmpExt:LocationShown", xmpinfo = gst_xmp_tag_create (NULL, "Iptc4xmpExt:LocationShown",
GstXmpTagTypeStruct, NULL, NULL); GstXmpTagTypeStruct, NULL, NULL);
xmpinfo->supertype = GstXmpTagTypeBag;
xmpinfo->parse_type = "Resource";
xmpinfo->children = g_slist_prepend (xmpinfo->children, xmpinfo->children = g_slist_prepend (xmpinfo->children,
gst_xmp_tag_create (GST_TAG_GEO_LOCATION_SUBLOCATION, gst_xmp_tag_create (GST_TAG_GEO_LOCATION_SUBLOCATION,
"LocationDetails:Sublocation", GstXmpTagTypeSimple, NULL, NULL)); "LocationDetails:Sublocation", GstXmpTagTypeSimple, NULL, NULL));
...@@ -1667,10 +1679,29 @@ write_one_tag (const GstTagList * list, XmpTag * xmp_tag, gpointer user_data) ...@@ -1667,10 +1679,29 @@ write_one_tag (const GstTagList * list, XmpTag * xmp_tag, gpointer user_data)
if (use_it) { if (use_it) {
if (xmp_tag->tag_name) if (xmp_tag->tag_name)
string_open_tag (data, 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, "<rdf:li rdf:parseType=\"");
g_string_append (data, xmp_tag->parse_type);
g_string_append_c (data, '"');
g_string_append_c (data, '>');
} else {
string_open_tag (data, "rdf:li");
}
}
/* now write it */ /* now write it */
for (iter = xmp_tag->children; iter; iter = g_slist_next (iter)) { for (iter = xmp_tag->children; iter; iter = g_slist_next (iter)) {
write_one_tag (list, iter->data, user_data); 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) if (xmp_tag->tag_name)
string_close_tag (data, 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) ...@@ -1703,7 +1734,7 @@ write_one_tag (const GstTagList * list, XmpTag * xmp_tag, gpointer user_data)
} else { } else {
const gchar *typename; 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); string_open_tag (data, typename);
for (i = 0; i < ct; i++) { for (i = 0; i < ct; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment