pad-monitor: improve timestamp ranges check
Keep the full range stored by the element in the monitor and check if outgoing timestamps are within that range. It is simple and should generally work.
This commit is contained in:
parent
a11cc64f90
commit
a7353e988b
@ -237,6 +237,12 @@ static gboolean
|
|||||||
gst_qa_pad_monitor_timestamp_is_in_received_range (GstQaPadMonitor * monitor,
|
gst_qa_pad_monitor_timestamp_is_in_received_range (GstQaPadMonitor * monitor,
|
||||||
GstClockTime ts)
|
GstClockTime ts)
|
||||||
{
|
{
|
||||||
|
GST_DEBUG_OBJECT (monitor, "Checking if timestamp %" GST_TIME_FORMAT
|
||||||
|
" is in range: %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT " for pad "
|
||||||
|
"%s:%s", GST_TIME_ARGS (ts),
|
||||||
|
GST_TIME_ARGS (monitor->timestamp_range_start),
|
||||||
|
GST_TIME_ARGS (monitor->timestamp_range_end),
|
||||||
|
GST_DEBUG_PAD_NAME (GST_QA_PAD_MONITOR_GET_PAD (monitor)));
|
||||||
return !GST_CLOCK_TIME_IS_VALID (monitor->timestamp_range_start) ||
|
return !GST_CLOCK_TIME_IS_VALID (monitor->timestamp_range_start) ||
|
||||||
!GST_CLOCK_TIME_IS_VALID (monitor->timestamp_range_end) ||
|
!GST_CLOCK_TIME_IS_VALID (monitor->timestamp_range_end) ||
|
||||||
(monitor->timestamp_range_start <= ts
|
(monitor->timestamp_range_start <= ts
|
||||||
@ -311,38 +317,6 @@ gst_qa_pad_monitor_check_buffer_timestamp_in_received_range (GstQaPadMonitor *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_qa_pad_monitor_notify_buffer_pushed (GstQaPadMonitor * monitor)
|
|
||||||
{
|
|
||||||
GstIterator *iter;
|
|
||||||
gboolean done;
|
|
||||||
GstPad *otherpad;
|
|
||||||
GstQaPadMonitor *othermonitor;
|
|
||||||
|
|
||||||
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:
|
|
||||||
othermonitor = g_object_get_data ((GObject *) otherpad, "qa-monitor");
|
|
||||||
othermonitor->buffer_pushed = TRUE;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_qa_pad_monitor_check_first_buffer (GstQaPadMonitor * pad_monitor,
|
gst_qa_pad_monitor_check_first_buffer (GstQaPadMonitor * pad_monitor,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
@ -370,20 +344,33 @@ static void
|
|||||||
gst_qa_pad_monitor_update_buffer_data (GstQaPadMonitor * pad_monitor,
|
gst_qa_pad_monitor_update_buffer_data (GstQaPadMonitor * pad_monitor,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
|
/* TODO handle reverse playback too */
|
||||||
pad_monitor->current_timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
pad_monitor->current_timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
pad_monitor->current_duration = GST_BUFFER_DURATION (buffer);
|
pad_monitor->current_duration = GST_BUFFER_DURATION (buffer);
|
||||||
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer)) &&
|
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer))) {
|
||||||
GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer))) {
|
if (GST_CLOCK_TIME_IS_VALID (pad_monitor->timestamp_range_start)) {
|
||||||
if (pad_monitor->buffer_pushed) {
|
pad_monitor->timestamp_range_start =
|
||||||
|
MIN (pad_monitor->timestamp_range_start,
|
||||||
|
GST_BUFFER_TIMESTAMP (buffer));
|
||||||
|
} else {
|
||||||
pad_monitor->timestamp_range_start = GST_BUFFER_TIMESTAMP (buffer);
|
pad_monitor->timestamp_range_start = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
}
|
}
|
||||||
pad_monitor->timestamp_range_end = GST_BUFFER_TIMESTAMP (buffer) +
|
|
||||||
GST_BUFFER_DURATION (buffer);
|
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer))) {
|
||||||
} else {
|
GstClockTime endts =
|
||||||
pad_monitor->timestamp_range_start = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer);
|
||||||
pad_monitor->timestamp_range_end = GST_CLOCK_TIME_NONE;
|
if (GST_CLOCK_TIME_IS_VALID (pad_monitor->timestamp_range_end)) {
|
||||||
|
pad_monitor->timestamp_range_end =
|
||||||
|
MAX (pad_monitor->timestamp_range_end, endts);
|
||||||
|
} else {
|
||||||
|
pad_monitor->timestamp_range_end = endts;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pad_monitor->buffer_pushed = FALSE;
|
GST_DEBUG_OBJECT (pad_monitor, "Current stored range: %" GST_TIME_FORMAT
|
||||||
|
" - %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (pad_monitor->timestamp_range_start),
|
||||||
|
GST_TIME_ARGS (pad_monitor->timestamp_range_end));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
@ -827,7 +814,6 @@ gst_qa_pad_monitor_buffer_probe (GstPad * pad, GstBuffer * buffer,
|
|||||||
gst_qa_pad_monitor_update_buffer_data (monitor, buffer);
|
gst_qa_pad_monitor_update_buffer_data (monitor, buffer);
|
||||||
|
|
||||||
gst_qa_pad_monitor_check_buffer_timestamp_in_received_range (monitor, buffer);
|
gst_qa_pad_monitor_check_buffer_timestamp_in_received_range (monitor, buffer);
|
||||||
gst_qa_pad_monitor_notify_buffer_pushed (monitor);
|
|
||||||
|
|
||||||
/* TODO should we assume that a pad-monitor should always have an
|
/* TODO should we assume that a pad-monitor should always have an
|
||||||
* element-monitor as a parent? */
|
* element-monitor as a parent? */
|
||||||
|
@ -88,17 +88,16 @@ struct _GstQaPadMonitor {
|
|||||||
|
|
||||||
GstFlowReturn last_flow_return;
|
GstFlowReturn last_flow_return;
|
||||||
|
|
||||||
/* Stores the current timestamp range of data
|
/* Stores the timestamp range of data that has flown through
|
||||||
* in this pad by using TIMESTAMP and TIMESTAMP+DURATION from
|
* this pad by using TIMESTAMP and TIMESTAMP+DURATION from
|
||||||
* incomming buffers.
|
* incomming buffers. Every time a buffer is pushed, this range
|
||||||
|
* is extended.
|
||||||
*
|
*
|
||||||
* If the internally linked pads haven't pushed a buffer, it will
|
* When a buffer is pushed, the timestamp range is checked against
|
||||||
* update the end to the new TIMESTAMP+DURATION, in case a buffer
|
* the outgoing timestamp to check it is in the received boundaries.
|
||||||
* was pushed, the start is also updated to be TIMESTMAP.
|
|
||||||
*/
|
*/
|
||||||
GstClockTime timestamp_range_start;
|
GstClockTime timestamp_range_start;
|
||||||
GstClockTime timestamp_range_end;
|
GstClockTime timestamp_range_end;
|
||||||
gboolean buffer_pushed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user