From fecdfe18caf970becec993021c2b87e78ef5294c Mon Sep 17 00:00:00 2001 From: Benjamin Gaignard Date: Mon, 27 May 2024 13:52:28 +0200 Subject: [PATCH] v4l2codecs: Do not register stateless decoder if the driver doesn't support VIDIOC_CREATE_BUFS If the driver can't allocate buffers with VIDIOC_CREATE_BUFS do not register it has stateless decoder. Part-of: --- .../sys/v4l2codecs/gstv4l2decoder.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c index 29352b0708..2187521313 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2decoder.c @@ -167,6 +167,11 @@ gst_v4l2_decoder_open (GstV4l2Decoder * self) { gint ret; struct v4l2_capability querycap; + struct v4l2_create_buffers createbufs = { + .count = 0, + .memory = V4L2_MEMORY_MMAP, + }; + guint32 capabilities; self->media_fd = open (self->media_device, 0); @@ -211,6 +216,15 @@ gst_v4l2_decoder_open (GstV4l2Decoder * self) return FALSE; } + createbufs.format.type = self->sink_buf_type; + ret = ioctl (self->video_fd, VIDIOC_CREATE_BUFS, &createbufs); + if (ret < 0) { + GST_ERROR_OBJECT (self, + "GStreamer requires VIDIOC_CREATE_BUFS to be supported by stateless decoders."); + gst_v4l2_decoder_close (self); + return FALSE; + } + self->opened = TRUE; return TRUE;