8#include <private/qcameradevice_p.h>
9#include <private/qcore_unix_p.h>
16#include <linux/videodev2.h>
30 return std::equal(
a.cbegin(),
a.cend(),
b.cbegin(),
b.cend(), areCamerasDataEqual);
53bool QV4L2CameraDevices::doCheckCameras()
55 QList<QCameraDevice> newCameras;
68 const int fd =
open(
file.constData(), O_RDONLY);
74 v4l2_fmtdesc formatDesc = {};
76 struct v4l2_capability
cap;
80 if (
cap.device_caps & V4L2_CAP_META_CAPTURE)
82 if (!(
cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
84 if (!(
cap.capabilities & V4L2_CAP_STREAMING))
87 auto camera = std::make_unique<QCameraDevicePrivate>();
93 formatDesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
95 while (!
xioctl(
fd, VIDIOC_ENUM_FMT, &formatDesc)) {
97 qCDebug(qLcV4L2CameraDevices) <<
" " << pixelFmt;
104 qCDebug(qLcV4L2CameraDevices) <<
"frame sizes:";
106 frameSize.pixel_format = formatDesc.pixelformat;
109 QList<QSize> resolutions;
110 if (
frameSize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
120 for (
auto resolution : resolutions) {
123 auto updateMaxMinFrameRate = [&max, &
min](
auto discreteFrameRate) {
124 const float rate = float(discreteFrameRate.denominator)
125 / float(discreteFrameRate.numerator);
132 v4l2_frmivalenum frameInterval = {};
133 frameInterval.pixel_format = formatDesc.pixelformat;
134 frameInterval.width = resolution.width();
135 frameInterval.height = resolution.height();
137 while (!
xioctl(
fd, VIDIOC_ENUM_FRAMEINTERVALS, &frameInterval)) {
138 if (frameInterval.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
139 updateMaxMinFrameRate(frameInterval.discrete);
141 updateMaxMinFrameRate(frameInterval.stepwise.max);
142 updateMaxMinFrameRate(frameInterval.stepwise.min);
144 ++frameInterval.index;
147 qCDebug(qLcV4L2CameraDevices) <<
" " << resolution <<
min << max;
150 auto fmt = std::make_unique<QCameraFormatPrivate>();
151 fmt->pixelFormat = pixelFmt;
152 fmt->resolution = resolution;
154 fmt->maxFrameRate = max;
155 camera->videoFormats.append(
fmt.release()->create());
156 camera->photoResolutions.append(resolution);
164 if (
camera->videoFormats.empty())
170 newCameras.append(
camera.release()->create());
176 m_cameras = std::move(newCameras);
182#include "moc_qv4l2cameradevices_p.cpp"
IOBluetoothDevice * device
static const QCameraDevicePrivate * handle(const QCameraDevice &device)
The QCameraDevice class provides general information about camera devices.
void directoryChanged(const QString &path, QPrivateSignal)
This signal is emitted when the directory at a specified path is modified (e.g., when a file is added...
bool addPath(const QString &file)
Adds path to the file system watcher if path exists.
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QList< QCameraDevice > videoDevices() const override
QV4L2CameraDevices(QPlatformMediaIntegration *integration)
Combined button and popup list for selecting options.
constexpr const T & min(const T &a, const T &b)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
static constexpr QSize frameSize(const T &frame)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
QLatin1StringView QLatin1String
QVideoFrameFormat::PixelFormat fmt
QVideoFrameFormat::PixelFormat formatForV4L2Format(uint32_t v4l2Format)
static bool areCamerasEqual(QList< QCameraDevice > a, QList< QCameraDevice > b)
QT_BEGIN_NAMESPACE int xioctl(int fd, int request, void *arg)
file open(QIODevice::ReadOnly)