summaryrefslogtreecommitdiff
path: root/tests/check/elements
diff options
context:
space:
mode:
authorSøren Juul <zpon.dk@gmail.com>2017-02-10 10:53:05 +0100
committerSebastian Dröge <sebastian@centricular.com>2017-02-19 12:55:36 +0200
commit856473b215520e42f4748e01f94ed97f17fa0482 (patch)
tree5b8b21bd447f948a59144d0eae2555dc257d5926 /tests/check/elements
parent2284fc579c1b9a7b0dba9abf4313803cd904bf16 (diff)
downloadgstreamer-plugins-good-856473b215520e42f4748e01f94ed97f17fa0482.tar.gz
icydemux: reset tags on empty value
Some radio streams uses StreamTitle='' to reset the title after a track stopped playing, e.g. while the host talks between tracks or during news segments. This change forces an empty tag object to be distributed if StreamTitle or StreamUrl is received with empty value, thus allowing downstream elements to get notified about this. https://bugzilla.gnome.org/show_bug.cgi?id=778437
Diffstat (limited to 'tests/check/elements')
-rw-r--r--tests/check/elements/icydemux.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/check/elements/icydemux.c b/tests/check/elements/icydemux.c
index 1a17e79b6..b5e43b434 100644
--- a/tests/check/elements/icydemux.c
+++ b/tests/check/elements/icydemux.c
@@ -31,12 +31,23 @@
#define ICY_METADATA \
"StreamTitle='" TEST_METADATA "';\0\0\0\0"
+#define EMPTY_ICY_STREAM_TITLE_METADATA \
+ "StreamTitle='';\0"
+
#define ICY_DATA \
"aaaaaaaa" \
"\x02" \
ICY_METADATA \
"bbbbbbbb"
+#define ICY_DATA_EMPTY_METADATA \
+ ICY_DATA \
+ "\x00" \
+ "dddddddd" \
+ "\x01" \
+ EMPTY_ICY_STREAM_TITLE_METADATA \
+ "cccccccc"
+
#define ICYCAPS "application/x-icy, metadata-interval = (int)8"
#define SRC_CAPS "application/x-icy, metadata-interval = (int)[0, MAX]"
@@ -220,6 +231,71 @@ GST_START_TEST (test_demux)
GST_END_TEST;
+GST_START_TEST (test_demux_empty_data)
+{
+ GstMessage *message;
+ GstTagList *tags;
+ const GValue *tag_val;
+ const gchar *tag;
+ GstCaps *caps;
+
+ fail_unless (gst_type_find_register (NULL, "success", GST_RANK_PRIMARY,
+ typefind_succeed, NULL, gst_static_caps_get (&typefind_caps), NULL,
+ NULL));
+
+ fake_typefind_caps = TRUE;
+
+ caps = gst_caps_from_string (ICYCAPS);
+
+ create_icydemux ();
+ gst_check_setup_events (srcpad, icydemux, caps, GST_FORMAT_TIME);
+
+ push_data ((guint8 *) ICY_DATA_EMPTY_METADATA,
+ sizeof (ICY_DATA_EMPTY_METADATA), -1);
+
+ message = gst_bus_poll (bus, GST_MESSAGE_TAG, -1);
+ fail_unless (message != NULL);
+
+ gst_message_parse_tag (message, &tags);
+ fail_unless (tags != NULL);
+
+ tag_val = gst_tag_list_get_value_index (tags, GST_TAG_TITLE, 0);
+ fail_unless (tag_val != NULL);
+
+ tag = g_value_get_string (tag_val);
+ fail_unless (tag != NULL);
+
+ fail_unless_equals_string (TEST_METADATA, (char *) tag);
+
+ gst_tag_list_unref (tags);
+ gst_message_unref (message);
+
+ message = gst_bus_poll (bus, GST_MESSAGE_TAG, -1);
+ fail_unless (message != NULL);
+
+ gst_message_parse_tag (message, &tags);
+ fail_unless (tags != NULL);
+
+ tag_val = gst_tag_list_get_value_index (tags, GST_TAG_TITLE, 0);
+ fail_unless (tag_val == NULL);
+
+ gst_message_unref (message);
+
+ /* Ensure that no further tag messages are received, i.e. the empty ICY tag
+ * is skipped */
+ message = gst_bus_poll (bus, GST_MESSAGE_TAG, 100000000);
+ fail_unless (message == NULL);
+
+ gst_tag_list_unref (tags);
+ gst_caps_unref (caps);
+
+ cleanup_icydemux ();
+
+ fake_typefind_caps = FALSE;
+}
+
+GST_END_TEST;
+
/* run this test first before the custom typefind function is set up */
GST_START_TEST (test_first_buf_offset_when_merged_for_typefinding)
{
@@ -292,6 +368,7 @@ icydemux_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_demux);
+ tcase_add_test (tc_chain, test_demux_empty_data);
tcase_add_test (tc_chain, test_first_buf_offset_when_merged_for_typefinding);
tcase_add_test (tc_chain, test_not_negotiated);