From ca38c4dc9a49ed82b46c6c9506ad29e77622fda0 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 19 May 2016 11:59:19 +0200 Subject: [PATCH] pad_monitor: Add a check for buffer DISCONT flag The first buffer after a FLUSH or SEGMENT should have the DISCONT flag set. --- validate/gst/validate/gst-validate-pad-monitor.c | 20 ++++++++++++++++++++ validate/gst/validate/gst-validate-pad-monitor.h | 4 ++++ validate/gst/validate/gst-validate-report.c | 3 +++ validate/gst/validate/gst-validate-report.h | 1 + 4 files changed, 28 insertions(+) diff --git a/validate/gst/validate/gst-validate-pad-monitor.c b/validate/gst/validate/gst-validate-pad-monitor.c index 5059e74..d7f4973 100644 --- a/validate/gst/validate/gst-validate-pad-monitor.c +++ b/validate/gst/validate/gst-validate-pad-monitor.c @@ -890,6 +890,7 @@ gst_validate_pad_monitor_init (GstValidatePadMonitor * pad_monitor) pad_monitor->expired_events = NULL; gst_segment_init (&pad_monitor->segment, GST_FORMAT_BYTES); pad_monitor->first_buffer = TRUE; + pad_monitor->pending_buffer_discont = TRUE; pad_monitor->timestamp_range_start = GST_CLOCK_TIME_NONE; pad_monitor->timestamp_range_end = GST_CLOCK_TIME_NONE; @@ -1117,6 +1118,18 @@ static void } static void +gst_validate_pad_monitor_check_discont (GstValidatePadMonitor * pad_monitor, + GstBuffer * buffer) +{ + if (pad_monitor->pending_buffer_discont) { + if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) + GST_VALIDATE_REPORT (pad_monitor, BUFFER_MISSING_DISCONT, + "Buffer is missing a DISCONT flag"); + pad_monitor->pending_buffer_discont = FALSE; + } +} + +static void gst_validate_pad_monitor_check_first_buffer (GstValidatePadMonitor * pad_monitor, GstBuffer * buffer) { @@ -1569,6 +1582,9 @@ gst_validate_pad_monitor_common_event_check (GstValidatePadMonitor * } pad_monitor->pending_flush_stop = FALSE; + /* Buffers following a FLUSH should have the DISCONT flag set */ + pad_monitor->pending_buffer_discont = TRUE; + /* cleanup our data */ gst_validate_pad_monitor_flush (pad_monitor); } @@ -1728,6 +1744,8 @@ gst_validate_pad_monitor_downstream_event_check (GstValidatePadMonitor * } pad_monitor->pending_eos_seqnum = seqnum; + /* Buffers following a SEGMENT should have the DISCONT flag set */ + pad_monitor->pending_buffer_discont = TRUE; if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) { gst_validate_pad_monitor_add_expected_newsegment (pad_monitor, event); @@ -2058,6 +2076,7 @@ gst_validate_pad_monitor_chain_func (GstPad * pad, GstObject * parent, GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (pad_monitor); GST_VALIDATE_MONITOR_LOCK (pad_monitor); + gst_validate_pad_monitor_check_discont (pad_monitor, buffer); gst_validate_pad_monitor_check_right_buffer (pad_monitor, buffer); gst_validate_pad_monitor_check_first_buffer (pad_monitor, buffer); gst_validate_pad_monitor_update_buffer_data (pad_monitor, buffer); @@ -2246,6 +2265,7 @@ gst_validate_pad_monitor_buffer_probe (GstPad * pad, GstBuffer * buffer, GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (monitor); GST_VALIDATE_MONITOR_LOCK (monitor); + gst_validate_pad_monitor_check_discont (monitor, buffer); gst_validate_pad_monitor_check_first_buffer (monitor, buffer); gst_validate_pad_monitor_update_buffer_data (monitor, buffer); gst_validate_pad_monitor_check_eos (monitor, buffer); diff --git a/validate/gst/validate/gst-validate-pad-monitor.h b/validate/gst/validate/gst-validate-pad-monitor.h index 7f907a9..ef6e243 100644 --- a/validate/gst/validate/gst-validate-pad-monitor.h +++ b/validate/gst/validate/gst-validate-pad-monitor.h @@ -89,6 +89,10 @@ struct _GstValidatePadMonitor { guint32 pending_newsegment_seqnum; guint32 pending_eos_seqnum; + /* Whether the next buffer should have a DISCONT flag on it, because + * it's the first one, or follows a SEGMENT and/or a FLUSH */ + gboolean pending_buffer_discont; + GstClockTime pending_seek_accurate_time; GstEvent *expected_segment; diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c index 2e2b42c..1053341 100644 --- a/validate/gst/validate/gst-validate-report.c +++ b/validate/gst/validate/gst-validate-report.c @@ -199,6 +199,9 @@ gst_validate_report_load_issues (void) _("GST_FLOW_ERROR returned without posting an ERROR on the bus"), _("Element MUST post a GST_MESSAGE_ERROR with GST_ELEMENT_ERROR before" " returning GST_FLOW_ERROR")); + REGISTER_VALIDATE_ISSUE (WARNING, BUFFER_MISSING_DISCONT, + _("Buffer didn't have expected DISCONT flag"), + _("Buffers after SEGMENT and FLUSH must have a DISCONT flag")); REGISTER_VALIDATE_ISSUE (ISSUE, CAPS_IS_MISSING_FIELD, _("caps is missing a required field for its type"), diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h index 21fba3a..a8db21d 100644 --- a/validate/gst/validate/gst-validate-report.h +++ b/validate/gst/validate/gst-validate-report.h @@ -64,6 +64,7 @@ typedef enum { #define BUFFER_AFTER_EOS _QUARK("buffer::after-eos") #define WRONG_BUFFER _QUARK("buffer::not-expected-one") #define FLOW_ERROR_WITHOUT_ERROR_MESSAGE _QUARK("buffer::flow-error-without-error-message") +#define BUFFER_MISSING_DISCONT _QUARK("buffer::missing-discont") #define CAPS_IS_MISSING_FIELD _QUARK("caps::is-missing-field") #define CAPS_FIELD_HAS_BAD_TYPE _QUARK("caps::field-has-bad-type") -- 2.7.4