[gst-cvs] gst-plugins-base: cddabasesrc: fix posting of discid tags after MERGE_MODE_REPLACE_ALL changes in core
Tim Mueller
tpm at kemper.freedesktop.org
Sun Apr 19 10:20:32 PDT 2009
Module: gst-plugins-base
Branch: master
Commit: 8efe6108c4f18e8838958b40ab2323e2b26a8c9e
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=8efe6108c4f18e8838958b40ab2323e2b26a8c9e
Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date: Sun Apr 19 18:15:28 2009 +0100
cddabasesrc: fix posting of discid tags after MERGE_MODE_REPLACE_ALL changes in core
Don't use REPLACE_ALL merge mode when that's not really what we want,
as now that REPLACE_ALL actually does what it's supposed to do in
core, we drop tags we wanted to keep, such as the various disc id
tags. Add unit test for this as well. Fixes #579463.
---
gst-libs/gst/cdda/gstcddabasesrc.c | 4 +-
tests/check/libs/cddabasesrc.c | 63 +++++++++++++++++++++++++++++++++---
2 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/gst-libs/gst/cdda/gstcddabasesrc.c b/gst-libs/gst/cdda/gstcddabasesrc.c
index 0ee3afa..3a0bea8 100644
--- a/gst-libs/gst/cdda/gstcddabasesrc.c
+++ b/gst-libs/gst/cdda/gstcddabasesrc.c
@@ -1271,7 +1271,7 @@ gst_cdda_base_src_add_tags (GstCddaBaseSrc * src)
GST_FORMAT_TIME, &duration);
gst_tag_list_add (src->tracks[i].tags,
- GST_TAG_MERGE_REPLACE_ALL,
+ GST_TAG_MERGE_REPLACE,
GST_TAG_TRACK_NUMBER, i + 1,
GST_TAG_TRACK_COUNT, src->num_tracks, GST_TAG_DURATION, duration, NULL);
}
@@ -1285,7 +1285,7 @@ gst_cdda_base_src_add_tags (GstCddaBaseSrc * src)
* gst_tag_list_get_value_index() rather than use tag names incl.
* the track number ?? *////////////////////////////////////////
- gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE_ALL,
+ gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
GST_TAG_TRACK_COUNT, src->num_tracks, NULL);
#if 0
for (i = 0; i < src->num_tracks; ++i) {
diff --git a/tests/check/libs/cddabasesrc.c b/tests/check/libs/cddabasesrc.c
index bada500..f966a1e 100644
--- a/tests/check/libs/cddabasesrc.c
+++ b/tests/check/libs/cddabasesrc.c
@@ -270,25 +270,78 @@ gst_cd_foo_src_read_sector (GstCddaBaseSrc * cddabasesrc, gint sector)
return buf;
}
+static inline gboolean
+tag_list_has_tag (GstTagList * list, const gchar * tag, GType type)
+{
+ const GValue *val = gst_tag_list_get_value_index (list, tag, 0);
+
+ if (val == NULL) {
+ GST_LOG ("no tag '%s' in taglist %" GST_PTR_FORMAT, tag, list);
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS (val, type)) {
+ GST_LOG ("tag '%s' in taglist %" GST_PTR_FORMAT " is not of type %s",
+ tag, list, g_type_name (type));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
GST_START_TEST (test_discid_calculations)
{
- GstElement *foosrc;
+ GstElement *foosrc, *pipeline, *sink;
gint i;
fail_unless (gst_element_register (NULL, "cdfoosrc", GST_RANK_SECONDARY,
GST_TYPE_CD_FOO_SRC));
+ pipeline = gst_pipeline_new ("pipeline");
+
+ sink = gst_element_factory_make ("fakesink", "sink");
+ fail_unless (sink != NULL, "couldn't create fakesink");
+
foosrc = gst_element_factory_make ("cdfoosrc", "cdfoosrc");
+ fail_unless (foosrc != NULL, "couldn't create cdfoosrc");
+
+ gst_bin_add (GST_BIN (pipeline), foosrc);
+ gst_bin_add (GST_BIN (pipeline), sink);
+ fail_unless (gst_element_link (foosrc, sink));
for (i = 0; i < G_N_ELEMENTS (test_discs); ++i) {
+ GstTagList *tags = NULL;
+ GstMessage *msg;
+
GST_LOG ("Testing disc layout %u ...", i);
GST_CD_FOO_SRC (foosrc)->cur_disc = i;
- gst_element_set_state (foosrc, GST_STATE_PLAYING);
- gst_element_get_state (foosrc, NULL, NULL, -1);
- gst_element_set_state (foosrc, GST_STATE_NULL);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ msg =
+ gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline),
+ GST_CLOCK_TIME_NONE, GST_MESSAGE_TAG);
+ gst_message_parse_tag (msg, &tags);
+ fail_unless (tags != NULL);
+ fail_unless (tag_list_has_tag (tags, "track-count", G_TYPE_UINT));
+ fail_unless (tag_list_has_tag (tags, "track-number", G_TYPE_UINT));
+ fail_unless (tag_list_has_tag (tags, "duration", G_TYPE_UINT64));
+ fail_unless (tag_list_has_tag (tags, "discid", G_TYPE_STRING));
+ fail_unless (tag_list_has_tag (tags, "discid-full", G_TYPE_STRING));
+ fail_unless (tag_list_has_tag (tags, "musicbrainz-discid", G_TYPE_STRING));
+ fail_unless (tag_list_has_tag (tags, "musicbrainz-discid-full",
+ G_TYPE_STRING));
+ gst_tag_list_free (tags);
+ gst_message_unref (msg);
+
+ msg =
+ gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline),
+ GST_CLOCK_TIME_NONE, GST_MESSAGE_ASYNC_DONE);
+ gst_message_unref (msg);
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
}
- gst_object_unref (foosrc);
+ gst_object_unref (pipeline);
gst_task_cleanup_all ();
}
More information about the Gstreamer-commits
mailing list