ext, gst, gst-libs, tests: update for tag list API changes
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 30 Oct 2011 11:09:10 +0000 (11:09 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Mon, 31 Oct 2011 14:22:39 +0000 (14:22 +0000)
21 files changed:
ext/ogg/gstoggdemux.c
ext/ogg/gstoggstream.c
ext/ogg/gstogmparse.c
ext/theora/gsttheoradec.c
ext/vorbis/gstvorbisdec.c
ext/vorbis/gstvorbisenc.c
gst-libs/gst/audio/gstaudioencoder.c
gst-libs/gst/cdda/gstcddabasesrc.c
gst-libs/gst/riff/riff-read.c
gst-libs/gst/tag/gstexiftag.c
gst-libs/gst/tag/gstid3tag.c
gst-libs/gst/tag/gstvorbistag.c
gst-libs/gst/tag/gstxmptag.c
gst-libs/gst/tag/id3v2.c
gst/audiotestsrc/gstaudiotestsrc.c
gst/subparse/gstssaparse.c
gst/subparse/gstsubparse.c
tests/check/elements/vorbistag.c
tests/check/libs/pbutils.c
tests/check/libs/tag.c
tests/check/libs/xmpwriter.c

index 117f1ec50a23af24fefd41e95f2eb35c305e8e92..ea42dd56d804510f669f88631e8b0ecc695f93e3 100644 (file)
@@ -1714,7 +1714,7 @@ gst_ogg_chain_new_stream (GstOggChain * chain, guint32 serialno)
     goto init_failed;
 
   /* FIXME: either do something with it or remove it */
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_SERIAL, serialno,
       NULL);
   gst_tag_list_free (list);
@@ -2406,7 +2406,7 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain,
     gst_ogg_demux_send_event (ogg, event);
 
     gst_element_found_tags (GST_ELEMENT_CAST (ogg),
-        gst_tag_list_new_full (GST_TAG_CONTAINER_FORMAT, "Ogg", NULL));
+        gst_tag_list_new (GST_TAG_CONTAINER_FORMAT, "Ogg", NULL));
   }
 
   GST_DEBUG_OBJECT (ogg, "starting chain");
index f43847af416ec7e6e443ee658e4c657e1ba67067..f09f02874f08227fa42cfd34912f00cac62c73ee 100644 (file)
@@ -461,7 +461,7 @@ extract_tags_theora (GstOggStream * pad, ogg_packet * packet)
         (const guint8 *) "\201theora", 7, &pad->taglist);
 
     if (!pad->taglist)
-      pad->taglist = gst_tag_list_new ();
+      pad->taglist = gst_tag_list_new_empty ();
 
     if (pad->bitrate)
       gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
@@ -775,7 +775,7 @@ extract_tags_vorbis (GstOggStream * pad, ogg_packet * packet)
         (const guint8 *) "\003vorbis", 7, &pad->taglist);
 
     if (!pad->taglist)
-      pad->taglist = gst_tag_list_new ();
+      pad->taglist = gst_tag_list_new_empty ();
 
     gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
         GST_TAG_ENCODER_VERSION, pad->version, NULL);
@@ -866,7 +866,7 @@ extract_tags_count (GstOggStream * pad, ogg_packet * packet)
     tag_list_from_vorbiscomment_packet (packet, NULL, 0, &pad->taglist);
 
     if (!pad->taglist)
-      pad->taglist = gst_tag_list_new ();
+      pad->taglist = gst_tag_list_new_empty ();
 
     if (pad->bitrate)
       gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
@@ -1796,7 +1796,7 @@ extract_tags_kate (GstOggStream * pad, ogg_packet * packet)
       g_strdelimit (language, NULL, '\0');
       canonical = gst_tag_get_language_code_iso_639_1 (language);
       if (canonical) {
-        list = gst_tag_list_new_full (GST_TAG_LANGUAGE_CODE, canonical, NULL);
+        list = gst_tag_list_new (GST_TAG_LANGUAGE_CODE, canonical, NULL);
       } else {
         GST_WARNING ("Unknown or invalid language code %s, ignored", language);
       }
