summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@collabora.com>2014-10-18 18:55:59 +0200
committerMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2014-10-21 20:40:27 +0200
commit6d0930bb36ae1a7fdf3230827e294286f43d8944 (patch)
treee2074e62d218790e4287cb3621ad44b6bcb46d80
parent23d7df37883d4ed37155ce366ca668ac231eef79 (diff)
validate: Verify that elements always send a segment before pushing EOS
EOS is some kind of data flow and thus a segment event should always be pushed before the EOS is sent
-rw-r--r--validate/gst/validate/gst-validate-pad-monitor.c8
-rw-r--r--validate/tests/check/validate/padmonitor.c52
2 files changed, 58 insertions, 2 deletions
diff --git a/validate/gst/validate/gst-validate-pad-monitor.c b/validate/gst/validate/gst-validate-pad-monitor.c
index 396e2ff..9f8c532 100644
--- a/validate/gst/validate/gst-validate-pad-monitor.c
+++ b/validate/gst/validate/gst-validate-pad-monitor.c
@@ -1588,7 +1588,7 @@ gst_validate_pad_monitor_downstream_event_check (GstValidatePadMonitor *
pad_monitor->pending_newsegment_seqnum = 0;
} else {
GST_VALIDATE_REPORT (pad_monitor, EVENT_HAS_WRONG_SEQNUM,
- "The expected EOS seqnum should be the same as the "
+ "The expected segment seqnum should be the same as the "
"one from the seek that caused it. Got: %u."
" Expected: %u", seqnum, pad_monitor->pending_eos_seqnum);
}
@@ -1630,7 +1630,11 @@ gst_validate_pad_monitor_downstream_event_check (GstValidatePadMonitor *
}
case GST_EVENT_EOS:
pad_monitor->is_eos = TRUE;
- if (pad_monitor->pending_eos_seqnum != seqnum) {
+ if (pad_monitor->pending_eos_seqnum == 0) {
+ GST_VALIDATE_REPORT (pad_monitor, EVENT_EOS_WITHOUT_SEGMENT,
+ "EOS %" GST_PTR_FORMAT " received before a segment was received",
+ event);
+ } else if (pad_monitor->pending_eos_seqnum != seqnum) {
GST_VALIDATE_REPORT (pad_monitor, EVENT_HAS_WRONG_SEQNUM,
"The expected EOS seqnum should be the same as the "
"one from the seek that caused it. Got: %u."
diff --git a/validate/tests/check/validate/padmonitor.c b/validate/tests/check/validate/padmonitor.c
index 657ce2f..4828420 100644
--- a/validate/tests/check/validate/padmonitor.c
+++ b/validate/tests/check/validate/padmonitor.c
@@ -799,6 +799,57 @@ GST_START_TEST (check_media_info)
GST_END_TEST;
+GST_START_TEST (eos_without_segment)
+{
+ GstPad *srcpad, *sinkpad;
+ GstValidateReport *report;
+ GstElement *decoder = fake_decoder_new ();
+ GstElement *sink = gst_element_factory_make ("fakesink", NULL);
+ GstBin *pipeline = GST_BIN (gst_pipeline_new ("validate-pipeline"));
+ GList *reports;
+ GstValidateRunner *runner;
+ GstValidateMonitor *monitor;
+
+ fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL", "all", TRUE));
+ runner = gst_validate_runner_new ();
+ monitor =
+ gst_validate_monitor_factory_create (GST_OBJECT (pipeline),
+ runner, NULL);
+
+ gst_bin_add_many (pipeline, decoder, sink, NULL);
+ srcpad = gst_pad_new ("srcpad1", GST_PAD_SRC);
+ sinkpad = decoder->sinkpads->data;
+ gst_pad_link (srcpad, sinkpad);
+
+ gst_element_link (decoder, sink);
+ fail_unless_equals_int (gst_element_set_state (GST_ELEMENT (pipeline),
+ GST_STATE_PLAYING), GST_STATE_CHANGE_ASYNC);
+ fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE));
+
+ reports = gst_validate_runner_get_reports (runner);
+ assert_equals_int (g_list_length (reports), 0);
+ g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref);
+
+ fail_unless (gst_pad_push_event (srcpad, gst_event_new_eos ()));
+ reports = gst_validate_runner_get_reports (runner);
+
+ /* Getting the issue on the srcpad -> decoder.sinkpad -> decoder->srcpad */
+ assert_equals_int (g_list_length (reports), 3);
+ report = reports->data;
+ fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_WARNING);
+ fail_unless_equals_int (report->issue->issue_id, EVENT_EOS_WITHOUT_SEGMENT);
+ clean_bus (GST_ELEMENT (pipeline));
+
+ g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref);
+
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+ check_destroyed (pipeline, NULL, NULL);
+ check_destroyed (monitor, NULL, NULL);
+ check_destroyed (runner, NULL, NULL);
+}
+
+GST_END_TEST;
+
static Suite *
gst_validate_suite (void)
{
@@ -814,6 +865,7 @@ gst_validate_suite (void)
tcase_add_test (tc_chain, flow_aggregation);
tcase_add_test (tc_chain, issue_concatenation);
tcase_add_test (tc_chain, check_media_info);
+ tcase_add_test (tc_chain, eos_without_segment);
return s;
}