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
This commit is contained in:
Nicolas Dufresne 2013-12-19 15:26:52 -05:00
parent 61183670c0
commit bd51c37196
3 changed files with 10 additions and 0 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}