3 * unit tests for the tag support library
5 * Copyright (C) 2006-2011 Tim-Philipp Müller <tim centricular net>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
27 #include <gst/check/gstcheck.h>
29 #include <gst/tag/tag.h>
30 #include <gst/base/gstbytewriter.h>
34 GST_START_TEST (test_parse_extended_comment)
36 gchar *key, *val, *lang;
38 /* first check the g_return_val_if_fail conditions */
39 ASSERT_CRITICAL (gst_tag_parse_extended_comment (NULL, NULL, NULL, NULL,
41 ASSERT_CRITICAL (gst_tag_parse_extended_comment ("\377\000", NULL, NULL, NULL,
44 key = val = lang = NULL;
45 fail_unless (gst_tag_parse_extended_comment ("a=b", &key, &lang, &val,
47 fail_unless (key != NULL);
48 fail_unless (lang == NULL);
49 fail_unless (val != NULL);
50 fail_unless_equals_string (key, "a");
51 fail_unless_equals_string (val, "b");
56 key = val = lang = NULL;
57 fail_unless (gst_tag_parse_extended_comment ("a[l]=b", &key, &lang, &val,
59 fail_unless (key != NULL);
60 fail_unless (lang != NULL);
61 fail_unless (val != NULL);
62 fail_unless_equals_string (key, "a");
63 fail_unless_equals_string (lang, "l");
64 fail_unless_equals_string (val, "b");
69 key = val = lang = NULL;
70 fail_unless (gst_tag_parse_extended_comment ("foo=bar", &key, &lang, &val,
72 fail_unless (key != NULL);
73 fail_unless (lang == NULL);
74 fail_unless (val != NULL);
75 fail_unless_equals_string (key, "foo");
76 fail_unless_equals_string (val, "bar");
81 key = val = lang = NULL;
82 fail_unless (gst_tag_parse_extended_comment ("foo[fr]=bar", &key, &lang, &val,
84 fail_unless (key != NULL);
85 fail_unless (lang != NULL);
86 fail_unless (val != NULL);
87 fail_unless_equals_string (key, "foo");
88 fail_unless_equals_string (lang, "fr");
89 fail_unless_equals_string (val, "bar");
94 key = val = lang = NULL;
95 fail_unless (gst_tag_parse_extended_comment ("foo=[fr]bar", &key, &lang, &val,
97 fail_unless (key != NULL);
98 fail_unless (lang == NULL);
99 fail_unless (val != NULL);
100 fail_unless_equals_string (key, "foo");
101 fail_unless_equals_string (val, "[fr]bar");
106 /* test NULL for output locations */
107 fail_unless (gst_tag_parse_extended_comment ("foo[fr]=bar", NULL, NULL, NULL,
110 /* test strict mode (key must be specified) */
111 fail_unless (gst_tag_parse_extended_comment ("foo[fr]=bar", NULL, NULL, NULL,
113 fail_unless (gst_tag_parse_extended_comment ("foo=bar", NULL, NULL, NULL,
115 fail_unless (gst_tag_parse_extended_comment ("foobar", NULL, NULL, NULL,
118 /* test non-strict mode (if there's no key, that's fine too) */
119 fail_unless (gst_tag_parse_extended_comment ("foobar", NULL, NULL, NULL,
121 fail_unless (gst_tag_parse_extended_comment ("[fr]bar", NULL, NULL, NULL,
124 key = val = lang = NULL;
125 fail_unless (gst_tag_parse_extended_comment ("[fr]bar", &key, &lang, &val,
127 fail_unless (key == NULL);
128 fail_unless (lang == NULL);
129 fail_unless (val != NULL);
130 fail_unless_equals_string (val, "[fr]bar");
138 #define ASSERT_TAG_LIST_HAS_STRING(list,field,string) \
140 gboolean got_match = FALSE; \
143 fail_unless (gst_tag_list_get_tag_size (list,field) > 0); \
144 size = gst_tag_list_get_tag_size (list,field); \
145 for (i = 0; i < size; ++i) { \
146 gchar *___s = NULL; \
148 fail_unless (gst_tag_list_get_string_index (list, field, i, &___s)); \
149 fail_unless (___s != NULL); \
150 if (g_str_equal (___s, string)) { \
157 fail_unless (got_match); \
160 #define ASSERT_TAG_LIST_HAS_UINT(list,field,num) \
164 fail_unless (gst_tag_list_get_tag_size (list,field) > 0); \
165 fail_unless (gst_tag_list_get_tag_size (list,field) == 1); \
166 fail_unless (gst_tag_list_get_uint_index (list, field, 0, &___n)); \
167 fail_unless_equals_int (___n, num); \
170 #define MATCH_DOUBLE(p1, p2) ((p1 < p2 + 1e-6) && (p2 < p1 + 1e-6))
171 #define ASSERT_TAG_LIST_HAS_DOUBLE(list,field,d) \
175 fail_unless (gst_tag_list_get_tag_size (list,field) > 0); \
176 fail_unless (gst_tag_list_get_tag_size (list,field) == 1); \
177 fail_unless (gst_tag_list_get_double_index (list, field, 0, &___d)); \
178 fail_unless (MATCH_DOUBLE (d, ___d), \
179 "%f does not match expected %f", ___d, d); \
182 GST_START_TEST (test_musicbrainz_tag_registration)
186 gst_tag_register_musicbrainz_tags ();
188 list = gst_tag_list_new_empty ();
190 /* musicbrainz tags aren't registered yet */
191 gst_vorbis_tag_add (list, "MUSICBRAINZ_TRACKID", "123456");
192 gst_vorbis_tag_add (list, "MUSICBRAINZ_ARTISTID", "234567");
193 gst_vorbis_tag_add (list, "MUSICBRAINZ_ALBUMID", "345678");
194 gst_vorbis_tag_add (list, "MUSICBRAINZ_ALBUMARTISTID", "4567890");
195 gst_vorbis_tag_add (list, "MUSICBRAINZ_TRMID", "5678901");
196 /* MUSICBRAINZ_SORTNAME = GST_TAG_ARTIST_SORTNAME now */
197 gst_vorbis_tag_add (list, "MUSICBRAINZ_SORTNAME", "Five, 678901");
199 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_MUSICBRAINZ_TRACKID, "123456");
200 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_MUSICBRAINZ_ARTISTID, "234567");
201 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_MUSICBRAINZ_ALBUMID, "345678");
202 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_MUSICBRAINZ_ALBUMARTISTID,
204 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_MUSICBRAINZ_TRMID, "5678901");
205 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_ARTIST_SORTNAME, "Five, 678901");
207 gst_tag_list_free (list);
212 /* is there an easier way to compare two structures / tagslists? */
214 taglists_are_equal (const GstTagList * list_1, const GstTagList * list_2)
216 GstCaps *c_list_1 = gst_caps_new_empty ();
217 GstCaps *c_list_2 = gst_caps_new_empty ();
220 gst_caps_append_structure (c_list_1,
221 gst_structure_copy ((GstStructure *) list_1));
222 gst_caps_append_structure (c_list_2,
223 gst_structure_copy ((GstStructure *) list_2));
225 ret = gst_caps_is_equal (c_list_2, c_list_1);
227 gst_caps_unref (c_list_1);
228 gst_caps_unref (c_list_2);
233 GST_START_TEST (test_vorbis_tags)
237 list = gst_tag_list_new_empty ();
239 /* NULL pointers aren't allowed */
240 ASSERT_CRITICAL (gst_vorbis_tag_add (NULL, "key", "value"));
241 ASSERT_CRITICAL (gst_vorbis_tag_add (list, NULL, "value"));
242 ASSERT_CRITICAL (gst_vorbis_tag_add (list, "key", NULL));
245 ASSERT_CRITICAL (gst_vorbis_tag_add (list, "key", "v\377lue"));
246 ASSERT_CRITICAL (gst_vorbis_tag_add (list, "k\377y", "value"));
248 /* key can't have a '=' in it */
249 ASSERT_CRITICAL (gst_vorbis_tag_add (list, "k=y", "value"));
250 ASSERT_CRITICAL (gst_vorbis_tag_add (list, "key=", "value"));
252 /* should be allowed in values though */
253 gst_vorbis_tag_add (list, "keeey", "va=ue");
256 gst_vorbis_tag_add (list, "TITLE", "Too");
257 gst_vorbis_tag_add (list, "ALBUM", "Aoo");
258 gst_vorbis_tag_add (list, "ARTIST", "Alboo");
259 gst_vorbis_tag_add (list, "PERFORMER", "Perfoo");
260 gst_vorbis_tag_add (list, "COPYRIGHT", "Copyfoo");
261 gst_vorbis_tag_add (list, "DESCRIPTION", "Descoo");
262 gst_vorbis_tag_add (list, "LICENSE", "Licoo");
263 gst_vorbis_tag_add (list, "LICENSE",
264 "http://creativecommons.org/licenses/by/3.0/");
265 gst_vorbis_tag_add (list, "LOCATION", "Bristol, UK");
266 gst_vorbis_tag_add (list, "ORGANIZATION", "Orgoo");
267 gst_vorbis_tag_add (list, "GENRE", "Goo");
268 gst_vorbis_tag_add (list, "CONTACT", "Coo");
269 gst_vorbis_tag_add (list, "COMMENT", "Stroodle is good");
270 gst_vorbis_tag_add (list, "COMMENT", "Peroxysulfid stroodles the brain");
272 gst_vorbis_tag_add (list, "TRACKNUMBER", "5");
273 gst_vorbis_tag_add (list, "TRACKTOTAL", "77");
274 gst_vorbis_tag_add (list, "DISCNUMBER", "1");
275 gst_vorbis_tag_add (list, "DISCTOTAL", "2");
276 gst_vorbis_tag_add (list, "DATE", "1954-12-31");
278 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_TITLE, "Too");
279 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_ALBUM, "Aoo");
280 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_ARTIST, "Alboo");
281 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_PERFORMER, "Perfoo");
282 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_COPYRIGHT, "Copyfoo");
283 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_DESCRIPTION, "Descoo");
284 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LICENSE, "Licoo");
285 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LICENSE_URI,
286 "http://creativecommons.org/licenses/by/3.0/");
287 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_GEO_LOCATION_NAME, "Bristol, UK");
288 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_ORGANIZATION, "Orgoo");
289 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_GENRE, "Goo");
290 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_CONTACT, "Coo");
291 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_COMMENT,
292 "Peroxysulfid stroodles the brain");
293 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_COMMENT, "Stroodle is good");
294 ASSERT_TAG_LIST_HAS_UINT (list, GST_TAG_TRACK_NUMBER, 5);
295 ASSERT_TAG_LIST_HAS_UINT (list, GST_TAG_TRACK_COUNT, 77);
296 ASSERT_TAG_LIST_HAS_UINT (list, GST_TAG_ALBUM_VOLUME_NUMBER, 1);
297 ASSERT_TAG_LIST_HAS_UINT (list, GST_TAG_ALBUM_VOLUME_COUNT, 2);
302 fail_unless (gst_tag_list_get_date (list, GST_TAG_DATE, &date));
303 fail_unless (date != NULL);
304 fail_unless (g_date_get_day (date) == 31);
305 fail_unless (g_date_get_month (date) == G_DATE_DECEMBER);
306 fail_unless (g_date_get_year (date) == 1954);
311 /* unknown vorbis comments should go into a GST_TAG_EXTENDED_COMMENT */
312 gst_vorbis_tag_add (list, "CoEdSub_ID", "98172AF-973-10-B");
313 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_EXTENDED_COMMENT,
314 "CoEdSub_ID=98172AF-973-10-B");
315 gst_vorbis_tag_add (list, "RuBuWuHash", "1337BA42F91");
316 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_EXTENDED_COMMENT,
317 "RuBuWuHash=1337BA42F91");
319 gst_vorbis_tag_add (list, "REPLAYGAIN_REFERENCE_LOUDNESS", "89.");
320 ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_REFERENCE_LEVEL, 89.);
321 gst_vorbis_tag_add (list, "REPLAYGAIN_TRACK_GAIN", "+12.36");
322 ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_TRACK_GAIN, +12.36);
323 gst_vorbis_tag_add (list, "REPLAYGAIN_TRACK_PEAK", "0.96349");
324 ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_TRACK_PEAK, 0.96349);
325 gst_vorbis_tag_add (list, "REPLAYGAIN_ALBUM_GAIN", "+10.12");
326 ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_ALBUM_GAIN, +10.12);
327 /* now check that we can parse floating point numbers with any separator
328 * (',' or '.') regardless of the current locale */
329 gst_vorbis_tag_add (list, "REPLAYGAIN_ALBUM_PEAK", "0,98107");
330 ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_ALBUM_PEAK, 0.98107);
331 gst_vorbis_tag_add (list, "LICENSE", "http://foo.com/license-1.html");
333 /* make sure we can convert back and forth without loss */
335 GstTagList *new_list, *even_newer_list;
336 GstBuffer *buf, *buf2;
337 gchar *vendor_id = NULL;
339 buf = gst_tag_list_to_vorbiscomment_buffer (list,
340 (const guint8 *) "\003vorbis", 7, "libgstunittest");
341 fail_unless (buf != NULL);
342 new_list = gst_tag_list_from_vorbiscomment_buffer (buf,
343 (const guint8 *) "\003vorbis", 7, &vendor_id);
344 fail_unless (new_list != NULL);
345 fail_unless (vendor_id != NULL);
349 GST_LOG ("new_list = %" GST_PTR_FORMAT, new_list);
350 fail_unless (taglists_are_equal (list, new_list));
352 buf2 = gst_tag_list_to_vorbiscomment_buffer (new_list,
353 (const guint8 *) "\003vorbis", 7, "libgstunittest");
354 fail_unless (buf2 != NULL);
355 even_newer_list = gst_tag_list_from_vorbiscomment_buffer (buf2,
356 (const guint8 *) "\003vorbis", 7, &vendor_id);
357 fail_unless (even_newer_list != NULL);
358 fail_unless (vendor_id != NULL);
362 GST_LOG ("even_newer_list = %" GST_PTR_FORMAT, even_newer_list);
363 fail_unless (taglists_are_equal (new_list, even_newer_list));
365 gst_tag_list_free (new_list);
366 gst_tag_list_free (even_newer_list);
367 gst_buffer_unref (buf);
368 gst_buffer_unref (buf2);
371 /* there can only be one language per taglist ... */
372 gst_tag_list_free (list);
373 list = gst_tag_list_new_empty ();
374 gst_vorbis_tag_add (list, "LANGUAGE", "fr");
375 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "fr");
377 gst_tag_list_free (list);
378 list = gst_tag_list_new_empty ();
379 gst_vorbis_tag_add (list, "LANGUAGE", "[fr]");
380 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "fr");
382 gst_tag_list_free (list);
383 list = gst_tag_list_new_empty ();
384 gst_vorbis_tag_add (list, "LANGUAGE", "French [fr]");
385 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "fr");
387 gst_tag_list_free (list);
388 list = gst_tag_list_new_empty ();
389 gst_vorbis_tag_add (list, "LANGUAGE", "[eng] English");
390 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "eng");
392 gst_tag_list_free (list);
393 list = gst_tag_list_new_empty ();
394 gst_vorbis_tag_add (list, "LANGUAGE", "eng");
395 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "eng");
397 gst_tag_list_free (list);
398 list = gst_tag_list_new_empty ();
399 gst_vorbis_tag_add (list, "LANGUAGE", "[eng]");
400 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "eng");
402 /* free-form *sigh* */
403 gst_tag_list_free (list);
404 list = gst_tag_list_new_empty ();
405 gst_vorbis_tag_add (list, "LANGUAGE", "English");
406 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "English");
408 /* now, while we still have a taglist, test _to_vorbiscomment_buffer() */
410 GstBuffer *buf1, *buf2;
411 guint8 *data1, *data2;
414 ASSERT_CRITICAL (gst_tag_list_to_vorbiscomment_buffer (NULL,
415 (const guint8 *) "x", 1, "x"));
417 buf1 = gst_tag_list_to_vorbiscomment_buffer (list, NULL, 0, NULL);
418 fail_unless (buf1 != NULL);
420 buf2 = gst_tag_list_to_vorbiscomment_buffer (list,
421 (const guint8 *) "foo", 3, NULL);
422 fail_unless (buf2 != NULL);
424 data1 = gst_buffer_map (buf1, &size1, NULL, GST_MAP_READ);
425 data2 = gst_buffer_map (buf2, &size2, NULL, GST_MAP_READ);
427 fail_unless (memcmp (data1, data2 + 3, size1) == 0);
429 gst_buffer_unmap (buf2, data2, size2);
430 gst_buffer_unmap (buf1, data1, size1);
432 gst_buffer_unref (buf1);
433 gst_buffer_unref (buf2);
436 gst_tag_list_free (list);
438 /* make sure gst_tag_list_from_vorbiscomment_buffer() works with an
439 * empty ID (for Speex) */
441 const guint8 speex_comments_buf1[] = { 0x03, 0x00, 0x00, 0x00, 'f', 'o',
442 'o', 0x00, 0x00, 0x00, 0x00
445 gchar *vendor = NULL;
447 buf = gst_buffer_new ();
448 gst_buffer_take_memory (buf, -1,
449 gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
450 (gpointer) speex_comments_buf1, NULL,
451 sizeof (speex_comments_buf1), 0, sizeof (speex_comments_buf1)));
453 /* make sure it doesn't memcmp over the end of the buffer */
454 fail_unless (gst_tag_list_from_vorbiscomment_buffer (buf,
455 (const guint8 *) "averylongstringbrownfoxjumpoverthefence", 39,
457 fail_unless (vendor == NULL);
459 /* make sure it bails out if the ID doesn't match */
460 fail_unless (gst_tag_list_from_vorbiscomment_buffer (buf,
461 (guint8 *) "short", 4, &vendor) == NULL);
462 fail_unless (vendor == NULL);
464 /* now read properly */
465 list = gst_tag_list_from_vorbiscomment_buffer (buf, NULL, 0, &vendor);
466 fail_unless (vendor != NULL);
467 fail_unless_equals_string (vendor, "foo");
468 fail_unless (list != NULL);
469 fail_unless (gst_structure_n_fields ((GstStructure *) list) == 0);
471 gst_tag_list_free (list);
473 /* now again without vendor */
474 list = gst_tag_list_from_vorbiscomment_buffer (buf, NULL, 0, NULL);
475 fail_unless (list != NULL);
476 fail_unless (gst_structure_n_fields ((GstStructure *) list) == 0);
477 gst_tag_list_free (list);
479 gst_buffer_unref (buf);
482 /* the same with an ID */
484 const guint8 vorbis_comments_buf[] = { 0x03, 'v', 'o', 'r', 'b', 'i', 's',
485 0x03, 0x00, 0x00, 0x00, 'f', 'o', 'o', 0x01, 0x00, 0x00, 0x00,
486 strlen ("ARTIST=foo bar"), 0x00, 0x00, 0x00, 'A', 'R', 'T', 'I', 'S',
487 'T', '=', 'f', 'o', 'o', ' ', 'b', 'a', 'r'
490 gchar *vendor = NULL;
492 buf = gst_buffer_new ();
493 gst_buffer_take_memory (buf, -1,
494 gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
495 (gpointer) vorbis_comments_buf, NULL,
496 sizeof (vorbis_comments_buf), 0, sizeof (vorbis_comments_buf)));
498 /* make sure it doesn't memcmp over the end of the buffer */
499 fail_unless (gst_tag_list_from_vorbiscomment_buffer (buf,
500 (const guint8 *) "averylongstringbrownfoxjumpoverthefence", 39,
502 fail_unless (vendor == NULL);
504 /* make sure it bails out if the ID doesn't match */
505 fail_unless (gst_tag_list_from_vorbiscomment_buffer (buf,
506 (guint8 *) "short", 4, &vendor) == NULL);
507 fail_unless (vendor == NULL);
509 /* now read properly */
510 list = gst_tag_list_from_vorbiscomment_buffer (buf,
511 (guint8 *) "\003vorbis", 7, &vendor);
512 fail_unless (vendor != NULL);
513 fail_unless_equals_string (vendor, "foo");
514 fail_unless (list != NULL);
515 fail_unless (gst_structure_n_fields ((GstStructure *) list) == 1);
516 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_ARTIST, "foo bar");
518 gst_tag_list_free (list);
520 /* now again without vendor */
521 list = gst_tag_list_from_vorbiscomment_buffer (buf,
522 (guint8 *) "\003vorbis", 7, NULL);
523 fail_unless (list != NULL);
524 fail_unless (gst_structure_n_fields ((GstStructure *) list) == 1);
525 ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_ARTIST, "foo bar");
526 gst_tag_list_free (list);
528 gst_buffer_unref (buf);
531 /* check date with time */
535 list = gst_tag_list_new_empty ();
536 gst_vorbis_tag_add (list, "DATE", "2006-09-25 22:02:38");
538 fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
539 fail_unless (date != NULL);
540 fail_unless (g_date_get_day (date) == 25);
541 fail_unless (g_date_get_month (date) == G_DATE_SEPTEMBER);
542 fail_unless (g_date_get_year (date) == 2006);
545 gst_tag_list_free (list);
548 /* check date with month/day of 00-00 */
552 list = gst_tag_list_new_empty ();
553 gst_vorbis_tag_add (list, "DATE", "1992-00-00");
555 fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
556 fail_unless (date != NULL);
557 fail_unless (g_date_get_year (date) == 1992);
560 gst_tag_list_free (list);
563 /* check date with valid month, but day of 00 */
567 list = gst_tag_list_new_empty ();
568 gst_vorbis_tag_add (list, "DATE", "1992-05-00");
570 fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
571 fail_unless (date != NULL);
572 fail_unless (g_date_get_year (date) == 1992);
573 fail_unless (g_date_get_month (date) == G_DATE_MAY);
576 gst_tag_list_free (list);
582 GST_START_TEST (test_id3_tags)
586 fail_unless (gst_tag_id3_genre_count () > 0);
588 for (i = 0; i < gst_tag_id3_genre_count (); ++i) {
591 genre = gst_tag_id3_genre_get (i);
592 GST_LOG ("genre: %s", genre);
593 fail_unless (genre != NULL);
597 /* TODO: GstTagList *gst_tag_list_new_from_id3v1 (const guint8 *data) */
600 /* gst_tag_from_id3_tag */
601 fail_unless (gst_tag_from_id3_tag ("TALB") != NULL);
602 ASSERT_CRITICAL (gst_tag_from_id3_tag (NULL));
603 fail_unless (gst_tag_from_id3_tag ("R2D2") == NULL);
604 fail_unless_equals_string (gst_tag_from_id3_tag ("WCOP"),
605 GST_TAG_COPYRIGHT_URI);
607 /* gst_tag_from_id3_user_tag */
608 ASSERT_CRITICAL (gst_tag_from_id3_user_tag (NULL, "foo"));
609 ASSERT_CRITICAL (gst_tag_from_id3_user_tag ("foo", NULL));
610 fail_unless (gst_tag_from_id3_user_tag ("R2D2", "R2D2") == NULL);
612 /* gst_tag_to_id3_tag */
613 ASSERT_CRITICAL (gst_tag_to_id3_tag (NULL));
614 fail_unless (gst_tag_to_id3_tag ("R2D2") == NULL);
615 fail_unless (gst_tag_to_id3_tag (GST_TAG_ARTIST) != NULL);
616 fail_unless_equals_string (gst_tag_to_id3_tag (GST_TAG_COPYRIGHT_URI),
619 fail_unless (GST_TYPE_TAG_IMAGE_TYPE != 0);
620 fail_unless (g_type_name (GST_TYPE_TAG_IMAGE_TYPE) != NULL);
626 GST_START_TEST (test_id3v1_utf8_tag)
628 const guint8 id3v1[128] = {
631 /* title (30 bytes) */
632 'D', 0xc3, 0xad, 'v', 'k', 'a', ' ', 's',
633 ' ', 'p', 'e', 'r', 'l', 'a', 'm', 'i',
634 ' ', 'v', 'e', ' ', 'v', 'l', 'a', 's',
635 'e', 'c', 'h', 0, 0, 0,
636 /* artist (30 bytes) */
637 'A', 'l', 'e', 0xc5, 0xa1, ' ', 'B', 'r', 'i', 'c', 'h', 't', 'a',
638 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
639 /* album (30 bytes) */
640 'B', 'e', 's', 't', ' ', 'o', 'f', ' ', '(', 'P', 'r', 'o', 's', 't',
641 0xc4, 0x9b, ' ', 0xc3, 0xba, 0xc5, 0xbe, 'a', 's', 'n', 0xc3, 0xbd, ')',
645 /* comment (28 bytes) */
646 '-', '-', '-', ' ', 0xc4, 0x8d, 'e', 's', 'k', 0xc3, 0xa9, ' ', 'p',
647 0xc3, 0xad, 's', 'n', 'i', 0xc4, 0x8d, 'k', 'y', ' ', '-', '-', '-',
658 /* set this, to make sure UTF-8 strings are really interpreted properly
659 * as UTF-8, regardless of the locale set */
660 g_setenv ("GST_ID3V1_TAG_ENCODING", "WINDOWS-1250", TRUE);
662 tags = gst_tag_list_new_from_id3v1 (id3v1);
663 fail_unless (tags != NULL);
665 GST_LOG ("Got tags: %" GST_PTR_FORMAT, tags);
668 fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s));
669 fail_unless (s != NULL);
670 fail_unless_equals_string (s, "Dívka s perlami ve vlasech");
674 fail_unless (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s));
675 fail_unless (s != NULL);
676 fail_unless_equals_string (s, "Aleš Brichta");
680 fail_unless (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s));
681 fail_unless (s != NULL);
682 fail_unless_equals_string (s, "Best of (Prostě úžasný)");
686 fail_unless (gst_tag_list_get_date (tags, GST_TAG_DATE, &d));
687 fail_unless (d != NULL);
688 fail_unless_equals_int (g_date_get_year (d), 2000);
692 gst_tag_list_free (tags);
694 g_unsetenv ("GST_ID3V1_TAG_ENCODING");
699 GST_START_TEST (test_language_utils)
701 gchar **lang_codes, **c;
703 #define ASSERT_STRINGS_EQUAL fail_unless_equals_string
705 lang_codes = gst_tag_get_language_codes ();
706 fail_unless (lang_codes != NULL);
707 fail_unless (*lang_codes != NULL);
709 for (c = lang_codes; c != NULL && *c != NULL; ++c) {
710 const gchar *lang_name, *c1, *c2t, *c2b;
712 lang_name = gst_tag_get_language_name (*c);
713 fail_unless (lang_name != NULL);
714 fail_unless (g_utf8_validate (lang_name, -1, NULL));
716 c1 = gst_tag_get_language_code_iso_639_1 (*c);
717 fail_unless (c1 != NULL);
718 fail_unless (g_utf8_validate (c1, -1, NULL));
720 c2t = gst_tag_get_language_code_iso_639_2T (*c);
721 fail_unless (c2t != NULL);
722 fail_unless (g_utf8_validate (c2t, -1, NULL));
724 c2b = gst_tag_get_language_code_iso_639_2B (*c);
725 fail_unless (c2b != NULL);
726 fail_unless (g_utf8_validate (c2b, -1, NULL));
728 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_1 (*c), *c);
729 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_1 (c2t), *c);
730 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_1 (c2b), *c);
732 GST_DEBUG ("[%s] %s %s %s : %s\n", *c, c1, c2t, c2b, lang_name);
735 g_strfreev (lang_codes);
737 fail_unless (gst_tag_get_language_name ("de") != NULL);
738 fail_unless (gst_tag_get_language_name ("deu") != NULL);
739 fail_unless (gst_tag_get_language_name ("ger") != NULL);
740 fail_unless_equals_string (gst_tag_get_language_name ("deu"),
741 gst_tag_get_language_name ("ger"));
742 fail_unless_equals_string (gst_tag_get_language_name ("de"),
743 gst_tag_get_language_name ("ger"));
744 fail_unless (gst_tag_get_language_name ("de") !=
745 gst_tag_get_language_name ("fr"));
747 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code ("deu"), "de");
748 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code ("de"), "de");
749 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code ("ger"), "de");
751 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_1 ("deu"), "de");
752 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_1 ("de"), "de");
753 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_1 ("ger"), "de");
755 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_2T ("de"), "deu");
756 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_2T ("deu"), "deu");
757 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_2T ("ger"), "deu");
759 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_2B ("de"), "ger");
760 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_2B ("deu"), "ger");
761 ASSERT_STRINGS_EQUAL (gst_tag_get_language_code_iso_639_2B ("ger"), "ger");
766 #define SPECIFIC_L "http://creativecommons.org/licenses/by-nc-sa/2.5/scotland/"
767 #define GENERIC_L "http://creativecommons.org/licenses/by/1.0/"
768 #define DERIVED_L "http://creativecommons.org/licenses/sampling+/1.0/tw/"
770 GST_START_TEST (test_license_utils)
774 gchar **liblicense_refs, **r;
776 gchar *path, *data = NULL;
779 gst_debug_set_threshold_for_name ("tag-licenses", GST_LEVEL_NONE);
781 /* test jurisdiction-specific license */
782 fail_unless_equals_int (gst_tag_get_license_flags (SPECIFIC_L), 0x01010703);
783 fail_unless_equals_string (gst_tag_get_license_nick (SPECIFIC_L),
784 "CC BY-NC-SA 2.5 SCOTLAND");
785 fail_unless_equals_string (gst_tag_get_license_version (SPECIFIC_L), "2.5");
786 fail_unless_equals_string (gst_tag_get_license_jurisdiction (SPECIFIC_L),
789 g_setenv ("GST_TAG_LICENSE_TRANSLATIONS_LANG", "C", TRUE);
790 fail_unless_equals_string (gst_tag_get_license_title (SPECIFIC_L),
791 "Attribution-NonCommercial-ShareAlike");
792 fail_unless (gst_tag_get_license_description (SPECIFIC_L) == NULL);
794 /* test generic license */
795 fail_unless_equals_int (gst_tag_get_license_flags (GENERIC_L), 0x01000307);
796 fail_unless_equals_string (gst_tag_get_license_nick (GENERIC_L), "CC BY 1.0");
797 fail_unless_equals_string (gst_tag_get_license_version (GENERIC_L), "1.0");
798 fail_unless (gst_tag_get_license_jurisdiction (GENERIC_L) == NULL);
800 g_setenv ("GST_TAG_LICENSE_TRANSLATIONS_LANG", "C", TRUE);
801 fail_unless_equals_string (gst_tag_get_license_title (GENERIC_L),
803 fail_unless_equals_string (gst_tag_get_license_description (GENERIC_L),
804 "You must attribute the work in the manner specified by the author or licensor.");
807 g_setenv ("GST_TAG_LICENSE_TRANSLATIONS_LANG", "fr", TRUE);
808 fail_unless_equals_string (gst_tag_get_license_title (GENERIC_L),
810 fail_unless_equals_string (gst_tag_get_license_description (GENERIC_L),
811 "L'offrant autorise les autres à reproduire, distribuer et communiquer cette création au public. En échange, les personnes qui acceptent ce contrat doivent citer le nom de l'auteur original.");
814 /* test derived (for a certain jurisdiction) license */
815 fail_unless_equals_int (gst_tag_get_license_flags (DERIVED_L), 0x0100030d);
816 fail_unless_equals_string (gst_tag_get_license_nick (DERIVED_L),
817 "CC SAMPLING+ 1.0 TW");
818 fail_unless_equals_string (gst_tag_get_license_version (DERIVED_L), "1.0");
819 fail_unless_equals_string (gst_tag_get_license_jurisdiction (DERIVED_L),
822 g_setenv ("GST_TAG_LICENSE_TRANSLATIONS_LANG", "C", TRUE);
823 fail_unless_equals_string (gst_tag_get_license_title (DERIVED_L),
825 fail_unless_equals_string (gst_tag_get_license_description (GENERIC_L),
826 "You must attribute the work in the manner specified by the author or licensor.");
828 /* test all we know about */
829 lrefs = gst_tag_get_licenses ();
830 fail_unless (lrefs != NULL);
831 fail_unless (*lrefs != NULL);
833 GST_INFO ("%d licenses", g_strv_length (lrefs));
834 fail_unless (g_strv_length (lrefs) >= 376);
836 ht = g_hash_table_new (g_str_hash, g_str_equal);
838 for (l = lrefs; l != NULL && *l != NULL; ++l) {
839 const gchar *ref, *nick, *title, *desc G_GNUC_UNUSED;
841 ref = (const gchar *) *l;
842 nick = gst_tag_get_license_nick (ref);
843 title = gst_tag_get_license_title (ref);
844 desc = gst_tag_get_license_description (ref);
845 fail_unless (nick != NULL, "no nick for license '%s'", ref);
846 fail_unless (title != NULL, "no title for license '%s'", ref);
847 GST_LOG ("ref: %s [nick %s]", ref, (nick) ? nick : "none");
848 GST_TRACE (" %s : %s", title, (desc) ? desc : "(no description)");
850 /* make sure the list contains no duplicates */
851 fail_if (g_hash_table_lookup (ht, (gpointer) ref) != NULL);
852 g_hash_table_insert (ht, (gpointer) ref, (gpointer) "meep");
854 g_hash_table_destroy (ht);
856 /* trailing slash shouldn't make a difference */
857 fail_unless_equals_int (gst_tag_get_license_flags
858 ("http://creativecommons.org/licenses/by-nd/1.0/"),
859 gst_tag_get_license_flags
860 ("http://creativecommons.org/licenses/by-nd/1.0"));
861 fail_unless_equals_string (gst_tag_get_license_nick
862 ("http://creativecommons.org/licenses/by-nd/1.0/"),
863 gst_tag_get_license_nick
864 ("http://creativecommons.org/licenses/by-nd/1.0"));
865 fail_unless_equals_int (gst_tag_get_license_flags
866 ("http://creativecommons.org/licenses/by-nd/2.5/ca/"),
867 gst_tag_get_license_flags
868 ("http://creativecommons.org/licenses/by-nd/2.5/ca"));
869 fail_unless_equals_string (gst_tag_get_license_nick
870 ("http://creativecommons.org/licenses/by-nd/2.5/ca/"),
871 gst_tag_get_license_nick
872 ("http://creativecommons.org/licenses/by-nd/2.5/ca"));
874 /* unknown licenses */
875 fail_unless (gst_tag_get_license_nick
876 ("http://creativecommons.org/licenses/by-nd/25/ca/") == NULL);
877 fail_unless (gst_tag_get_license_flags
878 ("http://creativecommons.org/licenses/by-nd/25/ca") == 0);
879 fail_unless (gst_tag_get_license_jurisdiction
880 ("http://creativecommons.org/licenses/by-nd/25/ca/") == NULL);
881 fail_unless (gst_tag_get_license_jurisdiction
882 ("http://creativecommons.org/licenses/by-nd/25/ca") == NULL);
883 fail_unless (gst_tag_get_license_title
884 ("http://creativecommons.org/licenses/by-nd/25/ca") == NULL);
885 fail_unless (gst_tag_get_license_jurisdiction
886 ("http://creativecommons.org/licenses/by-nd/25/ca") == NULL);
888 /* unknown prefixes even */
889 fail_unless (gst_tag_get_license_nick
890 ("http://copycats.org/licenses/by-nd/2.5/ca/") == NULL);
891 fail_unless (gst_tag_get_license_flags
892 ("http://copycats.org/licenses/by-nd/2.5/ca") == 0);
893 fail_unless (gst_tag_get_license_jurisdiction
894 ("http://copycats.org/licenses/by-nd/2.5/ca/") == NULL);
895 fail_unless (gst_tag_get_license_title
896 ("http://copycats.org/licenses/by-nd/2.5/ca/") == NULL);
897 fail_unless (gst_tag_get_license_description
898 ("http://copycats.org/licenses/by-nd/2.5/ca/") == NULL);
900 /* read list of liblicense refs from file */
901 path = g_build_filename (GST_TEST_FILES_PATH, "license-uris", NULL);
902 GST_LOG ("reading file '%s'", path);
903 if (!g_file_get_contents (path, &data, &data_len, &err)) {
904 g_error ("error loading test file: %s", err->message);
907 while (data_len > 0 && data[data_len - 1] == '\n') {
908 data[--data_len] = '\0';
911 liblicense_refs = g_strsplit (data, "\n", -1);
915 fail_unless (g_strv_length (lrefs) >= g_strv_length (liblicense_refs));
917 for (r = liblicense_refs; r != NULL && *r != NULL; ++r) {
918 GstTagLicenseFlags flags;
919 const gchar *version, *nick, *jur;
920 const gchar *ref = *r;
922 GST_LOG ("liblicense ref: %s", ref);
924 version = gst_tag_get_license_version (ref);
925 if (strstr (ref, "publicdomain") != NULL)
926 fail_unless (version == NULL);
928 fail_unless (version != NULL, "expected version for license %s", ref);
930 flags = gst_tag_get_license_flags (ref);
931 fail_unless (flags != 0, "expected non-zero flags for license %s", ref);
933 nick = gst_tag_get_license_nick (ref);
934 fail_unless (nick != NULL, "expected nick for license %s", ref);
936 jur = gst_tag_get_license_jurisdiction (ref);
937 if (g_str_has_suffix (ref, "de/")) {
938 fail_unless_equals_string (jur, "de");
939 } else if (g_str_has_suffix (ref, "scotland")) {
940 fail_unless_equals_string (jur, "scotland");
941 } else if (g_str_has_suffix (ref, ".0") || g_str_has_suffix (ref, ".1")) {
942 fail_unless (jur == NULL);
946 g_strfreev (liblicense_refs);
952 GST_START_TEST (test_xmp_formatting)
960 list = gst_tag_list_new (GST_TAG_TITLE, "test title",
961 GST_TAG_DESCRIPTION, "test decription",
962 GST_TAG_KEYWORDS, "keyword1", GST_TAG_KEYWORDS, "keyword2", NULL);
964 buf = gst_tag_list_to_xmp_buffer (list, FALSE);
965 fail_unless (buf != NULL);
967 text = gst_buffer_map (buf, &len, NULL, GST_MAP_READ);
969 /* check the content */
970 fail_unless (g_strrstr_len (text, len, "<?xpacket begin") == text);
971 fail_unless (g_strrstr_len (text, len, ">test title<") != NULL);
972 fail_unless (g_strrstr_len (text, len, ">test decription<") != NULL);
973 fail_unless (g_strrstr_len (text, len, ">keyword1<") != NULL);
974 fail_unless (g_strrstr_len (text, len, ">keyword2<") != NULL);
975 fail_unless (g_strrstr_len (text, len, "<?xpacket end") != NULL);
976 gst_buffer_unmap (buf, (gpointer) text, len);
978 gst_buffer_unref (buf);
979 gst_tag_list_free (list);
985 GST_START_TEST (test_xmp_parsing)
989 guint i, j, result_size;
991 const gchar *xmp_header =
992 "<?xpacket begin=\"\xEF\xBB\xBF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>"
993 "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"GStreamer\">"
994 "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">";
996 /* We used to write an extra trailing \n after the footer, keep compatibility
997 * with our old generated media by checking that it still can be parsed */
998 const gchar *xmp_footers[] = {
999 "</rdf:RDF>" "</x:xmpmeta>" "<?xpacket end=\"r\"?>",
1000 "</rdf:RDF>" "</x:xmpmeta>" "<?xpacket end=\"r\"?>\n",
1006 const gchar *xmp_data;
1012 "<rdf:Description rdf:about=\"\" />", 0, -1}, {
1013 "<rdf:Description rdf:about=\"\"></rdf:Description>", 0, -1}, {
1014 "<rdf:Description rdf:about=\"\" ></rdf:Description>", 0, -1}, {
1015 "<rdf:Description rdf:about=\"\"><dc:description>test</dc:description></rdf:Description>",
1017 "<rdf:Description rdf:about=\"\" dc:description=\"test\"></rdf:Description>",
1025 while (xmp_footers[j]) {
1026 while (test_data[i].xmp_data) {
1029 GST_DEBUG ("trying test-data %u", i);
1032 g_strconcat (xmp_header, test_data[i].xmp_data, xmp_footers[j], NULL);
1034 buf = gst_buffer_new ();
1035 len = strlen (text) + 1;
1036 gst_buffer_take_memory (buf, -1,
1037 gst_memory_new_wrapped (0, text, NULL, len, 0, len));
1039 list = gst_tag_list_from_xmp_buffer (buf);
1040 if (test_data[i].result_size >= 0) {
1041 fail_unless (list != NULL);
1043 result_size = gst_structure_n_fields ((GstStructure *) list);
1044 fail_unless (result_size == test_data[i].result_size);
1046 /* check the taglist content */
1047 switch (test_data[i].result_test) {
1049 ASSERT_TAG_LIST_HAS_STRING (list, "description", "test");
1056 gst_tag_list_free (list);
1058 gst_buffer_unref (buf);
1069 do_xmp_tag_serialization_deserialization (GstTagList * taglist,
1070 const gchar ** schemas)
1072 GstTagList *taglist2;
1075 buf = gst_tag_list_to_xmp_buffer_full (taglist, TRUE, schemas);
1076 taglist2 = gst_tag_list_from_xmp_buffer (buf);
1078 fail_unless (gst_tag_list_is_equal (taglist, taglist2));
1080 gst_buffer_unref (buf);
1081 gst_tag_list_free (taglist2);
1085 do_simple_xmp_tag_serialization_deserialization (const gchar * gsttag,
1088 GstTagList *taglist = gst_tag_list_new_empty ();
1090 gst_tag_list_add_value (taglist, GST_TAG_MERGE_REPLACE, gsttag, value);
1092 do_xmp_tag_serialization_deserialization (taglist, NULL);
1093 gst_tag_list_free (taglist);
1096 GST_START_TEST (test_xmp_tags_serialization_deserialization)
1098 GValue value = { 0 };
1100 GstDateTime *datetime;
1102 gst_tag_register_musicbrainz_tags ();
1104 g_value_init (&value, G_TYPE_STRING);
1105 g_value_set_static_string (&value, "my string");
1106 do_simple_xmp_tag_serialization_deserialization (GST_TAG_ARTIST, &value);
1107 do_simple_xmp_tag_serialization_deserialization (GST_TAG_COPYRIGHT, &value);
1108 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DESCRIPTION, &value);
1109 do_simple_xmp_tag_serialization_deserialization (GST_TAG_KEYWORDS, &value);
1110 do_simple_xmp_tag_serialization_deserialization (GST_TAG_TITLE, &value);
1111 do_simple_xmp_tag_serialization_deserialization (GST_TAG_VIDEO_CODEC, &value);
1112 do_simple_xmp_tag_serialization_deserialization (GST_TAG_GEO_LOCATION_COUNTRY,
1114 do_simple_xmp_tag_serialization_deserialization (GST_TAG_GEO_LOCATION_CITY,
1116 do_simple_xmp_tag_serialization_deserialization
1117 (GST_TAG_GEO_LOCATION_SUBLOCATION, &value);
1118 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DEVICE_MANUFACTURER,
1120 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DEVICE_MODEL,
1122 do_simple_xmp_tag_serialization_deserialization (GST_TAG_APPLICATION_NAME,
1125 g_value_set_static_string (&value, "rotate-0");
1126 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1128 g_value_set_static_string (&value, "flip-rotate-0");
1129 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1131 g_value_set_static_string (&value, "rotate-180");
1132 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1134 g_value_set_static_string (&value, "flip-rotate-180");
1135 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1137 g_value_set_static_string (&value, "flip-rotate-270");
1138 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1140 g_value_set_static_string (&value, "rotate-90");
1141 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1143 g_value_set_static_string (&value, "flip-rotate-90");
1144 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1146 g_value_set_static_string (&value, "rotate-270");
1147 do_simple_xmp_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1150 g_value_unset (&value);
1151 g_value_init (&value, G_TYPE_DOUBLE);
1153 g_value_set_double (&value, 0.0);
1154 do_simple_xmp_tag_serialization_deserialization
1155 (GST_TAG_GEO_LOCATION_LATITUDE, &value);
1156 do_simple_xmp_tag_serialization_deserialization
1157 (GST_TAG_GEO_LOCATION_LONGITUDE, &value);
1158 g_value_set_double (&value, 10.5);
1159 do_simple_xmp_tag_serialization_deserialization
1160 (GST_TAG_GEO_LOCATION_LATITUDE, &value);
1161 do_simple_xmp_tag_serialization_deserialization
1162 (GST_TAG_GEO_LOCATION_LONGITUDE, &value);
1163 g_value_set_double (&value, -32.375);
1164 do_simple_xmp_tag_serialization_deserialization
1165 (GST_TAG_GEO_LOCATION_LATITUDE, &value);
1166 do_simple_xmp_tag_serialization_deserialization
1167 (GST_TAG_GEO_LOCATION_LONGITUDE, &value);
1169 g_value_set_double (&value, 0);
1170 do_simple_xmp_tag_serialization_deserialization
1171 (GST_TAG_GEO_LOCATION_ELEVATION, &value);
1172 g_value_set_double (&value, 100);
1173 do_simple_xmp_tag_serialization_deserialization
1174 (GST_TAG_GEO_LOCATION_ELEVATION, &value);
1175 g_value_set_double (&value, 500.25);
1176 do_simple_xmp_tag_serialization_deserialization
1177 (GST_TAG_GEO_LOCATION_ELEVATION, &value);
1178 g_value_set_double (&value, -12.75);
1179 do_simple_xmp_tag_serialization_deserialization
1180 (GST_TAG_GEO_LOCATION_ELEVATION, &value);
1182 g_value_set_double (&value, 0.0);
1183 do_simple_xmp_tag_serialization_deserialization
1184 (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, &value);
1185 g_value_set_double (&value, 10.0);
1186 do_simple_xmp_tag_serialization_deserialization
1187 (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, &value);
1188 g_value_set_double (&value, 786.125);
1189 do_simple_xmp_tag_serialization_deserialization
1190 (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, &value);
1191 g_value_set_double (&value, -2.5);
1192 do_simple_xmp_tag_serialization_deserialization
1193 (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, &value);
1195 g_value_set_double (&value, 0.0);
1196 do_simple_xmp_tag_serialization_deserialization
1197 (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, &value);
1198 g_value_set_double (&value, 180.0);
1199 do_simple_xmp_tag_serialization_deserialization
1200 (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, &value);
1201 g_value_set_double (&value, 359.99);
1202 do_simple_xmp_tag_serialization_deserialization
1203 (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, &value);
1205 g_value_set_double (&value, 0.0);
1206 do_simple_xmp_tag_serialization_deserialization
1207 (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, &value);
1208 g_value_set_double (&value, 90.0);
1209 do_simple_xmp_tag_serialization_deserialization
1210 (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, &value);
1211 g_value_set_double (&value, 359.99);
1212 do_simple_xmp_tag_serialization_deserialization
1213 (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, &value);
1215 g_value_set_double (&value, 0.0);
1216 do_simple_xmp_tag_serialization_deserialization
1217 (GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
1218 g_value_set_double (&value, 1.0);
1219 do_simple_xmp_tag_serialization_deserialization
1220 (GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
1221 g_value_set_double (&value, -2.5);
1222 do_simple_xmp_tag_serialization_deserialization
1223 (GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
1224 g_value_unset (&value);
1226 g_value_init (&value, GST_TYPE_DATE);
1227 date = g_date_new_dmy (22, 3, 2010);
1228 gst_value_set_date (&value, date);
1230 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE, &value);
1231 g_value_unset (&value);
1233 g_value_init (&value, G_TYPE_UINT);
1234 g_value_set_uint (&value, 0);
1235 do_simple_xmp_tag_serialization_deserialization (GST_TAG_USER_RATING, &value);
1236 g_value_set_uint (&value, 100);
1237 do_simple_xmp_tag_serialization_deserialization (GST_TAG_USER_RATING, &value);
1238 g_value_set_uint (&value, 22);
1239 do_simple_xmp_tag_serialization_deserialization (GST_TAG_USER_RATING, &value);
1240 g_value_unset (&value);
1242 g_value_init (&value, GST_TYPE_DATE_TIME);
1243 datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10);
1244 g_value_set_boxed (&value, datetime);
1245 gst_date_time_unref (datetime);
1246 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1247 datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10.000125);
1248 g_value_set_boxed (&value, datetime);
1249 gst_date_time_unref (datetime);
1250 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1251 datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10.000001);
1252 g_value_set_boxed (&value, datetime);
1253 gst_date_time_unref (datetime);
1254 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1255 datetime = gst_date_time_new (0, 2010, 6, 22, 12, 5, 10.123456);
1256 g_value_set_boxed (&value, datetime);
1257 gst_date_time_unref (datetime);
1258 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1259 datetime = gst_date_time_new (-3, 2010, 6, 22, 12, 5, 10.123456);
1260 g_value_set_boxed (&value, datetime);
1261 gst_date_time_unref (datetime);
1262 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1263 datetime = gst_date_time_new (5, 2010, 6, 22, 12, 5, 10.123456);
1264 g_value_set_boxed (&value, datetime);
1265 gst_date_time_unref (datetime);
1266 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1267 datetime = gst_date_time_new_local_time (2010, 12, 2, 12, 5, 10.000043);
1268 g_value_set_boxed (&value, datetime);
1269 gst_date_time_unref (datetime);
1270 do_simple_xmp_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1271 g_value_unset (&value);
1277 GST_START_TEST (test_xmp_compound_tags)
1279 const gchar *schemas[] = { "Iptc4xmpExt", NULL };
1280 GstTagList *taglist = gst_tag_list_new_empty ();
1282 gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_KEYWORDS, "k1",
1283 GST_TAG_KEYWORDS, "k2", GST_TAG_TITLE, "title", GST_TAG_KEYWORDS, "k3",
1285 do_xmp_tag_serialization_deserialization (taglist, NULL);
1286 gst_tag_list_free (taglist);
1288 taglist = gst_tag_list_new_empty ();
1289 gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_GEO_LOCATION_COUNTRY,
1290 "Brazil", GST_TAG_GEO_LOCATION_CITY, "Campina Grande", NULL);
1291 do_xmp_tag_serialization_deserialization (taglist, schemas);
1292 gst_tag_list_free (taglist);
1298 GST_START_TEST (test_exif_parsing)
1300 GstTagList *taglist;
1302 GstByteWriter writer;
1303 const gchar *str = NULL;
1305 gst_byte_writer_init (&writer);
1309 gst_byte_writer_put_uint16_le (&writer, 1);
1313 gst_byte_writer_put_uint16_le (&writer, 0x8298);
1315 gst_byte_writer_put_uint16_le (&writer, 0x2);
1317 gst_byte_writer_put_uint32_le (&writer, strlen ("my copyright") + 1);
1319 gst_byte_writer_put_uint32_le (&writer, 8 + 14);
1322 gst_byte_writer_put_string (&writer, "my copyright");
1324 buf = gst_byte_writer_reset_and_get_buffer (&writer);
1326 taglist = gst_tag_list_from_exif_buffer (buf, G_LITTLE_ENDIAN, 8);
1328 fail_unless (gst_tag_list_get_tag_size (taglist, GST_TAG_COPYRIGHT) == 1);
1329 gst_tag_list_peek_string_index (taglist, GST_TAG_COPYRIGHT, 0, &str);
1330 fail_unless_equals_string (str, "my copyright");
1332 gst_tag_list_free (taglist);
1333 gst_buffer_unref (buf);
1340 do_exif_tag_serialization_deserialization (GstTagList * taglist)
1342 GstTagList *taglist2;
1346 buf = gst_tag_list_to_exif_buffer (taglist, G_LITTLE_ENDIAN, 0);
1347 taglist2 = gst_tag_list_from_exif_buffer (buf, G_LITTLE_ENDIAN, 0);
1348 gst_buffer_unref (buf);
1350 fail_unless (gst_tag_list_is_equal (taglist, taglist2));
1351 gst_tag_list_free (taglist2);
1354 buf = gst_tag_list_to_exif_buffer (taglist, G_BIG_ENDIAN, 0);
1355 taglist2 = gst_tag_list_from_exif_buffer (buf, G_BIG_ENDIAN, 0);
1356 gst_buffer_unref (buf);
1358 fail_unless (gst_tag_list_is_equal (taglist, taglist2));
1359 gst_tag_list_free (taglist2);
1362 buf = gst_tag_list_to_exif_buffer_with_tiff_header (taglist);
1363 taglist2 = gst_tag_list_from_exif_buffer_with_tiff_header (buf);
1364 gst_buffer_unref (buf);
1366 fail_unless (gst_tag_list_is_equal (taglist, taglist2));
1367 gst_tag_list_free (taglist2);
1371 do_simple_exif_tag_serialization_deserialization (const gchar * gsttag,
1374 GstTagList *taglist = gst_tag_list_new_empty ();
1376 gst_tag_list_add_value (taglist, GST_TAG_MERGE_REPLACE, gsttag, value);
1377 do_exif_tag_serialization_deserialization (taglist);
1379 gst_tag_list_free (taglist);
1383 * Adds tags from multiple ifd tables and tries serializing them
1385 GST_START_TEST (test_exif_multiple_tags)
1387 GstTagList *taglist;
1388 GstDateTime *datetime;
1389 GValue value = { 0 };
1391 gst_tag_register_musicbrainz_tags ();
1393 taglist = gst_tag_list_new (GST_TAG_ARTIST, "artist",
1394 GST_TAG_DEVICE_MANUFACTURER, "make",
1395 GST_TAG_DEVICE_MODEL, "model", GST_TAG_GEO_LOCATION_LATITUDE, 45.5,
1396 GST_TAG_GEO_LOCATION_LONGITUDE, -10.25,
1397 GST_TAG_IMAGE_HORIZONTAL_PPI, 300.0,
1398 GST_TAG_IMAGE_VERTICAL_PPI, 300.0, NULL);
1400 g_value_init (&value, GST_TYPE_DATE_TIME);
1401 datetime = gst_date_time_new_local_time (2010, 6, 22, 12, 5, 10);
1402 g_value_set_boxed (&value, datetime);
1403 gst_date_time_unref (datetime);
1404 gst_tag_list_add_value (taglist, GST_TAG_MERGE_APPEND, GST_TAG_DATE_TIME,
1406 g_value_unset (&value);
1408 do_exif_tag_serialization_deserialization (taglist);
1410 gst_tag_list_free (taglist);
1416 GST_START_TEST (test_exif_tags_serialization_deserialization)
1418 GValue value = { 0 };
1419 GstDateTime *datetime = NULL;
1420 GstBuffer *buf = NULL;
1422 GstTagList *taglist;
1425 gst_tag_register_musicbrainz_tags ();
1427 g_value_init (&value, G_TYPE_STRING);
1428 g_value_set_static_string (&value, "my string");
1429 do_simple_exif_tag_serialization_deserialization (GST_TAG_COPYRIGHT, &value);
1430 g_value_set_static_string (&value, "ty");
1431 do_simple_exif_tag_serialization_deserialization (GST_TAG_ARTIST, &value);
1432 g_value_set_static_string (&value, "Company Software 1.2b (info)");
1433 do_simple_exif_tag_serialization_deserialization (GST_TAG_APPLICATION_NAME,
1436 /* non ascii chars */
1437 g_value_set_static_string (&value, "AaÄäEeËëIiÏïOoÖöUuÜü");
1438 do_simple_exif_tag_serialization_deserialization (GST_TAG_ARTIST, &value);
1439 g_value_set_static_string (&value, "Äë");
1440 do_simple_exif_tag_serialization_deserialization (GST_TAG_ARTIST, &value);
1442 /* image orientation tests */
1443 g_value_set_static_string (&value, "rotate-0");
1444 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1446 g_value_set_static_string (&value, "flip-rotate-0");
1447 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1449 g_value_set_static_string (&value, "rotate-180");
1450 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1452 g_value_set_static_string (&value, "flip-rotate-180");
1453 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1455 g_value_set_static_string (&value, "flip-rotate-270");
1456 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1458 g_value_set_static_string (&value, "rotate-90");
1459 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1461 g_value_set_static_string (&value, "flip-rotate-90");
1462 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1464 g_value_set_static_string (&value, "rotate-270");
1465 do_simple_exif_tag_serialization_deserialization (GST_TAG_IMAGE_ORIENTATION,
1468 /* exposure program */
1469 g_value_set_static_string (&value, "undefined");
1470 do_simple_exif_tag_serialization_deserialization
1471 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1472 g_value_set_static_string (&value, "manual");
1473 do_simple_exif_tag_serialization_deserialization
1474 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1475 g_value_set_static_string (&value, "normal");
1476 do_simple_exif_tag_serialization_deserialization
1477 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1478 g_value_set_static_string (&value, "aperture-priority");
1479 do_simple_exif_tag_serialization_deserialization
1480 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1481 g_value_set_static_string (&value, "shutter-priority");
1482 do_simple_exif_tag_serialization_deserialization
1483 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1484 g_value_set_static_string (&value, "creative");
1485 do_simple_exif_tag_serialization_deserialization
1486 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1487 g_value_set_static_string (&value, "action");
1488 do_simple_exif_tag_serialization_deserialization
1489 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1490 g_value_set_static_string (&value, "portrait");
1491 do_simple_exif_tag_serialization_deserialization
1492 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1493 g_value_set_static_string (&value, "landscape");
1494 do_simple_exif_tag_serialization_deserialization
1495 (GST_TAG_CAPTURING_EXPOSURE_PROGRAM, &value);
1498 g_value_set_static_string (&value, "auto-exposure");
1499 do_simple_exif_tag_serialization_deserialization
1500 (GST_TAG_CAPTURING_EXPOSURE_MODE, &value);
1501 g_value_set_static_string (&value, "manual-exposure");
1502 do_simple_exif_tag_serialization_deserialization
1503 (GST_TAG_CAPTURING_EXPOSURE_MODE, &value);
1504 g_value_set_static_string (&value, "auto-bracket");
1505 do_simple_exif_tag_serialization_deserialization
1506 (GST_TAG_CAPTURING_EXPOSURE_MODE, &value);
1508 /* scene capture type */
1509 g_value_set_static_string (&value, "standard");
1510 do_simple_exif_tag_serialization_deserialization
1511 (GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE, &value);
1512 g_value_set_static_string (&value, "portrait");
1513 do_simple_exif_tag_serialization_deserialization
1514 (GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE, &value);
1515 g_value_set_static_string (&value, "landscape");
1516 do_simple_exif_tag_serialization_deserialization
1517 (GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE, &value);
1518 g_value_set_static_string (&value, "night-scene");
1519 do_simple_exif_tag_serialization_deserialization
1520 (GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE, &value);
1522 g_value_set_static_string (&value, "none");
1523 do_simple_exif_tag_serialization_deserialization
1524 (GST_TAG_CAPTURING_GAIN_ADJUSTMENT, &value);
1525 g_value_set_static_string (&value, "high-gain-up");
1526 do_simple_exif_tag_serialization_deserialization
1527 (GST_TAG_CAPTURING_GAIN_ADJUSTMENT, &value);
1528 g_value_set_static_string (&value, "low-gain-up");
1529 do_simple_exif_tag_serialization_deserialization
1530 (GST_TAG_CAPTURING_GAIN_ADJUSTMENT, &value);
1531 g_value_set_static_string (&value, "high-gain-down");
1532 do_simple_exif_tag_serialization_deserialization
1533 (GST_TAG_CAPTURING_GAIN_ADJUSTMENT, &value);
1534 g_value_set_static_string (&value, "low-gain-down");
1535 do_simple_exif_tag_serialization_deserialization
1536 (GST_TAG_CAPTURING_GAIN_ADJUSTMENT, &value);
1538 g_value_set_static_string (&value, "auto");
1539 do_simple_exif_tag_serialization_deserialization
1540 (GST_TAG_CAPTURING_WHITE_BALANCE, &value);
1541 g_value_set_static_string (&value, "manual");
1542 do_simple_exif_tag_serialization_deserialization
1543 (GST_TAG_CAPTURING_WHITE_BALANCE, &value);
1545 g_value_set_static_string (&value, "normal");
1546 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_CONTRAST,
1548 g_value_set_static_string (&value, "hard");
1549 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_CONTRAST,
1551 g_value_set_static_string (&value, "soft");
1552 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_CONTRAST,
1555 g_value_set_static_string (&value, "normal");
1556 do_simple_exif_tag_serialization_deserialization
1557 (GST_TAG_CAPTURING_SATURATION, &value);
1558 g_value_set_static_string (&value, "low-saturation");
1559 do_simple_exif_tag_serialization_deserialization
1560 (GST_TAG_CAPTURING_SATURATION, &value);
1561 g_value_set_static_string (&value, "high-saturation");
1562 do_simple_exif_tag_serialization_deserialization
1563 (GST_TAG_CAPTURING_SATURATION, &value);
1565 g_value_set_static_string (&value, "normal");
1566 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SHARPNESS,
1568 g_value_set_static_string (&value, "hard");
1569 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SHARPNESS,
1571 g_value_set_static_string (&value, "soft");
1572 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SHARPNESS,
1575 g_value_set_static_string (&value, "unknown");
1576 do_simple_exif_tag_serialization_deserialization
1577 (GST_TAG_CAPTURING_METERING_MODE, &value);
1578 g_value_set_static_string (&value, "average");
1579 do_simple_exif_tag_serialization_deserialization
1580 (GST_TAG_CAPTURING_METERING_MODE, &value);
1581 g_value_set_static_string (&value, "center-weighted-average");
1582 do_simple_exif_tag_serialization_deserialization
1583 (GST_TAG_CAPTURING_METERING_MODE, &value);
1584 g_value_set_static_string (&value, "spot");
1585 do_simple_exif_tag_serialization_deserialization
1586 (GST_TAG_CAPTURING_METERING_MODE, &value);
1587 g_value_set_static_string (&value, "multi-spot");
1588 do_simple_exif_tag_serialization_deserialization
1589 (GST_TAG_CAPTURING_METERING_MODE, &value);
1590 g_value_set_static_string (&value, "pattern");
1591 do_simple_exif_tag_serialization_deserialization
1592 (GST_TAG_CAPTURING_METERING_MODE, &value);
1593 g_value_set_static_string (&value, "partial");
1594 do_simple_exif_tag_serialization_deserialization
1595 (GST_TAG_CAPTURING_METERING_MODE, &value);
1596 g_value_set_static_string (&value, "other");
1597 do_simple_exif_tag_serialization_deserialization
1598 (GST_TAG_CAPTURING_METERING_MODE, &value);
1600 g_value_set_static_string (&value, "dsc");
1601 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
1603 g_value_set_static_string (&value, "other");
1604 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
1606 g_value_set_static_string (&value, "transparent-scanner");
1607 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
1609 g_value_set_static_string (&value, "reflex-scanner");
1610 do_simple_exif_tag_serialization_deserialization (GST_TAG_CAPTURING_SOURCE,
1612 g_value_unset (&value);
1614 g_value_init (&value, G_TYPE_DOUBLE);
1615 g_value_set_double (&value, 30.5);
1616 do_simple_exif_tag_serialization_deserialization
1617 (GST_TAG_GEO_LOCATION_LATITUDE, &value);
1618 g_value_set_double (&value, -12.125);
1619 do_simple_exif_tag_serialization_deserialization
1620 (GST_TAG_GEO_LOCATION_LATITUDE, &value);
1621 g_value_set_double (&value, 0);
1622 do_simple_exif_tag_serialization_deserialization
1623 (GST_TAG_GEO_LOCATION_LONGITUDE, &value);
1624 g_value_set_double (&value, 65.0);
1625 do_simple_exif_tag_serialization_deserialization
1626 (GST_TAG_GEO_LOCATION_LONGITUDE, &value);
1627 g_value_set_double (&value, -0.75);
1628 do_simple_exif_tag_serialization_deserialization
1629 (GST_TAG_GEO_LOCATION_LONGITUDE, &value);
1631 g_value_set_double (&value, 0.0);
1632 do_simple_exif_tag_serialization_deserialization
1633 (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, &value);
1634 g_value_set_double (&value, 180.5);
1635 do_simple_exif_tag_serialization_deserialization
1636 (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, &value);
1637 g_value_set_double (&value, 0.12345);
1638 do_simple_exif_tag_serialization_deserialization
1639 (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, &value);
1640 g_value_set_double (&value, 359.9);
1641 do_simple_exif_tag_serialization_deserialization
1642 (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, &value);
1644 g_value_set_double (&value, 0.0);
1645 do_simple_exif_tag_serialization_deserialization
1646 (GST_TAG_GEO_LOCATION_ELEVATION, &value);
1647 g_value_set_double (&value, 321.456);
1648 do_simple_exif_tag_serialization_deserialization
1649 (GST_TAG_GEO_LOCATION_ELEVATION, &value);
1650 g_value_set_double (&value, -12.56);
1651 do_simple_exif_tag_serialization_deserialization
1652 (GST_TAG_GEO_LOCATION_ELEVATION, &value);
1654 g_value_set_double (&value, 0);
1655 do_simple_exif_tag_serialization_deserialization
1656 (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, &value);
1657 g_value_set_double (&value, 100 / 3.6);
1658 do_simple_exif_tag_serialization_deserialization
1659 (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, &value);
1661 g_value_set_double (&value, 0);
1662 do_simple_exif_tag_serialization_deserialization
1663 (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, &value);
1664 g_value_set_double (&value, 50.25);
1665 do_simple_exif_tag_serialization_deserialization
1666 (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, &value);
1668 g_value_set_double (&value, 0);
1669 do_simple_exif_tag_serialization_deserialization
1670 (GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO, &value);
1671 g_value_set_double (&value, 2.5);
1672 do_simple_exif_tag_serialization_deserialization
1673 (GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO, &value);
1674 g_value_set_double (&value, 8.75);
1675 do_simple_exif_tag_serialization_deserialization
1676 (GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO, &value);
1678 g_value_set_double (&value, 20.0);
1679 do_simple_exif_tag_serialization_deserialization
1680 (GST_TAG_CAPTURING_FOCAL_LENGTH, &value);
1681 g_value_set_double (&value, 5.5);
1682 do_simple_exif_tag_serialization_deserialization
1683 (GST_TAG_CAPTURING_FOCAL_LENGTH, &value);
1685 g_value_set_double (&value, 16);
1686 do_simple_exif_tag_serialization_deserialization
1687 (GST_TAG_CAPTURING_FOCAL_RATIO, &value);
1688 g_value_set_double (&value, 2.7);
1689 do_simple_exif_tag_serialization_deserialization
1690 (GST_TAG_CAPTURING_FOCAL_LENGTH, &value);
1692 g_value_set_double (&value, 96.0);
1693 do_simple_exif_tag_serialization_deserialization
1694 (GST_TAG_IMAGE_HORIZONTAL_PPI, &value);
1695 g_value_set_double (&value, 300.0);
1696 do_simple_exif_tag_serialization_deserialization
1697 (GST_TAG_IMAGE_HORIZONTAL_PPI, &value);
1698 g_value_set_double (&value, 87.5);
1699 do_simple_exif_tag_serialization_deserialization
1700 (GST_TAG_IMAGE_VERTICAL_PPI, &value);
1701 g_value_set_double (&value, 600.0);
1702 do_simple_exif_tag_serialization_deserialization
1703 (GST_TAG_IMAGE_VERTICAL_PPI, &value);
1705 g_value_set_double (&value, 0.0);
1706 do_simple_exif_tag_serialization_deserialization
1707 (GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
1708 g_value_set_double (&value, 1.0);
1709 do_simple_exif_tag_serialization_deserialization
1710 (GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
1711 g_value_set_double (&value, -2.5);
1712 do_simple_exif_tag_serialization_deserialization
1713 (GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
1714 g_value_unset (&value);
1716 g_value_init (&value, G_TYPE_INT);
1717 g_value_set_int (&value, 400);
1718 do_simple_exif_tag_serialization_deserialization
1719 (GST_TAG_CAPTURING_ISO_SPEED, &value);
1720 g_value_set_int (&value, 1600);
1721 do_simple_exif_tag_serialization_deserialization
1722 (GST_TAG_CAPTURING_ISO_SPEED, &value);
1723 g_value_unset (&value);
1725 g_value_init (&value, GST_TYPE_DATE_TIME);
1726 datetime = gst_date_time_new_local_time (2010, 6, 22, 12, 5, 10);
1727 g_value_set_boxed (&value, datetime);
1728 gst_date_time_unref (datetime);
1729 do_simple_exif_tag_serialization_deserialization (GST_TAG_DATE_TIME, &value);
1730 g_value_unset (&value);
1732 g_value_init (&value, GST_TYPE_BUFFER);
1733 buf = gst_buffer_new_and_alloc (1024);
1734 data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
1735 for (i = 0; i < 1024; i++)
1737 gst_buffer_unmap (buf, data, 1024);
1738 gst_value_set_buffer (&value, buf);
1739 gst_buffer_unref (buf);
1740 do_simple_exif_tag_serialization_deserialization (GST_TAG_APPLICATION_DATA,
1742 g_value_unset (&value);
1744 g_value_init (&value, GST_TYPE_FRACTION);
1745 gst_value_set_fraction (&value, 1, 1);
1746 do_simple_exif_tag_serialization_deserialization
1747 (GST_TAG_CAPTURING_SHUTTER_SPEED, &value);
1748 gst_value_set_fraction (&value, 1, 30);
1749 do_simple_exif_tag_serialization_deserialization
1750 (GST_TAG_CAPTURING_SHUTTER_SPEED, &value);
1751 gst_value_set_fraction (&value, 1, 200);
1752 do_simple_exif_tag_serialization_deserialization
1753 (GST_TAG_CAPTURING_SHUTTER_SPEED, &value);
1754 gst_value_set_fraction (&value, 1, 8000);
1755 do_simple_exif_tag_serialization_deserialization
1756 (GST_TAG_CAPTURING_SHUTTER_SPEED, &value);
1757 g_value_unset (&value);
1759 /* flash is a little bit more tricky, because 2 tags are merged into 1 in
1761 taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, FALSE,
1762 GST_TAG_CAPTURING_FLASH_MODE, "auto", NULL);
1763 do_exif_tag_serialization_deserialization (taglist);
1764 gst_tag_list_free (taglist);
1766 taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, TRUE,
1767 GST_TAG_CAPTURING_FLASH_MODE, "auto", NULL);
1768 do_exif_tag_serialization_deserialization (taglist);
1769 gst_tag_list_free (taglist);
1771 taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, FALSE,
1772 GST_TAG_CAPTURING_FLASH_MODE, "never", NULL);
1773 do_exif_tag_serialization_deserialization (taglist);
1774 gst_tag_list_free (taglist);
1776 taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, TRUE,
1777 GST_TAG_CAPTURING_FLASH_MODE, "always", NULL);
1778 do_exif_tag_serialization_deserialization (taglist);
1779 gst_tag_list_free (taglist);
1787 Suite *s = suite_create ("tag support library");
1788 TCase *tc_chain = tcase_create ("general");
1790 suite_add_tcase (s, tc_chain);
1791 tcase_add_test (tc_chain, test_musicbrainz_tag_registration);
1792 tcase_add_test (tc_chain, test_parse_extended_comment);
1793 tcase_add_test (tc_chain, test_vorbis_tags);
1794 tcase_add_test (tc_chain, test_id3_tags);
1795 tcase_add_test (tc_chain, test_id3v1_utf8_tag);
1796 tcase_add_test (tc_chain, test_language_utils);
1797 tcase_add_test (tc_chain, test_license_utils);
1798 tcase_add_test (tc_chain, test_xmp_formatting);
1799 tcase_add_test (tc_chain, test_xmp_parsing);
1800 tcase_add_test (tc_chain, test_xmp_tags_serialization_deserialization);
1801 tcase_add_test (tc_chain, test_xmp_compound_tags);
1802 tcase_add_test (tc_chain, test_exif_parsing);
1803 tcase_add_test (tc_chain, test_exif_tags_serialization_deserialization);
1804 tcase_add_test (tc_chain, test_exif_multiple_tags);
1809 main (int argc, char **argv)
1813 Suite *s = tag_suite ();
1814 SRunner *sr = srunner_create (s);
1816 gst_check_init (&argc, &argv);
1818 srunner_run_all (sr, CK_NORMAL);
1819 nf = srunner_ntests_failed (sr);