From 9c958417e270c2162fa3fce62841b38ff6c13afd Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Wed, 17 Jul 2013 17:57:39 -0300 Subject: [PATCH] pad-monitor: check that returns are combined properly When getting a return from a sink pad, check that it combines properly the current returns from downstream source pads --- validate/gst/qa/gst-qa-pad-monitor.c | 72 ++++++++++++++++++++++++++++ validate/gst/qa/gst-qa-pad-monitor.h | 2 + 2 files changed, 74 insertions(+) diff --git a/validate/gst/qa/gst-qa-pad-monitor.c b/validate/gst/qa/gst-qa-pad-monitor.c index 2a327e6d2b..d59999e04d 100644 --- a/validate/gst/qa/gst-qa-pad-monitor.c +++ b/validate/gst/qa/gst-qa-pad-monitor.c @@ -366,6 +366,75 @@ gst_qa_pad_monitor_update_buffer_data (GstQaPadMonitor * pad_monitor, pad_monitor->buffer_pushed = FALSE; } +static GstFlowReturn +_combine_flows (GstFlowReturn ret1, GstFlowReturn ret2) +{ + /* TODO review the combination + * what about not-negotiated and unexpected ? */ + if (ret1 == ret2) + return ret1; + if (ret1 <= GST_FLOW_NOT_NEGOTIATED) + return ret1; + if (ret2 <= GST_FLOW_NOT_NEGOTIATED) + return ret2; + if (ret1 == GST_FLOW_OK || ret2 == GST_FLOW_OK) + return GST_FLOW_OK; + return ret2; +} + +static void +gst_qa_pad_monitor_check_aggregated_return (GstQaPadMonitor * monitor, + GstFlowReturn ret) +{ + GstIterator *iter; + gboolean done; + GstPad *otherpad; + GstPad *peerpad; + GstQaPadMonitor *othermonitor; + GstFlowReturn aggregated = GST_FLOW_NOT_LINKED; + gboolean found_a_pad = FALSE; + + iter = gst_pad_iterate_internal_links (GST_QA_PAD_MONITOR_GET_PAD (monitor)); + done = FALSE; + while (!done) { + switch (gst_iterator_next (iter, (gpointer *) & otherpad)) { + case GST_ITERATOR_OK: + found_a_pad = TRUE; + peerpad = gst_pad_get_peer (otherpad); + if (peerpad) { + othermonitor = g_object_get_data ((GObject *) peerpad, "qa-monitor"); + if (othermonitor) { + aggregated = + _combine_flows (aggregated, othermonitor->last_flow_return); + } + gst_object_unref (peerpad); + } + gst_object_unref (otherpad); + break; + case GST_ITERATOR_RESYNC: + gst_iterator_resync (iter); + break; + case GST_ITERATOR_ERROR: + GST_WARNING_OBJECT (monitor, "Internal links pad iteration error"); + done = TRUE; + break; + case GST_ITERATOR_DONE: + done = TRUE; + break; + } + } + gst_iterator_free (iter); + if (!found_a_pad) { + /* no peer pad found, nothing to do */ + return; + } + if (aggregated != ret) { + /* TODO review this error code */ + GST_QA_MONITOR_REPORT_CRITICAL (monitor, BUFFER, UNEXPECTED, + "Wrong combined flow return"); + } +} + static void gst_qa_pad_monitor_add_expected_newsegment (GstQaPadMonitor * monitor, GstEvent * event) @@ -664,6 +733,9 @@ gst_qa_pad_monitor_chain_func (GstPad * pad, GstBuffer * buffer) ret = pad_monitor->chain_func (pad, buffer); + pad_monitor->last_flow_return = ret; + gst_qa_pad_monitor_check_aggregated_return (pad_monitor, ret); + return ret; } diff --git a/validate/gst/qa/gst-qa-pad-monitor.h b/validate/gst/qa/gst-qa-pad-monitor.h index 696e401c3c..4bbb567c4e 100644 --- a/validate/gst/qa/gst-qa-pad-monitor.h +++ b/validate/gst/qa/gst-qa-pad-monitor.h @@ -86,6 +86,8 @@ struct _GstQaPadMonitor { GstClockTime current_timestamp; GstClockTime current_duration; + GstFlowReturn last_flow_return; + /* Stores the current timestamp range of data * in this pad by using TIMESTAMP and TIMESTAMP+DURATION from * incomming buffers.