diff options
Diffstat (limited to 'src/multimedia/camera/qcameradevice.cpp')
-rw-r--r-- | src/multimedia/camera/qcameradevice.cpp | 119 |
1 files changed, 68 insertions, 51 deletions
diff --git a/src/multimedia/camera/qcameradevice.cpp b/src/multimedia/camera/qcameradevice.cpp index e727301e3..63e7fb4c0 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" @@ -114,7 +78,7 @@ QCameraFormat::~QCameraFormat() = default; */ /*! - \qmlproperty enumeration QtMultimedia::CameraFormat::pixelFormat + \qmlproperty enumeration QtMultimedia::cameraFormat::pixelFormat Holds the pixel format. @@ -125,6 +89,8 @@ QCameraFormat::~QCameraFormat() = default; */ /*! + \property QCameraFormat::pixelFormat + Returns the pixel format. Most commonly this is either QVideoFrameFormat::Format_Jpeg or QVideoFrameFormat::Format_YUVY @@ -138,12 +104,14 @@ QVideoFrameFormat::PixelFormat QCameraFormat::pixelFormat() const noexcept } /*! - \qmlproperty size QtMultimedia::CameraFormat::resolution + \qmlproperty size QtMultimedia::cameraFormat::resolution Returns the resolution. */ /*! + \property QCameraFormat::resolution + Returns the resolution. */ QSize QCameraFormat::resolution() const noexcept @@ -152,12 +120,14 @@ QSize QCameraFormat::resolution() const noexcept } /*! - \qmlproperty real QtMultimedia::CameraFormat::minFrameRate + \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 @@ -166,18 +136,20 @@ float QCameraFormat::minFrameRate() const noexcept } /*! - \qmlproperty real QtMultimedia::CameraFormat::maxFrameRate + \qmlproperty real QtMultimedia::cameraFormat::maxFrameRate Returns the highest frame rate defined by this format. - In 6.2, the camera will always try to use the maximum frame rate supported by a + 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. - In 6.2, the camera will always try to use the highest frame rate supported by a + The camera will always try to use the highest frame rate supported by a certain video format. */ float QCameraFormat::maxFrameRate() const noexcept @@ -237,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 @@ -322,6 +293,8 @@ bool QCameraDevice::isNull() const */ /*! + \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. @@ -338,6 +311,8 @@ QByteArray QCameraDevice::id() const */ /*! + \property QCameraDevice::isDefault + Returns true if this is the default camera device. */ bool QCameraDevice::isDefault() const @@ -346,6 +321,38 @@ bool QCameraDevice::isDefault() const } /*! + \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. @@ -354,6 +361,8 @@ bool QCameraDevice::isDefault() const */ /*! + \property QCameraDevice::description + Returns the human-readable description of the camera. Use this string to present the device to the user. @@ -392,6 +401,8 @@ QString QCameraDevice::description() const */ /*! + \property QCameraDevice::position + Returns the physical position of the camera on the hardware system. */ QCameraDevice::Position QCameraDevice::position() const @@ -411,12 +422,14 @@ QList<QSize> QCameraDevice::photoResolutions() const } /*! - \qmlproperty CameraFormat QtMultiMedia::CameraDevice::videoFormats + \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 @@ -442,12 +455,16 @@ QCameraDevice& QCameraDevice::operator=(const QCameraDevice& other) = default; #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const QCameraDevice &camera) { - d.maybeSpace() << QStringLiteral("QCameraDevice(name=%1, position=%2, orientation=%3)") - .arg(camera.description()) - .arg(QString::fromLatin1(QCamera::staticMetaObject.enumerator(QCamera::staticMetaObject.indexOfEnumerator("Position")) - .valueToKey(camera.position()))); + d.maybeSpace() << QStringLiteral("QCameraDevice(name=%1, id=%2, position=%3)") + .arg(camera.description()) + .arg(QLatin1StringView(camera.id())) + .arg(QLatin1StringView( + QMetaEnum::fromType<QCameraDevice::Position>().valueToKey( + camera.position()))); return d.space(); } #endif QT_END_NAMESPACE + +#include "moc_qcameradevice.cpp" |