Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 <QtMultimedia/private/qmultimediautils_p.h>
7#include <QtCore/private/qcore_unix_p.h>
8
10
11namespace QtV4L2 {
12
13QV4L2FileDescriptor::QV4L2FileDescriptor(QUniqueFileDescriptorHandle descriptor)
15{
16 Q_ASSERT(isValid());
17}
18
19bool QV4L2FileDescriptor::call(int request, void *arg) const
20{
21 return QtMultimediaPrivate::qt_safe_ioctl(get(), request, arg) >= 0;
22}
23
24bool QV4L2FileDescriptor::requestBuffers(v4l2_memory memoryType, quint32 &buffersCount) const
25{
26 v4l2_requestbuffers req = {};
27 req.count = buffersCount;
28 req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
29 req.memory = memoryType;
30
31 if (!call(VIDIOC_REQBUFS, &req))
32 return false;
33
34 buffersCount = req.count;
35 return true;
36}
37
39{
40 int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
41 if (!call(VIDIOC_STREAMON, &type))
42 return false;
43
44 m_streamStarted = true;
45 return true;
46}
47
49{
50 int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
51 auto result = call(VIDIOC_STREAMOFF, &type);
52 m_streamStarted = false;
53 return result;
54}
55
56} // namespace QtV4L2
57
58QT_END_NAMESPACE
bool requestBuffers(v4l2_memory memoryType, quint32 &buffersCount) const
QV4L2FileDescriptor(QUniqueFileDescriptorHandle descriptor)
Combined button and popup list for selecting options.