pad_monitor: Add a check for buffer DISCONT flag
authorEdward Hervey <edward@centricular.com>
Thu, 19 May 2016 09:59:19 +0000 (11:59 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Thu, 19 May 2016 10:07:26 +0000 (12:07 +0200)
The first buffer after a FLUSH or SEGMENT should have the DISCONT flag
set.

validate/gst/validate/gst-validate-pad-monitor.c
validate/gst/validate/gst-validate-pad-monitor.h
validate/gst/validate/gst-validate-report.c
validate/gst/validate/gst-validate-report.h

index 5059e74..d7f4973 100644 (file)
@@ -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);
index 7f907a9..ef6e243 100644 (file)
@@ -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;
index 2e2b42c..1053341 100644 (file)
@@ -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"),
index 21fba3a..a8db21d 100644 (file)
@@ -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")