From 07cda3fbebafe124ca23397dae2a7098020d0db3 Mon Sep 17 00:00:00 2001
From: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date: Fri, 27 Feb 2015 16:56:06 +0000
Subject: [PATCH] validate: expect a buffer with discontinuity after a seek

https://bugzilla.gnome.org/show_bug.cgi?id=744783
---
 validate/gst/validate/gst-validate-report.c   |    2 ++
 validate/gst/validate/gst-validate-report.h   |    1 +
 validate/gst/validate/gst-validate-scenario.c |   18 +++++++++++++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c
index 80102b2..94d2635 100644
--- a/validate/gst/validate/gst-validate-report.c
+++ b/validate/gst/validate/gst-validate-report.c
@@ -153,6 +153,8 @@ gst_validate_report_load_issues (void)
           " all buffers coming into the decoders might be checked"
           " and should have the exact expected metadatas and hash of the"
           " content"));
+  REGISTER_VALIDATE_ISSUE (ISSUE, FIRST_BUFFER_NOT_DISCONT,
+      _("First buffer after a seek does not have the DISCONT flag set"), NULL);
   REGISTER_VALIDATE_ISSUE (CRITICAL, WRONG_FLOW_RETURN,
       _("flow return from pad push doesn't match expected value"),
       _("flow return from a 1:1 sink/src pad element is as simple as "
diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h
index 93265fe..f48023f 100644
--- a/validate/gst/validate/gst-validate-report.h
+++ b/validate/gst/validate/gst-validate-report.h
@@ -63,6 +63,7 @@ typedef enum {
 #define WRONG_FLOW_RETURN                        _QUARK("buffer::wrong-flow-return")
 #define BUFFER_AFTER_EOS                         _QUARK("buffer::after-eos")
 #define WRONG_BUFFER                             _QUARK("buffer::not-expected-one")
+#define FIRST_BUFFER_NOT_DISCONT                 _QUARK("buffer::first-buffer-not-discont")
 
 #define CAPS_IS_MISSING_FIELD                    _QUARK("caps::is-missing-field")
 #define CAPS_FIELD_HAS_BAD_TYPE                  _QUARK("caps::field-has-bad-type")
diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c
index bb65940..9078a8b 100644
--- a/validate/gst/validate/gst-validate-scenario.c
+++ b/validate/gst/validate/gst-validate-scenario.c
@@ -436,6 +436,19 @@ gst_validate_action_get_clocktime (GstValidateScenario * scenario,
 }
 
 static GstPadProbeReturn
+_check_discont_buffer_done (GstPad * pad, GstPadProbeInfo * info,
+    GstValidateAction * action)
+{
+  GstBuffer *buffer = GST_BUFFER (info->data);
+  if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
+    GST_VALIDATE_REPORT (action->scenario, FIRST_BUFFER_NOT_DISCONT,
+        "First buffer after a seek does not have the DISCONT flag set");
+  }
+  gst_validate_action_set_done (action);
+  return GST_PAD_PROBE_REMOVE;
+}
+
+static GstPadProbeReturn
 _check_new_segment_done (GstPad * pad, GstPadProbeInfo * info,
     GstValidateAction * action)
 {
@@ -452,7 +465,10 @@ _check_new_segment_done (GstPad * pad, GstPadProbeInfo * info,
           priv->seeked_in_pause = TRUE;
 
         gst_event_replace (&priv->last_seek, NULL);
-        gst_validate_action_set_done (action);
+
+        gst_pad_add_probe (pad,
+            GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
+            (GstPadProbeCallback) _check_discont_buffer_done, action, NULL);
 
         return GST_PAD_PROBE_REMOVE;
       }
-- 
1.7.9.5

