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
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
5#include "qqnxcamera_p.h"
6#include "private/qcameradevice_p.h"
8
9#include <qdir.h>
10#include <qdebug.h>
11
12#include <optional>
13
15
16static 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
41static 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
88QQnxVideoDevices::QQnxVideoDevices(QPlatformMediaIntegration *integration)
90{
91}
92
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
113QT_END_NAMESPACE
bool isValid() const
QList< QCameraDevice > findVideoInputs() const override
QQnxVideoDevices(QPlatformMediaIntegration *integration)
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE QVideoFrameFormat::PixelFormat fromCameraFrametype(camera_frametype_t type)
static std::optional< QCameraDevice > createCameraDevice(camera_unit_t unit, bool isDefault)