index 5e6b8efe82c83ce68568336b6b55e4971ed1eb9a..b06c1ab30346059d93034f4c5ca90b50c64a7987 100644 (file)
@@ -668,9 +668,7 @@ gst_ogm_parse_stream_header (GstOgmParse * ogm, const guint8 * data, guint size)
     {
       GstTagList *tags;
 
-      tags = gst_tag_list_new ();
-      gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_SUBTITLE_CODEC,
-          "Ogm", NULL);
+      tags = gst_tag_list_new (GST_TAG_SUBTITLE_CODEC, "Ogm", NULL);
       gst_element_found_tags_for_pad (GST_ELEMENT (ogm), ogm->srcpad, tags);
     }
   }
index a7418b8543d733eabdd0e59d71fe92a38bd0e07e..c1b22d3e4d6ab13ea98663a747601d69974a0f7c 100644 (file)
@@ -769,7 +769,7 @@ theora_handle_comment_packet (GstTheoraDec * dec, ogg_packet * packet)
 
   if (!list) {
     GST_ERROR_OBJECT (dec, "couldn't decode comments");
-    list = gst_tag_list_new ();
+    list = gst_tag_list_new_empty ();
   }
   if (encoder) {
     gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
index 45f0dc853a820e9c91cc33734e505567002f00df..910eb6d835e922e7f50f75beeb63a374eb71f968 100644 (file)
@@ -276,6 +276,7 @@ vorbis_handle_identification_packet (GstVorbisDec * vd)
   return GST_FLOW_OK;
 }
 
