pad-monitor: add check for out of segment buffer data
authorThiago Santos <thiago.sousa.santos@collabora.com>
Tue, 16 Jul 2013 11:06:27 +0000 (08:06 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Tue, 16 Jul 2013 11:06:27 +0000 (08:06 -0300)
validate/gst/qa/gst-qa-element-monitor.h
validate/gst/qa/gst-qa-pad-monitor.c

index 5afb357..f46c146 100644 (file)
@@ -39,6 +39,7 @@ G_BEGIN_DECLS
 #define GST_QA_ELEMENT_MONITOR_CLASS_CAST(klass)        ((GstQaElementMonitorClass*)(klass))
 
 #define GST_QA_ELEMENT_MONITOR_GET_ELEMENT(m) (GST_ELEMENT_CAST (GST_QA_MONITOR_GET_OBJECT (m)))
+#define GST_QA_ELEMENT_MONITOR_ELEMENT_IS_DECODER(m) (GST_QA_ELEMENT_MONITOR_CAST (m)->is_decoder)
 
 typedef struct _GstQaElementMonitor GstQaElementMonitor;
 typedef struct _GstQaElementMonitorClass GstQaElementMonitorClass;
index 742edd1..13c0f4e 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "gst-qa-pad-monitor.h"
+#include "gst-qa-element-monitor.h"
 
 /**
  * SECTION:gst-qa-pad-monitor
@@ -381,8 +382,21 @@ gst_qa_pad_monitor_buffer_probe (GstPad * pad, GstBuffer * buffer,
 {
   GstQaPadMonitor *monitor = udata;
 
+  /* TODO should we assume that a pad-monitor should always have an
+   * element-monitor as a parent? */
   if (G_LIKELY (GST_QA_MONITOR_GET_PARENT (monitor))) {
     /* a GstQaPadMonitor parent must be a GstQaElementMonitor */
+    if (GST_QA_ELEMENT_MONITOR_ELEMENT_IS_DECODER (monitor)) {
+      /* should not push out of segment data */
+      if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer)) &&
+          GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer)) &&
+          !gst_segment_clip (&monitor->segment, monitor->segment.format,
+              GST_BUFFER_TIMESTAMP (buffer), GST_BUFFER_TIMESTAMP (buffer) +
+              GST_BUFFER_DURATION (buffer), NULL, NULL)) {
+        /* TODO error */
+        g_assert_not_reached ();
+      }
+    }
   }
   return TRUE;
 }