diff options
Diffstat (limited to 'src/plugins/android/src/mediacapture')
49 files changed, 0 insertions, 6656 deletions
diff --git a/src/plugins/android/src/mediacapture/mediacapture.pri b/src/plugins/android/src/mediacapture/mediacapture.pri deleted file mode 100644 index a42a6a40c..000000000 --- a/src/plugins/android/src/mediacapture/mediacapture.pri +++ /dev/null @@ -1,53 +0,0 @@ -INCLUDEPATH += $$PWD - -SOURCES += \ - $$PWD/qandroidcaptureservice.cpp \ - $$PWD/qandroidcameracontrol.cpp \ - $$PWD/qandroidvideodeviceselectorcontrol.cpp \ - $$PWD/qandroidcamerasession.cpp \ - $$PWD/qandroidcamerazoomcontrol.cpp \ - $$PWD/qandroidcameraexposurecontrol.cpp \ - $$PWD/qandroidcameraimageprocessingcontrol.cpp \ - $$PWD/qandroidimageencodercontrol.cpp \ - $$PWD/qandroidcameraimagecapturecontrol.cpp \ - $$PWD/qandroidcameracapturedestinationcontrol.cpp \ - $$PWD/qandroidcameracapturebufferformatcontrol.cpp \ - $$PWD/qandroidcameraflashcontrol.cpp \ - $$PWD/qandroidcamerafocuscontrol.cpp \ - $$PWD/qandroidviewfindersettingscontrol.cpp \ - $$PWD/qandroidcameralockscontrol.cpp \ - $$PWD/qandroidcapturesession.cpp \ - $$PWD/qandroidmediarecordercontrol.cpp \ - $$PWD/qandroidaudioencodersettingscontrol.cpp \ - $$PWD/qandroidmediacontainercontrol.cpp \ - $$PWD/qandroidvideoencodersettingscontrol.cpp \ - $$PWD/qandroidaudioinputselectorcontrol.cpp \ - $$PWD/qandroidmediavideoprobecontrol.cpp \ - $$PWD/qandroidcamerainfocontrol.cpp \ - $$PWD/qandroidcameravideorenderercontrol.cpp - -HEADERS += \ - $$PWD/qandroidcaptureservice.h \ - $$PWD/qandroidcameracontrol.h \ - $$PWD/qandroidvideodeviceselectorcontrol.h \ - $$PWD/qandroidcamerasession.h \ - $$PWD/qandroidcamerazoomcontrol.h \ - $$PWD/qandroidcameraexposurecontrol.h \ - $$PWD/qandroidcameraimageprocessingcontrol.h \ - $$PWD/qandroidimageencodercontrol.h \ - $$PWD/qandroidcameraimagecapturecontrol.h \ - $$PWD/qandroidcameracapturedestinationcontrol.h \ - $$PWD/qandroidcameracapturebufferformatcontrol.h \ - $$PWD/qandroidcameraflashcontrol.h \ - $$PWD/qandroidcamerafocuscontrol.h \ - $$PWD/qandroidviewfindersettingscontrol.h \ - $$PWD/qandroidcameralockscontrol.h \ - $$PWD/qandroidcapturesession.h \ - $$PWD/qandroidmediarecordercontrol.h \ - $$PWD/qandroidaudioencodersettingscontrol.h \ - $$PWD/qandroidmediacontainercontrol.h \ - $$PWD/qandroidvideoencodersettingscontrol.h \ - $$PWD/qandroidaudioinputselectorcontrol.h \ - $$PWD/qandroidmediavideoprobecontrol.h \ - $$PWD/qandroidcamerainfocontrol.h \ - $$PWD/qandroidcameravideorenderercontrol.h diff --git a/src/plugins/android/src/mediacapture/qandroidaudioencodersettingscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidaudioencodersettingscontrol.cpp deleted file mode 100644 index 4bd94425d..000000000 --- a/src/plugins/android/src/mediacapture/qandroidaudioencodersettingscontrol.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidaudioencodersettingscontrol.h" - -#include "qandroidcapturesession.h" - -QT_BEGIN_NAMESPACE - -QAndroidAudioEncoderSettingsControl::QAndroidAudioEncoderSettingsControl(QAndroidCaptureSession *session) - : QAudioEncoderSettingsControl() - , m_session(session) -{ -} - -QStringList QAndroidAudioEncoderSettingsControl::supportedAudioCodecs() const -{ - return QStringList() << QLatin1String("amr-nb") << QLatin1String("amr-wb") << QLatin1String("aac"); -} - -QString QAndroidAudioEncoderSettingsControl::codecDescription(const QString &codecName) const -{ - if (codecName == QLatin1String("amr-nb")) - return tr("Adaptive Multi-Rate Narrowband (AMR-NB) audio codec"); - else if (codecName == QLatin1String("amr-wb")) - return tr("Adaptive Multi-Rate Wideband (AMR-WB) audio codec"); - else if (codecName == QLatin1String("aac")) - return tr("AAC Low Complexity (AAC-LC) audio codec"); - - return QString(); -} - -QList<int> QAndroidAudioEncoderSettingsControl::supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous) const -{ - if (continuous) - *continuous = false; - - if (settings.isNull() || settings.codec().isNull() || settings.codec() == QLatin1String("aac")) { - return QList<int>() << 8000 << 11025 << 12000 << 16000 << 22050 - << 24000 << 32000 << 44100 << 48000 << 96000; - } else if (settings.codec() == QLatin1String("amr-nb")) { - return QList<int>() << 8000; - } else if (settings.codec() == QLatin1String("amr-wb")) { - return QList<int>() << 16000; - } - - return QList<int>(); -} - -QAudioEncoderSettings QAndroidAudioEncoderSettingsControl::audioSettings() const -{ - return m_session->audioSettings(); -} - -void QAndroidAudioEncoderSettingsControl::setAudioSettings(const QAudioEncoderSettings &settings) -{ - m_session->setAudioSettings(settings); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidaudioencodersettingscontrol.h b/src/plugins/android/src/mediacapture/qandroidaudioencodersettingscontrol.h deleted file mode 100644 index e68bf6ef7..000000000 --- a/src/plugins/android/src/mediacapture/qandroidaudioencodersettingscontrol.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDAUDIOENCODERSETTINGSCONTROL_H -#define QANDROIDAUDIOENCODERSETTINGSCONTROL_H - -#include <qaudioencodersettingscontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCaptureSession; - -class QAndroidAudioEncoderSettingsControl : public QAudioEncoderSettingsControl -{ - Q_OBJECT -public: - explicit QAndroidAudioEncoderSettingsControl(QAndroidCaptureSession *session); - - QStringList supportedAudioCodecs() const override; - QString codecDescription(const QString &codecName) const override; - QList<int> supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous = 0) const override; - QAudioEncoderSettings audioSettings() const override; - void setAudioSettings(const QAudioEncoderSettings &settings) override; - -private: - QAndroidCaptureSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDAUDIOENCODERSETTINGSCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidaudioinputselectorcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidaudioinputselectorcontrol.cpp deleted file mode 100644 index bf2161a7e..000000000 --- a/src/plugins/android/src/mediacapture/qandroidaudioinputselectorcontrol.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidaudioinputselectorcontrol.h" - -#include "qandroidcapturesession.h" - -QT_BEGIN_NAMESPACE - -QAndroidAudioInputSelectorControl::QAndroidAudioInputSelectorControl(QAndroidCaptureSession *session) - : QAudioInputSelectorControl() - , m_session(session) -{ - connect(m_session, SIGNAL(audioInputChanged(QString)), this, SIGNAL(activeInputChanged(QString))); -} - -QList<QString> QAndroidAudioInputSelectorControl::availableInputs() const -{ - return QList<QString>() << QLatin1String("default") - << QLatin1String("mic") - << QLatin1String("voice_uplink") - << QLatin1String("voice_downlink") - << QLatin1String("voice_call") - << QLatin1String("voice_recognition"); -} - -QString QAndroidAudioInputSelectorControl::inputDescription(const QString& name) const -{ - return availableDeviceDescription(name.toLatin1()); -} - -QString QAndroidAudioInputSelectorControl::defaultInput() const -{ - return QLatin1String("default"); -} - -QString QAndroidAudioInputSelectorControl::activeInput() const -{ - return m_session->audioInput(); -} - -void QAndroidAudioInputSelectorControl::setActiveInput(const QString& name) -{ - m_session->setAudioInput(name); -} - -QList<QByteArray> QAndroidAudioInputSelectorControl::availableDevices() -{ - return QList<QByteArray>() << "default" - << "mic" - << "voice_uplink" - << "voice_downlink" - << "voice_call" - << "voice_recognition"; -} - -QString QAndroidAudioInputSelectorControl::availableDeviceDescription(const QByteArray &device) -{ - if (device == "default") - return QLatin1String("Default audio source"); - else if (device == "mic") - return QLatin1String("Microphone audio source"); - else if (device == "voice_uplink") - return QLatin1String("Voice call uplink (Tx) audio source"); - else if (device == "voice_downlink") - return QLatin1String("Voice call downlink (Rx) audio source"); - else if (device == "voice_call") - return QLatin1String("Voice call uplink + downlink audio source"); - else if (device == "voice_recognition") - return QLatin1String("Microphone audio source tuned for voice recognition"); - else - return QString(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidaudioinputselectorcontrol.h b/src/plugins/android/src/mediacapture/qandroidaudioinputselectorcontrol.h deleted file mode 100644 index c24167fb3..000000000 --- a/src/plugins/android/src/mediacapture/qandroidaudioinputselectorcontrol.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDAUDIOINPUTSELECTORCONTROL_H -#define QANDROIDAUDIOINPUTSELECTORCONTROL_H - -#include <qaudioinputselectorcontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCaptureSession; - -class QAndroidAudioInputSelectorControl : public QAudioInputSelectorControl -{ - Q_OBJECT -public: - explicit QAndroidAudioInputSelectorControl(QAndroidCaptureSession *session); - - QList<QString> availableInputs() const; - QString inputDescription(const QString& name) const; - QString defaultInput() const; - - QString activeInput() const; - void setActiveInput(const QString& name); - - static QList<QByteArray> availableDevices(); - static QString availableDeviceDescription(const QByteArray &device); - -private: - QAndroidCaptureSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDAUDIOINPUTSELECTORCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameracapturebufferformatcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameracapturebufferformatcontrol.cpp deleted file mode 100644 index a47fa4f72..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameracapturebufferformatcontrol.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameracapturebufferformatcontrol.h" - -QT_BEGIN_NAMESPACE - -QAndroidCameraCaptureBufferFormatControl::QAndroidCameraCaptureBufferFormatControl() - : QCameraCaptureBufferFormatControl() -{ -} - -QList<QVideoFrame::PixelFormat> QAndroidCameraCaptureBufferFormatControl::supportedBufferFormats() const -{ - return (QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_Jpeg); -} - -QVideoFrame::PixelFormat QAndroidCameraCaptureBufferFormatControl::bufferFormat() const -{ - return QVideoFrame::Format_Jpeg; -} - -void QAndroidCameraCaptureBufferFormatControl::setBufferFormat(QVideoFrame::PixelFormat format) -{ - Q_UNUSED(format); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameracapturebufferformatcontrol.h b/src/plugins/android/src/mediacapture/qandroidcameracapturebufferformatcontrol.h deleted file mode 100644 index b27727543..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameracapturebufferformatcontrol.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERACAPTUREBUFFERFORMATCONTROL_H -#define QANDROIDCAMERACAPTUREBUFFERFORMATCONTROL_H - -#include <qcameracapturebufferformatcontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraCaptureBufferFormatControl : public QCameraCaptureBufferFormatControl -{ - Q_OBJECT -public: - QAndroidCameraCaptureBufferFormatControl(); - - QList<QVideoFrame::PixelFormat> supportedBufferFormats() const override; - QVideoFrame::PixelFormat bufferFormat() const override; - void setBufferFormat(QVideoFrame::PixelFormat format) override; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERACAPTUREBUFFERFORMATCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameracapturedestinationcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameracapturedestinationcontrol.cpp deleted file mode 100644 index 6a6847007..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameracapturedestinationcontrol.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameracapturedestinationcontrol.h" - -#include "qandroidcamerasession.h" - -QT_BEGIN_NAMESPACE - -QAndroidCameraCaptureDestinationControl::QAndroidCameraCaptureDestinationControl(QAndroidCameraSession *session) - : QCameraCaptureDestinationControl() - , m_session(session) -{ - connect(m_session, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)), - this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations))); -} - -bool QAndroidCameraCaptureDestinationControl::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const -{ - return m_session->isCaptureDestinationSupported(destination); -} - -QCameraImageCapture::CaptureDestinations QAndroidCameraCaptureDestinationControl::captureDestination() const -{ - return m_session->captureDestination();; -} - -void QAndroidCameraCaptureDestinationControl::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) -{ - m_session->setCaptureDestination(destination); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameracapturedestinationcontrol.h b/src/plugins/android/src/mediacapture/qandroidcameracapturedestinationcontrol.h deleted file mode 100644 index 1edfdab12..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameracapturedestinationcontrol.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERACAPTUREDESTINATIONCONTROL_H -#define QANDROIDCAMERACAPTUREDESTINATIONCONTROL_H - -#include <qcameracapturedestinationcontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraCaptureDestinationControl : public QCameraCaptureDestinationControl -{ - Q_OBJECT -public: - explicit QAndroidCameraCaptureDestinationControl(QAndroidCameraSession *session); - - bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const override; - QCameraImageCapture::CaptureDestinations captureDestination() const override; - void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) override; - -private: - QAndroidCameraSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERACAPTUREDESTINATIONCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp deleted file mode 100644 index a75215920..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameracontrol.h" - -#include "qandroidcamerasession.h" - -QT_BEGIN_NAMESPACE - -QAndroidCameraControl::QAndroidCameraControl(QAndroidCameraSession *session) - : QCameraControl(0) - , m_cameraSession(session) - -{ - connect(m_cameraSession, SIGNAL(statusChanged(QCamera::Status)), - this, SIGNAL(statusChanged(QCamera::Status))); - - connect(m_cameraSession, SIGNAL(stateChanged(QCamera::State)), - this, SIGNAL(stateChanged(QCamera::State))); - - connect(m_cameraSession, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); - - connect(m_cameraSession, SIGNAL(captureModeChanged(QCamera::CaptureModes)), - this, SIGNAL(captureModeChanged(QCamera::CaptureModes))); -} - -QAndroidCameraControl::~QAndroidCameraControl() -{ -} - -QCamera::CaptureModes QAndroidCameraControl::captureMode() const -{ - return m_cameraSession->captureMode(); -} - -void QAndroidCameraControl::setCaptureMode(QCamera::CaptureModes mode) -{ - m_cameraSession->setCaptureMode(mode); -} - -bool QAndroidCameraControl::isCaptureModeSupported(QCamera::CaptureModes mode) const -{ - return m_cameraSession->isCaptureModeSupported(mode); -} - -void QAndroidCameraControl::setState(QCamera::State state) -{ - m_cameraSession->setState(state); -} - -QCamera::State QAndroidCameraControl::state() const -{ - return m_cameraSession->state(); -} - -QCamera::Status QAndroidCameraControl::status() const -{ - return m_cameraSession->status(); -} - -bool QAndroidCameraControl::canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const -{ - Q_UNUSED(status); - - switch (changeType) { - case QCameraControl::CaptureMode: - case QCameraControl::ImageEncodingSettings: - case QCameraControl::VideoEncodingSettings: - case QCameraControl::Viewfinder: - return true; - default: - return false; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameracontrol.h b/src/plugins/android/src/mediacapture/qandroidcameracontrol.h deleted file mode 100644 index 80eead627..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameracontrol.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - - -#ifndef QANDROIDCAMERACONTROL_H -#define QANDROIDCAMERACONTROL_H - -#include <qcameracontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraControl : public QCameraControl -{ - Q_OBJECT -public: - explicit QAndroidCameraControl(QAndroidCameraSession *session); - virtual ~QAndroidCameraControl(); - - QCamera::State state() const; - void setState(QCamera::State state); - - QCamera::Status status() const; - - QCamera::CaptureModes captureMode() const; - void setCaptureMode(QCamera::CaptureModes mode); - bool isCaptureModeSupported(QCamera::CaptureModes mode) const; - - bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const; - -private: - QAndroidCameraSession *m_cameraSession; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERACONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.cpp deleted file mode 100644 index cf4587379..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameraexposurecontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" - -QT_BEGIN_NAMESPACE - -QAndroidCameraExposureControl::QAndroidCameraExposureControl(QAndroidCameraSession *session) - : QCameraExposureControl() - , m_session(session) - , m_minExposureCompensationIndex(0) - , m_maxExposureCompensationIndex(0) - , m_exposureCompensationStep(0.0) - , m_requestedExposureCompensation(0.0) - , m_actualExposureCompensation(0.0) - , m_requestedExposureMode(QCameraExposure::ExposureAuto) - , m_actualExposureMode(QCameraExposure::ExposureAuto) -{ - connect(m_session, SIGNAL(opened()), - this, SLOT(onCameraOpened())); -} - -bool QAndroidCameraExposureControl::isParameterSupported(ExposureParameter parameter) const -{ - if (!m_session->camera()) - return false; - - switch (parameter) { - case QCameraExposureControl::ISO: - return false; - case QCameraExposureControl::Aperture: - return false; - case QCameraExposureControl::ShutterSpeed: - return false; - case QCameraExposureControl::ExposureCompensation: - return !m_supportedExposureCompensations.isEmpty(); - case QCameraExposureControl::FlashPower: - return false; - case QCameraExposureControl::FlashCompensation: - return false; - case QCameraExposureControl::TorchPower: - return false; - case QCameraExposureControl::SpotMeteringPoint: - return false; - case QCameraExposureControl::ExposureMode: - return !m_supportedExposureModes.isEmpty(); - case QCameraExposureControl::MeteringMode: - return false; - default: - return false; - } -} - -QVariantList QAndroidCameraExposureControl::supportedParameterRange(ExposureParameter parameter, bool *continuous) const -{ - if (!m_session->camera()) - return QVariantList(); - - if (continuous) - *continuous = false; - - if (parameter == QCameraExposureControl::ExposureCompensation) - return m_supportedExposureCompensations; - else if (parameter == QCameraExposureControl::ExposureMode) - return m_supportedExposureModes; - - return QVariantList(); -} - -QVariant QAndroidCameraExposureControl::requestedValue(ExposureParameter parameter) const -{ - if (parameter == QCameraExposureControl::ExposureCompensation) - return QVariant::fromValue(m_requestedExposureCompensation); - else if (parameter == QCameraExposureControl::ExposureMode) - return QVariant::fromValue(m_requestedExposureMode); - - return QVariant(); -} - -QVariant QAndroidCameraExposureControl::actualValue(ExposureParameter parameter) const -{ - if (parameter == QCameraExposureControl::ExposureCompensation) - return QVariant::fromValue(m_actualExposureCompensation); - else if (parameter == QCameraExposureControl::ExposureMode) - return QVariant::fromValue(m_actualExposureMode); - - return QVariant(); -} - -bool QAndroidCameraExposureControl::setValue(ExposureParameter parameter, const QVariant& value) -{ - if (!value.isValid()) - return false; - - if (parameter == QCameraExposureControl::ExposureCompensation) { - qreal expComp = value.toReal(); - if (!qFuzzyCompare(m_requestedExposureCompensation, expComp)) { - m_requestedExposureCompensation = expComp; - emit requestedValueChanged(QCameraExposureControl::ExposureCompensation); - } - - if (!m_session->camera()) - return true; - - int expCompIndex = qRound(m_requestedExposureCompensation / m_exposureCompensationStep); - if (expCompIndex >= m_minExposureCompensationIndex - && expCompIndex <= m_maxExposureCompensationIndex) { - qreal comp = expCompIndex * m_exposureCompensationStep; - m_session->camera()->setExposureCompensation(expCompIndex); - if (!qFuzzyCompare(m_actualExposureCompensation, comp)) { - m_actualExposureCompensation = expCompIndex * m_exposureCompensationStep; - emit actualValueChanged(QCameraExposureControl::ExposureCompensation); - } - - return true; - } - - } else if (parameter == QCameraExposureControl::ExposureMode) { - QCameraExposure::ExposureMode expMode = value.value<QCameraExposure::ExposureMode>(); - if (m_requestedExposureMode != expMode) { - m_requestedExposureMode = expMode; - emit requestedValueChanged(QCameraExposureControl::ExposureMode); - } - - if (!m_session->camera()) - return true; - - if (!m_supportedExposureModes.isEmpty()) { - m_actualExposureMode = m_requestedExposureMode; - - QString sceneMode; - switch (m_requestedExposureMode) { - case QCameraExposure::ExposureAuto: - sceneMode = QLatin1String("auto"); - break; - case QCameraExposure::ExposureSports: - sceneMode = QLatin1String("sports"); - break; - case QCameraExposure::ExposurePortrait: - sceneMode = QLatin1String("portrait"); - break; - case QCameraExposure::ExposureBeach: - sceneMode = QLatin1String("beach"); - break; - case QCameraExposure::ExposureSnow: - sceneMode = QLatin1String("snow"); - break; - case QCameraExposure::ExposureNight: - sceneMode = QLatin1String("night"); - break; - case QCameraExposure::ExposureAction: - sceneMode = QLatin1String("action"); - break; - case QCameraExposure::ExposureLandscape: - sceneMode = QLatin1String("landscape"); - break; - case QCameraExposure::ExposureNightPortrait: - sceneMode = QLatin1String("night-portrait"); - break; - case QCameraExposure::ExposureTheatre: - sceneMode = QLatin1String("theatre"); - break; - case QCameraExposure::ExposureSunset: - sceneMode = QLatin1String("sunset"); - break; - case QCameraExposure::ExposureSteadyPhoto: - sceneMode = QLatin1String("steadyphoto"); - break; - case QCameraExposure::ExposureFireworks: - sceneMode = QLatin1String("fireworks"); - break; - case QCameraExposure::ExposureParty: - sceneMode = QLatin1String("party"); - break; - case QCameraExposure::ExposureCandlelight: - sceneMode = QLatin1String("candlelight"); - break; - case QCameraExposure::ExposureBarcode: - sceneMode = QLatin1String("barcode"); - break; - default: - sceneMode = QLatin1String("auto"); - m_actualExposureMode = QCameraExposure::ExposureAuto; - break; - } - - m_session->camera()->setSceneMode(sceneMode); - emit actualValueChanged(QCameraExposureControl::ExposureMode); - - return true; - } - } - - return false; -} - -void QAndroidCameraExposureControl::onCameraOpened() -{ - m_supportedExposureCompensations.clear(); - m_minExposureCompensationIndex = m_session->camera()->getMinExposureCompensation(); - m_maxExposureCompensationIndex = m_session->camera()->getMaxExposureCompensation(); - m_exposureCompensationStep = m_session->camera()->getExposureCompensationStep(); - if (m_minExposureCompensationIndex != 0 || m_maxExposureCompensationIndex != 0) { - for (int i = m_minExposureCompensationIndex; i <= m_maxExposureCompensationIndex; ++i) - m_supportedExposureCompensations.append(i * m_exposureCompensationStep); - emit parameterRangeChanged(QCameraExposureControl::ExposureCompensation); - } - - m_supportedExposureModes.clear(); - QStringList sceneModes = m_session->camera()->getSupportedSceneModes(); - if (!sceneModes.isEmpty()) { - for (int i = 0; i < sceneModes.size(); ++i) { - const QString &sceneMode = sceneModes.at(i); - if (sceneMode == QLatin1String("auto")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureAuto); - else if (sceneMode == QLatin1String("beach")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureBeach); - else if (sceneMode == QLatin1String("night")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureNight); - else if (sceneMode == QLatin1String("portrait")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposurePortrait); - else if (sceneMode == QLatin1String("snow")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureSnow); - else if (sceneMode == QLatin1String("sports")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureSports); - else if (sceneMode == QLatin1String("action")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureAction); - else if (sceneMode == QLatin1String("landscape")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureLandscape); - else if (sceneMode == QLatin1String("night-portrait")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureNightPortrait); - else if (sceneMode == QLatin1String("theatre")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureTheatre); - else if (sceneMode == QLatin1String("sunset")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureSunset); - else if (sceneMode == QLatin1String("steadyphoto")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureSteadyPhoto); - else if (sceneMode == QLatin1String("fireworks")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureFireworks); - else if (sceneMode == QLatin1String("party")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureParty); - else if (sceneMode == QLatin1String("candlelight")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureCandlelight); - else if (sceneMode == QLatin1String("barcode")) - m_supportedExposureModes << QVariant::fromValue(QCameraExposure::ExposureBarcode); - } - emit parameterRangeChanged(QCameraExposureControl::ExposureMode); - } - - setValue(QCameraExposureControl::ExposureCompensation, QVariant::fromValue(m_requestedExposureCompensation)); - setValue(QCameraExposureControl::ExposureMode, QVariant::fromValue(m_requestedExposureMode)); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.h b/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.h deleted file mode 100644 index e87e6cd3a..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraexposurecontrol.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAEXPOSURECONTROL_H -#define QANDROIDCAMERAEXPOSURECONTROL_H - -#include <qcameraexposurecontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraExposureControl : public QCameraExposureControl -{ - Q_OBJECT -public: - explicit QAndroidCameraExposureControl(QAndroidCameraSession *session); - - bool isParameterSupported(ExposureParameter parameter) const override; - QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const override; - - QVariant requestedValue(ExposureParameter parameter) const override; - QVariant actualValue(ExposureParameter parameter) const override; - bool setValue(ExposureParameter parameter, const QVariant& value) override; - -private Q_SLOTS: - void onCameraOpened(); - -private: - QAndroidCameraSession *m_session; - - QVariantList m_supportedExposureCompensations; - QVariantList m_supportedExposureModes; - - int m_minExposureCompensationIndex; - int m_maxExposureCompensationIndex; - qreal m_exposureCompensationStep; - - qreal m_requestedExposureCompensation; - qreal m_actualExposureCompensation; - QCameraExposure::ExposureMode m_requestedExposureMode; - QCameraExposure::ExposureMode m_actualExposureMode; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAEXPOSURECONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.cpp deleted file mode 100644 index 20a4b005c..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameraflashcontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" - -QT_BEGIN_NAMESPACE - -QAndroidCameraFlashControl::QAndroidCameraFlashControl(QAndroidCameraSession *session) - : QCameraFlashControl() - , m_session(session) - , m_flashMode(QCameraExposure::FlashOff) -{ - connect(m_session, SIGNAL(opened()), - this, SLOT(onCameraOpened())); -} - -QCameraExposure::FlashModes QAndroidCameraFlashControl::flashMode() const -{ - return m_flashMode; -} - -void QAndroidCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode) -{ - if (!m_session->camera()) { - m_flashMode = mode; - return; - } - - if (!isFlashModeSupported(mode)) - return; - - // if torch was enabled, it first needs to be turned off before setting another mode - if (m_flashMode == QCameraExposure::FlashVideoLight) - m_session->camera()->setFlashMode(QLatin1String("off")); - - m_flashMode = mode; - - QString flashMode; - if (mode.testFlag(QCameraExposure::FlashAuto)) - flashMode = QLatin1String("auto"); - else if (mode.testFlag(QCameraExposure::FlashOn)) - flashMode = QLatin1String("on"); - else if (mode.testFlag(QCameraExposure::FlashRedEyeReduction)) - flashMode = QLatin1String("red-eye"); - else if (mode.testFlag(QCameraExposure::FlashVideoLight)) - flashMode = QLatin1String("torch"); - else // FlashOff - flashMode = QLatin1String("off"); - - m_session->camera()->setFlashMode(flashMode); -} - -bool QAndroidCameraFlashControl::isFlashModeSupported(QCameraExposure::FlashModes mode) const -{ - return m_session->camera() ? m_supportedFlashModes.contains(mode) : false; -} - -bool QAndroidCameraFlashControl::isFlashReady() const -{ - // Android doesn't have an API for that - return true; -} - -void QAndroidCameraFlashControl::onCameraOpened() -{ - m_supportedFlashModes.clear(); - - QStringList flashModes = m_session->camera()->getSupportedFlashModes(); - for (int i = 0; i < flashModes.size(); ++i) { - const QString &flashMode = flashModes.at(i); - if (flashMode == QLatin1String("off")) - m_supportedFlashModes << QCameraExposure::FlashOff; - else if (flashMode == QLatin1String("auto")) - m_supportedFlashModes << QCameraExposure::FlashAuto; - else if (flashMode == QLatin1String("on")) - m_supportedFlashModes << QCameraExposure::FlashOn; - else if (flashMode == QLatin1String("red-eye")) - m_supportedFlashModes << QCameraExposure::FlashRedEyeReduction; - else if (flashMode == QLatin1String("torch")) - m_supportedFlashModes << QCameraExposure::FlashVideoLight; - } - - if (!m_supportedFlashModes.contains(m_flashMode)) - m_flashMode = QCameraExposure::FlashOff; - - setFlashMode(m_flashMode); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.h b/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.h deleted file mode 100644 index 071c45c72..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraflashcontrol.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAFLASHCONTROL_H -#define QANDROIDCAMERAFLASHCONTROL_H - -#include <qcameraflashcontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraFlashControl : public QCameraFlashControl -{ - Q_OBJECT -public: - explicit QAndroidCameraFlashControl(QAndroidCameraSession *session); - - QCameraExposure::FlashModes flashMode() const override; - void setFlashMode(QCameraExposure::FlashModes mode) override; - bool isFlashModeSupported(QCameraExposure::FlashModes mode) const override; - bool isFlashReady() const override; - -private Q_SLOTS: - void onCameraOpened(); - -private: - QAndroidCameraSession *m_session; - QList<QCameraExposure::FlashModes> m_supportedFlashModes; - QCameraExposure::FlashModes m_flashMode; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAFLASHCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp deleted file mode 100644 index 4b8a94976..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcamerafocuscontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" - -QT_BEGIN_NAMESPACE - -static QRect adjustedArea(const QRectF &area) -{ - // Qt maps focus points in the range (0.0, 0.0) -> (1.0, 1.0) - // Android maps focus points in the range (-1000, -1000) -> (1000, 1000) - // Converts an area in Qt coordinates to Android coordinates - return QRect(-1000 + qRound(area.x() * 2000), - -1000 + qRound(area.y() * 2000), - qRound(area.width() * 2000), - qRound(area.height() * 2000)) - .intersected(QRect(-1000, -1000, 2000, 2000)); -} - -QAndroidCameraFocusControl::QAndroidCameraFocusControl(QAndroidCameraSession *session) - : QCameraFocusControl() - , m_session(session) - , m_focusMode(QCameraFocus::AutoFocus) - , m_focusPointMode(QCameraFocus::FocusPointAuto) - , m_actualFocusPoint(0.5, 0.5) - , m_continuousPictureFocusSupported(false) - , m_continuousVideoFocusSupported(false) -{ - connect(m_session, SIGNAL(opened()), - this, SLOT(onCameraOpened())); - connect(m_session, SIGNAL(captureModeChanged(QCamera::CaptureModes)), - this, SLOT(onCameraCaptureModeChanged())); -} - -QCameraFocus::FocusModes QAndroidCameraFocusControl::focusMode() const -{ - return m_focusMode; -} - -void QAndroidCameraFocusControl::setFocusMode(QCameraFocus::FocusModes mode) -{ - if (!m_session->camera()) { - setFocusModeHelper(mode); - return; - } - - if (isFocusModeSupported(mode)) { - QString focusMode = QLatin1String("fixed"); - - if (mode.testFlag(QCameraFocus::HyperfocalFocus)) { - focusMode = QLatin1String("edof"); - } else if (mode.testFlag(QCameraFocus::ManualFocus)) { - focusMode = QLatin1String("fixed"); - } else if (mode.testFlag(QCameraFocus::AutoFocus)) { - focusMode = QLatin1String("auto"); - } else if (mode.testFlag(QCameraFocus::MacroFocus)) { - focusMode = QLatin1String("macro"); - } else if (mode.testFlag(QCameraFocus::ContinuousFocus)) { - if ((m_session->captureMode().testFlag(QCamera::CaptureVideo) && m_continuousVideoFocusSupported) - || !m_continuousPictureFocusSupported) { - focusMode = QLatin1String("continuous-video"); - } else { - focusMode = QLatin1String("continuous-picture"); - } - } else if (mode.testFlag(QCameraFocus::InfinityFocus)) { - focusMode = QLatin1String("infinity"); - } - - m_session->camera()->setFocusMode(focusMode); - - // reset focus position - m_session->camera()->cancelAutoFocus(); - - setFocusModeHelper(mode); - } -} - -bool QAndroidCameraFocusControl::isFocusModeSupported(QCameraFocus::FocusModes mode) const -{ - return m_session->camera() ? m_supportedFocusModes.contains(mode) : false; -} - -QCameraFocus::FocusPointMode QAndroidCameraFocusControl::focusPointMode() const -{ - return m_focusPointMode; -} - -void QAndroidCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode) -{ - if (!m_session->camera()) { - setFocusPointModeHelper(mode); - return; - } - - if (isFocusPointModeSupported(mode)) { - if (mode == QCameraFocus::FocusPointCustom) { - m_actualFocusPoint = m_customFocusPoint; - } else { - // FocusPointAuto | FocusPointCenter - // note: there is no way to know the actual focus point in FocusPointAuto mode, - // so just report the focus point to be at the center of the frame - m_actualFocusPoint = QPointF(0.5, 0.5); - } - - setFocusPointModeHelper(mode); - - updateFocusZones(); - setCameraFocusArea(); - } -} - -bool QAndroidCameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const -{ - return m_session->camera() ? m_supportedFocusPointModes.contains(mode) : false; -} - -QPointF QAndroidCameraFocusControl::customFocusPoint() const -{ - return m_customFocusPoint; -} - -void QAndroidCameraFocusControl::setCustomFocusPoint(const QPointF &point) -{ - if (m_customFocusPoint != point) { - m_customFocusPoint = point; - emit customFocusPointChanged(m_customFocusPoint); - } - - if (m_session->camera() && m_focusPointMode == QCameraFocus::FocusPointCustom) { - m_actualFocusPoint = m_customFocusPoint; - updateFocusZones(); - setCameraFocusArea(); - } -} - -QCameraFocusZoneList QAndroidCameraFocusControl::focusZones() const -{ - return m_focusZones; -} - -void QAndroidCameraFocusControl::onCameraOpened() -{ - connect(m_session->camera(), SIGNAL(previewSizeChanged()), - this, SLOT(onViewportSizeChanged())); - connect(m_session->camera(), SIGNAL(autoFocusStarted()), - this, SLOT(onAutoFocusStarted())); - connect(m_session->camera(), SIGNAL(autoFocusComplete(bool)), - this, SLOT(onAutoFocusComplete(bool))); - - m_supportedFocusModes.clear(); - m_continuousPictureFocusSupported = false; - m_continuousVideoFocusSupported = false; - m_supportedFocusPointModes.clear(); - - QStringList focusModes = m_session->camera()->getSupportedFocusModes(); - for (int i = 0; i < focusModes.size(); ++i) { - const QString &focusMode = focusModes.at(i); - if (focusMode == QLatin1String("auto")) { - m_supportedFocusModes << QCameraFocus::AutoFocus; - } else if (focusMode == QLatin1String("continuous-picture")) { - m_supportedFocusModes << QCameraFocus::ContinuousFocus; - m_continuousPictureFocusSupported = true; - } else if (focusMode == QLatin1String("continuous-video")) { - m_supportedFocusModes << QCameraFocus::ContinuousFocus; - m_continuousVideoFocusSupported = true; - } else if (focusMode == QLatin1String("edof")) { - m_supportedFocusModes << QCameraFocus::HyperfocalFocus; - } else if (focusMode == QLatin1String("fixed")) { - m_supportedFocusModes << QCameraFocus::ManualFocus; - } else if (focusMode == QLatin1String("infinity")) { - m_supportedFocusModes << QCameraFocus::InfinityFocus; - } else if (focusMode == QLatin1String("macro")) { - m_supportedFocusModes << QCameraFocus::MacroFocus; - } - } - - m_supportedFocusPointModes << QCameraFocus::FocusPointAuto; - if (m_session->camera()->getMaxNumFocusAreas() > 0) - m_supportedFocusPointModes << QCameraFocus::FocusPointCenter << QCameraFocus::FocusPointCustom; - - if (!m_supportedFocusModes.contains(m_focusMode)) - setFocusModeHelper(QCameraFocus::AutoFocus); - if (!m_supportedFocusPointModes.contains(m_focusPointMode)) - setFocusPointModeHelper(QCameraFocus::FocusPointAuto); - - setFocusMode(m_focusMode); - setCustomFocusPoint(m_customFocusPoint); - setFocusPointMode(m_focusPointMode); -} - -void QAndroidCameraFocusControl::updateFocusZones(QCameraFocusZone::FocusZoneStatus status) -{ - if (!m_session->camera()) - return; - - // create a focus zone (50x50 pixel) around the focus point - m_focusZones.clear(); - - if (!m_actualFocusPoint.isNull()) { - QSize viewportSize = m_session->camera()->previewSize(); - - if (!viewportSize.isValid()) - return; - - QSizeF focusSize(50.f / viewportSize.width(), 50.f / viewportSize.height()); - float x = qBound(qreal(0), - m_actualFocusPoint.x() - (focusSize.width() / 2), - 1.f - focusSize.width()); - float y = qBound(qreal(0), - m_actualFocusPoint.y() - (focusSize.height() / 2), - 1.f - focusSize.height()); - - QRectF area(QPointF(x, y), focusSize); - - m_focusZones.append(QCameraFocusZone(area, status)); - } - - emit focusZonesChanged(); -} - -void QAndroidCameraFocusControl::setCameraFocusArea() -{ - QList<QRect> areas; - if (m_focusPointMode != QCameraFocus::FocusPointAuto) { - // in FocusPointAuto mode, leave the area list empty - // to let the driver choose the focus point. - - for (int i = 0; i < m_focusZones.size(); ++i) - areas.append(adjustedArea(m_focusZones.at(i).area())); - - } - m_session->camera()->setFocusAreas(areas); -} - -void QAndroidCameraFocusControl::onViewportSizeChanged() -{ - QCameraFocusZone::FocusZoneStatus status = QCameraFocusZone::Selected; - if (!m_focusZones.isEmpty()) - status = m_focusZones.at(0).status(); - updateFocusZones(status); - setCameraFocusArea(); -} - -void QAndroidCameraFocusControl::onCameraCaptureModeChanged() -{ - if (m_session->camera() && m_focusMode == QCameraFocus::ContinuousFocus) { - QString focusMode; - if ((m_session->captureMode().testFlag(QCamera::CaptureVideo) && m_continuousVideoFocusSupported) - || !m_continuousPictureFocusSupported) { - focusMode = QLatin1String("continuous-video"); - } else { - focusMode = QLatin1String("continuous-picture"); - } - m_session->camera()->setFocusMode(focusMode); - m_session->camera()->cancelAutoFocus(); - } -} - -void QAndroidCameraFocusControl::onAutoFocusStarted() -{ - updateFocusZones(QCameraFocusZone::Selected); -} - -void QAndroidCameraFocusControl::onAutoFocusComplete(bool success) -{ - if (success) - updateFocusZones(QCameraFocusZone::Focused); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.h b/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.h deleted file mode 100644 index 9c606cf7d..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAFOCUSCONTROL_H -#define QANDROIDCAMERAFOCUSCONTROL_H - -#include <qcamerafocuscontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraFocusControl : public QCameraFocusControl -{ - Q_OBJECT -public: - explicit QAndroidCameraFocusControl(QAndroidCameraSession *session); - - QCameraFocus::FocusModes focusMode() const override; - void setFocusMode(QCameraFocus::FocusModes mode) override; - bool isFocusModeSupported(QCameraFocus::FocusModes mode) const override; - QCameraFocus::FocusPointMode focusPointMode() const override; - void setFocusPointMode(QCameraFocus::FocusPointMode mode) override; - bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const override; - QPointF customFocusPoint() const override; - void setCustomFocusPoint(const QPointF &point) override; - QCameraFocusZoneList focusZones() const override; - -private Q_SLOTS: - void onCameraOpened(); - void onViewportSizeChanged(); - void onCameraCaptureModeChanged(); - void onAutoFocusStarted(); - void onAutoFocusComplete(bool success); - -private: - inline void setFocusModeHelper(QCameraFocus::FocusModes mode) - { - if (m_focusMode != mode) { - m_focusMode = mode; - emit focusModeChanged(mode); - } - } - - inline void setFocusPointModeHelper(QCameraFocus::FocusPointMode mode) - { - if (m_focusPointMode != mode) { - m_focusPointMode = mode; - emit focusPointModeChanged(mode); - } - } - - void updateFocusZones(QCameraFocusZone::FocusZoneStatus status = QCameraFocusZone::Selected); - void setCameraFocusArea(); - - QAndroidCameraSession *m_session; - - QCameraFocus::FocusModes m_focusMode; - QCameraFocus::FocusPointMode m_focusPointMode; - QPointF m_actualFocusPoint; - QPointF m_customFocusPoint; - QCameraFocusZoneList m_focusZones; - - QList<QCameraFocus::FocusModes> m_supportedFocusModes; - bool m_continuousPictureFocusSupported; - bool m_continuousVideoFocusSupported; - - QList<QCameraFocus::FocusPointMode> m_supportedFocusPointModes; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAFOCUSCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameraimagecapturecontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameraimagecapturecontrol.cpp deleted file mode 100644 index f39a53665..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraimagecapturecontrol.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameraimagecapturecontrol.h" - -#include "qandroidcamerasession.h" - -QT_BEGIN_NAMESPACE - -QAndroidCameraImageCaptureControl::QAndroidCameraImageCaptureControl(QAndroidCameraSession *session) - : QCameraImageCaptureControl() - , m_session(session) -{ - connect(m_session, SIGNAL(readyForCaptureChanged(bool)), this, SIGNAL(readyForCaptureChanged(bool))); - connect(m_session, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed(int))); - connect(m_session, SIGNAL(imageCaptured(int,QImage)), this, SIGNAL(imageCaptured(int,QImage))); - connect(m_session, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), this, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); - connect(m_session, SIGNAL(imageAvailable(int,QVideoFrame)), this, SIGNAL(imageAvailable(int,QVideoFrame))); - connect(m_session, SIGNAL(imageSaved(int,QString)), this, SIGNAL(imageSaved(int,QString))); - connect(m_session, SIGNAL(imageCaptureError(int,int,QString)), this, SIGNAL(error(int,int,QString))); -} - -bool QAndroidCameraImageCaptureControl::isReadyForCapture() const -{ - return m_session->isReadyForCapture(); -} - -QCameraImageCapture::DriveMode QAndroidCameraImageCaptureControl::driveMode() const -{ - return m_session->driveMode(); -} - -void QAndroidCameraImageCaptureControl::setDriveMode(QCameraImageCapture::DriveMode mode) -{ - m_session->setDriveMode(mode); -} - -int QAndroidCameraImageCaptureControl::capture(const QString &fileName) -{ - return m_session->capture(fileName); -} - -void QAndroidCameraImageCaptureControl::cancelCapture() -{ - m_session->cancelCapture(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameraimagecapturecontrol.h b/src/plugins/android/src/mediacapture/qandroidcameraimagecapturecontrol.h deleted file mode 100644 index cfe748c39..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraimagecapturecontrol.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAIMAGECAPTURECONTROL_H -#define QANDROIDCAMERAIMAGECAPTURECONTROL_H - -#include <qcameraimagecapturecontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraImageCaptureControl : public QCameraImageCaptureControl -{ - Q_OBJECT -public: - explicit QAndroidCameraImageCaptureControl(QAndroidCameraSession *session); - - bool isReadyForCapture() const override; - - QCameraImageCapture::DriveMode driveMode() const override; - void setDriveMode(QCameraImageCapture::DriveMode mode) override; - - int capture(const QString &fileName) override; - void cancelCapture() override; - -private: - QAndroidCameraSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAIMAGECAPTURECONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.cpp deleted file mode 100644 index c69f1946b..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameraimageprocessingcontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" - -QT_BEGIN_NAMESPACE - -QAndroidCameraImageProcessingControl::QAndroidCameraImageProcessingControl(QAndroidCameraSession *session) - : QCameraImageProcessingControl() - , m_session(session) - , m_whiteBalanceMode(QCameraImageProcessing::WhiteBalanceAuto) -{ - connect(m_session, SIGNAL(opened()), - this, SLOT(onCameraOpened())); -} - -bool QAndroidCameraImageProcessingControl::isParameterSupported(ProcessingParameter parameter) const -{ - return parameter == QCameraImageProcessingControl::WhiteBalancePreset - && m_session->camera() - && !m_supportedWhiteBalanceModes.isEmpty(); -} - -bool QAndroidCameraImageProcessingControl::isParameterValueSupported(ProcessingParameter parameter, - const QVariant &value) const -{ - return parameter == QCameraImageProcessingControl::WhiteBalancePreset - && m_session->camera() - && m_supportedWhiteBalanceModes.contains(value.value<QCameraImageProcessing::WhiteBalanceMode>()); -} - -QVariant QAndroidCameraImageProcessingControl::parameter(ProcessingParameter parameter) const -{ - if (parameter != QCameraImageProcessingControl::WhiteBalancePreset) - return QVariant(); - - return QVariant::fromValue(m_whiteBalanceMode); -} - -void QAndroidCameraImageProcessingControl::setParameter(ProcessingParameter parameter, const QVariant &value) -{ - if (parameter != QCameraImageProcessingControl::WhiteBalancePreset) - return; - - QCameraImageProcessing::WhiteBalanceMode mode = value.value<QCameraImageProcessing::WhiteBalanceMode>(); - - if (m_session->camera()) - setWhiteBalanceModeHelper(mode); - else - m_whiteBalanceMode = mode; -} - -void QAndroidCameraImageProcessingControl::setWhiteBalanceModeHelper(QCameraImageProcessing::WhiteBalanceMode mode) -{ - QString wb = m_supportedWhiteBalanceModes.value(mode, QString()); - if (!wb.isEmpty()) { - m_session->camera()->setWhiteBalance(wb); - m_whiteBalanceMode = mode; - } -} - -void QAndroidCameraImageProcessingControl::onCameraOpened() -{ - m_supportedWhiteBalanceModes.clear(); - QStringList whiteBalanceModes = m_session->camera()->getSupportedWhiteBalance(); - for (int i = 0; i < whiteBalanceModes.size(); ++i) { - const QString &wb = whiteBalanceModes.at(i); - if (wb == QLatin1String("auto")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceAuto, - QStringLiteral("auto")); - } else if (wb == QLatin1String("cloudy-daylight")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceCloudy, - QStringLiteral("cloudy-daylight")); - } else if (wb == QLatin1String("daylight")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceSunlight, - QStringLiteral("daylight")); - } else if (wb == QLatin1String("fluorescent")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceFluorescent, - QStringLiteral("fluorescent")); - } else if (wb == QLatin1String("incandescent")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceTungsten, - QStringLiteral("incandescent")); - } else if (wb == QLatin1String("shade")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceShade, - QStringLiteral("shade")); - } else if (wb == QLatin1String("twilight")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceSunset, - QStringLiteral("twilight")); - } else if (wb == QLatin1String("warm-fluorescent")) { - m_supportedWhiteBalanceModes.insert(QCameraImageProcessing::WhiteBalanceFlash, - QStringLiteral("warm-fluorescent")); - } - } - - if (!m_supportedWhiteBalanceModes.contains(m_whiteBalanceMode)) - m_whiteBalanceMode = QCameraImageProcessing::WhiteBalanceAuto; - - setWhiteBalanceModeHelper(m_whiteBalanceMode); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.h b/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.h deleted file mode 100644 index 9845c80dc..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameraimageprocessingcontrol.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAIMAGEPROCESSINGCONTROL_H -#define QANDROIDCAMERAIMAGEPROCESSINGCONTROL_H - -#include <qcameraimageprocessingcontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraImageProcessingControl : public QCameraImageProcessingControl -{ - Q_OBJECT -public: - explicit QAndroidCameraImageProcessingControl(QAndroidCameraSession *session); - - bool isParameterSupported(ProcessingParameter) const override; - bool isParameterValueSupported(ProcessingParameter parameter, const QVariant &value) const override; - QVariant parameter(ProcessingParameter parameter) const override; - void setParameter(ProcessingParameter parameter, const QVariant &value) override; - -private Q_SLOTS: - void onCameraOpened(); - -private: - void setWhiteBalanceModeHelper(QCameraImageProcessing::WhiteBalanceMode mode); - - QAndroidCameraSession *m_session; - - QCameraImageProcessing::WhiteBalanceMode m_whiteBalanceMode; - - QMap<QCameraImageProcessing::WhiteBalanceMode, QString> m_supportedWhiteBalanceModes; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAIMAGEPROCESSINGCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcamerainfocontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcamerainfocontrol.cpp deleted file mode 100644 index 911ffc3ca..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerainfocontrol.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcamerainfocontrol.h" - -#include "qandroidcamerasession.h" - -QT_BEGIN_NAMESPACE - -QCamera::Position QAndroidCameraInfoControl::position(const QString &deviceName) -{ - const QList<AndroidCameraInfo> &cameras = QAndroidCameraSession::availableCameras(); - for (int i = 0; i < cameras.count(); ++i) { - const AndroidCameraInfo &info = cameras.at(i); - if (QString::fromLatin1(info.name) == deviceName) - return info.position; - } - - return QCamera::UnspecifiedPosition; -} - -int QAndroidCameraInfoControl::orientation(const QString &deviceName) -{ - const QList<AndroidCameraInfo> &cameras = QAndroidCameraSession::availableCameras(); - for (int i = 0; i < cameras.count(); ++i) { - const AndroidCameraInfo &info = cameras.at(i); - if (QString::fromLatin1(info.name) == deviceName) - return info.orientation; - } - - return 0; -} - -QCamera::Position QAndroidCameraInfoControl::cameraPosition(const QString &deviceName) const -{ - return position(deviceName); -} - -int QAndroidCameraInfoControl::cameraOrientation(const QString &deviceName) const -{ - return orientation(deviceName); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcamerainfocontrol.h b/src/plugins/android/src/mediacapture/qandroidcamerainfocontrol.h deleted file mode 100644 index 349c73c97..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerainfocontrol.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAINFOCONTROL_H -#define QANDROIDCAMERAINFOCONTROL_H - -#include <qcamerainfocontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraInfoControl : public QCameraInfoControl -{ - Q_OBJECT -public: - QCamera::Position cameraPosition(const QString &deviceName) const; - int cameraOrientation(const QString &deviceName) const; - - static QCamera::Position position(const QString &deviceName); - static int orientation(const QString &deviceName); -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAINFOCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.cpp deleted file mode 100644 index 180a2f483..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameralockscontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" -#include <qtimer.h> - -QT_BEGIN_NAMESPACE - -QAndroidCameraLocksControl::QAndroidCameraLocksControl(QAndroidCameraSession *session) - : QCameraLocksControl() - , m_session(session) - , m_supportedLocks(QCamera::NoLock) - , m_focusLockStatus(QCamera::Unlocked) - , m_exposureLockStatus(QCamera::Unlocked) - , m_whiteBalanceLockStatus(QCamera::Unlocked) -{ - connect(m_session, SIGNAL(opened()), - this, SLOT(onCameraOpened())); - - m_recalculateTimer = new QTimer(this); - m_recalculateTimer->setInterval(1000); - m_recalculateTimer->setSingleShot(true); - connect(m_recalculateTimer, SIGNAL(timeout()), this, SLOT(onRecalculateTimeOut())); -} - -QCamera::LockTypes QAndroidCameraLocksControl::supportedLocks() const -{ - return m_supportedLocks; -} - -QCamera::LockStatus QAndroidCameraLocksControl::lockStatus(QCamera::LockType lock) const -{ - if (!m_supportedLocks.testFlag(lock) || !m_session->camera()) - return QCamera::Unlocked; - - if (lock == QCamera::LockFocus) - return m_focusLockStatus; - - if (lock == QCamera::LockExposure) - return m_exposureLockStatus; - - if (lock == QCamera::LockWhiteBalance) - return m_whiteBalanceLockStatus; - - return QCamera::Unlocked; -} - -void QAndroidCameraLocksControl::searchAndLock(QCamera::LockTypes locks) -{ - if (!m_session->camera()) - return; - - // filter out unsupported locks - locks &= m_supportedLocks; - - if (locks.testFlag(QCamera::LockFocus)) { - QString focusMode = m_session->camera()->getFocusMode(); - if (focusMode == QLatin1String("auto") - || focusMode == QLatin1String("macro") - || focusMode == QLatin1String("continuous-picture") - || focusMode == QLatin1String("continuous-video")) { - - if (m_focusLockStatus == QCamera::Searching) - m_session->camera()->cancelAutoFocus(); - else - setFocusLockStatus(QCamera::Searching, QCamera::UserRequest); - - m_session->camera()->autoFocus(); - - } else { - setFocusLockStatus(QCamera::Locked, QCamera::LockAcquired); - } - } - - if (locks.testFlag(QCamera::LockExposure) && m_exposureLockStatus != QCamera::Searching) { - if (m_session->camera()->getAutoExposureLock()) { - // if already locked, unlock and give some time to recalculate exposure - m_session->camera()->setAutoExposureLock(false); - setExposureLockStatus(QCamera::Searching, QCamera::UserRequest); - } else { - m_session->camera()->setAutoExposureLock(true); - setExposureLockStatus(QCamera::Locked, QCamera::LockAcquired); - } - } - - if (locks.testFlag(QCamera::LockWhiteBalance) && m_whiteBalanceLockStatus != QCamera::Searching) { - if (m_session->camera()->getAutoWhiteBalanceLock()) { - // if already locked, unlock and give some time to recalculate white balance - m_session->camera()->setAutoWhiteBalanceLock(false); - setWhiteBalanceLockStatus(QCamera::Searching, QCamera::UserRequest); - } else { - m_session->camera()->setAutoWhiteBalanceLock(true); - setWhiteBalanceLockStatus(QCamera::Locked, QCamera::LockAcquired); - } - } - - if (m_exposureLockStatus == QCamera::Searching || m_whiteBalanceLockStatus == QCamera::Searching) - m_recalculateTimer->start(); -} - -void QAndroidCameraLocksControl::unlock(QCamera::LockTypes locks) -{ - if (!m_session->camera()) - return; - - if (m_recalculateTimer->isActive()) - m_recalculateTimer->stop(); - - // filter out unsupported locks - locks &= m_supportedLocks; - - if (locks.testFlag(QCamera::LockFocus)) { - m_session->camera()->cancelAutoFocus(); - setFocusLockStatus(QCamera::Unlocked, QCamera::UserRequest); - } - - if (locks.testFlag(QCamera::LockExposure)) { - m_session->camera()->setAutoExposureLock(false); - setExposureLockStatus(QCamera::Unlocked, QCamera::UserRequest); - } - - if (locks.testFlag(QCamera::LockWhiteBalance)) { - m_session->camera()->setAutoWhiteBalanceLock(false); - setWhiteBalanceLockStatus(QCamera::Unlocked, QCamera::UserRequest); - } -} - -void QAndroidCameraLocksControl::onCameraOpened() -{ - m_supportedLocks = QCamera::NoLock; - m_focusLockStatus = QCamera::Unlocked; - m_exposureLockStatus = QCamera::Unlocked; - m_whiteBalanceLockStatus = QCamera::Unlocked; - - // check if focus lock is supported - QStringList focusModes = m_session->camera()->getSupportedFocusModes(); - for (int i = 0; i < focusModes.size(); ++i) { - const QString &focusMode = focusModes.at(i); - if (focusMode == QLatin1String("auto") - || focusMode == QLatin1String("continuous-picture") - || focusMode == QLatin1String("continuous-video") - || focusMode == QLatin1String("macro")) { - - m_supportedLocks |= QCamera::LockFocus; - setFocusLockStatus(QCamera::Unlocked, QCamera::UserRequest); - - connect(m_session->camera(), SIGNAL(autoFocusComplete(bool)), - this, SLOT(onCameraAutoFocusComplete(bool))); - - break; - } - } - - if (m_session->camera()->isAutoExposureLockSupported()) { - m_supportedLocks |= QCamera::LockExposure; - setExposureLockStatus(QCamera::Unlocked, QCamera::UserRequest); - } - - if (m_session->camera()->isAutoWhiteBalanceLockSupported()) { - m_supportedLocks |= QCamera::LockWhiteBalance; - setWhiteBalanceLockStatus(QCamera::Unlocked, QCamera::UserRequest); - - connect(m_session->camera(), SIGNAL(whiteBalanceChanged()), - this, SLOT(onWhiteBalanceChanged())); - } -} - -void QAndroidCameraLocksControl::onCameraAutoFocusComplete(bool success) -{ - m_focusLockStatus = success ? QCamera::Locked : QCamera::Unlocked; - QCamera::LockChangeReason reason = success ? QCamera::LockAcquired : QCamera::LockFailed; - emit lockStatusChanged(QCamera::LockFocus, m_focusLockStatus, reason); -} - -void QAndroidCameraLocksControl::onRecalculateTimeOut() -{ - if (m_exposureLockStatus == QCamera::Searching) { - m_session->camera()->setAutoExposureLock(true); - setExposureLockStatus(QCamera::Locked, QCamera::LockAcquired); - } - - if (m_whiteBalanceLockStatus == QCamera::Searching) { - m_session->camera()->setAutoWhiteBalanceLock(true); - setWhiteBalanceLockStatus(QCamera::Locked, QCamera::LockAcquired); - } -} - -void QAndroidCameraLocksControl::onWhiteBalanceChanged() -{ - // changing the white balance mode releases the white balance lock - if (m_whiteBalanceLockStatus != QCamera::Unlocked) - setWhiteBalanceLockStatus(QCamera::Unlocked, QCamera::LockLost); -} - -void QAndroidCameraLocksControl::setFocusLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason) -{ - m_focusLockStatus = status; - emit lockStatusChanged(QCamera::LockFocus, m_focusLockStatus, reason); -} - -void QAndroidCameraLocksControl::setWhiteBalanceLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason) -{ - m_whiteBalanceLockStatus = status; - emit lockStatusChanged(QCamera::LockWhiteBalance, m_whiteBalanceLockStatus, reason); -} - -void QAndroidCameraLocksControl::setExposureLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason) -{ - m_exposureLockStatus = status; - emit lockStatusChanged(QCamera::LockExposure, m_exposureLockStatus, reason); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.h b/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.h deleted file mode 100644 index 149da0f32..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameralockscontrol.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERALOCKSCONTROL_H -#define QANDROIDCAMERALOCKSCONTROL_H - -#include <qcameralockscontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; -class QTimer; - -class QAndroidCameraLocksControl : public QCameraLocksControl -{ - Q_OBJECT -public: - explicit QAndroidCameraLocksControl(QAndroidCameraSession *session); - - QCamera::LockTypes supportedLocks() const override; - QCamera::LockStatus lockStatus(QCamera::LockType lock) const override; - void searchAndLock(QCamera::LockTypes locks) override; - void unlock(QCamera::LockTypes locks) override; - -private Q_SLOTS: - void onCameraOpened(); - void onCameraAutoFocusComplete(bool success); - void onRecalculateTimeOut(); - void onWhiteBalanceChanged(); - -private: - void setFocusLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason); - void setWhiteBalanceLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason); - void setExposureLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason); - - QAndroidCameraSession *m_session; - - QTimer *m_recalculateTimer; - - QCamera::LockTypes m_supportedLocks; - - QCamera::LockStatus m_focusLockStatus; - QCamera::LockStatus m_exposureLockStatus; - QCamera::LockStatus m_whiteBalanceLockStatus; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERALOCKSCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp deleted file mode 100644 index ff5c7be15..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp +++ /dev/null @@ -1,942 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Ruslan Baratov -** 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$ -** -****************************************************************************/ - -#include "qandroidcamerasession.h" - -#include "androidcamera.h" -#include "androidmultimediautils.h" -#include "qandroidvideooutput.h" -#include "qandroidmediavideoprobecontrol.h" -#include "qandroidmultimediautils.h" -#include "qandroidcameravideorenderercontrol.h" -#include <qabstractvideosurface.h> -#include <QtConcurrent/qtconcurrentrun.h> -#include <qfile.h> -#include <qguiapplication.h> -#include <qdebug.h> -#include <qvideoframe.h> -#include <private/qmemoryvideobuffer_p.h> -#include <QtCore/private/qjnihelpers_p.h> - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QList<AndroidCameraInfo>, g_availableCameras) - -QAndroidCameraSession::QAndroidCameraSession(QObject *parent) - : QObject(parent) - , m_selectedCamera(0) - , m_camera(0) - , m_nativeOrientation(0) - , m_videoOutput(0) - , m_captureMode(QCamera::CaptureStillImage) - , m_state(QCamera::UnloadedState) - , m_savedState(-1) - , m_status(QCamera::UnloadedStatus) - , m_previewStarted(false) - , m_captureDestination(QCameraImageCapture::CaptureToFile) - , m_captureImageDriveMode(QCameraImageCapture::SingleImageCapture) - , m_lastImageCaptureId(0) - , m_readyForCapture(false) - , m_captureCanceled(false) - , m_currentImageCaptureId(-1) - , m_previewCallback(0) - , m_keepActive(false) -{ - m_mediaStorageLocation.addStorageLocation( - QMediaStorageLocation::Pictures, - AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM)); - - if (qApp) { - connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), - this, SLOT(onApplicationStateChanged(Qt::ApplicationState))); - } -} - -QAndroidCameraSession::~QAndroidCameraSession() -{ - close(); -} - -void QAndroidCameraSession::setCaptureMode(QCamera::CaptureModes mode) -{ - if (m_captureMode == mode || !isCaptureModeSupported(mode)) - return; - - m_captureMode = mode; - emit captureModeChanged(m_captureMode); - - if (m_previewStarted && m_captureMode.testFlag(QCamera::CaptureStillImage)) - applyViewfinderSettings(m_actualImageSettings.resolution()); -} - -bool QAndroidCameraSession::isCaptureModeSupported(QCamera::CaptureModes mode) const -{ - if (mode & (QCamera::CaptureStillImage & QCamera::CaptureVideo)) - return false; - - return true; -} - -void QAndroidCameraSession::setState(QCamera::State state) -{ - if (m_state == state) - return; - - m_state = state; - emit stateChanged(m_state); - - // If the application is inactive, the camera shouldn't be started. Save the desired state - // instead and it will be set when the application becomes active. - if (qApp->applicationState() == Qt::ApplicationActive) - setStateHelper(state); - else - m_savedState = state; -} - -void QAndroidCameraSession::setStateHelper(QCamera::State state) -{ - switch (state) { - case QCamera::UnloadedState: - close(); - break; - case QCamera::LoadedState: - case QCamera::ActiveState: - if (!m_camera && !open()) { - m_state = QCamera::UnloadedState; - emit stateChanged(m_state); - emit error(QCamera::CameraError, QStringLiteral("Failed to open camera")); - m_status = QCamera::UnloadedStatus; - emit statusChanged(m_status); - return; - } - if (state == QCamera::ActiveState) - startPreview(); - else if (state == QCamera::LoadedState) - stopPreview(); - break; - } -} - -void QAndroidCameraSession::updateAvailableCameras() -{ - g_availableCameras->clear(); - - const int numCameras = AndroidCamera::getNumberOfCameras(); - for (int i = 0; i < numCameras; ++i) { - AndroidCameraInfo info; - AndroidCamera::getCameraInfo(i, &info); - - if (!info.name.isNull()) - g_availableCameras->append(info); - } -} - -const QList<AndroidCameraInfo> &QAndroidCameraSession::availableCameras() -{ - if (g_availableCameras->isEmpty()) - updateAvailableCameras(); - - return *g_availableCameras; -} - -bool QAndroidCameraSession::open() -{ - close(); - - m_status = QCamera::LoadingStatus; - emit statusChanged(m_status); - - m_camera = AndroidCamera::open(m_selectedCamera); - - if (m_camera) { - connect(m_camera, SIGNAL(pictureExposed()), this, SLOT(onCameraPictureExposed())); - connect(m_camera, SIGNAL(lastPreviewFrameFetched(QVideoFrame)), - this, SLOT(onLastPreviewFrameFetched(QVideoFrame)), - Qt::DirectConnection); - connect(m_camera, SIGNAL(newPreviewFrame(QVideoFrame)), - this, SLOT(onNewPreviewFrame(QVideoFrame)), - Qt::DirectConnection); - connect(m_camera, SIGNAL(pictureCaptured(QByteArray)), this, SLOT(onCameraPictureCaptured(QByteArray))); - connect(m_camera, SIGNAL(previewStarted()), this, SLOT(onCameraPreviewStarted())); - connect(m_camera, SIGNAL(previewStopped()), this, SLOT(onCameraPreviewStopped())); - connect(m_camera, &AndroidCamera::previewFailedToStart, this, &QAndroidCameraSession::onCameraPreviewFailedToStart); - connect(m_camera, &AndroidCamera::takePictureFailed, this, &QAndroidCameraSession::onCameraTakePictureFailed); - - m_nativeOrientation = m_camera->getNativeOrientation(); - - m_status = QCamera::LoadedStatus; - - if (m_camera->getPreviewFormat() != AndroidCamera::NV21) - m_camera->setPreviewFormat(AndroidCamera::NV21); - - m_camera->notifyNewFrames(m_videoProbes.count() || m_previewCallback); - - emit opened(); - emit statusChanged(m_status); - } - - return m_camera != 0; -} - -void QAndroidCameraSession::close() -{ - if (!m_camera) - return; - - stopPreview(); - - m_status = QCamera::UnloadingStatus; - emit statusChanged(m_status); - - m_readyForCapture = false; - m_currentImageCaptureId = -1; - m_currentImageCaptureFileName.clear(); - m_actualImageSettings = m_requestedImageSettings; - m_actualViewfinderSettings = m_requestedViewfinderSettings; - - m_camera->release(); - delete m_camera; - m_camera = 0; - - m_status = QCamera::UnloadedStatus; - emit statusChanged(m_status); -} - -void QAndroidCameraSession::setVideoOutput(QAndroidVideoOutput *output) -{ - if (m_videoOutput) { - m_videoOutput->stop(); - m_videoOutput->reset(); - } - - if (output) { - m_videoOutput = output; - if (m_videoOutput->isReady()) - onVideoOutputReady(true); - else - connect(m_videoOutput, SIGNAL(readyChanged(bool)), this, SLOT(onVideoOutputReady(bool))); - } else { - m_videoOutput = 0; - } -} - -void QAndroidCameraSession::setViewfinderSettings(const QCameraViewfinderSettings &settings) -{ - if (m_requestedViewfinderSettings == settings) - return; - - m_requestedViewfinderSettings = m_actualViewfinderSettings = settings; - - if (m_readyForCapture) - applyViewfinderSettings(); -} - -void QAndroidCameraSession::applyViewfinderSettings(const QSize &captureSize, bool restartPreview) -{ - if (!m_camera) - return; - - const QSize currentViewfinderResolution = m_camera->previewSize(); - const AndroidCamera::ImageFormat currentPreviewFormat = m_camera->getPreviewFormat(); - const AndroidCamera::FpsRange currentFpsRange = m_camera->getPreviewFpsRange(); - - // -- adjust resolution - QSize adjustedViewfinderResolution; - const bool validCaptureSize = captureSize.width() > 0 && captureSize.height() > 0; - if (m_captureMode.testFlag(QCamera::CaptureVideo) - && validCaptureSize - && m_camera->getPreferredPreviewSizeForVideo().isEmpty()) { - // According to the Android doc, if getPreferredPreviewSizeForVideo() returns null, it means - // the preview size cannot be different from the capture size - adjustedViewfinderResolution = captureSize; - } else { - qreal captureAspectRatio = 0; - if (validCaptureSize) - captureAspectRatio = qreal(captureSize.width()) / qreal(captureSize.height()); - - const QList<QSize> previewSizes = m_camera->getSupportedPreviewSizes(); - - const QSize vfRes = m_requestedViewfinderSettings.resolution(); - if (vfRes.width() > 0 && vfRes.height() > 0 - && (!validCaptureSize || qAbs(captureAspectRatio - (qreal(vfRes.width()) / vfRes.height())) < 0.01) - && previewSizes.contains(vfRes)) { - adjustedViewfinderResolution = vfRes; - } else if (validCaptureSize) { - // search for viewfinder resolution with the same aspect ratio - qreal minAspectDiff = 1; - QSize closestResolution; - for (int i = previewSizes.count() - 1; i >= 0; --i) { - const QSize &size = previewSizes.at(i); - const qreal sizeAspect = qreal(size.width()) / size.height(); - if (qFuzzyCompare(captureAspectRatio, sizeAspect)) { - adjustedViewfinderResolution = size; - break; - } else if (minAspectDiff > qAbs(sizeAspect - captureAspectRatio)) { - closestResolution = size; - minAspectDiff = qAbs(sizeAspect - captureAspectRatio); - } - } - if (!adjustedViewfinderResolution.isValid()) { - qWarning("Cannot find a viewfinder resolution matching the capture aspect ratio."); - if (closestResolution.isValid()) { - adjustedViewfinderResolution = closestResolution; - qWarning("Using closest viewfinder resolution."); - } else { - return; - } - } - } else { - adjustedViewfinderResolution = previewSizes.last(); - } - } - m_actualViewfinderSettings.setResolution(adjustedViewfinderResolution); - - // -- adjust pixel format - - AndroidCamera::ImageFormat adjustedPreviewFormat = AndroidCamera::NV21; - if (m_requestedViewfinderSettings.pixelFormat() != QVideoFrame::Format_Invalid) { - const AndroidCamera::ImageFormat f = AndroidImageFormatFromQtPixelFormat(m_requestedViewfinderSettings.pixelFormat()); - if (f == AndroidCamera::UnknownImageFormat || !m_camera->getSupportedPreviewFormats().contains(f)) - qWarning("Unsupported viewfinder pixel format"); - else - adjustedPreviewFormat = f; - } - m_actualViewfinderSettings.setPixelFormat(QtPixelFormatFromAndroidImageFormat(adjustedPreviewFormat)); - - // -- adjust FPS - - AndroidCamera::FpsRange adjustedFps = currentFpsRange; - const AndroidCamera::FpsRange requestedFpsRange = AndroidCamera::FpsRange::makeFromQReal(m_requestedViewfinderSettings.minimumFrameRate(), - m_requestedViewfinderSettings.maximumFrameRate()); - if (requestedFpsRange.min > 0 || requestedFpsRange.max > 0) { - int minDist = INT_MAX; - const QList<AndroidCamera::FpsRange> supportedFpsRanges = m_camera->getSupportedPreviewFpsRange(); - auto it = supportedFpsRanges.rbegin(), end = supportedFpsRanges.rend(); - for (; it != end; ++it) { - int dist = (requestedFpsRange.min > 0 ? qAbs(requestedFpsRange.min - it->min) : 0) - + (requestedFpsRange.max > 0 ? qAbs(requestedFpsRange.max - it->max) : 0); - if (dist < minDist) { - minDist = dist; - adjustedFps = *it; - if (minDist == 0) - break; // exact match - } - } - } - m_actualViewfinderSettings.setMinimumFrameRate(adjustedFps.getMinReal()); - m_actualViewfinderSettings.setMaximumFrameRate(adjustedFps.getMaxReal()); - - // -- Set values on camera - - if (currentViewfinderResolution != adjustedViewfinderResolution - || currentPreviewFormat != adjustedPreviewFormat - || currentFpsRange.min != adjustedFps.min - || currentFpsRange.max != adjustedFps.max) { - - if (m_videoOutput) - m_videoOutput->setVideoSize(adjustedViewfinderResolution); - - // if preview is started, we have to stop it first before changing its size - if (m_previewStarted && restartPreview) - m_camera->stopPreview(); - - m_camera->setPreviewSize(adjustedViewfinderResolution); - m_camera->setPreviewFormat(adjustedPreviewFormat); - m_camera->setPreviewFpsRange(adjustedFps); - - // restart preview - if (m_previewStarted && restartPreview) - m_camera->startPreview(); - } -} - -QList<QSize> QAndroidCameraSession::getSupportedPreviewSizes() const -{ - return m_camera ? m_camera->getSupportedPreviewSizes() : QList<QSize>(); -} - -QList<QVideoFrame::PixelFormat> QAndroidCameraSession::getSupportedPixelFormats() const -{ - QList<QVideoFrame::PixelFormat> formats; - - if (!m_camera) - return formats; - - const QList<AndroidCamera::ImageFormat> nativeFormats = m_camera->getSupportedPreviewFormats(); - - formats.reserve(nativeFormats.size()); - - for (AndroidCamera::ImageFormat nativeFormat : nativeFormats) { - QVideoFrame::PixelFormat format = QtPixelFormatFromAndroidImageFormat(nativeFormat); - if (format != QVideoFrame::Format_Invalid) - formats.append(format); - } - - return formats; -} - -QList<AndroidCamera::FpsRange> QAndroidCameraSession::getSupportedPreviewFpsRange() const -{ - return m_camera ? m_camera->getSupportedPreviewFpsRange() : QList<AndroidCamera::FpsRange>(); -} - -struct NullSurface : QAbstractVideoSurface -{ - NullSurface(QObject *parent = nullptr) : QAbstractVideoSurface(parent) { } - QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const override - { - QList<QVideoFrame::PixelFormat> result; - if (type == QAbstractVideoBuffer::NoHandle) - result << QVideoFrame::Format_NV21; - - return result; - } - - bool present(const QVideoFrame &) { return false; } -}; - -bool QAndroidCameraSession::startPreview() -{ - if (!m_camera) - return false; - - if (m_previewStarted) - return true; - - if (m_videoOutput) { - if (!m_videoOutput->isReady()) - return true; // delay starting until the video output is ready - - Q_ASSERT(m_videoOutput->surfaceTexture() || m_videoOutput->surfaceHolder()); - - if ((m_videoOutput->surfaceTexture() && !m_camera->setPreviewTexture(m_videoOutput->surfaceTexture())) - || (m_videoOutput->surfaceHolder() && !m_camera->setPreviewDisplay(m_videoOutput->surfaceHolder()))) - return false; - } else { - auto control = new QAndroidCameraVideoRendererControl(this, this); - control->setSurface(new NullSurface(this)); - qWarning() << "Starting camera without viewfinder available"; - - return true; - } - - m_status = QCamera::StartingStatus; - emit statusChanged(m_status); - - applyImageSettings(); - applyViewfinderSettings(m_captureMode.testFlag(QCamera::CaptureStillImage) ? m_actualImageSettings.resolution() - : QSize()); - - AndroidMultimediaUtils::enableOrientationListener(true); - - // Before API level 24 the orientation was always 0, which is what we're expecting, so - // we'll enforce that here. - if (QtAndroidPrivate::androidSdkVersion() > 23) - m_camera->setDisplayOrientation(0); - - m_camera->startPreview(); - m_previewStarted = true; - - return true; -} - -void QAndroidCameraSession::stopPreview() -{ - if (!m_camera || !m_previewStarted) - return; - - m_status = QCamera::StoppingStatus; - emit statusChanged(m_status); - - AndroidMultimediaUtils::enableOrientationListener(false); - - m_camera->stopPreview(); - m_camera->setPreviewSize(QSize()); - m_camera->setPreviewTexture(0); - m_camera->setPreviewDisplay(0); - - if (m_videoOutput) { - m_videoOutput->stop(); - m_videoOutput->reset(); - } - m_previewStarted = false; -} - -void QAndroidCameraSession::setImageSettings(const QImageEncoderSettings &settings) -{ - if (m_requestedImageSettings == settings) - return; - - m_requestedImageSettings = m_actualImageSettings = settings; - - applyImageSettings(); - - if (m_readyForCapture && m_captureMode.testFlag(QCamera::CaptureStillImage)) - applyViewfinderSettings(m_actualImageSettings.resolution()); -} - -int QAndroidCameraSession::currentCameraRotation() const -{ - if (!m_camera) - return 0; - - // subtract natural camera orientation and physical device orientation - int rotation = 0; - int deviceOrientation = (AndroidMultimediaUtils::getDeviceOrientation() + 45) / 90 * 90; - if (m_camera->getFacing() == AndroidCamera::CameraFacingFront) - rotation = (m_nativeOrientation - deviceOrientation + 360) % 360; - else // back-facing camera - rotation = (m_nativeOrientation + deviceOrientation) % 360; - - return rotation; -} - -void QAndroidCameraSession::addProbe(QAndroidMediaVideoProbeControl *probe) -{ - m_videoProbesMutex.lock(); - if (probe) - m_videoProbes << probe; - if (m_camera) - m_camera->notifyNewFrames(m_videoProbes.count() || m_previewCallback); - m_videoProbesMutex.unlock(); -} - -void QAndroidCameraSession::removeProbe(QAndroidMediaVideoProbeControl *probe) -{ - m_videoProbesMutex.lock(); - m_videoProbes.remove(probe); - if (m_camera) - m_camera->notifyNewFrames(m_videoProbes.count() || m_previewCallback); - m_videoProbesMutex.unlock(); -} - -void QAndroidCameraSession::setPreviewFormat(AndroidCamera::ImageFormat format) -{ - if (format == AndroidCamera::UnknownImageFormat) - return; - - m_camera->setPreviewFormat(format); -} - -void QAndroidCameraSession::setPreviewCallback(PreviewCallback *callback) -{ - m_videoProbesMutex.lock(); - m_previewCallback = callback; - if (m_camera) - m_camera->notifyNewFrames(m_videoProbes.count() || m_previewCallback); - m_videoProbesMutex.unlock(); -} - -void QAndroidCameraSession::applyImageSettings() -{ - if (!m_camera) - return; - - if (m_actualImageSettings.codec().isEmpty()) - m_actualImageSettings.setCodec(QLatin1String("jpeg")); - - const QSize requestedResolution = m_requestedImageSettings.resolution(); - const QList<QSize> supportedResolutions = m_camera->getSupportedPictureSizes(); - if (!requestedResolution.isValid()) { - // if the viewfinder resolution is explicitly set, pick the highest available capture - // resolution with the same aspect ratio - if (m_requestedViewfinderSettings.resolution().isValid()) { - const QSize vfResolution = m_actualViewfinderSettings.resolution(); - const qreal vfAspectRatio = qreal(vfResolution.width()) / vfResolution.height(); - - auto it = supportedResolutions.rbegin(), end = supportedResolutions.rend(); - for (; it != end; ++it) { - if (qAbs(vfAspectRatio - (qreal(it->width()) / it->height())) < 0.01) { - m_actualImageSettings.setResolution(*it); - break; - } - } - } else { - // otherwise, use the highest supported one - m_actualImageSettings.setResolution(supportedResolutions.last()); - } - } else if (!supportedResolutions.contains(requestedResolution)) { - // if the requested resolution is not supported, find the closest one - int reqPixelCount = requestedResolution.width() * requestedResolution.height(); - QList<int> supportedPixelCounts; - for (int i = 0; i < supportedResolutions.size(); ++i) { - const QSize &s = supportedResolutions.at(i); - supportedPixelCounts.append(s.width() * s.height()); - } - int closestIndex = qt_findClosestValue(supportedPixelCounts, reqPixelCount); - m_actualImageSettings.setResolution(supportedResolutions.at(closestIndex)); - } - m_camera->setPictureSize(m_actualImageSettings.resolution()); - - int jpegQuality = 100; - switch (m_requestedImageSettings.quality()) { - case QMultimedia::VeryLowQuality: - jpegQuality = 20; - break; - case QMultimedia::LowQuality: - jpegQuality = 40; - break; - case QMultimedia::NormalQuality: - jpegQuality = 60; - break; - case QMultimedia::HighQuality: - jpegQuality = 80; - break; - case QMultimedia::VeryHighQuality: - jpegQuality = 100; - break; - } - m_camera->setJpegQuality(jpegQuality); -} - -bool QAndroidCameraSession::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const -{ - return destination & (QCameraImageCapture::CaptureToFile | QCameraImageCapture::CaptureToBuffer); -} - -QCameraImageCapture::CaptureDestinations QAndroidCameraSession::captureDestination() const -{ - return m_captureDestination; -} - -void QAndroidCameraSession::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) -{ - if (m_captureDestination != destination) { - m_captureDestination = destination; - emit captureDestinationChanged(m_captureDestination); - } -} - -bool QAndroidCameraSession::isReadyForCapture() const -{ - return m_status == QCamera::ActiveStatus && m_readyForCapture; -} - -void QAndroidCameraSession::setReadyForCapture(bool ready) -{ - if (m_readyForCapture == ready) - return; - - m_readyForCapture = ready; - emit readyForCaptureChanged(ready); -} - -QCameraImageCapture::DriveMode QAndroidCameraSession::driveMode() const -{ - return m_captureImageDriveMode; -} - -void QAndroidCameraSession::setDriveMode(QCameraImageCapture::DriveMode mode) -{ - m_captureImageDriveMode = mode; -} - -int QAndroidCameraSession::capture(const QString &fileName) -{ - ++m_lastImageCaptureId; - - if (!isReadyForCapture()) { - emit imageCaptureError(m_lastImageCaptureId, QCameraImageCapture::NotReadyError, - tr("Camera not ready")); - return m_lastImageCaptureId; - } - - if (m_captureImageDriveMode == QCameraImageCapture::SingleImageCapture) { - setReadyForCapture(false); - - m_currentImageCaptureId = m_lastImageCaptureId; - m_currentImageCaptureFileName = fileName; - - applyImageSettings(); - applyViewfinderSettings(m_actualImageSettings.resolution()); - - // adjust picture rotation depending on the device orientation - m_camera->setRotation(currentCameraRotation()); - - m_camera->takePicture(); - } else { - //: Drive mode is the camera's shutter mode, for example single shot, continuos exposure, etc. - emit imageCaptureError(m_lastImageCaptureId, QCameraImageCapture::NotSupportedFeatureError, - tr("Drive mode not supported")); - } - - return m_lastImageCaptureId; -} - -void QAndroidCameraSession::cancelCapture() -{ - if (m_readyForCapture) - return; - - m_captureCanceled = true; -} - -void QAndroidCameraSession::onCameraTakePictureFailed() -{ - emit imageCaptureError(m_currentImageCaptureId, QCameraImageCapture::ResourceError, - tr("Failed to capture image")); - - // Preview needs to be restarted and the preview call back must be setup again - m_camera->startPreview(); -} - -void QAndroidCameraSession::onCameraPictureExposed() -{ - if (m_captureCanceled || !m_camera) - return; - - emit imageExposed(m_currentImageCaptureId); - m_camera->fetchLastPreviewFrame(); -} - -void QAndroidCameraSession::onLastPreviewFrameFetched(const QVideoFrame &frame) -{ - if (m_captureCanceled || !m_camera) - return; - - QtConcurrent::run(&QAndroidCameraSession::processPreviewImage, this, - m_currentImageCaptureId, - frame, - m_camera->getRotation()); -} - -void QAndroidCameraSession::processPreviewImage(int id, const QVideoFrame &frame, int rotation) -{ - // Preview display of front-facing cameras is flipped horizontally, but the frame data - // we get here is not. Flip it ourselves if the camera is front-facing to match what the user - // sees on the viewfinder. - QTransform transform; - if (m_camera->getFacing() == AndroidCamera::CameraFacingFront) - transform.scale(-1, 1); - transform.rotate(rotation); - - emit imageCaptured(id, frame.image().transformed(transform)); -} - -void QAndroidCameraSession::onNewPreviewFrame(const QVideoFrame &frame) -{ - if (!m_camera) - return; - - m_videoProbesMutex.lock(); - - for (QAndroidMediaVideoProbeControl *probe : qAsConst(m_videoProbes)) - probe->newFrameProbed(frame); - - if (m_previewCallback) - m_previewCallback->onFrameAvailable(frame); - - m_videoProbesMutex.unlock(); -} - -void QAndroidCameraSession::onCameraPictureCaptured(const QByteArray &data) -{ - if (!m_captureCanceled) { - // Loading and saving the captured image can be slow, do it in a separate thread - QtConcurrent::run(&QAndroidCameraSession::processCapturedImage, this, - m_currentImageCaptureId, - data, - m_actualImageSettings.resolution(), - m_captureDestination, - m_currentImageCaptureFileName); - } - - m_captureCanceled = false; - - // Preview needs to be restarted after taking a picture - if (m_camera) - m_camera->startPreview(); -} - -void QAndroidCameraSession::onCameraPreviewStarted() -{ - if (m_status == QCamera::StartingStatus) { - m_status = QCamera::ActiveStatus; - emit statusChanged(m_status); - } - - setReadyForCapture(true); -} - -void QAndroidCameraSession::onCameraPreviewFailedToStart() -{ - if (m_status == QCamera::StartingStatus) { - Q_EMIT error(QCamera::CameraError, tr("Camera preview failed to start.")); - - AndroidMultimediaUtils::enableOrientationListener(false); - m_camera->setPreviewSize(QSize()); - m_camera->setPreviewTexture(0); - if (m_videoOutput) { - m_videoOutput->stop(); - m_videoOutput->reset(); - } - m_previewStarted = false; - - m_status = QCamera::LoadedStatus; - emit statusChanged(m_status); - - setReadyForCapture(false); - } -} - -void QAndroidCameraSession::onCameraPreviewStopped() -{ - if (m_status == QCamera::StoppingStatus) { - m_status = QCamera::LoadedStatus; - emit statusChanged(m_status); - } - - setReadyForCapture(false); -} - -void QAndroidCameraSession::processCapturedImage(int id, - const QByteArray &data, - const QSize &resolution, - QCameraImageCapture::CaptureDestinations dest, - const QString &fileName) -{ - - - if (dest & QCameraImageCapture::CaptureToFile) { - const QString actualFileName = m_mediaStorageLocation.generateFileName(fileName, - QMediaStorageLocation::Pictures, - QLatin1String("IMG_"), - QLatin1String("jpg")); - - QFile file(actualFileName); - if (file.open(QFile::WriteOnly)) { - if (file.write(data) == data.size()) { - // if the picture is saved into the standard picture location, register it - // with the Android media scanner so it appears immediately in apps - // such as the gallery. - QString standardLoc = AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM); - if (actualFileName.startsWith(standardLoc)) - AndroidMultimediaUtils::registerMediaFile(actualFileName); - - emit imageSaved(id, actualFileName); - } else { - emit imageCaptureError(id, QCameraImageCapture::OutOfSpaceError, file.errorString()); - } - } else { - const QString errorMessage = tr("Could not open destination file: %1").arg(actualFileName); - emit imageCaptureError(id, QCameraImageCapture::ResourceError, errorMessage); - } - } - - if (dest & QCameraImageCapture::CaptureToBuffer) { - QVideoFrame frame(new QMemoryVideoBuffer(data, -1), resolution, QVideoFrame::Format_Jpeg); - emit imageAvailable(id, frame); - } -} - -QVideoFrame::PixelFormat QAndroidCameraSession::QtPixelFormatFromAndroidImageFormat(AndroidCamera::ImageFormat format) -{ - switch (format) { - case AndroidCamera::RGB565: - return QVideoFrame::Format_RGB565; - case AndroidCamera::NV21: - return QVideoFrame::Format_NV21; - case AndroidCamera::YUY2: - return QVideoFrame::Format_YUYV; - case AndroidCamera::JPEG: - return QVideoFrame::Format_Jpeg; - case AndroidCamera::YV12: - return QVideoFrame::Format_YV12; - default: - return QVideoFrame::Format_Invalid; - } -} - -AndroidCamera::ImageFormat QAndroidCameraSession::AndroidImageFormatFromQtPixelFormat(QVideoFrame::PixelFormat format) -{ - switch (format) { - case QVideoFrame::Format_RGB565: - return AndroidCamera::RGB565; - case QVideoFrame::Format_NV21: - return AndroidCamera::NV21; - case QVideoFrame::Format_YUYV: - return AndroidCamera::YUY2; - case QVideoFrame::Format_Jpeg: - return AndroidCamera::JPEG; - case QVideoFrame::Format_YV12: - return AndroidCamera::YV12; - default: - return AndroidCamera::UnknownImageFormat; - } -} - -void QAndroidCameraSession::onVideoOutputReady(bool ready) -{ - if (ready && m_state == QCamera::ActiveState) - startPreview(); -} - -void QAndroidCameraSession::onApplicationStateChanged(Qt::ApplicationState state) -{ - switch (state) { - case Qt::ApplicationInactive: - if (!m_keepActive && m_state != QCamera::UnloadedState) { - m_savedState = m_state; - close(); - m_state = QCamera::UnloadedState; - emit stateChanged(m_state); - } - break; - case Qt::ApplicationActive: - if (m_savedState != -1) { - setStateHelper(QCamera::State(m_savedState)); - m_savedState = -1; - } - break; - default: - break; - } -} - -bool QAndroidCameraSession::requestRecordingPermission() -{ - m_keepActive = true; - const bool result = qt_androidRequestRecordingPermission(); - m_keepActive = false; - return result; -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.h b/src/plugins/android/src/mediacapture/qandroidcamerasession.h deleted file mode 100644 index 728dc484e..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerasession.h +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Ruslan Baratov -** 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 QANDROIDCAMERASESSION_H -#define QANDROIDCAMERASESSION_H - -#include <qcamera.h> -#include <qmediaencodersettings.h> -#include <QCameraImageCapture> -#include <QSet> -#include <QMutex> -#include <private/qmediastoragelocation_p.h> -#include "androidcamera.h" - -QT_BEGIN_NAMESPACE - -class QAndroidVideoOutput; -class QAndroidMediaVideoProbeControl; - -class QAndroidCameraSession : public QObject -{ - Q_OBJECT -public: - explicit QAndroidCameraSession(QObject *parent = 0); - ~QAndroidCameraSession(); - - static const QList<AndroidCameraInfo> &availableCameras(); - - void setSelectedCamera(int cameraId) { m_selectedCamera = cameraId; } - AndroidCamera *camera() const { return m_camera; } - - QCamera::State state() const { return m_state; } - void setState(QCamera::State state); - - QCamera::Status status() const { return m_status; } - - QCamera::CaptureModes captureMode() const { return m_captureMode; } - void setCaptureMode(QCamera::CaptureModes mode); - bool isCaptureModeSupported(QCamera::CaptureModes mode) const; - - QCameraViewfinderSettings viewfinderSettings() const { return m_actualViewfinderSettings; } - void setViewfinderSettings(const QCameraViewfinderSettings &settings); - void applyViewfinderSettings(const QSize &captureSize = QSize(), bool restartPreview = true); - - QAndroidVideoOutput *videoOutput() const { return m_videoOutput; } - void setVideoOutput(QAndroidVideoOutput *output); - - QList<QSize> getSupportedPreviewSizes() const; - QList<QVideoFrame::PixelFormat> getSupportedPixelFormats() const; - QList<AndroidCamera::FpsRange> getSupportedPreviewFpsRange() const; - - QImageEncoderSettings imageSettings() const { return m_actualImageSettings; } - void setImageSettings(const QImageEncoderSettings &settings); - - bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const; - QCameraImageCapture::CaptureDestinations captureDestination() const; - void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination); - - bool isReadyForCapture() const; - void setReadyForCapture(bool ready); - QCameraImageCapture::DriveMode driveMode() const; - void setDriveMode(QCameraImageCapture::DriveMode mode); - int capture(const QString &fileName); - void cancelCapture(); - - int currentCameraRotation() const; - - void addProbe(QAndroidMediaVideoProbeControl *probe); - void removeProbe(QAndroidMediaVideoProbeControl *probe); - - void setPreviewFormat(AndroidCamera::ImageFormat format); - - struct PreviewCallback - { - virtual void onFrameAvailable(const QVideoFrame &frame) = 0; - }; - void setPreviewCallback(PreviewCallback *callback); - bool requestRecordingPermission(); - -Q_SIGNALS: - void statusChanged(QCamera::Status status); - void stateChanged(QCamera::State); - void error(int error, const QString &errorString); - void captureModeChanged(QCamera::CaptureModes); - void opened(); - - void captureDestinationChanged(QCameraImageCapture::CaptureDestinations destination); - - void readyForCaptureChanged(bool); - void imageExposed(int id); - void imageCaptured(int id, const QImage &preview); - void imageMetadataAvailable(int id, const QString &key, const QVariant &value); - void imageAvailable(int id, const QVideoFrame &buffer); - void imageSaved(int id, const QString &fileName); - void imageCaptureError(int id, int error, const QString &errorString); - -private Q_SLOTS: - void onVideoOutputReady(bool ready); - - void onApplicationStateChanged(Qt::ApplicationState state); - - void onCameraTakePictureFailed(); - void onCameraPictureExposed(); - void onCameraPictureCaptured(const QByteArray &data); - void onLastPreviewFrameFetched(const QVideoFrame &frame); - void onNewPreviewFrame(const QVideoFrame &frame); - void onCameraPreviewStarted(); - void onCameraPreviewFailedToStart(); - void onCameraPreviewStopped(); - -private: - static void updateAvailableCameras(); - - bool open(); - void close(); - - bool startPreview(); - void stopPreview(); - - void applyImageSettings(); - - void processPreviewImage(int id, const QVideoFrame &frame, int rotation); - void processCapturedImage(int id, - const QByteArray &data, - const QSize &resolution, - QCameraImageCapture::CaptureDestinations dest, - const QString &fileName); - - static QVideoFrame::PixelFormat QtPixelFormatFromAndroidImageFormat(AndroidCamera::ImageFormat); - static AndroidCamera::ImageFormat AndroidImageFormatFromQtPixelFormat(QVideoFrame::PixelFormat); - - void setStateHelper(QCamera::State state); - - int m_selectedCamera; - AndroidCamera *m_camera; - int m_nativeOrientation; - QAndroidVideoOutput *m_videoOutput; - - QCamera::CaptureModes m_captureMode; - QCamera::State m_state; - int m_savedState; - QCamera::Status m_status; - bool m_previewStarted; - - QCameraViewfinderSettings m_requestedViewfinderSettings; - QCameraViewfinderSettings m_actualViewfinderSettings; - - QImageEncoderSettings m_requestedImageSettings; - QImageEncoderSettings m_actualImageSettings; - QCameraImageCapture::CaptureDestinations m_captureDestination; - QCameraImageCapture::DriveMode m_captureImageDriveMode; - int m_lastImageCaptureId; - bool m_readyForCapture; - bool m_captureCanceled; - int m_currentImageCaptureId; - QString m_currentImageCaptureFileName; - - QMediaStorageLocation m_mediaStorageLocation; - - QSet<QAndroidMediaVideoProbeControl *> m_videoProbes; - QMutex m_videoProbesMutex; - PreviewCallback *m_previewCallback; - bool m_keepActive; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERASESSION_H diff --git a/src/plugins/android/src/mediacapture/qandroidcameravideorenderercontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameravideorenderercontrol.cpp deleted file mode 100644 index 2243df732..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameravideorenderercontrol.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcameravideorenderercontrol.h" - -#include "qandroidcamerasession.h" -#include "qandroidvideooutput.h" -#include "androidsurfaceview.h" -#include "qandroidmultimediautils.h" -#include <qabstractvideosurface.h> -#include <qvideosurfaceformat.h> -#include <qcoreapplication.h> -#include <qthread.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraDataVideoOutput : public QAndroidVideoOutput - , public QAndroidCameraSession::PreviewCallback -{ - Q_OBJECT -public: - explicit QAndroidCameraDataVideoOutput(QAndroidCameraVideoRendererControl *control); - ~QAndroidCameraDataVideoOutput() override; - - AndroidSurfaceHolder *surfaceHolder() override; - - bool isReady() override; - - void stop() override; - -private Q_SLOTS: - void onSurfaceCreated(); - void configureFormat(); - -private: - void onFrameAvailable(const QVideoFrame &frame); - void presentFrame(); - bool event(QEvent *); - - QAndroidCameraVideoRendererControl *m_control; - AndroidSurfaceView *m_surfaceView; - QMutex m_mutex; - QVideoFrame::PixelFormat m_pixelFormat; - QVideoFrame m_lastFrame; -}; - -QAndroidCameraDataVideoOutput::QAndroidCameraDataVideoOutput(QAndroidCameraVideoRendererControl *control) - : QAndroidVideoOutput(control) - , m_control(control) - , m_pixelFormat(QVideoFrame::Format_Invalid) -{ - // The camera preview cannot be started unless we set a SurfaceTexture or a - // SurfaceHolder. In this case we don't actually care about either of these, but since - // we need to, we setup an offscreen dummy SurfaceView in order to be able to start - // the camera preview. We'll then be able to use setPreviewCallbackWithBuffer() to - // get the raw data. - - m_surfaceView = new AndroidSurfaceView; - - connect(m_surfaceView, &AndroidSurfaceView::surfaceCreated, - this, &QAndroidCameraDataVideoOutput::onSurfaceCreated); - - m_surfaceView->setGeometry(-1, -1, 1, 1); - m_surfaceView->setVisible(true); - - connect(m_control->cameraSession(), &QAndroidCameraSession::opened, - this, &QAndroidCameraDataVideoOutput::configureFormat); - connect(m_control->surface(), &QAbstractVideoSurface::supportedFormatsChanged, - this, &QAndroidCameraDataVideoOutput::configureFormat); - configureFormat(); -} - -QAndroidCameraDataVideoOutput::~QAndroidCameraDataVideoOutput() -{ - m_control->cameraSession()->setPreviewCallback(nullptr); - delete m_surfaceView; -} - -AndroidSurfaceHolder *QAndroidCameraDataVideoOutput::surfaceHolder() -{ - return m_surfaceView->holder(); -} - -bool QAndroidCameraDataVideoOutput::isReady() -{ - return m_surfaceView->holder() && m_surfaceView->holder()->isSurfaceCreated(); -} - -void QAndroidCameraDataVideoOutput::onSurfaceCreated() -{ - emit readyChanged(true); -} - -void QAndroidCameraDataVideoOutput::configureFormat() -{ - m_pixelFormat = QVideoFrame::Format_Invalid; - - if (!m_control->cameraSession()->camera()) - return; - - QList<QVideoFrame::PixelFormat> surfaceFormats = m_control->surface()->supportedPixelFormats(); - QList<AndroidCamera::ImageFormat> previewFormats = m_control->cameraSession()->camera()->getSupportedPreviewFormats(); - for (int i = 0; i < surfaceFormats.size(); ++i) { - QVideoFrame::PixelFormat pixFormat = surfaceFormats.at(i); - AndroidCamera::ImageFormat f = qt_androidImageFormatFromPixelFormat(pixFormat); - if (previewFormats.contains(f)) { - m_pixelFormat = pixFormat; - break; - } - } - - if (m_pixelFormat == QVideoFrame::Format_Invalid) { - m_control->cameraSession()->setPreviewCallback(nullptr); - qWarning("The video surface is not compatible with any format supported by the camera"); - } else { - m_control->cameraSession()->setPreviewCallback(this); - - if (m_control->cameraSession()->status() > QCamera::LoadedStatus) - m_control->cameraSession()->camera()->stopPreview(); - - m_control->cameraSession()->setPreviewFormat(qt_androidImageFormatFromPixelFormat(m_pixelFormat)); - - if (m_control->cameraSession()->status() > QCamera::LoadedStatus) - m_control->cameraSession()->camera()->startPreview(); - } -} - -void QAndroidCameraDataVideoOutput::stop() -{ - m_mutex.lock(); - m_lastFrame = QVideoFrame(); - m_mutex.unlock(); - - if (m_control->surface() && m_control->surface()->isActive()) - m_control->surface()->stop(); -} - -void QAndroidCameraDataVideoOutput::onFrameAvailable(const QVideoFrame &frame) -{ - m_mutex.lock(); - m_lastFrame = frame; - m_mutex.unlock(); - - if (thread() == QThread::currentThread()) - presentFrame(); - else - QCoreApplication::postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); -} - -bool QAndroidCameraDataVideoOutput::event(QEvent *e) -{ - if (e->type() == QEvent::User) { - presentFrame(); - return true; - } - - return QObject::event(e); -} - -void QAndroidCameraDataVideoOutput::presentFrame() -{ - Q_ASSERT(thread() == QThread::currentThread()); - - QMutexLocker locker(&m_mutex); - - if (m_control->surface() && m_lastFrame.isValid() && m_lastFrame.pixelFormat() == m_pixelFormat) { - - if (m_control->surface()->isActive() && (m_control->surface()->surfaceFormat().pixelFormat() != m_lastFrame.pixelFormat() - || m_control->surface()->surfaceFormat().frameSize() != m_lastFrame.size())) { - m_control->surface()->stop(); - } - - if (!m_control->surface()->isActive()) { - QVideoSurfaceFormat format(m_lastFrame.size(), m_lastFrame.pixelFormat(), m_lastFrame.handleType()); - // Front camera frames are automatically mirrored when using SurfaceTexture or SurfaceView, - // but the buffers we get from the data callback are not. Tell the QAbstractVideoSurface - // that it needs to mirror the frames. - if (m_control->cameraSession()->camera()->getFacing() == AndroidCamera::CameraFacingFront) - format.setProperty("mirrored", true); - - m_control->surface()->start(format); - } - - if (m_control->surface()->isActive()) - m_control->surface()->present(m_lastFrame); - } - - m_lastFrame = QVideoFrame(); -} - - -QAndroidCameraVideoRendererControl::QAndroidCameraVideoRendererControl(QAndroidCameraSession *session, QObject *parent) - : QVideoRendererControl(parent) - , m_cameraSession(session) - , m_surface(0) - , m_textureOutput(0) - , m_dataOutput(0) -{ -} - -QAndroidCameraVideoRendererControl::~QAndroidCameraVideoRendererControl() -{ - m_cameraSession->setVideoOutput(0); -} - -QAbstractVideoSurface *QAndroidCameraVideoRendererControl::surface() const -{ - return m_surface; -} - -void QAndroidCameraVideoRendererControl::setSurface(QAbstractVideoSurface *surface) -{ - if (m_surface == surface) - return; - - m_surface = surface; - QAndroidVideoOutput *oldOutput = m_textureOutput ? static_cast<QAndroidVideoOutput*>(m_textureOutput) - : static_cast<QAndroidVideoOutput*>(m_dataOutput); - QAndroidVideoOutput *newOutput = 0; - - if (m_surface) { - if (!m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty()) { - if (!m_textureOutput) { - m_dataOutput = 0; - newOutput = m_textureOutput = new QAndroidTextureVideoOutput(this); - } - } else if (!m_dataOutput) { - m_textureOutput = 0; - newOutput = m_dataOutput = new QAndroidCameraDataVideoOutput(this); - } - - if (m_textureOutput) - m_textureOutput->setSurface(m_surface); - } - - if (newOutput != oldOutput) { - m_cameraSession->setVideoOutput(newOutput); - delete oldOutput; - } -} - -QT_END_NAMESPACE - -#include "qandroidcameravideorenderercontrol.moc" - diff --git a/src/plugins/android/src/mediacapture/qandroidcameravideorenderercontrol.h b/src/plugins/android/src/mediacapture/qandroidcameravideorenderercontrol.h deleted file mode 100644 index 538226239..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcameravideorenderercontrol.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAVIDEORENDERERCONTROL_H -#define QANDROIDCAMERAVIDEORENDERERCONTROL_H - -#include <qvideorenderercontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; -class QAndroidTextureVideoOutput; -class QAndroidCameraDataVideoOutput; - -class QAndroidCameraVideoRendererControl : public QVideoRendererControl -{ - Q_OBJECT -public: - QAndroidCameraVideoRendererControl(QAndroidCameraSession *session, QObject *parent = 0); - ~QAndroidCameraVideoRendererControl() override; - - QAbstractVideoSurface *surface() const override; - void setSurface(QAbstractVideoSurface *surface) override; - - QAndroidCameraSession *cameraSession() const { return m_cameraSession; } - -private: - QAndroidCameraSession *m_cameraSession; - QAbstractVideoSurface *m_surface; - QAndroidTextureVideoOutput *m_textureOutput; - QAndroidCameraDataVideoOutput *m_dataOutput; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAVIDEORENDERERCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.cpp deleted file mode 100644 index 6f94bdfe7..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcamerazoomcontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" -#include "qandroidmultimediautils.h" -#include <qmath.h> - -QT_BEGIN_NAMESPACE - -QAndroidCameraZoomControl::QAndroidCameraZoomControl(QAndroidCameraSession *session) - : QCameraZoomControl() - , m_cameraSession(session) - , m_maximumZoom(1.0) - , m_requestedZoom(1.0) - , m_currentZoom(1.0) -{ - connect(m_cameraSession, SIGNAL(opened()), - this, SLOT(onCameraOpened())); -} - -qreal QAndroidCameraZoomControl::maximumOpticalZoom() const -{ - // Optical zoom not supported - return 1.0; -} - -qreal QAndroidCameraZoomControl::maximumDigitalZoom() const -{ - return m_maximumZoom; -} - -qreal QAndroidCameraZoomControl::requestedOpticalZoom() const -{ - // Optical zoom not supported - return 1.0; -} - -qreal QAndroidCameraZoomControl::requestedDigitalZoom() const -{ - return m_requestedZoom; -} - -qreal QAndroidCameraZoomControl::currentOpticalZoom() const -{ - // Optical zoom not supported - return 1.0; -} - -qreal QAndroidCameraZoomControl::currentDigitalZoom() const -{ - return m_currentZoom; -} - -void QAndroidCameraZoomControl::zoomTo(qreal optical, qreal digital) -{ - Q_UNUSED(optical); - - if (!qFuzzyCompare(m_requestedZoom, digital)) { - m_requestedZoom = digital; - emit requestedDigitalZoomChanged(m_requestedZoom); - } - - if (m_cameraSession->camera()) { - digital = qBound(qreal(1), digital, m_maximumZoom); - int validZoomIndex = qt_findClosestValue(m_zoomRatios, qRound(digital * 100)); - qreal newZoom = m_zoomRatios.at(validZoomIndex) / qreal(100); - if (!qFuzzyCompare(m_currentZoom, newZoom)) { - m_cameraSession->camera()->setZoom(validZoomIndex); - m_currentZoom = newZoom; - emit currentDigitalZoomChanged(m_currentZoom); - } - } -} - -void QAndroidCameraZoomControl::onCameraOpened() -{ - if (m_cameraSession->camera()->isZoomSupported()) { - m_zoomRatios = m_cameraSession->camera()->getZoomRatios(); - qreal maxZoom = m_zoomRatios.last() / qreal(100); - if (m_maximumZoom != maxZoom) { - m_maximumZoom = maxZoom; - emit maximumDigitalZoomChanged(m_maximumZoom); - } - zoomTo(1, m_requestedZoom); - } else { - m_zoomRatios.clear(); - if (!qFuzzyCompare(m_maximumZoom, qreal(1))) { - m_maximumZoom = 1.0; - emit maximumDigitalZoomChanged(m_maximumZoom); - } - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.h b/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.h deleted file mode 100644 index 96fc4f77b..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcamerazoomcontrol.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAMERAZOOMCONTROL_H -#define QANDROIDCAMERAZOOMCONTROL_H - -#include <qcamerazoomcontrol.h> -#include <qcamera.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCameraZoomControl : public QCameraZoomControl -{ - Q_OBJECT -public: - explicit QAndroidCameraZoomControl(QAndroidCameraSession *session); - - qreal maximumOpticalZoom() const override; - qreal maximumDigitalZoom() const override; - qreal requestedOpticalZoom() const override; - qreal requestedDigitalZoom() const override; - qreal currentOpticalZoom() const override; - qreal currentDigitalZoom() const override; - void zoomTo(qreal optical, qreal digital) override; - -private Q_SLOTS: - void onCameraOpened(); - -private: - QAndroidCameraSession *m_cameraSession; - - qreal m_maximumZoom; - QList<int> m_zoomRatios; - qreal m_requestedZoom; - qreal m_currentZoom; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAMERAZOOMCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp b/src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp deleted file mode 100644 index 65df54c3f..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Ruslan Baratov -** 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$ -** -****************************************************************************/ - -#include "qandroidcaptureservice.h" - -#include "qandroidmediarecordercontrol.h" -#include "qandroidcapturesession.h" -#include "qandroidcameracontrol.h" -#include "qandroidcamerainfocontrol.h" -#include "qandroidvideodeviceselectorcontrol.h" -#include "qandroidaudioinputselectorcontrol.h" -#include "qandroidcamerasession.h" -#include "qandroidcameravideorenderercontrol.h" -#include "qandroidcamerazoomcontrol.h" -#include "qandroidcameraexposurecontrol.h" -#include "qandroidcameraflashcontrol.h" -#include "qandroidcamerafocuscontrol.h" -#include "qandroidviewfindersettingscontrol.h" -#include "qandroidcameralockscontrol.h" -#include "qandroidcameraimageprocessingcontrol.h" -#include "qandroidimageencodercontrol.h" -#include "qandroidcameraimagecapturecontrol.h" -#include "qandroidcameracapturedestinationcontrol.h" -#include "qandroidcameracapturebufferformatcontrol.h" -#include "qandroidaudioencodersettingscontrol.h" -#include "qandroidvideoencodersettingscontrol.h" -#include "qandroidmediacontainercontrol.h" -#include "qandroidmediavideoprobecontrol.h" - -#include <qmediaserviceproviderplugin.h> - -QT_BEGIN_NAMESPACE - -QAndroidCaptureService::QAndroidCaptureService(const QString &service, QObject *parent) - : QMediaService(parent) - , m_service(service) - , m_videoRendererControl(0) -{ - if (m_service == QLatin1String(Q_MEDIASERVICE_CAMERA)) { - m_cameraSession = new QAndroidCameraSession; - m_cameraControl = new QAndroidCameraControl(m_cameraSession); - m_cameraInfoControl = new QAndroidCameraInfoControl; - m_videoInputControl = new QAndroidVideoDeviceSelectorControl(m_cameraSession); - m_cameraZoomControl = new QAndroidCameraZoomControl(m_cameraSession); - m_cameraExposureControl = new QAndroidCameraExposureControl(m_cameraSession); - m_cameraFlashControl = new QAndroidCameraFlashControl(m_cameraSession); - m_cameraFocusControl = new QAndroidCameraFocusControl(m_cameraSession); - m_viewfinderSettingsControl2 = new QAndroidViewfinderSettingsControl2(m_cameraSession); - m_cameraLocksControl = new QAndroidCameraLocksControl(m_cameraSession); - m_cameraImageProcessingControl = new QAndroidCameraImageProcessingControl(m_cameraSession); - m_imageEncoderControl = new QAndroidImageEncoderControl(m_cameraSession); - m_imageCaptureControl = new QAndroidCameraImageCaptureControl(m_cameraSession); - m_captureDestinationControl = new QAndroidCameraCaptureDestinationControl(m_cameraSession); - m_captureBufferFormatControl = new QAndroidCameraCaptureBufferFormatControl; - m_audioInputControl = 0; - } else { - m_cameraSession = 0; - m_cameraControl = 0; - m_cameraInfoControl = 0; - m_videoInputControl = 0; - m_cameraZoomControl = 0; - m_cameraExposureControl = 0; - m_cameraFlashControl = 0; - m_cameraFocusControl = 0; - m_viewfinderSettingsControl2 = 0; - m_cameraLocksControl = 0; - m_cameraImageProcessingControl = 0; - m_imageEncoderControl = 0; - m_imageCaptureControl = 0; - m_captureDestinationControl = 0; - m_captureBufferFormatControl = 0; - m_videoEncoderSettingsControl = 0; - } - - m_captureSession = new QAndroidCaptureSession(m_cameraSession); - m_recorderControl = new QAndroidMediaRecorderControl(m_captureSession); - m_audioEncoderSettingsControl = new QAndroidAudioEncoderSettingsControl(m_captureSession); - m_mediaContainerControl = new QAndroidMediaContainerControl(m_captureSession); - - if (m_service == QLatin1String(Q_MEDIASERVICE_CAMERA)) { - m_videoEncoderSettingsControl = new QAndroidVideoEncoderSettingsControl(m_captureSession); - } else { - m_audioInputControl = new QAndroidAudioInputSelectorControl(m_captureSession); - m_captureSession->setAudioInput(m_audioInputControl->defaultInput()); - } -} - -QAndroidCaptureService::~QAndroidCaptureService() -{ - delete m_audioEncoderSettingsControl; - delete m_videoEncoderSettingsControl; - delete m_mediaContainerControl; - delete m_recorderControl; - delete m_captureSession; - delete m_cameraControl; - delete m_cameraInfoControl; - delete m_audioInputControl; - delete m_videoInputControl; - delete m_videoRendererControl; - delete m_cameraZoomControl; - delete m_cameraExposureControl; - delete m_cameraFlashControl; - delete m_cameraFocusControl; - delete m_viewfinderSettingsControl2; - delete m_cameraLocksControl; - delete m_cameraImageProcessingControl; - delete m_imageEncoderControl; - delete m_imageCaptureControl; - delete m_captureDestinationControl; - delete m_captureBufferFormatControl; - delete m_cameraSession; -} - -QMediaControl *QAndroidCaptureService::requestControl(const char *name) -{ - if (qstrcmp(name, QMediaRecorderControl_iid) == 0) - return m_recorderControl; - - if (qstrcmp(name, QMediaContainerControl_iid) == 0) - return m_mediaContainerControl; - - if (qstrcmp(name, QAudioEncoderSettingsControl_iid) == 0) - return m_audioEncoderSettingsControl; - - if (qstrcmp(name, QVideoEncoderSettingsControl_iid) == 0) - return m_videoEncoderSettingsControl; - - if (qstrcmp(name, QCameraControl_iid) == 0) - return m_cameraControl; - - if (qstrcmp(name, QCameraInfoControl_iid) == 0) - return m_cameraInfoControl; - - if (qstrcmp(name, QAudioInputSelectorControl_iid) == 0) - return m_audioInputControl; - - if (qstrcmp(name, QVideoDeviceSelectorControl_iid) == 0) - return m_videoInputControl; - - if (qstrcmp(name, QCameraZoomControl_iid) == 0) - return m_cameraZoomControl; - - if (qstrcmp(name, QCameraExposureControl_iid) == 0) - return m_cameraExposureControl; - - if (qstrcmp(name, QCameraFlashControl_iid) == 0) - return m_cameraFlashControl; - - if (qstrcmp(name, QCameraFocusControl_iid) == 0) - return m_cameraFocusControl; - - if (qstrcmp(name, QCameraViewfinderSettingsControl2_iid) == 0) - return m_viewfinderSettingsControl2; - - if (qstrcmp(name, QCameraLocksControl_iid) == 0) - return m_cameraLocksControl; - - if (qstrcmp(name, QCameraImageProcessingControl_iid) == 0) - return m_cameraImageProcessingControl; - - if (qstrcmp(name, QImageEncoderControl_iid) == 0) - return m_imageEncoderControl; - - if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0) - return m_imageCaptureControl; - - if (qstrcmp(name, QCameraCaptureDestinationControl_iid) == 0) - return m_captureDestinationControl; - - if (qstrcmp(name, QCameraCaptureBufferFormatControl_iid) == 0) - return m_captureBufferFormatControl; - - if (qstrcmp(name, QVideoRendererControl_iid) == 0 - && m_service == QLatin1String(Q_MEDIASERVICE_CAMERA) - && !m_videoRendererControl) { - m_videoRendererControl = new QAndroidCameraVideoRendererControl(m_cameraSession); - return m_videoRendererControl; - } - - if (qstrcmp(name,QMediaVideoProbeControl_iid) == 0) { - QAndroidMediaVideoProbeControl *videoProbe = 0; - if (m_cameraSession) { - videoProbe = new QAndroidMediaVideoProbeControl(this); - m_cameraSession->addProbe(videoProbe); - } - return videoProbe; - } - - return 0; -} - -void QAndroidCaptureService::releaseControl(QMediaControl *control) -{ - if (control) { - if (control == m_videoRendererControl) { - delete m_videoRendererControl; - m_videoRendererControl = 0; - return; - } - - QAndroidMediaVideoProbeControl *videoProbe = qobject_cast<QAndroidMediaVideoProbeControl *>(control); - if (videoProbe) { - if (m_cameraSession) - m_cameraSession->removeProbe(videoProbe); - delete videoProbe; - return; - } - } - -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcaptureservice.h b/src/plugins/android/src/mediacapture/qandroidcaptureservice.h deleted file mode 100644 index 85816fdd6..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcaptureservice.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Ruslan Baratov -** 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 QANDROIDCAPTURESERVICE_H -#define QANDROIDCAPTURESERVICE_H - -#include <qmediaservice.h> -#include <qmediacontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidMediaRecorderControl; -class QAndroidCaptureSession; -class QAndroidCameraControl; -class QAndroidCameraInfoControl; -class QAndroidVideoDeviceSelectorControl; -class QAndroidAudioInputSelectorControl; -class QAndroidCameraSession; -class QAndroidCameraVideoRendererControl; -class QAndroidCameraZoomControl; -class QAndroidCameraExposureControl; -class QAndroidCameraFlashControl; -class QAndroidCameraFocusControl; -class QAndroidViewfinderSettingsControl2; -class QAndroidCameraLocksControl; -class QAndroidCameraImageProcessingControl; -class QAndroidImageEncoderControl; -class QAndroidCameraImageCaptureControl; -class QAndroidCameraCaptureDestinationControl; -class QAndroidCameraCaptureBufferFormatControl; -class QAndroidAudioEncoderSettingsControl; -class QAndroidVideoEncoderSettingsControl; -class QAndroidMediaContainerControl; - -class QAndroidCaptureService : public QMediaService -{ - Q_OBJECT - -public: - explicit QAndroidCaptureService(const QString &service, QObject *parent = 0); - virtual ~QAndroidCaptureService(); - - QMediaControl *requestControl(const char *name); - void releaseControl(QMediaControl *); - -private: - QString m_service; - - QAndroidMediaRecorderControl *m_recorderControl; - QAndroidCaptureSession *m_captureSession; - QAndroidCameraControl *m_cameraControl; - QAndroidCameraInfoControl *m_cameraInfoControl; - QAndroidVideoDeviceSelectorControl *m_videoInputControl; - QAndroidAudioInputSelectorControl *m_audioInputControl; - QAndroidCameraSession *m_cameraSession; - QAndroidCameraVideoRendererControl *m_videoRendererControl; - QAndroidCameraZoomControl *m_cameraZoomControl; - QAndroidCameraExposureControl *m_cameraExposureControl; - QAndroidCameraFlashControl *m_cameraFlashControl; - QAndroidCameraFocusControl *m_cameraFocusControl; - QAndroidViewfinderSettingsControl2 *m_viewfinderSettingsControl2; - QAndroidCameraLocksControl *m_cameraLocksControl; - QAndroidCameraImageProcessingControl *m_cameraImageProcessingControl; - QAndroidImageEncoderControl *m_imageEncoderControl; - QAndroidCameraImageCaptureControl *m_imageCaptureControl; - QAndroidCameraCaptureDestinationControl *m_captureDestinationControl; - QAndroidCameraCaptureBufferFormatControl *m_captureBufferFormatControl; - QAndroidAudioEncoderSettingsControl *m_audioEncoderSettingsControl; - QAndroidVideoEncoderSettingsControl *m_videoEncoderSettingsControl; - QAndroidMediaContainerControl *m_mediaContainerControl; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAPTURESERVICE_H diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp deleted file mode 100644 index 768bb4442..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp +++ /dev/null @@ -1,594 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidcapturesession.h" - -#include "androidcamera.h" -#include "qandroidcamerasession.h" -#include "androidmultimediautils.h" -#include "qandroidmultimediautils.h" -#include "qandroidvideooutput.h" -#include "qandroidglobal.h" - -#include <algorithm> - -QT_BEGIN_NAMESPACE - -QAndroidCaptureSession::QAndroidCaptureSession(QAndroidCameraSession *cameraSession) - : QObject() - , m_mediaRecorder(0) - , m_cameraSession(cameraSession) - , m_audioSource(AndroidMediaRecorder::DefaultAudioSource) - , m_duration(0) - , m_state(QMediaRecorder::StoppedState) - , m_status(QMediaRecorder::UnloadedStatus) - , m_containerFormatDirty(true) - , m_videoSettingsDirty(true) - , m_audioSettingsDirty(true) - , m_outputFormat(AndroidMediaRecorder::DefaultOutputFormat) - , m_audioEncoder(AndroidMediaRecorder::DefaultAudioEncoder) - , m_videoEncoder(AndroidMediaRecorder::DefaultVideoEncoder) -{ - m_mediaStorageLocation.addStorageLocation( - QMediaStorageLocation::Movies, - AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM)); - - m_mediaStorageLocation.addStorageLocation( - QMediaStorageLocation::Sounds, - AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::Sounds)); - - if (cameraSession) { - connect(cameraSession, SIGNAL(opened()), this, SLOT(onCameraOpened())); - connect(cameraSession, &QAndroidCameraSession::statusChanged, this, - [this](QCamera::Status status) { - if (status == QCamera::UnavailableStatus) { - setState(QMediaRecorder::StoppedState); - setStatus(QMediaRecorder::UnavailableStatus); - return; - } - - // Stop recording when stopping the camera. - if (status == QCamera::StoppingStatus) { - setState(QMediaRecorder::StoppedState); - setStatus(QMediaRecorder::UnloadedStatus); - return; - } - - if (status == QCamera::LoadingStatus) - setStatus(QMediaRecorder::LoadingStatus); - }); - connect(cameraSession, &QAndroidCameraSession::captureModeChanged, this, - [this](QCamera::CaptureModes mode) { - if (!mode.testFlag(QCamera::CaptureVideo)) { - setState(QMediaRecorder::StoppedState); - setStatus(QMediaRecorder::UnloadedStatus); - } - }); - connect(cameraSession, &QAndroidCameraSession::readyForCaptureChanged, this, - [this](bool ready) { - if (ready) - setStatus(QMediaRecorder::LoadedStatus); - }); - } else { - // Audio-only recording. - setStatus(QMediaRecorder::LoadedStatus); - } - - m_notifyTimer.setInterval(1000); - connect(&m_notifyTimer, SIGNAL(timeout()), this, SLOT(updateDuration())); -} - -QAndroidCaptureSession::~QAndroidCaptureSession() -{ - stop(); - delete m_mediaRecorder; -} - -void QAndroidCaptureSession::setAudioInput(const QString &input) -{ - if (m_audioInput == input) - return; - - m_audioInput = input; - - if (m_audioInput == QLatin1String("default")) - m_audioSource = AndroidMediaRecorder::DefaultAudioSource; - else if (m_audioInput == QLatin1String("mic")) - m_audioSource = AndroidMediaRecorder::Mic; - else if (m_audioInput == QLatin1String("voice_uplink")) - m_audioSource = AndroidMediaRecorder::VoiceUplink; - else if (m_audioInput == QLatin1String("voice_downlink")) - m_audioSource = AndroidMediaRecorder::VoiceDownlink; - else if (m_audioInput == QLatin1String("voice_call")) - m_audioSource = AndroidMediaRecorder::VoiceCall; - else if (m_audioInput == QLatin1String("voice_recognition")) - m_audioSource = AndroidMediaRecorder::VoiceRecognition; - else - m_audioSource = AndroidMediaRecorder::DefaultAudioSource; - - emit audioInputChanged(m_audioInput); -} - -QUrl QAndroidCaptureSession::outputLocation() const -{ - return m_actualOutputLocation; -} - -bool QAndroidCaptureSession::setOutputLocation(const QUrl &location) -{ - if (m_requestedOutputLocation == location) - return false; - - m_actualOutputLocation = QUrl(); - m_requestedOutputLocation = location; - - if (m_requestedOutputLocation.isEmpty()) - return true; - - if (m_requestedOutputLocation.isValid() - && (m_requestedOutputLocation.isLocalFile() || m_requestedOutputLocation.isRelative())) { - return true; - } - - m_requestedOutputLocation = QUrl(); - return false; -} - -QMediaRecorder::State QAndroidCaptureSession::state() const -{ - return m_state; -} - -void QAndroidCaptureSession::setState(QMediaRecorder::State state) -{ - if (m_state == state) - return; - - switch (state) { - case QMediaRecorder::StoppedState: - stop(); - break; - case QMediaRecorder::RecordingState: - start(); - break; - case QMediaRecorder::PausedState: - // Not supported by Android API - qWarning("QMediaRecorder::PausedState is not supported on Android"); - break; - } -} - -void QAndroidCaptureSession::start() -{ - if (m_state == QMediaRecorder::RecordingState || m_status != QMediaRecorder::LoadedStatus) - return; - - setStatus(QMediaRecorder::StartingStatus); - - if (m_mediaRecorder) { - m_mediaRecorder->release(); - delete m_mediaRecorder; - } - - const bool granted = m_cameraSession - ? m_cameraSession->requestRecordingPermission() - : qt_androidRequestRecordingPermission(); - if (!granted) { - setStatus(QMediaRecorder::UnavailableStatus); - Q_EMIT error(QMediaRecorder::ResourceError, QLatin1String("Permission denied.")); - return; - } - - m_mediaRecorder = new AndroidMediaRecorder; - connect(m_mediaRecorder, SIGNAL(error(int,int)), this, SLOT(onError(int,int))); - connect(m_mediaRecorder, SIGNAL(info(int,int)), this, SLOT(onInfo(int,int))); - - // Set audio/video sources - if (m_cameraSession) { - updateViewfinder(); - m_cameraSession->camera()->unlock(); - m_mediaRecorder->setCamera(m_cameraSession->camera()); - m_mediaRecorder->setAudioSource(AndroidMediaRecorder::Camcorder); - m_mediaRecorder->setVideoSource(AndroidMediaRecorder::Camera); - } else { - m_mediaRecorder->setAudioSource(m_audioSource); - } - - // Set output format - m_mediaRecorder->setOutputFormat(m_outputFormat); - - // Set audio encoder settings - m_mediaRecorder->setAudioChannels(m_audioSettings.channelCount()); - m_mediaRecorder->setAudioEncodingBitRate(m_audioSettings.bitRate()); - m_mediaRecorder->setAudioSamplingRate(m_audioSettings.sampleRate()); - m_mediaRecorder->setAudioEncoder(m_audioEncoder); - - // Set video encoder settings - if (m_cameraSession) { - m_mediaRecorder->setVideoSize(m_videoSettings.resolution()); - m_mediaRecorder->setVideoFrameRate(qRound(m_videoSettings.frameRate())); - m_mediaRecorder->setVideoEncodingBitRate(m_videoSettings.bitRate()); - m_mediaRecorder->setVideoEncoder(m_videoEncoder); - - m_mediaRecorder->setOrientationHint(m_cameraSession->currentCameraRotation()); - } - - // Set output file - QString filePath = m_mediaStorageLocation.generateFileName( - m_requestedOutputLocation.isLocalFile() ? m_requestedOutputLocation.toLocalFile() - : m_requestedOutputLocation.toString(), - m_cameraSession ? QMediaStorageLocation::Movies - : QMediaStorageLocation::Sounds, - m_cameraSession ? QLatin1String("VID_") - : QLatin1String("REC_"), - m_containerFormat); - - m_usedOutputLocation = QUrl::fromLocalFile(filePath); - m_mediaRecorder->setOutputFile(filePath); - - // Even though the Android doc explicitly says that calling MediaRecorder.setPreviewDisplay() - // is not necessary when the Camera already has a Surface, it doesn't actually work on some - // devices. For example on the Samsung Galaxy Tab 2, the camera server dies after prepare() - // and start() if MediaRecorder.setPreviewDispaly() is not called. - if (m_cameraSession) { - // When using a SurfaceTexture, we need to pass a new one to the MediaRecorder, not the same - // one that is set on the Camera or it will crash, hence the reset(). - m_cameraSession->videoOutput()->reset(); - if (m_cameraSession->videoOutput()->surfaceTexture()) - m_mediaRecorder->setSurfaceTexture(m_cameraSession->videoOutput()->surfaceTexture()); - else if (m_cameraSession->videoOutput()->surfaceHolder()) - m_mediaRecorder->setSurfaceHolder(m_cameraSession->videoOutput()->surfaceHolder()); - } - - if (!m_mediaRecorder->prepare()) { - emit error(QMediaRecorder::FormatError, QLatin1String("Unable to prepare the media recorder.")); - if (m_cameraSession) - restartViewfinder(); - return; - } - - if (!m_mediaRecorder->start()) { - emit error(QMediaRecorder::FormatError, QLatin1String("Unable to start the media recorder.")); - if (m_cameraSession) - restartViewfinder(); - return; - } - - m_elapsedTime.start(); - m_notifyTimer.start(); - updateDuration(); - - if (m_cameraSession) { - m_cameraSession->setReadyForCapture(false); - - // Preview frame callback is cleared when setting up the camera with the media recorder. - // We need to reset it. - m_cameraSession->camera()->setupPreviewFrameCallback(); - } - - m_state = QMediaRecorder::RecordingState; - emit stateChanged(m_state); - setStatus(QMediaRecorder::RecordingStatus); -} - -void QAndroidCaptureSession::stop(bool error) -{ - if (m_state == QMediaRecorder::StoppedState || m_mediaRecorder == 0) - return; - - setStatus(QMediaRecorder::FinalizingStatus); - - m_mediaRecorder->stop(); - m_notifyTimer.stop(); - updateDuration(); - m_elapsedTime.invalidate(); - m_mediaRecorder->release(); - delete m_mediaRecorder; - m_mediaRecorder = 0; - - if (m_cameraSession && m_cameraSession->status() == QCamera::ActiveStatus) { - // Viewport needs to be restarted after recording - restartViewfinder(); - } - - if (!error) { - // if the media is saved into the standard media location, register it - // with the Android media scanner so it appears immediately in apps - // such as the gallery. - QString mediaPath = m_usedOutputLocation.toLocalFile(); - QString standardLoc = m_cameraSession ? AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM) - : AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::Sounds); - if (mediaPath.startsWith(standardLoc)) - AndroidMultimediaUtils::registerMediaFile(mediaPath); - - m_actualOutputLocation = m_usedOutputLocation; - emit actualLocationChanged(m_actualOutputLocation); - } - - m_state = QMediaRecorder::StoppedState; - emit stateChanged(m_state); - if (!m_cameraSession) - setStatus(QMediaRecorder::LoadedStatus); -} - -void QAndroidCaptureSession::setStatus(QMediaRecorder::Status status) -{ - if (m_status == status) - return; - - m_status = status; - emit statusChanged(m_status); -} - -QMediaRecorder::Status QAndroidCaptureSession::status() const -{ - return m_status; -} - -qint64 QAndroidCaptureSession::duration() const -{ - return m_duration; -} - -void QAndroidCaptureSession::setContainerFormat(const QString &format) -{ - if (m_containerFormat == format) - return; - - m_containerFormat = format; - m_containerFormatDirty = true; -} - -void QAndroidCaptureSession::setAudioSettings(const QAudioEncoderSettings &settings) -{ - if (m_audioSettings == settings) - return; - - m_audioSettings = settings; - m_audioSettingsDirty = true; -} - -void QAndroidCaptureSession::setVideoSettings(const QVideoEncoderSettings &settings) -{ - if (!m_cameraSession || m_videoSettings == settings) - return; - - m_videoSettings = settings; - m_videoSettingsDirty = true; -} - -void QAndroidCaptureSession::applySettings() -{ - // container settings - if (m_containerFormatDirty) { - if (m_containerFormat.isEmpty()) { - m_containerFormat = m_defaultSettings.outputFileExtension; - m_outputFormat = m_defaultSettings.outputFormat; - } else if (m_containerFormat == QLatin1String("3gp")) { - m_outputFormat = AndroidMediaRecorder::THREE_GPP; - } else if (!m_cameraSession && m_containerFormat == QLatin1String("amr")) { - m_outputFormat = AndroidMediaRecorder::AMR_NB_Format; - } else if (!m_cameraSession && m_containerFormat == QLatin1String("awb")) { - m_outputFormat = AndroidMediaRecorder::AMR_WB_Format; - } else { - m_containerFormat = QStringLiteral("mp4"); - m_outputFormat = AndroidMediaRecorder::MPEG_4; - } - - m_containerFormatDirty = false; - } - - // audio settings - if (m_audioSettingsDirty) { - if (m_audioSettings.channelCount() <= 0) - m_audioSettings.setChannelCount(m_defaultSettings.audioChannels); - if (m_audioSettings.bitRate() <= 0) - m_audioSettings.setBitRate(m_defaultSettings.audioBitRate); - if (m_audioSettings.sampleRate() <= 0) - m_audioSettings.setSampleRate(m_defaultSettings.audioSampleRate); - - if (m_audioSettings.codec().isEmpty()) - m_audioEncoder = m_defaultSettings.audioEncoder; - else if (m_audioSettings.codec() == QLatin1String("aac")) - m_audioEncoder = AndroidMediaRecorder::AAC; - else if (m_audioSettings.codec() == QLatin1String("amr-nb")) - m_audioEncoder = AndroidMediaRecorder::AMR_NB_Encoder; - else if (m_audioSettings.codec() == QLatin1String("amr-wb")) - m_audioEncoder = AndroidMediaRecorder::AMR_WB_Encoder; - else - m_audioEncoder = m_defaultSettings.audioEncoder; - - m_audioSettingsDirty = false; - } - - // video settings - if (m_cameraSession && m_cameraSession->camera() && m_videoSettingsDirty) { - if (m_videoSettings.resolution().isEmpty()) { - m_videoSettings.setResolution(m_defaultSettings.videoResolution); - } else if (!m_supportedResolutions.contains(m_videoSettings.resolution())) { - // if the requested resolution is not supported, find the closest one - QSize reqSize = m_videoSettings.resolution(); - int reqPixelCount = reqSize.width() * reqSize.height(); - QList<int> supportedPixelCounts; - for (int i = 0; i < m_supportedResolutions.size(); ++i) { - const QSize &s = m_supportedResolutions.at(i); - supportedPixelCounts.append(s.width() * s.height()); - } - int closestIndex = qt_findClosestValue(supportedPixelCounts, reqPixelCount); - m_videoSettings.setResolution(m_supportedResolutions.at(closestIndex)); - } - - if (m_videoSettings.frameRate() <= 0) - m_videoSettings.setFrameRate(m_defaultSettings.videoFrameRate); - if (m_videoSettings.bitRate() <= 0) - m_videoSettings.setBitRate(m_defaultSettings.videoBitRate); - - if (m_videoSettings.codec().isEmpty()) - m_videoEncoder = m_defaultSettings.videoEncoder; - else if (m_videoSettings.codec() == QLatin1String("h263")) - m_videoEncoder = AndroidMediaRecorder::H263; - else if (m_videoSettings.codec() == QLatin1String("h264")) - m_videoEncoder = AndroidMediaRecorder::H264; - else if (m_videoSettings.codec() == QLatin1String("mpeg4_sp")) - m_videoEncoder = AndroidMediaRecorder::MPEG_4_SP; - else - m_videoEncoder = m_defaultSettings.videoEncoder; - - m_videoSettingsDirty = false; - } -} - -void QAndroidCaptureSession::updateViewfinder() -{ - m_cameraSession->camera()->stopPreviewSynchronous(); - m_cameraSession->applyViewfinderSettings(m_videoSettings.resolution(), false); -} - -void QAndroidCaptureSession::restartViewfinder() -{ - if (!m_cameraSession) - return; - - m_cameraSession->camera()->reconnect(); - - // This is not necessary on most devices, but it crashes on some if we don't stop the - // preview and reset the preview display on the camera when recording is over. - m_cameraSession->camera()->stopPreviewSynchronous(); - m_cameraSession->videoOutput()->reset(); - if (m_cameraSession->videoOutput()->surfaceTexture()) - m_cameraSession->camera()->setPreviewTexture(m_cameraSession->videoOutput()->surfaceTexture()); - else if (m_cameraSession->videoOutput()->surfaceHolder()) - m_cameraSession->camera()->setPreviewDisplay(m_cameraSession->videoOutput()->surfaceHolder()); - - m_cameraSession->camera()->startPreview(); - m_cameraSession->setReadyForCapture(true); -} - -void QAndroidCaptureSession::updateDuration() -{ - if (m_elapsedTime.isValid()) - m_duration = m_elapsedTime.elapsed(); - - emit durationChanged(m_duration); -} - -void QAndroidCaptureSession::onCameraOpened() -{ - m_supportedResolutions.clear(); - m_supportedFramerates.clear(); - - // get supported resolutions from predefined profiles - for (int i = 0; i < 8; ++i) { - CaptureProfile profile = getProfile(i); - if (!profile.isNull) { - if (i == AndroidCamcorderProfile::QUALITY_HIGH) - m_defaultSettings = profile; - - if (!m_supportedResolutions.contains(profile.videoResolution)) - m_supportedResolutions.append(profile.videoResolution); - if (!m_supportedFramerates.contains(profile.videoFrameRate)) - m_supportedFramerates.append(profile.videoFrameRate); - } - } - - std::sort(m_supportedResolutions.begin(), m_supportedResolutions.end(), qt_sizeLessThan); - std::sort(m_supportedFramerates.begin(), m_supportedFramerates.end()); - - applySettings(); -} - -QAndroidCaptureSession::CaptureProfile QAndroidCaptureSession::getProfile(int id) -{ - CaptureProfile profile; - const bool hasProfile = AndroidCamcorderProfile::hasProfile(m_cameraSession->camera()->cameraId(), - AndroidCamcorderProfile::Quality(id)); - - if (hasProfile) { - AndroidCamcorderProfile camProfile = AndroidCamcorderProfile::get(m_cameraSession->camera()->cameraId(), - AndroidCamcorderProfile::Quality(id)); - - profile.outputFormat = AndroidMediaRecorder::OutputFormat(camProfile.getValue(AndroidCamcorderProfile::fileFormat)); - profile.audioEncoder = AndroidMediaRecorder::AudioEncoder(camProfile.getValue(AndroidCamcorderProfile::audioCodec)); - profile.audioBitRate = camProfile.getValue(AndroidCamcorderProfile::audioBitRate); - profile.audioChannels = camProfile.getValue(AndroidCamcorderProfile::audioChannels); - profile.audioSampleRate = camProfile.getValue(AndroidCamcorderProfile::audioSampleRate); - profile.videoEncoder = AndroidMediaRecorder::VideoEncoder(camProfile.getValue(AndroidCamcorderProfile::videoCodec)); - profile.videoBitRate = camProfile.getValue(AndroidCamcorderProfile::videoBitRate); - profile.videoFrameRate = camProfile.getValue(AndroidCamcorderProfile::videoFrameRate); - profile.videoResolution = QSize(camProfile.getValue(AndroidCamcorderProfile::videoFrameWidth), - camProfile.getValue(AndroidCamcorderProfile::videoFrameHeight)); - - if (profile.outputFormat == AndroidMediaRecorder::MPEG_4) - profile.outputFileExtension = QStringLiteral("mp4"); - else if (profile.outputFormat == AndroidMediaRecorder::THREE_GPP) - profile.outputFileExtension = QStringLiteral("3gp"); - else if (profile.outputFormat == AndroidMediaRecorder::AMR_NB_Format) - profile.outputFileExtension = QStringLiteral("amr"); - else if (profile.outputFormat == AndroidMediaRecorder::AMR_WB_Format) - profile.outputFileExtension = QStringLiteral("awb"); - - profile.isNull = false; - } - - return profile; -} - -void QAndroidCaptureSession::onError(int what, int extra) -{ - Q_UNUSED(what); - Q_UNUSED(extra); - stop(true); - emit error(QMediaRecorder::ResourceError, QLatin1String("Unknown error.")); -} - -void QAndroidCaptureSession::onInfo(int what, int extra) -{ - Q_UNUSED(extra); - if (what == 800) { - // MEDIA_RECORDER_INFO_MAX_DURATION_REACHED - setState(QMediaRecorder::StoppedState); - emit error(QMediaRecorder::OutOfSpaceError, QLatin1String("Maximum duration reached.")); - } else if (what == 801) { - // MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED - setState(QMediaRecorder::StoppedState); - emit error(QMediaRecorder::OutOfSpaceError, QLatin1String("Maximum file size reached.")); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.h b/src/plugins/android/src/mediacapture/qandroidcapturesession.h deleted file mode 100644 index 8cfb9ad2a..000000000 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.h +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDCAPTURESESSION_H -#define QANDROIDCAPTURESESSION_H - -#include <qobject.h> -#include <qmediarecorder.h> -#include <qurl.h> -#include <qelapsedtimer.h> -#include <qtimer.h> -#include <private/qmediastoragelocation_p.h> -#include "androidmediarecorder.h" - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidCaptureSession : public QObject -{ - Q_OBJECT -public: - explicit QAndroidCaptureSession(QAndroidCameraSession *cameraSession = 0); - ~QAndroidCaptureSession(); - - QList<QSize> supportedResolutions() const { return m_supportedResolutions; } - QList<qreal> supportedFrameRates() const { return m_supportedFramerates; } - - QString audioInput() const { return m_audioInput; } - void setAudioInput(const QString &input); - - QUrl outputLocation() const; - bool setOutputLocation(const QUrl &location); - - QMediaRecorder::State state() const; - void setState(QMediaRecorder::State state); - - QMediaRecorder::Status status() const; - - qint64 duration() const; - - QString containerFormat() const { return m_containerFormat; } - void setContainerFormat(const QString &format); - - QAudioEncoderSettings audioSettings() const { return m_audioSettings; } - void setAudioSettings(const QAudioEncoderSettings &settings); - - QVideoEncoderSettings videoSettings() const { return m_videoSettings; } - void setVideoSettings(const QVideoEncoderSettings &settings); - - void applySettings(); - -Q_SIGNALS: - void audioInputChanged(const QString& name); - void stateChanged(QMediaRecorder::State state); - void statusChanged(QMediaRecorder::Status status); - void durationChanged(qint64 position); - void actualLocationChanged(const QUrl &location); - void error(int error, const QString &errorString); - -private Q_SLOTS: - void updateDuration(); - void onCameraOpened(); - - void onError(int what, int extra); - void onInfo(int what, int extra); - -private: - struct CaptureProfile { - AndroidMediaRecorder::OutputFormat outputFormat; - QString outputFileExtension; - - AndroidMediaRecorder::AudioEncoder audioEncoder; - int audioBitRate; - int audioChannels; - int audioSampleRate; - - AndroidMediaRecorder::VideoEncoder videoEncoder; - int videoBitRate; - int videoFrameRate; - QSize videoResolution; - - bool isNull; - - CaptureProfile() - : outputFormat(AndroidMediaRecorder::MPEG_4) - , outputFileExtension(QLatin1String("mp4")) - , audioEncoder(AndroidMediaRecorder::DefaultAudioEncoder) - , audioBitRate(128000) - , audioChannels(2) - , audioSampleRate(44100) - , videoEncoder(AndroidMediaRecorder::DefaultVideoEncoder) - , videoBitRate(1) - , videoFrameRate(-1) - , videoResolution(320, 240) - , isNull(true) - { } - }; - - CaptureProfile getProfile(int id); - - void start(); - void stop(bool error = false); - - void setStatus(QMediaRecorder::Status status); - - void updateViewfinder(); - void restartViewfinder(); - - AndroidMediaRecorder *m_mediaRecorder; - QAndroidCameraSession *m_cameraSession; - - QString m_audioInput; - AndroidMediaRecorder::AudioSource m_audioSource; - - QMediaStorageLocation m_mediaStorageLocation; - - QElapsedTimer m_elapsedTime; - QTimer m_notifyTimer; - qint64 m_duration; - - QMediaRecorder::State m_state; - QMediaRecorder::Status m_status; - QUrl m_requestedOutputLocation; - QUrl m_usedOutputLocation; - QUrl m_actualOutputLocation; - - CaptureProfile m_defaultSettings; - - QString m_containerFormat; - QAudioEncoderSettings m_audioSettings; - QVideoEncoderSettings m_videoSettings; - bool m_containerFormatDirty; - bool m_videoSettingsDirty; - bool m_audioSettingsDirty; - AndroidMediaRecorder::OutputFormat m_outputFormat; - AndroidMediaRecorder::AudioEncoder m_audioEncoder; - AndroidMediaRecorder::VideoEncoder m_videoEncoder; - - QList<QSize> m_supportedResolutions; - QList<qreal> m_supportedFramerates; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDCAPTURESESSION_H diff --git a/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.cpp b/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.cpp deleted file mode 100644 index 666f553e5..000000000 --- a/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidimageencodercontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" - -QT_BEGIN_NAMESPACE - -QAndroidImageEncoderControl::QAndroidImageEncoderControl(QAndroidCameraSession *session) - : QImageEncoderControl() - , m_session(session) -{ - connect(m_session, SIGNAL(opened()), - this, SLOT(onCameraOpened())); -} - -QStringList QAndroidImageEncoderControl::supportedImageCodecs() const -{ - return QStringList() << QLatin1String("jpeg"); -} - -QString QAndroidImageEncoderControl::imageCodecDescription(const QString &codecName) const -{ - if (codecName == QLatin1String("jpeg")) - return tr("JPEG image"); - - return QString(); -} - -QList<QSize> QAndroidImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const -{ - Q_UNUSED(settings); - - if (continuous) - *continuous = false; - - return m_supportedResolutions; -} - -QImageEncoderSettings QAndroidImageEncoderControl::imageSettings() const -{ - return m_session->imageSettings(); -} - -void QAndroidImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings) -{ - m_session->setImageSettings(settings); -} - -void QAndroidImageEncoderControl::onCameraOpened() -{ - m_supportedResolutions = m_session->camera()->getSupportedPictureSizes(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.h b/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.h deleted file mode 100644 index 52f602e78..000000000 --- a/src/plugins/android/src/mediacapture/qandroidimageencodercontrol.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDIMAGEENCODERCONTROL_H -#define QANDROIDIMAGEENCODERCONTROL_H - -#include <qimageencodercontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidImageEncoderControl : public QImageEncoderControl -{ - Q_OBJECT -public: - explicit QAndroidImageEncoderControl(QAndroidCameraSession *session); - - QStringList supportedImageCodecs() const override; - QString imageCodecDescription(const QString &codecName) const override; - QList<QSize> supportedResolutions(const QImageEncoderSettings &settings, bool *continuous = 0) const override; - QImageEncoderSettings imageSettings() const override; - void setImageSettings(const QImageEncoderSettings &settings) override; - -private Q_SLOTS: - void onCameraOpened(); - -private: - QAndroidCameraSession *m_session; - - QList<QSize> m_supportedResolutions; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDIMAGEENCODERCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidmediacontainercontrol.cpp b/src/plugins/android/src/mediacapture/qandroidmediacontainercontrol.cpp deleted file mode 100644 index bda711367..000000000 --- a/src/plugins/android/src/mediacapture/qandroidmediacontainercontrol.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidmediacontainercontrol.h" - -#include "qandroidcapturesession.h" - -QT_BEGIN_NAMESPACE - -QAndroidMediaContainerControl::QAndroidMediaContainerControl(QAndroidCaptureSession *session) - : QMediaContainerControl() - , m_session(session) -{ -} - -QStringList QAndroidMediaContainerControl::supportedContainers() const -{ - return QStringList() << QLatin1String("mp4") - << QLatin1String("3gp") - << QLatin1String("amr") - << QLatin1String("awb"); -} - -QString QAndroidMediaContainerControl::containerFormat() const -{ - return m_session->containerFormat(); -} - -void QAndroidMediaContainerControl::setContainerFormat(const QString &format) -{ - m_session->setContainerFormat(format); -} - -QString QAndroidMediaContainerControl::containerDescription(const QString &formatMimeType) const -{ - if (formatMimeType == QLatin1String("mp4")) - return tr("MPEG4 media file format"); - else if (formatMimeType == QLatin1String("3gp")) - return tr("3GPP media file format"); - else if (formatMimeType == QLatin1String("amr")) - return tr("AMR NB file format"); - else if (formatMimeType == QLatin1String("awb")) - return tr("AMR WB file format"); - - return QString(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidmediacontainercontrol.h b/src/plugins/android/src/mediacapture/qandroidmediacontainercontrol.h deleted file mode 100644 index 1d90fb6cd..000000000 --- a/src/plugins/android/src/mediacapture/qandroidmediacontainercontrol.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDMEDIACONTAINERCONTROL_H -#define QANDROIDMEDIACONTAINERCONTROL_H - -#include <qmediacontainercontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCaptureSession; - -class QAndroidMediaContainerControl : public QMediaContainerControl -{ - Q_OBJECT -public: - QAndroidMediaContainerControl(QAndroidCaptureSession *session); - - QStringList supportedContainers() const override; - QString containerFormat() const override; - void setContainerFormat(const QString &format) override; - QString containerDescription(const QString &formatMimeType) const override; - -private: - QAndroidCaptureSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDMEDIACONTAINERCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidmediarecordercontrol.cpp b/src/plugins/android/src/mediacapture/qandroidmediarecordercontrol.cpp deleted file mode 100644 index fa68409d3..000000000 --- a/src/plugins/android/src/mediacapture/qandroidmediarecordercontrol.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidmediarecordercontrol.h" - -#include "qandroidcapturesession.h" - -QT_BEGIN_NAMESPACE - -QAndroidMediaRecorderControl::QAndroidMediaRecorderControl(QAndroidCaptureSession *session) - : QMediaRecorderControl() - , m_session(session) -{ - connect(m_session, SIGNAL(stateChanged(QMediaRecorder::State)), this, SIGNAL(stateChanged(QMediaRecorder::State))); - connect(m_session, SIGNAL(statusChanged(QMediaRecorder::Status)), this, SIGNAL(statusChanged(QMediaRecorder::Status))); - connect(m_session, SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64))); - connect(m_session, SIGNAL(actualLocationChanged(QUrl)), this, SIGNAL(actualLocationChanged(QUrl))); - connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); -} - -QUrl QAndroidMediaRecorderControl::outputLocation() const -{ - return m_session->outputLocation(); -} - -bool QAndroidMediaRecorderControl::setOutputLocation(const QUrl &location) -{ - return m_session->setOutputLocation(location); -} - -QMediaRecorder::State QAndroidMediaRecorderControl::state() const -{ - return m_session->state(); -} - -QMediaRecorder::Status QAndroidMediaRecorderControl::status() const -{ - return m_session->status(); -} - -qint64 QAndroidMediaRecorderControl::duration() const -{ - return m_session->duration(); -} - -bool QAndroidMediaRecorderControl::isMuted() const -{ - // No API for this in Android - return false; -} - -qreal QAndroidMediaRecorderControl::volume() const -{ - // No API for this in Android - return 1.0; -} - -void QAndroidMediaRecorderControl::applySettings() -{ - m_session->applySettings(); -} - -void QAndroidMediaRecorderControl::setState(QMediaRecorder::State state) -{ - m_session->setState(state); -} - -void QAndroidMediaRecorderControl::setMuted(bool muted) -{ - // No API for this in Android - Q_UNUSED(muted); - qWarning("QMediaRecorder::setMuted() is not supported on Android."); -} - -void QAndroidMediaRecorderControl::setVolume(qreal volume) -{ - // No API for this in Android - Q_UNUSED(volume); - qWarning("QMediaRecorder::setVolume() is not supported on Android."); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidmediarecordercontrol.h b/src/plugins/android/src/mediacapture/qandroidmediarecordercontrol.h deleted file mode 100644 index 6da59a50d..000000000 --- a/src/plugins/android/src/mediacapture/qandroidmediarecordercontrol.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDMEDIARECORDERCONTROL_H -#define QANDROIDMEDIARECORDERCONTROL_H - -#include <qmediarecordercontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCaptureSession; - -class QAndroidMediaRecorderControl : public QMediaRecorderControl -{ - Q_OBJECT -public: - explicit QAndroidMediaRecorderControl(QAndroidCaptureSession *session); - - QUrl outputLocation() const override; - bool setOutputLocation(const QUrl &location) override; - QMediaRecorder::State state() const override; - QMediaRecorder::Status status() const override; - qint64 duration() const override; - bool isMuted() const override; - qreal volume() const override; - void applySettings() override; - -public Q_SLOTS: - void setState(QMediaRecorder::State state) override; - void setMuted(bool muted) override; - void setVolume(qreal volume) override; - -private: - QAndroidCaptureSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDMEDIARECORDERCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidmediavideoprobecontrol.cpp b/src/plugins/android/src/mediacapture/qandroidmediavideoprobecontrol.cpp deleted file mode 100644 index 1995ebf6a..000000000 --- a/src/plugins/android/src/mediacapture/qandroidmediavideoprobecontrol.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Integrated Computer Solutions, Inc -** 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$ -** -****************************************************************************/ - -#include "qandroidmediavideoprobecontrol.h" -#include <qvideoframe.h> - -QT_BEGIN_NAMESPACE - -QAndroidMediaVideoProbeControl::QAndroidMediaVideoProbeControl(QObject *parent) : - QMediaVideoProbeControl(parent) -{ -} - -QAndroidMediaVideoProbeControl::~QAndroidMediaVideoProbeControl() -{ - -} - -void QAndroidMediaVideoProbeControl::newFrameProbed(const QVideoFrame &frame) -{ - emit videoFrameProbed(frame); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidmediavideoprobecontrol.h b/src/plugins/android/src/mediacapture/qandroidmediavideoprobecontrol.h deleted file mode 100644 index 3306ad224..000000000 --- a/src/plugins/android/src/mediacapture/qandroidmediavideoprobecontrol.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Integrated Computer Solutions, Inc -** 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 QANDROIDMEDIAVIDEOPROBECONTROL_H -#define QANDROIDMEDIAVIDEOPROBECONTROL_H - -#include <qmediavideoprobecontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidMediaVideoProbeControl : public QMediaVideoProbeControl -{ - Q_OBJECT -public: - explicit QAndroidMediaVideoProbeControl(QObject *parent = 0); - virtual ~QAndroidMediaVideoProbeControl(); - - void newFrameProbed(const QVideoFrame& frame); - -}; - -QT_END_NAMESPACE - -#endif // QANDROIDMEDIAVIDEOPROBECONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.cpp b/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.cpp deleted file mode 100644 index 65005c796..000000000 --- a/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidvideodeviceselectorcontrol.h" - -#include "qandroidcamerasession.h" -#include "androidcamera.h" - -QT_BEGIN_NAMESPACE - -QAndroidVideoDeviceSelectorControl::QAndroidVideoDeviceSelectorControl(QAndroidCameraSession *session) - : QVideoDeviceSelectorControl(0) - , m_selectedDevice(0) - , m_cameraSession(session) -{ -} - -QAndroidVideoDeviceSelectorControl::~QAndroidVideoDeviceSelectorControl() -{ -} - -int QAndroidVideoDeviceSelectorControl::deviceCount() const -{ - return QAndroidCameraSession::availableCameras().count(); -} - -QString QAndroidVideoDeviceSelectorControl::deviceName(int index) const -{ - if (index < 0 || index >= QAndroidCameraSession::availableCameras().count()) - return QString(); - - return QString::fromLatin1(QAndroidCameraSession::availableCameras().at(index).name); -} - -QString QAndroidVideoDeviceSelectorControl::deviceDescription(int index) const -{ - if (index < 0 || index >= QAndroidCameraSession::availableCameras().count()) - return QString(); - - return QAndroidCameraSession::availableCameras().at(index).description; -} - -int QAndroidVideoDeviceSelectorControl::defaultDevice() const -{ - return 0; -} - -int QAndroidVideoDeviceSelectorControl::selectedDevice() const -{ - return m_selectedDevice; -} - -void QAndroidVideoDeviceSelectorControl::setSelectedDevice(int index) -{ - if (index != m_selectedDevice) { - m_selectedDevice = index; - m_cameraSession->setSelectedCamera(m_selectedDevice); - emit selectedDeviceChanged(index); - emit selectedDeviceChanged(deviceName(index)); - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.h b/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.h deleted file mode 100644 index b6cc30b2d..000000000 --- a/src/plugins/android/src/mediacapture/qandroidvideodeviceselectorcontrol.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDVIDEODEVICESELECTORCONTROL_H -#define QANDROIDVIDEODEVICESELECTORCONTROL_H - -#include <qvideodeviceselectorcontrol.h> -#include <QtCore/qstringlist.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidVideoDeviceSelectorControl : public QVideoDeviceSelectorControl -{ - Q_OBJECT -public: - explicit QAndroidVideoDeviceSelectorControl(QAndroidCameraSession *session); - ~QAndroidVideoDeviceSelectorControl(); - - int deviceCount() const; - - QString deviceName(int index) const; - QString deviceDescription(int index) const; - - int defaultDevice() const; - int selectedDevice() const; - void setSelectedDevice(int index); - -private: - int m_selectedDevice; - - QAndroidCameraSession *m_cameraSession; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDVIDEODEVICESELECTORCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidvideoencodersettingscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidvideoencodersettingscontrol.cpp deleted file mode 100644 index 3d67e8cfa..000000000 --- a/src/plugins/android/src/mediacapture/qandroidvideoencodersettingscontrol.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qandroidvideoencodersettingscontrol.h" - -#include "qandroidcapturesession.h" - -QT_BEGIN_NAMESPACE - -QAndroidVideoEncoderSettingsControl::QAndroidVideoEncoderSettingsControl(QAndroidCaptureSession *session) - : QVideoEncoderSettingsControl() - , m_session(session) -{ -} - -QList<QSize> QAndroidVideoEncoderSettingsControl::supportedResolutions(const QVideoEncoderSettings &, bool *continuous) const -{ - if (continuous) - *continuous = false; - - return m_session->supportedResolutions(); -} - -QList<qreal> QAndroidVideoEncoderSettingsControl::supportedFrameRates(const QVideoEncoderSettings &, bool *continuous) const -{ - if (continuous) - *continuous = false; - - return m_session->supportedFrameRates(); -} - -QStringList QAndroidVideoEncoderSettingsControl::supportedVideoCodecs() const -{ - return QStringList() << QLatin1String("h263") - << QLatin1String("h264") - << QLatin1String("mpeg4_sp"); -} - -QString QAndroidVideoEncoderSettingsControl::videoCodecDescription(const QString &codecName) const -{ - if (codecName == QLatin1String("h263")) - return tr("H.263 compression"); - else if (codecName == QLatin1String("h264")) - return tr("H.264 compression"); - else if (codecName == QLatin1String("mpeg4_sp")) - return tr("MPEG-4 SP compression"); - - return QString(); -} - -QVideoEncoderSettings QAndroidVideoEncoderSettingsControl::videoSettings() const -{ - return m_session->videoSettings(); -} - -void QAndroidVideoEncoderSettingsControl::setVideoSettings(const QVideoEncoderSettings &settings) -{ - m_session->setVideoSettings(settings); -} - -QT_END_NAMESPACE diff --git a/src/plugins/android/src/mediacapture/qandroidvideoencodersettingscontrol.h b/src/plugins/android/src/mediacapture/qandroidvideoencodersettingscontrol.h deleted file mode 100644 index 146b44ac4..000000000 --- a/src/plugins/android/src/mediacapture/qandroidvideoencodersettingscontrol.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QANDROIDVIDEOENCODERSETTINGSCONTROL_H -#define QANDROIDVIDEOENCODERSETTINGSCONTROL_H - -#include <qvideoencodersettingscontrol.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCaptureSession; - -class QAndroidVideoEncoderSettingsControl : public QVideoEncoderSettingsControl -{ - Q_OBJECT -public: - explicit QAndroidVideoEncoderSettingsControl(QAndroidCaptureSession *session); - - QList<QSize> supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous = 0) const override; - QList<qreal> supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous = 0) const override; - QStringList supportedVideoCodecs() const override; - QString videoCodecDescription(const QString &codecName) const override; - QVideoEncoderSettings videoSettings() const override; - void setVideoSettings(const QVideoEncoderSettings &settings) override; - -private: - QAndroidCaptureSession *m_session; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDVIDEOENCODERSETTINGSCONTROL_H diff --git a/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.cpp deleted file mode 100644 index 01a826064..000000000 --- a/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Ruslan Baratov -** 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$ -** -****************************************************************************/ - -#include "qandroidviewfindersettingscontrol.h" -#include "qandroidcamerasession.h" - -QT_BEGIN_NAMESPACE - -QAndroidViewfinderSettingsControl2::QAndroidViewfinderSettingsControl2(QAndroidCameraSession *session) - : m_cameraSession(session) -{ -} - -QList<QCameraViewfinderSettings> QAndroidViewfinderSettingsControl2::supportedViewfinderSettings() const -{ - QList<QCameraViewfinderSettings> viewfinderSettings; - - const QList<QSize> previewSizes = m_cameraSession->getSupportedPreviewSizes(); - const QList<QVideoFrame::PixelFormat> pixelFormats = m_cameraSession->getSupportedPixelFormats(); - const QList<AndroidCamera::FpsRange> fpsRanges = m_cameraSession->getSupportedPreviewFpsRange(); - - viewfinderSettings.reserve(previewSizes.size() * pixelFormats.size() * fpsRanges.size()); - - for (const QSize& size : previewSizes) { - for (QVideoFrame::PixelFormat pixelFormat : pixelFormats) { - for (const AndroidCamera::FpsRange& fpsRange : fpsRanges) { - QCameraViewfinderSettings s; - s.setResolution(size); - s.setPixelAspectRatio(QSize(1, 1)); - s.setPixelFormat(pixelFormat); - s.setMinimumFrameRate(fpsRange.getMinReal()); - s.setMaximumFrameRate(fpsRange.getMaxReal()); - viewfinderSettings << s; - } - } - } - return viewfinderSettings; -} - -QCameraViewfinderSettings QAndroidViewfinderSettingsControl2::viewfinderSettings() const -{ - return m_cameraSession->viewfinderSettings(); -} - -void QAndroidViewfinderSettingsControl2::setViewfinderSettings(const QCameraViewfinderSettings &settings) -{ - m_cameraSession->setViewfinderSettings(settings); -} - -QT_END_NAMESPACE - -#include "moc_qandroidviewfindersettingscontrol.cpp" diff --git a/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.h b/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.h deleted file mode 100644 index c7863a144..000000000 --- a/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Ruslan Baratov -** 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 QANDROIDVIEWFINDERSETTINGSCONTROL_H -#define QANDROIDVIEWFINDERSETTINGSCONTROL_H - -#include <QtMultimedia/qcameraviewfindersettingscontrol.h> -#include <QtMultimedia/qcameraviewfindersettings.h> - -#include <QtCore/qpointer.h> -#include <QtCore/qglobal.h> -#include <QtCore/qsize.h> - -QT_BEGIN_NAMESPACE - -class QAndroidCameraSession; - -class QAndroidViewfinderSettingsControl2 : public QCameraViewfinderSettingsControl2 -{ - Q_OBJECT -public: - explicit QAndroidViewfinderSettingsControl2(QAndroidCameraSession *session); - - QList<QCameraViewfinderSettings> supportedViewfinderSettings() const override; - QCameraViewfinderSettings viewfinderSettings() const override; - void setViewfinderSettings(const QCameraViewfinderSettings &settings) override; - -private: - QAndroidCameraSession *m_cameraSession; -}; - -QT_END_NAMESPACE - -#endif // QANDROIDVIEWFINDERSETTINGSCONTROL_H |