1 From bdaa1fab0a20839f050659a52ab8855a203fe96c Mon Sep 17 00:00:00 2001
2 From: Thiago Santos <thiago.sousa.santos@collabora.co.uk>
3 Date: Mon, 18 Apr 2011 10:20:00 -0300
4 Subject: [PATCH] tag: xmp: Write the same tag to all schemas
6 Instead of writing only the xmp tag for the first found entry
7 that matches the gstreamer tag, look for all mappings to write
8 the tag to different schemas.
10 The rationale here is that some reader application might only
11 be interested on a particular schema tags, so we should try
12 to write as many tags for all schemas.
14 gst-libs/gst/tag/gstxmptag.c | 56 +++++++++++++++++++++++++++++++++---------
15 1 files changed, 44 insertions(+), 12 deletions(-)
17 diff --git a/gst-libs/gst/tag/gstxmptag.c b/gst-libs/gst/tag/gstxmptag.c
18 index ca05895..cc6c766 100644
19 --- a/gst-libs/gst/tag/gstxmptag.c
20 +++ b/gst-libs/gst/tag/gstxmptag.c
21 @@ -182,6 +182,21 @@ gst_xmp_schema_new ()
23 static GHashTable *__xmp_schemas;
25 +static GstXmpSchema *
26 +_gst_xmp_get_schema (const gchar * name)
29 + GstXmpSchema *schema;
31 + key = g_quark_from_string (name);
33 + schema = g_hash_table_lookup (__xmp_schemas, GUINT_TO_POINTER (key));
35 + GST_WARNING ("Schema %s doesn't exist", name);
41 _gst_xmp_add_schema (const gchar * name, GstXmpSchema * schema)
43 @@ -240,6 +255,7 @@ _gst_xmp_schema_add_simple_mapping (GstXmpSchema * schema,
44 * appended, and the API is not public, so we shouldn't
45 * have our lists modified during usage
49 _xmp_tag_get_mapping (const gchar * gst_tag, XmpSerializationData * serdata)
51 @@ -260,6 +276,7 @@ _xmp_tag_get_mapping (const gchar * gst_tag, XmpSerializationData * serdata)
57 /* finds the gst tag that maps to this xmp tag in this schema */
59 @@ -1520,22 +1537,14 @@ gst_value_serialize_xmp (const GValue * value)
63 -write_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
64 +write_one_tag (const GstTagList * list, const gchar * tag,
65 + GPtrArray * xmp_tag_array, gpointer user_data)
67 guint i = 0, ct = gst_tag_list_get_tag_size (list, tag), tag_index;
68 XmpSerializationData *serialization_data = user_data;
69 GString *data = serialization_data->data;
70 - GPtrArray *xmp_tag_array = NULL;
73 - /* map gst-tag to xmp tag */
74 - xmp_tag_array = _xmp_tag_get_mapping (tag, serialization_data);
76 - if (!xmp_tag_array) {
77 - GST_WARNING ("no mapping for %s to xmp", tag);
81 for (tag_index = 0; tag_index < xmp_tag_array->len; tag_index++) {
84 @@ -1635,8 +1644,31 @@ gst_tag_list_to_xmp_buffer_full (const GstTagList * list, gboolean read_only,
85 g_string_append (data, ">\n");
86 g_string_append (data, "<rdf:Description rdf:about=\"\">\n");
88 - /* iterate the taglist */
89 - gst_tag_list_foreach (list, write_one_tag, &serialization_data);
90 + /* iterate the schemas */
91 + if (schemas == NULL) {
92 + /* use all schemas */
93 + schemas = gst_tag_xmp_list_schemas ();
96 + for (i = 0; schemas[i] != NULL; i++) {
97 + GstXmpSchema *schema = _gst_xmp_get_schema (schemas[i]);
98 + GHashTableIter iter;
99 + gpointer key, value;
101 + if (schema == NULL)
104 + /* Iterate over the hashtable */
105 + g_hash_table_iter_init (&iter, schema);
106 + while (g_hash_table_iter_next (&iter, &key, &value)) {
107 + const gchar *tag = g_quark_to_string (GPOINTER_TO_UINT (key));
109 + if (gst_tag_list_get_value_index (list, tag, 0) != NULL) {
110 + write_one_tag (list, tag, value, (gpointer) & serialization_data);
117 g_string_append (data, "</rdf:Description>\n");