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
4
#
include
"qv4l2filedescriptor_p.h"
5
6
#
include
<
sys
/
ioctl
.
h
>
7
#
include
<
private
/
qcore_unix_p
.
h
>
8
9
#
include
<
linux
/
videodev2
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
int
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
24
QV4L2FileDescriptor
::
QV4L2FileDescriptor
(
int
descriptor) : m_descriptor(descriptor)
25
{
26
Q_ASSERT(descriptor >= 0);
27
}
28
29
QV4L2FileDescriptor
::~
QV4L2FileDescriptor
()
30
{
31
qt_safe_close(m_descriptor);
32
}
33
34
bool
QV4L2FileDescriptor
::
call
(
int
request,
void
*arg)
const
35
{
36
return
::xioctl(m_descriptor, request, arg) >= 0;
37
}
38
39
bool
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
53
bool
QV4L2FileDescriptor
::
startStream
()
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
63
bool
QV4L2FileDescriptor
::
stopStream
()
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
71
QT_END_NAMESPACE
QV4L2FileDescriptor
Definition
qv4l2filedescriptor_p.h:25
QV4L2FileDescriptor::stopStream
bool stopStream()
Definition
qv4l2filedescriptor.cpp:63
QV4L2FileDescriptor::QV4L2FileDescriptor
QV4L2FileDescriptor(int descriptor)
Definition
qv4l2filedescriptor.cpp:24
QV4L2FileDescriptor::~QV4L2FileDescriptor
~QV4L2FileDescriptor()
Definition
qv4l2filedescriptor.cpp:29
QV4L2FileDescriptor::startStream
bool startStream()
Definition
qv4l2filedescriptor.cpp:53
QV4L2FileDescriptor::call
bool call(int request, void *arg) const
Definition
qv4l2filedescriptor.cpp:34
QV4L2FileDescriptor::requestBuffers
bool requestBuffers(quint32 memoryType, quint32 &buffersCount) const
Definition
qv4l2filedescriptor.cpp:39
xioctl
QT_BEGIN_NAMESPACE int xioctl(int fd, int request, void *arg)
Definition
qv4l2filedescriptor.cpp:13
qtmultimedia
src
plugins
multimedia
ffmpeg
qv4l2filedescriptor.cpp
Generated on
for Qt by
1.14.0