+/* FIXME 0.11: remove tag handling and let container take care of that? */
 static GstFlowReturn
 vorbis_handle_comment_packet (GstVorbisDec * vd, ogg_packet * packet)
 {
@@ -303,7 +304,7 @@ vorbis_handle_comment_packet (GstVorbisDec * vd, ogg_packet * packet)
 
   if (!vd->taglist) {
     GST_ERROR_OBJECT (vd, "couldn't decode comments");
-    vd->taglist = gst_tag_list_new ();
+    vd->taglist = gst_tag_list_new_empty ();
   }
   if (encoder) {
     if (encoder[0])
index 3ea4b6d16f614ee5b9e6c71e79e5766135a1b542..8460b7615613e3b3d950d16008c996d4c1ee3afa 100644 (file)
@@ -226,7 +226,7 @@ gst_vorbis_enc_start (GstAudioEncoder * enc)
   GstVorbisEnc *vorbisenc = GST_VORBISENC (enc);
 
   GST_DEBUG_OBJECT (enc, "start");
-  vorbisenc->tags = gst_tag_list_new ();
+  vorbisenc->tags = gst_tag_list_new_empty ();
   vorbisenc->header_sent = FALSE;
 
   return TRUE;
index 2a7a1af40e2492426f915e1fd9d5429290c9c706..4952236280200ff4a3e4184b6b9292e21e66c7ff 100644 (file)
@@ -1686,7 +1686,7 @@ gst_audio_encoder_activate (GstAudioEncoder * enc, gboolean active)
 
     if (enc->priv->tags)
       gst_tag_list_free (enc->priv->tags);
-    enc->priv->tags = gst_tag_list_new ();
+    enc->priv->tags = gst_tag_list_new_empty ();
 
     if (!enc->priv->active && klass->start)
       result = klass->start (enc);
index 6e09fbd37e3c197ed6fa4b28aac8bcc17706d9b7..6768df0a803f853072736b322b2f60cdb90b7049 100644 (file)
@@ -1294,7 +1294,7 @@ gst_cdda_base_src_add_tags (GstCddaBaseSrc * src)
     guint num_sectors;
 
     if (src->tracks[i].tags == NULL)
-      src->tracks[i].tags = gst_tag_list_new ();
+      src->tracks[i].tags = gst_tag_list_new_empty ();
 
     num_sectors = src->tracks[i].end - src->tracks[i].start + 1;
     gst_cdda_base_src_convert (src, sector_format, num_sectors,
@@ -1428,7 +1428,7 @@ gst_cdda_base_src_start (GstBaseSrc * basesrc)
 
   GST_LOG_OBJECT (basesrc, "opening device %s", device);
 
-  src->tags = gst_tag_list_new ();
+  src->tags = gst_tag_list_new_empty ();
 
   ret = klass->open (src, device);
   g_free (device);
index 4ed77a741a21a4fa0216e41b7c0ed53aef23a3e9..b3ac371ec763d455b8ff132dcae0e35a6d072f6a 100644 (file)
@@ -650,7 +650,7 @@ gst_riff_parse_info (GstElement * element,
   }
   data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
 
-  taglist = gst_tag_list_new ();
+  taglist = gst_tag_list_new_empty ();
 
   ptr = data;
   left = size;
index 967f5351a59493f48a5645aea78b3bc202bd2658..ef74de19ce96ce61f6aed4225e812a26547c4802 100644 (file)
@@ -458,7 +458,7 @@ gst_exif_reader_init (GstExifReader * reader, gint byte_order,
 {
   ensure_exif_tags ();
 
-  reader->taglist = gst_tag_list_new ();
+  reader->taglist = gst_tag_list_new_empty ();
   reader->buffer = buf;
   reader->base_offset = base_offset;
   reader->byte_order = byte_order;
index 8b1b8f1db745a46bd1b8c9a3fbf6bf03d1316fd2..021bffa1f4c27804abb848e0dd8e6ac5a5f90536 100644 (file)
@@ -261,7 +261,7 @@ gst_tag_list_new_from_id3v1 (const guint8 * data)
 
   if (data[0] != 'T' || data[1] != 'A' || data[2] != 'G')
     return NULL;
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_tag_extract_id3v1_string (list, GST_TAG_TITLE, (gchar *) & data[3], 30);
   gst_tag_extract_id3v1_string (list, GST_TAG_ARTIST, (gchar *) & data[33], 30);
   gst_tag_extract_id3v1_string (list, GST_TAG_ALBUM, (gchar *) & data[63], 30);
index 44cb50f32d3294ccad2d17debaf90c6264041ec5..8f9a81b5e1d3be3b18070d8d1a574f355028c1a3 100644 (file)
@@ -459,7 +459,7 @@ gst_tag_list_from_vorbiscomment (const guint8 * data, gsize size,
   g_return_val_if_fail (data != NULL, NULL);
   g_return_val_if_fail (id_data != NULL || id_data_length == 0, NULL);
 
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
 
   if (size < 11 || size <= id_data_length + 4)
     goto error;
index 0c178b4df1c80ab1af6d73f1adb9bd8dd9efb8cc..9a2b2ca063ff64dccfcbdab8312ecc387cfc35cf 100644 (file)
@@ -1343,7 +1343,7 @@ gst_tag_list_from_xmp_buffer (GstBuffer * buffer)
 
   /* no tag can be longer that the whole buffer */
   part = g_malloc (xp2 - xp1);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
 
   /* parse data into a list of nodes */
   /* data is between xp1..xp2 */
index f1f2e4a65e716984da1f0c811ae7383811897658..f5c4076e949cac45094d1291d6abfb81e1b23d2b 100644 (file)
@@ -479,7 +479,7 @@ id3v2_frames_to_tag_list (ID3TagsWorking * work, guint size)
     return FALSE;               /* Must have at least one frame */
   }
 
-  work->tags = gst_tag_list_new ();
+  work->tags = gst_tag_list_new_empty ();
 
   while (work->hdr.frame_data_size > frame_hdr_size) {
     guint frame_size = 0;
index ba6f255c836146df768aee53aab21107a646ee9a..2d819fd64f873ed8c5a9d3e8657a17cbc24823cc 100644 (file)
@@ -1113,10 +1113,7 @@ gst_audio_test_src_fill (GstBaseSrc * basesrc, guint64 offset,
   if (!src->tags_pushed) {
     GstTagList *taglist;
 
-    taglist = gst_tag_list_new ();
-
-    gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND,
-        GST_TAG_DESCRIPTION, "audiotest wave", NULL);
+    taglist = gst_tag_list_new (GST_TAG_DESCRIPTION, "audiotest wave", NULL);
 
     eclass = GST_ELEMENT_CLASS (parent_class);
     if (eclass->send_event)
index dc75364c3d34dbde220033a4bfae30ea2741606c..6eb80f2ad619d02b2ef6f2b016fbf876220deca2 100644 (file)
@@ -319,7 +319,7 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf)
   if (G_UNLIKELY (parse->send_tags)) {
     GstTagList *tags;
 
-    tags = gst_tag_list_new ();
+    tags = gst_tag_list_new_empty ();
     gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_SUBTITLE_CODEC,
         "SubStation Alpha", NULL);
     gst_element_found_tags_for_pad (GST_ELEMENT (parse), parse->srcpad, tags);
index 88e3f7fbd8e4df26bad6a9b9e9b38d47212a797c..712e4db9dee370a7624b0b2289996014b9607b22 100644 (file)
@@ -1461,12 +1461,9 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
 
     /* push tags */
     if (self->subtitle_codec != NULL) {
-      GstTagList *tags;
-
-      tags = gst_tag_list_new ();
-      gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_SUBTITLE_CODEC,
-          self->subtitle_codec, NULL);
-      gst_element_found_tags_for_pad (GST_ELEMENT (self), self->srcpad, tags);
+      gst_element_found_tags_for_pad (GST_ELEMENT (self), self->srcpad,
+          gst_tag_list_new (GST_TAG_SUBTITLE_CODEC, self->subtitle_codec,
+              NULL));
     }
   }
 
index 960162523ca0ff371847277cb6d0b2342de56219..4b7196bcd364458a0db32cbe117a8f8e2b787a3d 100644 (file)
@@ -234,7 +234,7 @@ GST_START_TEST (test_empty_tags_set)
 
   vorbistag = setup_vorbistag ();
 
-  tags = gst_tag_list_new ();
+  tags = gst_tag_list_new_empty ();
   gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_TITLE, "foobar", NULL);
   gst_tag_setter_merge_tags (GST_TAG_SETTER (vorbistag), tags,
       GST_TAG_MERGE_REPLACE);
@@ -290,7 +290,7 @@ GST_START_TEST (test_filled_tags_unset)
 
   vorbistag = setup_vorbistag ();
 
-  tags = gst_tag_list_new ();
+  tags = gst_tag_list_new_empty ();
   gst_tag_setter_merge_tags (GST_TAG_SETTER (vorbistag), tags,
       GST_TAG_MERGE_REPLACE);
   gst_tag_setter_set_tag_merge_mode (GST_TAG_SETTER (vorbistag),
@@ -345,7 +345,7 @@ GST_START_TEST (test_filled_tags_change)
 
   vorbistag = setup_vorbistag ();
 
-  tags = gst_tag_list_new ();
+  tags = gst_tag_list_new_empty ();
   gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_TITLE, "foobar", NULL);
   gst_tag_setter_merge_tags (GST_TAG_SETTER (vorbistag), tags,
       GST_TAG_MERGE_REPLACE);
index 503ebebb2b646df631b802e8343dc5fbf2ff53af..5cf3efcc0eb469a3fd4375b2f776cc5e3c645546 100644 (file)
@@ -428,7 +428,7 @@ GST_START_TEST (test_pb_utils_taglist_add_codec_info)
   GstCaps *caps;
 
   gst_pb_utils_init ();
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   caps = gst_caps_new_empty_simple ("video/x-theora");
   ASSERT_CRITICAL (fail_if
       (gst_pb_utils_add_codec_description_to_tag_list (NULL,
index 8dfd793ff55d1dd339bf54a378c36f259c417eb7..061e5d0aa26c8359e5f6d7b46283290294f4031f 100644 (file)
@@ -185,7 +185,7 @@ GST_START_TEST (test_musicbrainz_tag_registration)
 
   gst_tag_register_musicbrainz_tags ();
 
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
 
   /* musicbrainz tags aren't registered yet */
   gst_vorbis_tag_add (list, "MUSICBRAINZ_TRACKID", "123456");
@@ -234,7 +234,7 @@ GST_START_TEST (test_vorbis_tags)
 {
   GstTagList *list;
 
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
 
   /* NULL pointers aren't allowed */
   ASSERT_CRITICAL (gst_vorbis_tag_add (NULL, "key", "value"));
@@ -370,38 +370,38 @@ GST_START_TEST (test_vorbis_tags)
 
   /* there can only be one language per taglist ... */
   gst_tag_list_free (list);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_vorbis_tag_add (list, "LANGUAGE", "fr");
   ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "fr");
 
   gst_tag_list_free (list);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_vorbis_tag_add (list, "LANGUAGE", "[fr]");
   ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "fr");
 
   gst_tag_list_free (list);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_vorbis_tag_add (list, "LANGUAGE", "French [fr]");
   ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "fr");
 
   gst_tag_list_free (list);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_vorbis_tag_add (list, "LANGUAGE", "[eng] English");
   ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "eng");
 
   gst_tag_list_free (list);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_vorbis_tag_add (list, "LANGUAGE", "eng");
   ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "eng");
 
   gst_tag_list_free (list);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_vorbis_tag_add (list, "LANGUAGE", "[eng]");
   ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "eng");
 
   /* free-form *sigh* */
   gst_tag_list_free (list);
-  list = gst_tag_list_new ();
+  list = gst_tag_list_new_empty ();
   gst_vorbis_tag_add (list, "LANGUAGE", "English");
   ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "English");
 
