summaryrefslogtreecommitdiffstats
path: root/src/multimedia/camera/qcameradevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/camera/qcameradevice.cpp')
-rw-r--r--src/multimedia/camera/qcameradevice.cpp319
1 files changed, 277 insertions, 42 deletions
diff --git a/src/multimedia/camera/qcameradevice.cpp b/src/multimedia/camera/qcameradevice.cpp
index 5d030b27a..50727d49c 100644
--- a/src/multimedia/camera/qcameradevice.cpp
+++ b/src/multimedia/camera/qcameradevice.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qcameradevice_p.h"
@@ -43,40 +7,167 @@
QT_BEGIN_NAMESPACE
+
+/*!
+ \class QCameraFormat
+ \since 6.2
+ \brief The QCameraFormat class describes a video format supported by a camera device.
+ \inmodule QtMultimedia
+ \ingroup multimedia
+ \ingroup multimedia_camera
+
+ QCameraFormat represents a certain video format supported by a camera device.
+
+ The format is a combination of a
+ \l{QVideoFrameFormat::PixelFormat}{pixel format}, resolution and a range of frame
+ rates.
+
+ QCameraFormat objects can be queried from QCameraDevice to inspect the set of
+ supported video formats.
+
+ \sa QCameraDevice, QCamera
+*/
+
+/*!
+ \qmlvaluetype cameraFormat
+ \ingroup qmlvaluetypes
+ \inqmlmodule QtMultimedia
+ \since 6.2
+ //! \instantiates QCameraFormat
+ \brief Describes a video format supported by a camera device.
+ \ingroup multimedia_qml
+ \ingroup multimedia_video_qml
+
+ cameraFormat represents a certain video format supported by a camera device.
+
+ The format is a combination of a
+ \l{pixel format}{QVideoFrameFormat::PixelFormat}, resolution and a range of frame
+ rates.
+
+ cameraFormat objects can be queried from \l cameraDevice to inspect the set of
+ supported video formats.
+
+ \sa cameraDevice, Camera
+*/
+
+/*!
+ Constructs a null camera format.
+
+ \sa isNull()
+*/
QCameraFormat::QCameraFormat() noexcept = default;
+/*!
+ Copy constructs a camera format from the \a other format.
+*/
QCameraFormat::QCameraFormat(const QCameraFormat &other) noexcept = default;
+/*!
+ Assign \a other to this.
+*/
QCameraFormat &QCameraFormat::operator=(const QCameraFormat &other) noexcept = default;
+/*!
+ Destructs the camera format object.
+*/
QCameraFormat::~QCameraFormat() = default;
+/*! \fn bool QCameraFormat::isNull() const noexcept
+
+ Returns true if this is a default constructed QCameraFormat.
+*/
+
+/*!
+ \qmlproperty enumeration QtMultimedia::cameraFormat::pixelFormat
+
+ Holds the pixel format.
+
+ Most commonly this is either QVideoFrameFormat::Format_Jpeg or QVideoFrameFormat::Format_YUVY
+ but other formats could also be supported by the camera.
+
+ \sa QVideoFrameFormat::PixelFormat
+*/
+
+/*!
+ \property QCameraFormat::pixelFormat
+
+ Returns the pixel format.
+
+ Most commonly this is either QVideoFrameFormat::Format_Jpeg or QVideoFrameFormat::Format_YUVY
+ but other formats could also be supported by the camera.
+
+ \sa QVideoFrameFormat::PixelFormat
+*/
QVideoFrameFormat::PixelFormat QCameraFormat::pixelFormat() const noexcept
{
return d ? d->pixelFormat : QVideoFrameFormat::Format_Invalid;
}
+/*!
+ \qmlproperty size QtMultimedia::cameraFormat::resolution
+
+ Returns the resolution.
+*/
+
+/*!
+ \property QCameraFormat::resolution
+
+ Returns the resolution.
+*/
QSize QCameraFormat::resolution() const noexcept
{
return d ? d->resolution : QSize();
}
+/*!
+ \qmlproperty real QtMultimedia::cameraFormat::minFrameRate
+
+ Returns the lowest frame rate defined by this format.
+*/
+
+/*!
+ \property QCameraFormat::minFrameRate
+
+ Returns the lowest frame rate defined by this format.
+*/
float QCameraFormat::minFrameRate() const noexcept
{
return d ? d->minFrameRate : 0;
}
+/*!
+ \qmlproperty real QtMultimedia::cameraFormat::maxFrameRate
+
+ Returns the highest frame rate defined by this format.
+
+ The camera will always try to use the maximum frame rate supported by a
+ certain video format.
+*/
+
+/*!
+ \property QCameraFormat::maxFrameRate
+
+ Returns the highest frame rate defined by this format.
+
+ The camera will always try to use the highest frame rate supported by a
+ certain video format.
+*/
float QCameraFormat::maxFrameRate() const noexcept
{
return d ? d->maxFrameRate : 0;
}
-
+/*!
+ \internal
+*/
QCameraFormat::QCameraFormat(QCameraFormatPrivate *p)
: d(p)
{
}
+/*!
+ Returns \c true if the \a other format is equal to this camera format, otherwise \c false.
+*/
bool QCameraFormat::operator==(const QCameraFormat &other) const
{
if (d == other.d)
@@ -90,9 +181,14 @@ bool QCameraFormat::operator==(const QCameraFormat &other) const
}
/*!
+ \fn bool QCameraFormat::operator!=(const QCameraFormat &other) const
+
+ Returns \c false if the \a other format is equal to this camera format, otherwise \c true.
+*/
+
+/*!
\class QCameraDevice
\brief The QCameraDevice class provides general information about camera devices.
- \since 5.3
\inmodule QtMultimedia
\ingroup multimedia
\ingroup multimedia_camera
@@ -113,8 +209,7 @@ bool QCameraFormat::operator==(const QCameraFormat &other) const
\snippet multimedia-snippets/camera.cpp Camera selection
You can also use QCameraDevice to get general information about a camera
- device such as description, physical position on the system, or camera sensor
- orientation.
+ device such as description and physical position on the system.
\snippet multimedia-snippets/camera.cpp Camera info
@@ -122,6 +217,35 @@ bool QCameraFormat::operator==(const QCameraFormat &other) const
*/
/*!
+ \qmlvaluetype cameraDevice
+ \ingroup qmlvaluetypes
+ \inqmlmodule QtMultimedia
+ \since 6.2
+ //! \instantiates QCameraDevice
+ \brief Describes a camera device.
+ \ingroup multimedia_qml
+ \ingroup multimedia_video_qml
+
+ The cameraDevice value type describes the properties of a camera device that
+ is connected to the system.
+
+ The list of camera devices can be queried from the \l{MediaDevices}
+ type. To select a certain camera device set it as the device
+ on \l{Camera}.
+
+ \qml
+ CaptureSession {
+ camera: Camera {
+ cameraDevice: mediaDevices.defaultVideoInput
+ }
+ }
+ MediaDevices {
+ id: mediaDevices
+ }
+ \endqml
+*/
+
+/*!
Constructs a null camera device
*/
QCameraDevice::QCameraDevice() = default;
@@ -161,6 +285,16 @@ bool QCameraDevice::isNull() const
}
/*!
+ \qmlproperty string QtMultimedia::cameraDevice::id
+
+ Holds he device id of the camera
+
+ This is a unique ID to identify the camera and may not be human-readable.
+*/
+
+/*!
+ \property QCameraDevice::id
+
Returns the device id of the camera
This is a unique ID to identify the camera and may not be human-readable.
@@ -170,13 +304,68 @@ QByteArray QCameraDevice::id() const
return d ? d->id : QByteArray();
}
+/*!
+ \qmlproperty bool QtMultimedia::cameraDevice::isDefault
+
+ Is true if this is the default camera device.
+*/
+
+/*!
+ \property QCameraDevice::isDefault
+
+ Returns true if this is the default camera device.
+*/
bool QCameraDevice::isDefault() const
{
return d ? d->isDefault : false;
}
/*!
+ \since 6.7
+ \qmlproperty QtVideo::Rotation QtMultimedia::cameraDevice::correctionAngle
+
+ Returns the rotation angle needed to compensate for the physical camera rotation of the camera
+ compared to its native orientation. In other words, the property represents the clockwise angle
+ through which the output image needs to be rotated to be upright on the device screen in its
+ native orientation. Since \a correctionAngle is relative to the native orientation, this value
+ does not change with altering the device orientation (portrait/landscape). The correction angle
+ may be non-zero mostly on Android, where native and camera orientations are defined by the manufacturer.
+
+ \image camera_correctionAngle_90.png Example with 90 degrees \a correctionAngle
+*/
+
+/*!
+ \since 6.7
+ \property QCameraDevice::correctionAngle
+
+ Returns the rotation angle needed to compensate for the physical camera rotation of the camera
+ compared to its native orientation. In other words, the property represents the clockwise angle
+ through which the output image needs to be rotated to be upright on the device screen in its
+ native orientation. Since \a correctionAngle is relative to the native orientation, this value
+ does not change with altering the device orientation (portrait/landscape). The correction angle
+ may be non-zero mostly on Android, where native and camera orientations are defined by the manufacturer.
+
+ \image camera_correctionAngle_90.png Example with 90 degrees \a correctionAngle
+*/
+QtVideo::Rotation QCameraDevice::correctionAngle() const
+{
+ return d ? QtVideo::Rotation(d->orientation) : QtVideo::Rotation::None;
+}
+
+/*!
+ \qmlproperty string QtMultimedia::cameraDevice::description
+
+ Holds a human readable name of the camera.
+
+ Use this string to present the device to the user.
+*/
+
+/*!
+ \property QCameraDevice::description
+
Returns the human-readable description of the camera.
+
+ Use this string to present the device to the user.
*/
QString QCameraDevice::description() const
{
@@ -184,6 +373,36 @@ QString QCameraDevice::description() const
}
/*!
+ \enum QCameraDevice::Position
+
+ This enum specifies the physical position of the camera on the system hardware.
+
+ \value UnspecifiedPosition The camera position is unspecified or unknown.
+ \value BackFace The camera is on the back face of the system hardware. For example on a
+ mobile device, it means it is on the opposite side to that of the screen.
+ \value FrontFace The camera is on the front face of the system hardware. For example on a
+ mobile device, it means it is on the same side as that of the screen.
+
+ \sa position()
+*/
+
+/*!
+ \qmlproperty enumeration QtMultimedia::cameraDevice::position
+
+ Returns the physical position of the camera on the hardware system.
+
+ The returned value can be one of the following:
+
+ \value cameraDevice.UnspecifiedPosition The camera position is unspecified or unknown.
+ \value cameraDevice.BackFace The camera is on the back face of the system hardware. For example on a
+ mobile device, it means it is on the opposite side to that of the screen.
+ \value cameraDevice.FrontFace The camera is on the front face of the system hardware. For example on a
+ mobile device, it means it is on the same side as that of the screen.
+*/
+
+/*!
+ \property QCameraDevice::position
+
Returns the physical position of the camera on the hardware system.
*/
QCameraDevice::Position QCameraDevice::position() const
@@ -191,12 +410,26 @@ QCameraDevice::Position QCameraDevice::position() const
return d ? d->position : QCameraDevice::UnspecifiedPosition;
}
+/*!
+ Returns a list of resolutions that the camera can use to
+ capture still images.
+
+ \sa QImageCapture
+ */
QList<QSize> QCameraDevice::photoResolutions() const
{
return d ? d->photoResolutions : QList<QSize>{};
}
/*!
+ \qmlproperty CameraFormat QtMultimedia::cameraDevice::videoFormats
+
+ Holds the video formats supported by the camera.
+*/
+
+/*!
+ \property QCameraDevice::videoFormats
+
Returns the video formats supported by the camera.
*/
QList<QCameraFormat> QCameraDevice::videoFormats() const
@@ -231,3 +464,5 @@ QDebug operator<<(QDebug d, const QCameraDevice &camera)
#endif
QT_END_NAMESPACE
+
+#include "moc_qcameradevice.cpp"