Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qv4l2filedescriptor.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <sys/ioctl.h>
7#include <private/qcore_unix_p.h>
8
9#include <linux/videodev2.h>
10
12
13int xioctl(int fd, int request, void *arg)
14{
15 int res;
16
17 do {
18 res = ::ioctl(fd, request, arg);
19 } while (res == -1 && EINTR == errno);
20
21 return res;
22}
23
24QV4L2FileDescriptor::QV4L2FileDescriptor(int descriptor) : m_descriptor(descriptor)
25{
26 Q_ASSERT(descriptor >= 0);
27}
28
33
35{
36 return ::xioctl(m_descriptor, request, arg) >= 0;
37}
38
39bool QV4L2FileDescriptor::requestBuffers(quint32 memoryType, quint32 &buffersCount) const
40{
41 v4l2_requestbuffers req = {};
42 req.count = buffersCount;
43 req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
44 req.memory = memoryType;
45
46 if (!call(VIDIOC_REQBUFS, &req))
47 return false;
48
49 buffersCount = req.count;
50 return true;
51}
52
54{
55 int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
56 if (!call(VIDIOC_STREAMON, &type))
57 return false;
58
59 m_streamStarted = true;
60 return true;
61}
62
64{
65 int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
66 auto result = call(VIDIOC_STREAMOFF, &type);
67 m_streamStarted = false;
68 return result;
69}
70
QV4L2FileDescriptor(int descriptor)
bool call(int request, void *arg) const
bool requestBuffers(quint32 memoryType, quint32 &buffersCount) const
Combined button and popup list for selecting options.
static int qt_safe_close(int fd)
GLenum type
GLuint64 GLenum GLint fd
GLuint res
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int void * arg
unsigned int quint32
Definition qtypes.h:50
QT_BEGIN_NAMESPACE int xioctl(int fd, int request, void *arg)
QNetworkRequest request(url)