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
qqnxvideodevices.cpp
Go to the documentation of this file.
1
// Copyright (C) 2021 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
"qqnxvideodevices_p.h"
5
#
include
"camera/qqnxcamera_p.h"
6
#
include
"private/qcameradevice_p.h"
7
#
include
"qcameradevice.h"
8
9
#
include
<
qdir
.
h
>
10
#
include
<
qdebug
.
h
>
11
12
#
include
<
optional
>
13
14
QT_BEGIN_NAMESPACE
15
16
static
QVideoFrameFormat
::
PixelFormat
fromCameraFrametype
(camera_frametype_t type)
17
{
18
switch
(type) {
19
default
:
20
case
CAMERA_FRAMETYPE_UNSPECIFIED:
21
return
QVideoFrameFormat::Format_Invalid;
22
case
CAMERA_FRAMETYPE_NV12:
23
return
QVideoFrameFormat::Format_NV12;
24
case
CAMERA_FRAMETYPE_RGB8888:
25
return
QVideoFrameFormat::Format_ARGB8888;
26
#
if
_NTO_VERSION
<
800
27
case
CAMERA_FRAMETYPE_JPEG:
28
return
QVideoFrameFormat::Format_Jpeg;
29
#
endif
30
case
CAMERA_FRAMETYPE_GRAY8:
31
return
QVideoFrameFormat::Format_Y8;
32
case
CAMERA_FRAMETYPE_CBYCRY:
33
return
QVideoFrameFormat::Format_UYVY;
34
case
CAMERA_FRAMETYPE_YCBCR420P:
35
return
QVideoFrameFormat::Format_YUV420P;
36
case
CAMERA_FRAMETYPE_YCBYCR:
37
return
QVideoFrameFormat::Format_YUYV;
38
}
39
}
40
41
static
std
::
optional
<
QCameraDevice
>
createCameraDevice
(camera_unit_t unit,
bool
isDefault)
42
{
43
const
QQnxCamera
camera(unit);
44
45
if
(!camera
.
isValid
(
)
) {
46
qWarning() <<
"Invalid camera unit:"
<< unit;
47
return
{};
48
}
49
50
auto
*p =
new
QCameraDevicePrivate;
51
52
p->id = QByteArray::number(camera.unit());
53
p->description = camera.name();
54
p->isDefault = isDefault;
55
56
const
QList<camera_frametype_t> frameTypes = camera.supportedVfFrameTypes();
57
58
for
(camera_res_t res : camera.supportedVfResolutions()) {
59
const
QSize resolution(res.width, res.height);
60
61
p->photoResolutions.append(resolution);
62
63
for
(camera_frametype_t frameType : camera.supportedVfFrameTypes()) {
64
const
QVideoFrameFormat::PixelFormat pixelFormat = fromCameraFrametype(frameType);
65
66
if
(pixelFormat == QVideoFrameFormat::Format_Invalid)
67
continue
;
68
69
auto
*f =
new
QCameraFormatPrivate;
70
p->videoFormats.append(f->create());
71
72
f->resolution = resolution;
73
f->pixelFormat = pixelFormat;
74
f->minFrameRate = 1.e10;
75
76
for
(
double
fr : camera.specifiedVfFrameRates(frameType, res)) {
77
if
(fr < f->minFrameRate)
78
f->minFrameRate = fr;
79
if
(fr > f->maxFrameRate)
80
f->maxFrameRate = fr;
81
}
82
}
83
}
84
85
return
p->create();
86
}
87
88
QQnxVideoDevices
::
QQnxVideoDevices
(QPlatformMediaIntegration *integration)
89
:
QPlatformVideoDevices
(
integration
)
90
{
91
}
92
93
QList
<
QCameraDevice
>
QQnxVideoDevices
::
findVideoInputs
()
const
94
{
95
QList<QCameraDevice> cameras;
96
97
bool
isDefault =
true
;
98
99
for
(
const
camera_unit_t cameraUnit : QQnxCamera::supportedUnits()) {
100
const
std::optional<QCameraDevice> cameraDevice = createCameraDevice(cameraUnit, isDefault);
101
102
if
(!cameraDevice)
103
continue
;
104
105
cameras.append(*cameraDevice);
106
107
isDefault =
false
;
108
}
109
110
return
cameras;
111
}
112
113
QT_END_NAMESPACE
QQnxCamera
Definition
qqnxcamera_p.h:38
QQnxCamera::isValid
bool isValid() const
Definition
qqnxcamera.cpp:108
QQnxVideoDevices
Definition
qqnxvideodevices_p.h:23
QQnxVideoDevices::findVideoInputs
QList< QCameraDevice > findVideoInputs() const override
Definition
qqnxvideodevices.cpp:93
QQnxVideoDevices::QQnxVideoDevices
QQnxVideoDevices(QPlatformMediaIntegration *integration)
Definition
qqnxvideodevices.cpp:88
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
fromCameraFrametype
static QT_BEGIN_NAMESPACE QVideoFrameFormat::PixelFormat fromCameraFrametype(camera_frametype_t type)
Definition
qqnxvideodevices.cpp:16
createCameraDevice
static std::optional< QCameraDevice > createCameraDevice(camera_unit_t unit, bool isDefault)
Definition
qqnxvideodevices.cpp:41
qtmultimedia
src
plugins
multimedia
qnx
qqnxvideodevices.cpp
Generated on
for Qt by
1.18.0