diff options
Diffstat (limited to 'src/plugins/multimedia/qnx/camera/qqnxcamera_p.h')
-rw-r--r-- | src/plugins/multimedia/qnx/camera/qqnxcamera_p.h | 260 |
1 files changed, 96 insertions, 164 deletions
diff --git a/src/plugins/multimedia/qnx/camera/qqnxcamera_p.h b/src/plugins/multimedia/qnx/camera/qqnxcamera_p.h index aab112000..a4ddbfed6 100644 --- a/src/plugins/multimedia/qnx/camera/qqnxcamera_p.h +++ b/src/plugins/multimedia/qnx/camera/qqnxcamera_p.h @@ -1,43 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** 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$ -** -****************************************************************************/ -#ifndef QQnxCamera_H -#define QQnxCamera_H +// Copyright (C) 2016 Research In Motion +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQNXCAMERA_H +#define QQNXCAMERA_H // // W A R N I N G @@ -50,17 +15,18 @@ // We mean it. // -#include <private/qplatformcamera_p.h> -#include <private/qplatformmediarecorder_p.h> +#include "qqnxcamerahandle_p.h" #include <QtCore/qlist.h> #include <QtCore/qmutex.h> +#include <QtCore/qobject.h> #include <QtCore/qurl.h> #include <camera/camera_api.h> #include <camera/camera_3a.h> #include <memory> +#include <optional> QT_BEGIN_NAMESPACE @@ -68,156 +34,128 @@ class QQnxCameraFrameBuffer; class QQnxMediaCaptureSession; class QQnxVideoSink; -class CameraHandle +class QQnxCamera : public QObject { + Q_OBJECT public: - CameraHandle() = default; - - explicit CameraHandle(camera_handle_t h) - : m_handle (h) {} - - explicit CameraHandle(CameraHandle &&other) - : m_handle(other.m_handle) - , m_lastError(other.m_lastError) - { - other = CameraHandle(); - } - - CameraHandle(const CameraHandle&) = delete; + explicit QQnxCamera(camera_unit_t unit, QObject *parent = nullptr); + ~QQnxCamera(); - CameraHandle& operator=(CameraHandle&& other) - { - m_handle = other.m_handle; - m_lastError = other.m_lastError; + camera_unit_t unit() const; - other = CameraHandle(); + QString name() const; - return *this; - } + bool isValid() const; - ~CameraHandle() - { - close(); - } + bool isActive() const; + void start(); + void stop(); - bool open(camera_unit_t unit, uint32_t mode) - { - if (isOpen()) { - m_lastError = CAMERA_EALREADY; - return false; - } + bool startVideoRecording(const QString &filename); + void stopVideoRecording(); - return cacheError(camera_open, unit, mode, &m_handle); - } + bool setCameraFormat(uint32_t width, uint32_t height, double frameRate); - bool close() - { - if (!isOpen()) - return true; + bool isFocusModeSupported(camera_focusmode_t mode) const; + bool setFocusMode(camera_focusmode_t mode); + camera_focusmode_t focusMode() const; - const bool success = cacheError(camera_close, m_handle); - m_handle = CAMERA_HANDLE_INVALID; + void setCustomFocusPoint(const QPointF &point); - return success; - } + void setManualFocusStep(int step); + int manualFocusStep() const; + int maxFocusStep() const; - camera_handle_t get() const - { - return m_handle; - } + QSize viewFinderSize() const; - bool isOpen() const - { - return m_handle != CAMERA_HANDLE_INVALID; - } + uint32_t minimumZoomLevel() const; + uint32_t maximumZoomLevel() const; + bool isSmoothZoom() const; + double zoomRatio(uint32_t zoomLevel) const; + bool setZoomFactor(uint32_t factor); - camera_error_t lastError() const - { - return m_lastError; - } + void setEvOffset(float ev); -private: - template <typename Func, typename ...Args> - bool cacheError(Func f, Args &&...args) - { - m_lastError = f(std::forward<Args>(args)...); + uint32_t manualIsoSensitivity() const; + void setManualIsoSensitivity(uint32_t value); + void setManualExposureTime(double seconds); + double manualExposureTime() const; - return m_lastError == CAMERA_EOK; - } + void setWhiteBalanceMode(camera_whitebalancemode_t mode); + camera_whitebalancemode_t whiteBalanceMode() const; - camera_handle_t m_handle = CAMERA_HANDLE_INVALID; - camera_error_t m_lastError = CAMERA_EOK; -}; + void setManualWhiteBalance(uint32_t value); + uint32_t manualWhiteBalance() const; + bool hasFeature(camera_feature_t feature) const; -class QQnxCamera : public QPlatformCamera -{ - Q_OBJECT -public: - explicit QQnxCamera(QCamera *parent); - ~QQnxCamera(); + camera_handle_t handle() const; - bool isActive() const override; - void setActive(bool active) override; - void start(); - void stop(); + QList<camera_vfmode_t> supportedVfModes() const; + QList<camera_res_t> supportedVfResolutions() const; + QList<camera_frametype_t> supportedVfFrameTypes() const; + QList<camera_focusmode_t> supportedFocusModes() const; + QList<double> specifiedVfFrameRates(camera_frametype_t frameType, + camera_res_t resolution) const; - void setCamera(const QCameraDevice &camera) override; + QList<camera_frametype_t> supportedRecordingFrameTypes() const; - bool setCameraFormat(const QCameraFormat &format) override; + QList<uint32_t> supportedWhiteBalanceValues() const; - void setCaptureSession(QPlatformMediaCaptureSession *session) override; + bool hasContinuousWhiteBalanceValues() const; - bool isFocusModeSupported(QCamera::FocusMode mode) const override; - void setFocusMode(QCamera::FocusMode mode) override; + static QList<camera_unit_t> supportedUnits(); - void setCustomFocusPoint(const QPointF &point) override; + std::unique_ptr<QQnxCameraFrameBuffer> takeCurrentFrame(); - void setFocusDistance(float distance) override; +Q_SIGNALS: + void focusModeChanged(camera_focusmode_t mode); + void customFocusPointChanged(const QPointF &point); + void minimumZoomFactorChanged(double factor); - int maxFocusDistance() const; + double maximumZoomFactorChanged(double factor); - void zoomTo(float /*newZoomFactor*/, float /*rate*/ = -1.) override; + void frameAvailable(); - void setExposureCompensation(float ev) override; +private: + struct FocusStep + { + int step; // current step + int maxStep; // max supported step + }; - int isoSensitivity() const override; - void setManualIsoSensitivity(int value) override; - void setManualExposureTime(float seconds) override; - float exposureTime() const override; + FocusStep focusStep() const; - bool isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const override; - void setWhiteBalanceMode(QCamera::WhiteBalanceMode /*mode*/) override; - void setColorTemperature(int /*temperature*/) override; + struct VideoFormat + { + uint32_t width; + uint32_t height; + uint32_t rotation; + double frameRate; + camera_frametype_t frameType; + }; - void setOutputUrl(const QUrl &url); - void setMediaEncoderSettings(const QMediaEncoderSettings &settings); + friend QDebug &operator<<(QDebug&, const VideoFormat&); - camera_handle_t handle() const; + VideoFormat vfFormat() const; + void setVfFormat(const VideoFormat &format); - QList<camera_vfmode_t> supportedVfModes() const; - QList<camera_res_t> supportedVfResolutions() const; - QList<camera_focusmode_t> supportedFocusModes() const; + VideoFormat recordingFormat() const; + void setRecordingFormat(const VideoFormat &format); -private: - void updateCameraFeatures(); + void updateZoomLimits(); + void updateSupportedWhiteBalanceValues(); void setColorTemperatureInternal(unsigned temp); - void startVideoRecording(); - void stopVideoRecording(); - bool isVideoEncodingSupported() const; void handleVfBuffer(camera_buffer_t *buffer); - Q_INVOKABLE void processFrame(); - // viewfinder callback void handleVfStatus(camera_devstatus_t status, uint16_t extraData); // our handler running on main thread - void handleStatusChange(camera_devstatus_t status, uint16_t extraData); - + Q_INVOKABLE void handleStatusChange(camera_devstatus_t status, uint16_t extraData); template <typename T, typename U> using QueryFuncPtr = camera_error_t (*)(camera_handle_t, U, U *, T *); @@ -225,9 +163,6 @@ private: template <typename T, typename U> QList<T> queryValues(QueryFuncPtr<T, U> func) const; - template <typename ...Args> - using CamAPIFunc = camera_error_t (*)(camera_handle_t, Args...); - static void viewfinderCallback(camera_handle_t handle, camera_buffer_t *buffer, void *arg); @@ -235,35 +170,32 @@ private: uint16_t extraData, void *arg); QQnxMediaCaptureSession *m_session = nullptr; - QQnxVideoSink *m_videoSink = nullptr; - QCameraDevice m_camera; camera_unit_t m_cameraUnit = CAMERA_UNIT_NONE; - QUrl m_outputUrl; - - QMediaEncoderSettings m_encoderSettings; - - CameraHandle m_handle; + QQnxCameraHandle m_handle; - uint minZoom = 1; - uint maxZoom = 1; - mutable bool whiteBalanceModesChecked = false; - mutable bool continuousColorTemperatureSupported = false; - mutable int minColorTemperature = 0; - mutable int maxColorTemperature = 0; - mutable QList<unsigned> manualColorTemperatureValues; + uint32_t m_minZoom = 0; + uint32_t m_maxZoom = 0; QMutex m_currentFrameMutex; + QList<uint32_t> m_supportedWhiteBalanceValues; + std::unique_ptr<QQnxCameraFrameBuffer> m_currentFrame; + std::optional<VideoFormat> m_originalVfFormat; + bool m_viewfinderActive = false; bool m_recordingVideo = false; + bool m_valid = false; + bool m_smoothZoom = false; + bool m_continuousWhiteBalanceValues = false; }; QT_END_NAMESPACE Q_DECLARE_METATYPE(camera_devstatus_t) +Q_DECLARE_METATYPE(uint16_t) #endif |