@@ -532,7 +532,7 @@ GST_START_TEST (test_vorbis_tags)
   {
     GDate *date = NULL;
 
-    list = gst_tag_list_new ();
+    list = gst_tag_list_new_empty ();
     gst_vorbis_tag_add (list, "DATE", "2006-09-25 22:02:38");
 
     fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
@@ -549,7 +549,7 @@ GST_START_TEST (test_vorbis_tags)
   {
     GDate *date = NULL;
 
-    list = gst_tag_list_new ();
+    list = gst_tag_list_new_empty ();
     gst_vorbis_tag_add (list, "DATE", "1992-00-00");
 
     fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
@@ -564,7 +564,7 @@ GST_START_TEST (test_vorbis_tags)
   {
     GDate *date = NULL;
 
-    list = gst_tag_list_new ();
+    list = gst_tag_list_new_empty ();
     gst_vorbis_tag_add (list, "DATE", "1992-05-00");
 
     fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
@@ -957,7 +957,7 @@ GST_START_TEST (test_xmp_formatting)
   gsize len;
 
   /* test data */
-  list = gst_tag_list_new_full (GST_TAG_TITLE, "test title",
+  list = gst_tag_list_new (GST_TAG_TITLE, "test title",
       GST_TAG_DESCRIPTION, "test decription",
       GST_TAG_KEYWORDS, "keyword1", GST_TAG_KEYWORDS, "keyword2", NULL);
 
@@ -1052,65 +1052,6 @@ GST_START_TEST (test_xmp_parsing)
 
 GST_END_TEST;
 
-static void
-tag_list_equals (GstTagList * taglist, GstTagList * taglist2)
-{
-  const gchar *name_sent, *name_recv;
-  const GValue *value_sent, *value_recv;
-  gboolean found;
-  gint comparison;
-  gint n_recv;
-  gint n_sent;
-  gint i, j;
-
-  /* verify tags */
-  fail_unless (taglist2 != NULL);
-  n_recv = gst_structure_n_fields (taglist2);
-  n_sent = gst_structure_n_fields (taglist);
-  fail_unless (n_recv == n_sent);
-  fail_unless (n_sent > 0);
-
-  /* FIXME: compare taglist values */
-  for (i = 0; i < n_sent; i++) {
-    name_sent = gst_structure_nth_field_name (taglist, i);
-    value_sent = gst_structure_get_value (taglist, name_sent);
-    found = FALSE;
-    for (j = 0; j < n_recv; j++) {
-      name_recv = gst_structure_nth_field_name (taglist2, j);
-      if (!strcmp (name_sent, name_recv)) {
-        value_recv = gst_structure_get_value (taglist2, name_recv);
-        comparison = gst_value_compare (value_sent, value_recv);
-        if (comparison != GST_VALUE_EQUAL) {
-          gchar *vs = g_strdup_value_contents (value_sent);
-          gchar *vr = g_strdup_value_contents (value_recv);
-          GST_DEBUG ("sent = %s:'%s', recv = %s:'%s'",
-              G_VALUE_TYPE_NAME (value_sent), vs,
-              G_VALUE_TYPE_NAME (value_recv), vr);
-          g_free (vs);
-          g_free (vr);
-        }
-        if (comparison != GST_VALUE_EQUAL &&
-            G_VALUE_HOLDS (value_sent, G_TYPE_DOUBLE)) {
-          gdouble vs;
-          gdouble vr;
-
-          /* add some tolerance for doubles */
-          vs = g_value_get_double (value_sent);
-          vr = g_value_get_double (value_recv);
-          if (vr >= vs - 0.001 && vr <= vs + 0.001)
-            comparison = GST_VALUE_EQUAL;
-        }
-        fail_unless (comparison == GST_VALUE_EQUAL,
-            "tag item %s has been received with different type or value",
-            name_sent);
-        found = TRUE;
-        break;
-      }
-    }
-    fail_unless (found, "tag item %s is lost", name_sent);
-  }
-}
-
 static void
 do_xmp_tag_serialization_deserialization (GstTagList * taglist,
     const gchar ** schemas)
@@ -1121,7 +1062,7 @@ do_xmp_tag_serialization_deserialization (GstTagList * taglist,
   buf = gst_tag_list_to_xmp_buffer_full (taglist, TRUE, schemas);
   taglist2 = gst_tag_list_from_xmp_buffer (buf);
 
-  tag_list_equals (taglist, taglist2);
+  fail_unless (gst_tag_list_is_equal (taglist, taglist2));
 
   gst_buffer_unref (buf);
   gst_tag_list_free (taglist2);
@@ -1131,7 +1072,7 @@ static void
 do_simple_xmp_tag_serialization_deserialization (const gchar * gsttag,
     GValue * value)
 {
-  GstTagList *taglist = gst_tag_list_new ();
+  GstTagList *taglist = gst_tag_list_new_empty ();
 
   gst_tag_list_add_value (taglist, GST_TAG_MERGE_REPLACE, gsttag, value);
 
@@ -1323,7 +1264,7 @@ GST_END_TEST;
 GST_START_TEST (test_xmp_compound_tags)
 {
   const gchar *schemas[] = { "Iptc4xmpExt", NULL };
-  GstTagList *taglist = gst_tag_list_new ();
+  GstTagList *taglist = gst_tag_list_new_empty ();
 
   gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_KEYWORDS, "k1",
       GST_TAG_KEYWORDS, "k2", GST_TAG_TITLE, "title", GST_TAG_KEYWORDS, "k3",
@@ -1331,7 +1272,7 @@ GST_START_TEST (test_xmp_compound_tags)
   do_xmp_tag_serialization_deserialization (taglist, NULL);
   gst_tag_list_free (taglist);
 
-  taglist = gst_tag_list_new ();
+  taglist = gst_tag_list_new_empty ();
   gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_GEO_LOCATION_COUNTRY,
       "Brazil", GST_TAG_GEO_LOCATION_CITY, "Campina Grande", NULL);
   do_xmp_tag_serialization_deserialization (taglist, schemas);
@@ -1346,7 +1287,7 @@ GST_START_TEST (test_exif_parsing)
   GstTagList *taglist;
   GstBuffer *buf;
   GstByteWriter writer;
-  const gchar *str;
+  const gchar *str = NULL;
 
   gst_byte_writer_init (&writer);
 
@@ -1371,11 +1312,9 @@ GST_START_TEST (test_exif_parsing)
 
   taglist = gst_tag_list_from_exif_buffer (buf, G_LITTLE_ENDIAN, 8);
 
-  fail_unless (gst_structure_n_fields (taglist) == 1);
-  fail_unless (gst_structure_has_field_typed (taglist, GST_TAG_COPYRIGHT,
-          G_TYPE_STRING));
-  str = gst_structure_get_string (taglist, GST_TAG_COPYRIGHT);
-  fail_unless (strcmp (str, "my copyright") == 0);
+  fail_unless (gst_tag_list_get_tag_size (taglist, GST_TAG_COPYRIGHT) == 1);
+  gst_tag_list_peek_string_index (taglist, GST_TAG_COPYRIGHT, 0, &str);
+  fail_unless_equals_string (str, "my copyright");
 
   gst_tag_list_free (taglist);
   gst_buffer_unref (buf);
@@ -1395,7 +1334,7 @@ do_exif_tag_serialization_deserialization (GstTagList * taglist)
   taglist2 = gst_tag_list_from_exif_buffer (buf, G_LITTLE_ENDIAN, 0);
   gst_buffer_unref (buf);
 
-  tag_list_equals (taglist, taglist2);
+  fail_unless (gst_tag_list_is_equal (taglist, taglist2));
   gst_tag_list_free (taglist2);
 
   /* BE */
@@ -1403,7 +1342,7 @@ do_exif_tag_serialization_deserialization (GstTagList * taglist)
   taglist2 = gst_tag_list_from_exif_buffer (buf, G_BIG_ENDIAN, 0);
   gst_buffer_unref (buf);
 
-  tag_list_equals (taglist, taglist2);
+  fail_unless (gst_tag_list_is_equal (taglist, taglist2));
   gst_tag_list_free (taglist2);
 
   /* APP1 */
@@ -1411,7 +1350,7 @@ do_exif_tag_serialization_deserialization (GstTagList * taglist)
   taglist2 = gst_tag_list_from_exif_buffer_with_tiff_header (buf);
   gst_buffer_unref (buf);
 
-  tag_list_equals (taglist, taglist2);
+  fail_unless (gst_tag_list_is_equal (taglist, taglist2));
   gst_tag_list_free (taglist2);
 }
 
@@ -1419,7 +1358,7 @@ static void
 do_simple_exif_tag_serialization_deserialization (const gchar * gsttag,
     GValue * value)
 {
-  GstTagList *taglist = gst_tag_list_new ();
+  GstTagList *taglist = gst_tag_list_new_empty ();
 
   gst_tag_list_add_value (taglist, GST_TAG_MERGE_REPLACE, gsttag, value);
   do_exif_tag_serialization_deserialization (taglist);
@@ -1438,7 +1377,7 @@ GST_START_TEST (test_exif_multiple_tags)
 
   gst_tag_register_musicbrainz_tags ();
 
-  taglist = gst_tag_list_new_full (GST_TAG_ARTIST, "artist",
+  taglist = gst_tag_list_new (GST_TAG_ARTIST, "artist",
       GST_TAG_DEVICE_MANUFACTURER, "make",
       GST_TAG_DEVICE_MODEL, "model", GST_TAG_GEO_LOCATION_LATITUDE, 45.5,
       GST_TAG_GEO_LOCATION_LONGITUDE, -10.25,
@@ -1806,22 +1745,22 @@ GST_START_TEST (test_exif_tags_serialization_deserialization)
 
   /* flash is a little bit more tricky, because 2 tags are merged into 1 in
    * exif */
-  taglist = gst_tag_list_new_full (GST_TAG_CAPTURING_FLASH_FIRED, FALSE,
+  taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, FALSE,
       GST_TAG_CAPTURING_FLASH_MODE, "auto", NULL);
   do_exif_tag_serialization_deserialization (taglist);
   gst_tag_list_free (taglist);
 
-  taglist = gst_tag_list_new_full (GST_TAG_CAPTURING_FLASH_FIRED, TRUE,
+  taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, TRUE,
       GST_TAG_CAPTURING_FLASH_MODE, "auto", NULL);
   do_exif_tag_serialization_deserialization (taglist);
   gst_tag_list_free (taglist);
 
-  taglist = gst_tag_list_new_full (GST_TAG_CAPTURING_FLASH_FIRED, FALSE,
+  taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, FALSE,
       GST_TAG_CAPTURING_FLASH_MODE, "never", NULL);
   do_exif_tag_serialization_deserialization (taglist);
   gst_tag_list_free (taglist);
 
-  taglist = gst_tag_list_new_full (GST_TAG_CAPTURING_FLASH_FIRED, TRUE,
+  taglist = gst_tag_list_new (GST_TAG_CAPTURING_FLASH_FIRED, TRUE,
       GST_TAG_CAPTURING_FLASH_MODE, "always", NULL);
   do_exif_tag_serialization_deserialization (taglist);
   gst_tag_list_free (taglist);
index 49fd1e7392b1814fbdf491390b1267b1600db4d8..7e1a544a2e914143d308303cf1162daa1daa6e92 100644 (file)
@@ -76,65 +76,6 @@ test_element_init (TestElement * this)
 {
 }
 
-static void
-tag_list_equals (GstTagList * taglist, GstTagList * taglist2)
-{
-  const gchar *name_sent, *name_recv;
-  const GValue *value_sent, *value_recv;
-  gboolean found;
-  gint comparison;
-  gint n_recv;
-  gint n_sent;
-  gint i, j;
-
-  /* verify tags */
-  fail_unless (taglist2 != NULL);
-  n_recv = gst_structure_n_fields (taglist2);
-  n_sent = gst_structure_n_fields (taglist);
-  fail_unless (n_recv == n_sent);
-  fail_unless (n_sent > 0);
-
-  /* FIXME: compare taglist values */
-  for (i = 0; i < n_sent; i++) {
-    name_sent = gst_structure_nth_field_name (taglist, i);
-    value_sent = gst_structure_get_value (taglist, name_sent);
-    found = FALSE;
-    for (j = 0; j < n_recv; j++) {
-      name_recv = gst_structure_nth_field_name (taglist2, j);
-      if (!strcmp (name_sent, name_recv)) {
-        value_recv = gst_structure_get_value (taglist2, name_recv);
-        comparison = gst_value_compare (value_sent, value_recv);
-        if (comparison != GST_VALUE_EQUAL) {
-          gchar *vs = g_strdup_value_contents (value_sent);
-          gchar *vr = g_strdup_value_contents (value_recv);
-          GST_DEBUG ("sent = %s:'%s', recv = %s:'%s'",
-              G_VALUE_TYPE_NAME (value_sent), vs,
-              G_VALUE_TYPE_NAME (value_recv), vr);
-          g_free (vs);
-          g_free (vr);
-        }
-        if (comparison != GST_VALUE_EQUAL &&
-            G_VALUE_HOLDS (value_sent, G_TYPE_DOUBLE)) {
-          gdouble vs;
-          gdouble vr;
-
-          /* add some tolerance for doubles */
-          vs = g_value_get_double (value_sent);
-          vr = g_value_get_double (value_recv);
-          if (vr >= vs - 0.001 && vr <= vs + 0.001)
-            comparison = GST_VALUE_EQUAL;
-        }
-        fail_unless (comparison == GST_VALUE_EQUAL,
-            "tag item %s has been received with different type or value",
-            name_sent);
-        found = TRUE;
-        break;
-      }
-    }
-    fail_unless (found, "tag item %s is lost", name_sent);
-  }
-}
-
 static gboolean
 gst_buffer_equals (GstBuffer * buf_a, GstBuffer * buf_b)
 {
@@ -159,7 +100,7 @@ gst_buffer_equals (GstBuffer * buf_a, GstBuffer * buf_b)
 static GstTagList *
 create_taglist (void)
 {
-  return gst_tag_list_new_full (GST_TAG_ARTIST, "artist",
+  return gst_tag_list_new (GST_TAG_ARTIST, "artist",
       GST_TAG_TITLE, "title", GST_TAG_COPYRIGHT, "copyright", NULL);
 }
 
@@ -213,7 +154,7 @@ GST_START_TEST (test_disable)
   GstBuffer *buf;
   const gchar *str;
 
-  taglist = gst_tag_list_new_full (GST_TAG_ARTIST, "artist", NULL);
+  taglist = gst_tag_list_new (GST_TAG_ARTIST, "artist", NULL);
 
   /* add a tag that is mapped on xmp schema (as of Mar, 21th 2011) */
   gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, GST_TAG_USER_RATING, 5,
@@ -223,7 +164,7 @@ GST_START_TEST (test_disable)
       gst_tag_xmp_writer_tag_list_to_xmp_buffer (GST_TAG_XMP_WRITER
       (test_element), taglist, TRUE);
   taglist2 = gst_tag_list_from_xmp_buffer (buf);
-  tag_list_equals (taglist, taglist2);
+  fail_unless (gst_tag_list_is_equal (taglist, taglist2));
   gst_tag_list_free (taglist2);
   gst_buffer_unref (buf);