From 1d43f6d852c2114f230fdfb075c211720e175c3d Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Wed, 16 Mar 2016 16:24:55 +0100
Subject: [PATCH] v4l2videodec: only set latency if the frame duration is valid
If the duration of the v4l2object is GST_CLOCK_TIME_NONE, because the
sink did not specify a framerate in the caps and the driver accepts the
framerate, the decoder element uses GST_CLOCK_TIME_NONE to calculate and
set the element latency.
While this is a bug of the capture driver, the decoder element should
not use the invalid duration to calculate a latency, but print a warning
instead.
https://bugzilla.gnome.org/show_bug.cgi?id=779466
---
sys/v4l2/gstv4l2videodec.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c
index d148b66ad5..8f713b60a8 100644
--- a/sys/v4l2/gstv4l2videodec.c
+++ b/sys/v4l2/gstv4l2videodec.c
@@ -752,8 +752,14 @@ gst_v4l2_video_dec_decide_allocation (GstVideoDecoder * decoder,
ret = GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder,
query);
- latency = self->v4l2capture->min_buffers * self->v4l2capture->duration;
- gst_video_decoder_set_latency (decoder, latency, latency);
+ if (GST_CLOCK_TIME_IS_VALID (self->v4l2capture->duration)) {
+ GST_DEBUG_OBJECT (self, "Setting latency: %u * %llu",
+ self->v4l2capture->min_buffers, self->v4l2capture->duration);
+ latency = self->v4l2capture->min_buffers * self->v4l2capture->duration;
+ gst_video_decoder_set_latency (decoder, latency, latency);
+ } else {
+ GST_WARNING_OBJECT (self, "Duration invalid, not setting latency");
+ }
return ret;
}