Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / debian / patches / 0022-tag-xmp-Write-the-same-tag-to-all-schemas.patch
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
5
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.
9
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.
13 ---
14  gst-libs/gst/tag/gstxmptag.c |   56 +++++++++++++++++++++++++++++++++---------
15  1 files changed, 44 insertions(+), 12 deletions(-)
16
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 ()
22   */
23  static GHashTable *__xmp_schemas;
24  
25 +static GstXmpSchema *
26 +_gst_xmp_get_schema (const gchar * name)
27 +{
28 +  GQuark key;
29 +  GstXmpSchema *schema;
30 +
31 +  key = g_quark_from_string (name);
32 +
33 +  schema = g_hash_table_lookup (__xmp_schemas, GUINT_TO_POINTER (key));
34 +  if (!schema) {
35 +    GST_WARNING ("Schema %s doesn't exist", name);
36 +  }
37 +  return schema;
38 +}
39 +
40  static void
41  _gst_xmp_add_schema (const gchar * name, GstXmpSchema * schema)
42  {
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
46   */
47 +#if 0
48  static GPtrArray *
49  _xmp_tag_get_mapping (const gchar * gst_tag, XmpSerializationData * serdata)
50  {
51 @@ -260,6 +276,7 @@ _xmp_tag_get_mapping (const gchar * gst_tag, XmpSerializationData * serdata)
52    }
53    return ret;
54  }
55 +#endif
56  
57  /* finds the gst tag that maps to this xmp tag in this schema */
58  static const gchar *
59 @@ -1520,22 +1537,14 @@ gst_value_serialize_xmp (const GValue * value)
60  }
61  
62  static void
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)
66  {
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;
71    char *s;
72  
73 -  /* map gst-tag to xmp tag */
74 -  xmp_tag_array = _xmp_tag_get_mapping (tag, serialization_data);
75 -
76 -  if (!xmp_tag_array) {
77 -    GST_WARNING ("no mapping for %s to xmp", tag);
78 -    return;
79 -  }
80 -
81    for (tag_index = 0; tag_index < xmp_tag_array->len; tag_index++) {
82      XmpTag *xmp_tag;
83  
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");
87  
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 ();
94 +  }
95 +  i = 0;
96 +  for (i = 0; schemas[i] != NULL; i++) {
97 +    GstXmpSchema *schema = _gst_xmp_get_schema (schemas[i]);
98 +    GHashTableIter iter;
99 +    gpointer key, value;
100 +
101 +    if (schema == NULL)
102 +      continue;
103 +
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));
108 +
109 +      if (gst_tag_list_get_value_index (list, tag, 0) != NULL) {
110 +        write_one_tag (list, tag, value, (gpointer) & serialization_data);
111 +      }
112 +
113 +    }
114 +  }
115  
116    /* xmp footer */
117    g_string_append (data, "</rdf:Description>\n");