tag: xmp: Keep compatibility with our old generated xmp
We used to add a trailing \n to the end of generated xmp packets. Windows viewer was unhappy with it and we fixed it in 96d2120c2bb0b29e1849098198f5fbef81939cdd The problem is that this caused xmp generated before this fix to not be recognized and parsed anymore. This patch makes it recognize xmp with the trailing \n and without, fixing the regression. Also adds tests for it.
This commit is contained in:
parent
ceeff69bc1
commit
77353dad21
@ -1317,7 +1317,10 @@ gst_tag_list_from_xmp_buffer (const GstBuffer * buffer)
|
||||
if (*xp1 != '>')
|
||||
goto missing_header;
|
||||
|
||||
max_ft_len = 1 + strlen ("<?xpacket end=\".\"?>");
|
||||
/* Use 2 here to count for an extra trailing \n that was added
|
||||
* in old versions, this makes it able to parse xmp packets with
|
||||
* and without this trailing char */
|
||||
max_ft_len = 2 + strlen ("<?xpacket end=\".\"?>");
|
||||
if (len < max_ft_len)
|
||||
goto missing_footer;
|
||||
|
||||
|
@ -975,13 +975,21 @@ GST_START_TEST (test_xmp_parsing)
|
||||
{
|
||||
GstTagList *list;
|
||||
GstBuffer *buf;
|
||||
guint i, result_size;
|
||||
guint i, j, result_size;
|
||||
gchar *text;
|
||||
const gchar *xmp_header =
|
||||
"<?xpacket begin=\"\xEF\xBB\xBF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>"
|
||||
"<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"GStreamer\">"
|
||||
"<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">";
|
||||
const gchar *xmp_footer = "</rdf:RDF>" "</x:xmpmeta>" "<?xpacket end=\"r\"?>";
|
||||
|
||||
/* We used to write an extra trailing \n after the footer, keep compatibility
|
||||
* with our old generated media by checking that it still can be parsed */
|
||||
const gchar *xmp_footers[] = {
|
||||
"</rdf:RDF>" "</x:xmpmeta>" "<?xpacket end=\"r\"?>",
|
||||
"</rdf:RDF>" "</x:xmpmeta>" "<?xpacket end=\"r\"?>\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
const gchar *xmp_data;
|
||||
@ -1003,36 +1011,40 @@ GST_START_TEST (test_xmp_parsing)
|
||||
/* test data */
|
||||
buf = gst_buffer_new ();
|
||||
|
||||
j = 0;
|
||||
i = 0;
|
||||
while (test_data[i].xmp_data) {
|
||||
GST_DEBUG ("trying test-data %u", i);
|
||||
while (xmp_footers[j]) {
|
||||
while (test_data[i].xmp_data) {
|
||||
GST_DEBUG ("trying test-data %u", i);
|
||||
|
||||
text = g_strconcat (xmp_header, test_data[i].xmp_data, xmp_footer, NULL);
|
||||
GST_BUFFER_DATA (buf) = (guint8 *) text;
|
||||
GST_BUFFER_SIZE (buf) = strlen (text) + 1;
|
||||
text =
|
||||
g_strconcat (xmp_header, test_data[i].xmp_data, xmp_footers[j], NULL);
|
||||
GST_BUFFER_DATA (buf) = (guint8 *) text;
|
||||
GST_BUFFER_SIZE (buf) = strlen (text) + 1;
|
||||
|
||||
list = gst_tag_list_from_xmp_buffer (buf);
|
||||
if (test_data[i].result_size >= 0) {
|
||||
fail_unless (list != NULL);
|
||||
|
||||
list = gst_tag_list_from_xmp_buffer (buf);
|
||||
if (test_data[i].result_size >= 0) {
|
||||
fail_unless (list != NULL);
|
||||
result_size = gst_structure_n_fields ((GstStructure *) list);
|
||||
fail_unless (result_size == test_data[i].result_size);
|
||||
|
||||
result_size = gst_structure_n_fields ((GstStructure *) list);
|
||||
fail_unless (result_size == test_data[i].result_size);
|
||||
|
||||
/* check the taglist content */
|
||||
switch (test_data[i].result_test) {
|
||||
case 0:
|
||||
ASSERT_TAG_LIST_HAS_STRING (list, "description", "test");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
/* check the taglist content */
|
||||
switch (test_data[i].result_test) {
|
||||
case 0:
|
||||
ASSERT_TAG_LIST_HAS_STRING (list, "description", "test");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list)
|
||||
gst_tag_list_free (list);
|
||||
if (list)
|
||||
gst_tag_list_free (list);
|
||||
|
||||
g_free (text);
|
||||
i++;
|
||||
g_free (text);
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user