Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
4
#
include
"qv4l2filedescriptor_p.h"
5
6
#
include
<
QtMultimedia
/
private
/
qmultimediautils_p
.
h
>
7
#
include
<
QtCore
/
private
/
qcore_unix_p
.
h
>
8
9
QT_BEGIN_NAMESPACE
10
11
namespace
QtV4L2
{
12
13
QV4L2FileDescriptor
::
QV4L2FileDescriptor
(QUniqueFileDescriptorHandle descriptor)
14
:
QUniqueFileDescriptorHandle
(
std
::
move
(
descriptor
))
15
{
16
Q_ASSERT(isValid());
17
}
18
19
q23::expected<
int
, std::error_code>
QV4L2FileDescriptor
::call(
int
request,
void
*arg)
const
20
{
21
const
int
result = QtMultimediaPrivate::qt_safe_ioctl(get(), request, arg);
22
if
(result < 0)
23
return
q23::unexpected(std::error_code{ errno, std::system_category() });
24
25
return
result;
26
}
27
28
q23
::
expected
<
int
,
std
::
error_code
>
QV4L2FileDescriptor
::
requestBuffers
(v4l2_memory memoryType,
29
uint32_t bufferCount)
const
30
{
31
v4l2_requestbuffers req = {};
32
req.count = bufferCount;
33
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
34
req.memory = memoryType;
35
36
auto
callResult = call(VIDIOC_REQBUFS, &req);
37
if
(!callResult)
38
return
q23::unexpected(callResult.error());
39
40
return
int
(req.count);
41
}
42
43
q23
::
expected
<
void
,
std
::
error_code
>
QV4L2FileDescriptor
::
releaseAllBuffers
(v4l2_memory type)
const
44
{
45
auto
status = requestBuffers(type, 0);
46
if
(!status)
47
return
q23::unexpected(status.error());
48
return
{};
49
}
50
51
q23
::
expected
<
void
,
std
::
error_code
>
QV4L2FileDescriptor
::
startStream
()
52
{
53
int
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
54
auto
result = call(VIDIOC_STREAMON, &type);
55
if
(!result)
56
return
q23::unexpected(result.error());
57
58
m_streamStarted =
true
;
59
return
{};
60
}
61
62
q23
::
expected
<
void
,
std
::
error_code
>
QV4L2FileDescriptor
::
stopStream
()
63
{
64
int
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
65
auto
result = call(VIDIOC_STREAMOFF, &type);
66
m_streamStarted =
false
;
67
if
(!result)
68
return
q23::unexpected(result.error());
69
return
{};
70
}
71
72
q23
::
expected
<
v4l2_queryctrl
,
std
::
error_code
>
QV4L2FileDescriptor
::
queryControl
(uint32_t id)
const
73
{
74
v4l2_queryctrl queryControl{};
75
queryControl.id = id;
76
auto
result = call(VIDIOC_QUERYCTRL, &queryControl);
77
if
(!result)
78
return
q23::unexpected(result.error());
79
return
queryControl;
80
}
81
82
}
// namespace QtV4L2
83
84
QT_END_NAMESPACE
QtV4L2::QV4L2FileDescriptor
Definition
qv4l2filedescriptor_p.h:33
QtV4L2::QV4L2FileDescriptor::requestBuffers
q23::expected< int, std::error_code > requestBuffers(v4l2_memory memoryType, uint32_t bufferCount) const
Definition
qv4l2filedescriptor.cpp:28
QtV4L2::QV4L2FileDescriptor::stopStream
q23::expected< void, std::error_code > stopStream()
Definition
qv4l2filedescriptor.cpp:62
QtV4L2::QV4L2FileDescriptor::releaseAllBuffers
q23::expected< void, std::error_code > releaseAllBuffers(v4l2_memory) const
Definition
qv4l2filedescriptor.cpp:43
QtV4L2::QV4L2FileDescriptor::startStream
q23::expected< void, std::error_code > startStream()
Definition
qv4l2filedescriptor.cpp:51
QtV4L2::QV4L2FileDescriptor::QV4L2FileDescriptor
QV4L2FileDescriptor(QUniqueFileDescriptorHandle descriptor)
Definition
qv4l2filedescriptor.cpp:13
QtV4L2::QV4L2FileDescriptor::queryControl
q23::expected< v4l2_queryctrl, std::error_code > queryControl(uint32_t id) const
Definition
qv4l2filedescriptor.cpp:72
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtV4L2
Definition
qv4l2camera.cpp:23
qtmultimedia
src
multimedia
v4l2
qv4l2filedescriptor.cpp
Generated on
for Qt by
1.18.0