Commit bd51c371 authored by Nicolas Dufresne's avatar Nicolas Dufresne

v4l2videodec: Calculate latency from device information

Decoders or other devices that expose a minimum buffers required produce
an first output. We use this information to calculate latency.

https://bugzilla.gnome.org/show_bug.cgi?id=722128
parent 61183670
......@@ -3296,6 +3296,7 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query)
if (v4l2_ioctl (obj->video_fd, VIDIOC_G_CTRL, &ctl) >= 0) {
GST_DEBUG_OBJECT (obj->element, "driver require a minimum of %d buffers",
ctl.value);
obj->min_buffers_for_capture = ctl.value;
min += ctl.value;
}
......
......@@ -137,6 +137,10 @@ struct _GstV4l2Object {
*/
gboolean prefered_non_contiguous;
/* This will be set if supported in decide_allocation. It can be used to
* calculate the minimum latency of a m2m decoder. */
guint32 min_buffers_for_capture;
/* wanted mode */
GstV4l2IOMode req_mode;
......
......@@ -520,12 +520,17 @@ gst_v4l2_video_dec_decide_allocation (GstVideoDecoder * decoder,
GstQuery * query)
{
GstV4l2VideoDec *self = GST_V4L2_VIDEO_DEC (decoder);
GstClockTime latency;
gboolean ret = FALSE;
if (gst_v4l2_object_decide_allocation (self->v4l2capture, query))
ret = GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder,
query);
latency = self->v4l2capture->min_buffers_for_capture *
self->v4l2capture->duration;
gst_video_decoder_set_latency (decoder, latency, latency);
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment