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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7684>
This commit is contained in:
Benjamin Gaignard 2024-05-27 13:52:28 +02:00 committed by GStreamer Marge Bot
parent 2753a8f0c1
commit fecdfe18ca

View file

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