summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-01-04 09:31:49 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-21 19:56:38 +0000
commitf8f33da7964977e30f8d2a3439a9058ba21bc798 (patch)
treed96edb4f609e491fd5933fa84b41ca58c1aca61e
parent4f7daef43da220869475d085ec2fb68083d53696 (diff)
Merge the viewfindersettingscontrol into QCameraControl
Change-Id: I6410cc5fa9e787454a3ed61723b26238012aea6e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
-rw-r--r--src/imports/multimedia/qdeclarativecameraviewfinder.cpp2
-rw-r--r--src/imports/multimedia/qdeclarativecameraviewfinder_p.h1
-rw-r--r--src/multimedia/CMakeLists.txt1
-rw-r--r--src/multimedia/camera/qcamera.cpp20
-rw-r--r--src/multimedia/camera/qcamera.h2
-rw-r--r--src/multimedia/camera/qcamera_p.h4
-rw-r--r--src/multimedia/controls/controls.pri2
-rw-r--r--src/multimedia/controls/qcameracontrol.cpp24
-rw-r--r--src/multimedia/controls/qcameracontrol.h5
-rw-r--r--src/multimedia/controls/qcameraviewfindersettingscontrol.cpp105
-rw-r--r--src/multimedia/controls/qcameraviewfindersettingscontrol.h74
-rw-r--r--src/plugins/android/src/CMakeLists.txt1
-rw-r--r--src/plugins/android/src/mediacapture/mediacapture.pri2
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp36
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcameracontrol.h4
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp7
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcaptureservice.h2
-rw-r--r--src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.cpp89
-rw-r--r--src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.h71
-rw-r--r--src/plugins/avfoundation/camera/CMakeLists.txt1
-rw-r--r--src/plugins/avfoundation/camera/avfcameracontrol.h25
-rw-r--r--src/plugins/avfoundation/camera/avfcameracontrol.mm382
-rw-r--r--src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm3
-rw-r--r--src/plugins/avfoundation/camera/avfcameraservice.h3
-rw-r--r--src/plugins/avfoundation/camera/avfcameraservice.mm6
-rw-r--r--src/plugins/avfoundation/camera/avfcamerasession.mm13
-rw-r--r--src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.h95
-rw-r--r--src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm446
-rw-r--r--src/plugins/avfoundation/camera/avfimageencodercontrol.mm1
-rw-r--r--src/plugins/avfoundation/camera/camera.pro2
-rw-r--r--src/plugins/gstreamer/camerabin/CMakeLists.txt2
-rw-r--r--src/plugins/gstreamer/camerabin/camerabin.pro2
-rw-r--r--src/plugins/gstreamer/camerabin/camerabincontrol.cpp15
-rw-r--r--src/plugins/gstreamer/camerabin/camerabincontrol.h5
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinservice.cpp10
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinservice.h3
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp73
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h67
-rw-r--r--tests/auto/unit/qcamera/CMakeLists.txt1
-rw-r--r--tests/auto/unit/qcamera/tst_qcamera.cpp10
-rw-r--r--tests/auto/unit/qcameraimagecapture/CMakeLists.txt1
-rw-r--r--tests/auto/unit/qcamerainfo/CMakeLists.txt1
-rw-r--r--tests/auto/unit/qcameraviewfinder/CMakeLists.txt1
-rw-r--r--tests/auto/unit/qcamerawidgets/CMakeLists.txt1
-rw-r--r--tests/auto/unit/qdeclarativecamera/CMakeLists.txt1
-rw-r--r--tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml4
-rw-r--r--tests/auto/unit/qdeclarativemultimediaglobal/CMakeLists.txt1
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamera.pri3
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameracontrol.h60
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraservice.h7
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h106
51 files changed, 580 insertions, 1223 deletions
diff --git a/src/imports/multimedia/qdeclarativecameraviewfinder.cpp b/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
index 2b3c16429..26945e69a 100644
--- a/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
+++ b/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
@@ -40,7 +40,7 @@
#include "qdeclarativecamera_p.h"
#include "qdeclarativecameraviewfinder_p.h"
-#include <QtMultimedia/qcameraviewfindersettingscontrol.h>
+#include <QtMultimedia/qcameracontrol.h>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/multimedia/qdeclarativecameraviewfinder_p.h b/src/imports/multimedia/qdeclarativecameraviewfinder_p.h
index 472f03ece..1b1090432 100644
--- a/src/imports/multimedia/qdeclarativecameraviewfinder_p.h
+++ b/src/imports/multimedia/qdeclarativecameraviewfinder_p.h
@@ -58,7 +58,6 @@
QT_BEGIN_NAMESPACE
class QDeclarativeCamera;
-class QCameraViewfinderSettingsControl;
class QDeclarativeCameraViewfinder : public QObject
{
diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt
index dcb44d095..d8ecdebc6 100644
--- a/src/multimedia/CMakeLists.txt
+++ b/src/multimedia/CMakeLists.txt
@@ -39,7 +39,6 @@ qt_add_module(Multimedia
controls/qcamerafocuscontrol.cpp controls/qcamerafocuscontrol.h
controls/qcameraimagecapturecontrol.cpp controls/qcameraimagecapturecontrol.h
controls/qcameraimageprocessingcontrol.cpp controls/qcameraimageprocessingcontrol.h
- controls/qcameraviewfindersettingscontrol.cpp controls/qcameraviewfindersettingscontrol.h
controls/qimageencodercontrol.cpp controls/qimageencodercontrol.h
controls/qmediaaudioprobecontrol.cpp controls/qmediaaudioprobecontrol.h
controls/qmediacontainercontrol.cpp controls/qmediacontainercontrol.h
diff --git a/src/multimedia/camera/qcamera.cpp b/src/multimedia/camera/qcamera.cpp
index eadafe940..47550e803 100644
--- a/src/multimedia/camera/qcamera.cpp
+++ b/src/multimedia/camera/qcamera.cpp
@@ -48,7 +48,6 @@
#include <qcameraimageprocessingcontrol.h>
#include <qcameraimagecapturecontrol.h>
#include <qvideodeviceselectorcontrol.h>
-#include <qcameraviewfindersettingscontrol.h>
#include <QDebug>
@@ -181,7 +180,6 @@ void QCameraPrivate::initControls()
if (service) {
control = qobject_cast<QCameraControl *>(service->requestControl(QCameraControl_iid));
deviceControl = qobject_cast<QVideoDeviceSelectorControl*>(service->requestControl(QVideoDeviceSelectorControl_iid));
- viewfinderSettingsControl = qobject_cast<QCameraViewfinderSettingsControl*>(service->requestControl(QCameraViewfinderSettingsControl_iid));
if (control) {
q->connect(control, SIGNAL(stateChanged(QCamera::State)), q, SLOT(_q_updateState(QCamera::State)));
@@ -197,7 +195,6 @@ void QCameraPrivate::initControls()
} else {
control = nullptr;
deviceControl = nullptr;
- viewfinderSettingsControl = nullptr;
error = QCamera::ServiceMissingError;
errorString = QCamera::tr("The camera service is missing");
@@ -215,8 +212,6 @@ void QCameraPrivate::clear()
service->releaseControl(control);
if (deviceControl)
service->releaseControl(deviceControl);
- if (viewfinderSettingsControl)
- service->releaseControl(viewfinderSettingsControl);
provider->releaseService(service);
}
@@ -226,7 +221,6 @@ void QCameraPrivate::clear()
imageProcessing = nullptr;
control = nullptr;
deviceControl = nullptr;
- viewfinderSettingsControl = nullptr;
service = nullptr;
}
@@ -539,8 +533,8 @@ QCameraViewfinderSettings QCamera::viewfinderSettings() const
{
Q_D(const QCamera);
- if (d->viewfinderSettingsControl)
- return d->viewfinderSettingsControl->viewfinderSettings();
+ if (d->control)
+ return d->control->viewfinderSettings();
return QCameraViewfinderSettings();
}
@@ -567,11 +561,11 @@ void QCamera::setViewfinderSettings(const QCameraViewfinderSettings &settings)
{
Q_D(QCamera);
- if (!d->viewfinderSettingsControl)
+ if (!d->control)
return;
d->_q_preparePropertyChange(QCameraControl::ViewfinderSettings);
- d->viewfinderSettingsControl->setViewfinderSettings(settings);
+ d->control->setViewfinderSettings(settings);
}
/*!
@@ -595,14 +589,14 @@ QList<QCameraViewfinderSettings> QCamera::supportedViewfinderSettings(const QCam
{
Q_D(const QCamera);
- if (!d->viewfinderSettingsControl)
+ if (!d->control)
return QList<QCameraViewfinderSettings>();
if (settings.isNull())
- return d->viewfinderSettingsControl->supportedViewfinderSettings();
+ return d->control->supportedViewfinderSettings();
QList<QCameraViewfinderSettings> results;
- const QList<QCameraViewfinderSettings> supported = d->viewfinderSettingsControl->supportedViewfinderSettings();
+ const QList<QCameraViewfinderSettings> supported = d->control->supportedViewfinderSettings();
for (const QCameraViewfinderSettings &s : supported) {
if ((settings.resolution().isEmpty() || settings.resolution() == s.resolution())
&& (qFuzzyIsNull(settings.minimumFrameRate()) || qFuzzyCompare((float)settings.minimumFrameRate(), (float)s.minimumFrameRate()))
diff --git a/src/multimedia/camera/qcamera.h b/src/multimedia/camera/qcamera.h
index 483842c7a..e264d401e 100644
--- a/src/multimedia/camera/qcamera.h
+++ b/src/multimedia/camera/qcamera.h
@@ -46,9 +46,7 @@
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
-#include <QtMultimedia/qmediaservice.h>
#include <QtMultimedia/qmediaobject.h>
-#include <QtMultimedia/qmediaservice.h>
#include <QtMultimedia/qcameraexposure.h>
#include <QtMultimedia/qcamerafocus.h>
diff --git a/src/multimedia/camera/qcamera_p.h b/src/multimedia/camera/qcamera_p.h
index a3c8f8beb..a7c077124 100644
--- a/src/multimedia/camera/qcamera_p.h
+++ b/src/multimedia/camera/qcamera_p.h
@@ -60,8 +60,6 @@ QT_BEGIN_NAMESPACE
class QMediaServiceProvider;
class QCameraControl;
class QVideoDeviceSelectorControl;
-class QCameraViewfinderSettingsControl;
-class QCameraViewfinderSettingsControl;
class QCameraPrivate : public QMediaObjectPrivate
{
@@ -72,7 +70,6 @@ public:
provider(nullptr),
control(nullptr),
deviceControl(nullptr),
- viewfinderSettingsControl(nullptr),
cameraExposure(nullptr),
cameraFocus(nullptr),
imageProcessing(nullptr),
@@ -97,7 +94,6 @@ public:
QCameraControl *control;
QVideoDeviceSelectorControl *deviceControl;
- QCameraViewfinderSettingsControl *viewfinderSettingsControl;
QCameraExposure *cameraExposure;
QCameraFocus *cameraFocus;
diff --git a/src/multimedia/controls/controls.pri b/src/multimedia/controls/controls.pri
index bcec75e5e..4c69176f8 100644
--- a/src/multimedia/controls/controls.pri
+++ b/src/multimedia/controls/controls.pri
@@ -12,7 +12,6 @@ PUBLIC_HEADERS += \
controls/qcamerafocuscontrol.h \
controls/qcameraimagecapturecontrol.h \
controls/qcameraimageprocessingcontrol.h \
- controls/qcameraviewfindersettingscontrol.h \
controls/qimageencodercontrol.h \
controls/qmediacontainercontrol.h \
controls/qmediaplayercontrol.h \
@@ -34,7 +33,6 @@ SOURCES += \
controls/qcamerafocuscontrol.cpp \
controls/qcameraimagecapturecontrol.cpp \
controls/qcameraimageprocessingcontrol.cpp \
- controls/qcameraviewfindersettingscontrol.cpp \
controls/qimageencodercontrol.cpp \
controls/qmediacontainercontrol.cpp \
controls/qmediaplayercontrol.cpp \
diff --git a/src/multimedia/controls/qcameracontrol.cpp b/src/multimedia/controls/qcameracontrol.cpp
index 2468e9e2f..205f058df 100644
--- a/src/multimedia/controls/qcameracontrol.cpp
+++ b/src/multimedia/controls/qcameracontrol.cpp
@@ -221,6 +221,30 @@ QCameraControl::QCameraControl(QObject *parent)
Signals the lock \a type \a status was changed with the specified \a reason.
*/
+/*!
+ \fn QCameraControl::supportedViewfinderSettings() const
+
+ Returns a list of supported camera viewfinder settings.
+
+ The list is ordered by preference; preferred settings come first.
+*/
+
+/*!
+ \fn QCameraControl::viewfinderSettings() const
+
+ Returns the viewfinder settings.
+
+ If undefined or unsupported values are passed to QCameraControl::setViewfinderSettings(),
+ this function returns the actual settings used by the camera viewfinder. These may be available
+ only once the camera is active.
+*/
+
+/*!
+ \fn QCameraControl::setViewfinderSettings(const QCameraViewfinderSettings &settings)
+
+ Sets the camera viewfinder \a settings.
+*/
+
QT_END_NAMESPACE
#include "moc_qcameracontrol.cpp"
diff --git a/src/multimedia/controls/qcameracontrol.h b/src/multimedia/controls/qcameracontrol.h
index d57b74937..9490b563b 100644
--- a/src/multimedia/controls/qcameracontrol.h
+++ b/src/multimedia/controls/qcameracontrol.h
@@ -81,6 +81,11 @@ public:
virtual void searchAndLock(QCamera::LockTypes locks) = 0;
virtual void unlock(QCamera::LockTypes locks) = 0;
+ virtual QList<QCameraViewfinderSettings> supportedViewfinderSettings() const = 0;
+
+ virtual QCameraViewfinderSettings viewfinderSettings() const = 0;
+ virtual void setViewfinderSettings(const QCameraViewfinderSettings &settings) = 0;
+
Q_SIGNALS:
void stateChanged(QCamera::State);
void statusChanged(QCamera::Status);
diff --git a/src/multimedia/controls/qcameraviewfindersettingscontrol.cpp b/src/multimedia/controls/qcameraviewfindersettingscontrol.cpp
deleted file mode 100644
index a1936fdd5..000000000
--- a/src/multimedia/controls/qcameraviewfindersettingscontrol.cpp
+++ /dev/null
@@ -1,105 +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 "qcameraviewfindersettingscontrol.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QCameraviewfinderSettingsControl
- \inmodule QtMultimedia
- \ingroup multimedia_control
- \since 5.5
-
- \brief The QCameraviewfinderSettingsControl class provides access to the viewfinder settings
- of a camera media service.
-
- The functionality provided by this control is exposed to application code through the QCamera class.
-
- The interface name of QCameraviewfinderSettingsControl is \c org.qt-project.qt.cameraviewfinderSettingsControl/6.0 as
- defined in QCameraViewfinderSettingsControl_iid.
-
- \sa QMediaService::requestControl(), QCameraViewfinderSettings, QCamera
-*/
-
-/*!
- \macro QCameraViewfinderSettingsControl_iid
-
- \c org.qt-project.qt.cameraviewfinderSettingsControl/5.5
-
- Defines the interface name of the QCameraviewfinderSettingsControl class.
-
- \relates QCameraviewfinderSettingsControl
-*/
-
-/*!
- Constructs a camera viewfinder settings control object with \a parent.
-*/
-QCameraViewfinderSettingsControl::QCameraViewfinderSettingsControl(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- \fn QCameraviewfinderSettingsControl::supportedViewfinderSettings() const
-
- Returns a list of supported camera viewfinder settings.
-
- The list is ordered by preference; preferred settings come first.
-*/
-
-/*!
- \fn QCameraviewfinderSettingsControl::viewfinderSettings() const
-
- Returns the viewfinder settings.
-
- If undefined or unsupported values are passed to QCameraviewfinderSettingsControl::setViewfinderSettings(),
- this function returns the actual settings used by the camera viewfinder. These may be available
- only once the camera is active.
-*/
-
-/*!
- \fn QCameraviewfinderSettingsControl::setViewfinderSettings(const QCameraViewfinderSettings &settings)
-
- Sets the camera viewfinder \a settings.
-*/
-
-QT_END_NAMESPACE
-
-#include "moc_qcameraviewfindersettingscontrol.cpp"
diff --git a/src/multimedia/controls/qcameraviewfindersettingscontrol.h b/src/multimedia/controls/qcameraviewfindersettingscontrol.h
deleted file mode 100644
index 3c17b30f9..000000000
--- a/src/multimedia/controls/qcameraviewfindersettingscontrol.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 QCAMERAVIEWFINDERSETTINGSCONTROL_H
-#define QCAMERAVIEWFINDERSETTINGSCONTROL_H
-
-#include <QtMultimedia/qmediaservice.h>
-#include <QtMultimedia/qcamera.h>
-
-QT_BEGIN_NAMESPACE
-
-// Required for QDoc workaround
-class QString;
-
-// Required for QDoc workaround
-class QString;
-
-class Q_MULTIMEDIA_EXPORT QCameraViewfinderSettingsControl : public QObject
-{
- Q_OBJECT
-public:
- virtual QList<QCameraViewfinderSettings> supportedViewfinderSettings() const = 0;
-
- virtual QCameraViewfinderSettings viewfinderSettings() const = 0;
- virtual void setViewfinderSettings(const QCameraViewfinderSettings &settings) = 0;
-
-protected:
- explicit QCameraViewfinderSettingsControl(QObject *parent = nullptr);
-};
-
-#define QCameraViewfinderSettingsControl_iid "org.qt-project.qt.cameraviewfindersettingscontrol/6.0"
-Q_MEDIA_DECLARE_CONTROL(QCameraViewfinderSettingsControl, QCameraViewfinderSettingsControl_iid)
-
-QT_END_NAMESPACE
-
-#endif // QCAMERAVIEWFINDERSETTINGSCONTROL_H
diff --git a/src/plugins/android/src/CMakeLists.txt b/src/plugins/android/src/CMakeLists.txt
index c63582fbd..613125ae8 100644
--- a/src/plugins/android/src/CMakeLists.txt
+++ b/src/plugins/android/src/CMakeLists.txt
@@ -29,7 +29,6 @@ qt_internal_add_plugin(QAndroidMediaServicePlugin
mediacapture/qandroidmediavideoprobecontrol.cpp mediacapture/qandroidmediavideoprobecontrol.h
mediacapture/qandroidvideodeviceselectorcontrol.cpp mediacapture/qandroidvideodeviceselectorcontrol.h
mediacapture/qandroidvideoencodersettingscontrol.cpp mediacapture/qandroidvideoencodersettingscontrol.h
- mediacapture/qandroidviewfindersettingscontrol.cpp mediacapture/qandroidviewfindersettingscontrol.h
mediaplayer/qandroidmediaplayercontrol.cpp mediaplayer/qandroidmediaplayercontrol.h
mediaplayer/qandroidmediaplayervideorenderercontrol.cpp mediaplayer/qandroidmediaplayervideorenderercontrol.h
mediaplayer/qandroidmediaservice.cpp mediaplayer/qandroidmediaservice.h
diff --git a/src/plugins/android/src/mediacapture/mediacapture.pri b/src/plugins/android/src/mediacapture/mediacapture.pri
index 78bc0a862..effc652d6 100644
--- a/src/plugins/android/src/mediacapture/mediacapture.pri
+++ b/src/plugins/android/src/mediacapture/mediacapture.pri
@@ -11,7 +11,6 @@ SOURCES += \
$$PWD/qandroidcameraimagecapturecontrol.cpp \
$$PWD/qandroidcameracapturebufferformatcontrol.cpp \
$$PWD/qandroidcamerafocuscontrol.cpp \
- $$PWD/qandroidviewfindersettingscontrol.cpp \
$$PWD/qandroidcapturesession.cpp \
$$PWD/qandroidmediarecordercontrol.cpp \
$$PWD/qandroidaudioencodersettingscontrol.cpp \
@@ -32,7 +31,6 @@ HEADERS += \
$$PWD/qandroidcameraimagecapturecontrol.h \
$$PWD/qandroidcameracapturebufferformatcontrol.h \
$$PWD/qandroidcamerafocuscontrol.h \
- $$PWD/qandroidviewfindersettingscontrol.h \
$$PWD/qandroidcapturesession.h \
$$PWD/qandroidmediarecordercontrol.h \
$$PWD/qandroidaudioencodersettingscontrol.h \
diff --git a/src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp
index 551df7965..f9efaea8a 100644
--- a/src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcameracontrol.cpp
@@ -304,4 +304,40 @@ void QAndroidCameraControl::setExposureLockStatus(QCamera::LockStatus status, QC
emit lockStatusChanged(QCamera::LockExposure, m_exposureLockStatus, reason);
}
+QList<QCameraViewfinderSettings> QAndroidCameraControl::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 QAndroidCameraControl::viewfinderSettings() const
+{
+ return m_cameraSession->viewfinderSettings();
+}
+
+void QAndroidCameraControl::setViewfinderSettings(const QCameraViewfinderSettings &settings)
+{
+ m_cameraSession->setViewfinderSettings(settings);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/android/src/mediacapture/qandroidcameracontrol.h b/src/plugins/android/src/mediacapture/qandroidcameracontrol.h
index 5d8dad1b8..d30f507c3 100644
--- a/src/plugins/android/src/mediacapture/qandroidcameracontrol.h
+++ b/src/plugins/android/src/mediacapture/qandroidcameracontrol.h
@@ -70,6 +70,10 @@ public:
void searchAndLock(QCamera::LockTypes locks) override;
void unlock(QCamera::LockTypes locks) override;
+ QList<QCameraViewfinderSettings> supportedViewfinderSettings() const override;
+ QCameraViewfinderSettings viewfinderSettings() const override;
+ void setViewfinderSettings(const QCameraViewfinderSettings &settings) override;
+
private Q_SLOTS:
void onCameraOpened();
void onCameraAutoFocusComplete(bool success);
diff --git a/src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp b/src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp
index ceda6fd3b..8badb46de 100644
--- a/src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcaptureservice.cpp
@@ -49,7 +49,6 @@
#include "qandroidcameravideorenderercontrol.h"
#include "qandroidcameraexposurecontrol.h"
#include "qandroidcamerafocuscontrol.h"
-#include "qandroidviewfindersettingscontrol.h"
#include "qandroidcameraimageprocessingcontrol.h"
#include "qandroidimageencodercontrol.h"
#include "qandroidcameraimagecapturecontrol.h"
@@ -74,7 +73,6 @@ QAndroidCaptureService::QAndroidCaptureService(const QString &service, QObject *
m_videoInputControl = new QAndroidVideoDeviceSelectorControl(m_cameraSession);
m_cameraExposureControl = new QAndroidCameraExposureControl(m_cameraSession);
m_cameraFocusControl = new QAndroidCameraFocusControl(m_cameraSession);
- m_viewfinderSettingsControl = new QAndroidViewfinderSettingsControl(m_cameraSession);
m_cameraImageProcessingControl = new QAndroidCameraImageProcessingControl(m_cameraSession);
m_imageEncoderControl = new QAndroidImageEncoderControl(m_cameraSession);
m_imageCaptureControl = new QAndroidCameraImageCaptureControl(m_cameraSession);
@@ -86,7 +84,6 @@ QAndroidCaptureService::QAndroidCaptureService(const QString &service, QObject *
m_videoInputControl = 0;
m_cameraExposureControl = 0;
m_cameraFocusControl = 0;
- m_viewfinderSettingsControl = 0;
m_cameraImageProcessingControl = 0;
m_imageEncoderControl = 0;
m_imageCaptureControl = 0;
@@ -120,7 +117,6 @@ QAndroidCaptureService::~QAndroidCaptureService()
delete m_videoRendererControl;
delete m_cameraExposureControl;
delete m_cameraFocusControl;
- delete m_viewfinderSettingsControl;
delete m_cameraImageProcessingControl;
delete m_imageEncoderControl;
delete m_imageCaptureControl;
@@ -157,9 +153,6 @@ QObject *QAndroidCaptureService::requestControl(const char *name)
if (qstrcmp(name, QCameraFocusControl_iid) == 0)
return m_cameraFocusControl;
- if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0)
- return m_viewfinderSettingsControl;
-
if (qstrcmp(name, QCameraImageProcessingControl_iid) == 0)
return m_cameraImageProcessingControl;
diff --git a/src/plugins/android/src/mediacapture/qandroidcaptureservice.h b/src/plugins/android/src/mediacapture/qandroidcaptureservice.h
index 088f7f976..ae32a6544 100644
--- a/src/plugins/android/src/mediacapture/qandroidcaptureservice.h
+++ b/src/plugins/android/src/mediacapture/qandroidcaptureservice.h
@@ -55,7 +55,6 @@ class QAndroidCameraSession;
class QAndroidCameraVideoRendererControl;
class QAndroidCameraExposureControl;
class QAndroidCameraFocusControl;
-class QAndroidViewfinderSettingsControl;
class QAndroidCameraImageProcessingControl;
class QAndroidImageEncoderControl;
class QAndroidCameraImageCaptureControl;
@@ -87,7 +86,6 @@ private:
QAndroidCameraVideoRendererControl *m_videoRendererControl;
QAndroidCameraExposureControl *m_cameraExposureControl;
QAndroidCameraFocusControl *m_cameraFocusControl;
- QAndroidViewfinderSettingsControl *m_viewfinderSettingsControl;
QAndroidCameraImageProcessingControl *m_cameraImageProcessingControl;
QAndroidImageEncoderControl *m_imageEncoderControl;
QAndroidCameraImageCaptureControl *m_imageCaptureControl;
diff --git a/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidviewfindersettingscontrol.cpp
deleted file mode 100644
index 8a45c7d8f..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
-
-QAndroidViewfinderSettingsControl::QAndroidViewfinderSettingsControl(QAndroidCameraSession *session)
- : m_cameraSession(session)
-{
-}
-
-QList<QCameraViewfinderSettings> QAndroidViewfinderSettingsControl::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 QAndroidViewfinderSettingsControl::viewfinderSettings() const
-{
- return m_cameraSession->viewfinderSettings();
-}
-
-void QAndroidViewfinderSettingsControl::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 5e803f0ee..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 QAndroidViewfinderSettingsControl : public QCameraViewfinderSettingsControl
-{
- Q_OBJECT
-public:
- explicit QAndroidViewfinderSettingsControl(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
diff --git a/src/plugins/avfoundation/camera/CMakeLists.txt b/src/plugins/avfoundation/camera/CMakeLists.txt
index c6abccbde..1a0eabdb7 100644
--- a/src/plugins/avfoundation/camera/CMakeLists.txt
+++ b/src/plugins/avfoundation/camera/CMakeLists.txt
@@ -21,7 +21,6 @@ qt_internal_add_plugin(AVFServicePlugin
avfcameraserviceplugin.h avfcameraserviceplugin.mm
avfcamerasession.h avfcamerasession.mm
avfcamerautility.h avfcamerautility.mm
- avfcameraviewfindersettingscontrol.h avfcameraviewfindersettingscontrol.mm
avfcamerawindowcontrol.h avfcamerawindowcontrol.mm
avfcapturedestinationcontrol.h avfcapturedestinationcontrol.mm
avfimagecapturecontrol.h avfimagecapturecontrol.mm
diff --git a/src/plugins/avfoundation/camera/avfcameracontrol.h b/src/plugins/avfoundation/camera/avfcameracontrol.h
index 5d2e48329..1792645f7 100644
--- a/src/plugins/avfoundation/camera/avfcameracontrol.h
+++ b/src/plugins/avfoundation/camera/avfcameracontrol.h
@@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE
class AVFCameraSession;
class AVFCameraService;
+@class AVCaptureDeviceFormat;
+@class AVCaptureConnection;
class AVFCameraControl : public QCameraControl
{
@@ -74,11 +76,34 @@ public:
void searchAndLock(QCamera::LockTypes locks) override;
void unlock(QCamera::LockTypes locks) override;
+ QList<QCameraViewfinderSettings> supportedViewfinderSettings() const override;
+ QCameraViewfinderSettings viewfinderSettings() const override;
+ void setViewfinderSettings(const QCameraViewfinderSettings &settings) override;
+
+ // "Converters":
+ static QVideoFrame::PixelFormat QtPixelFormatFromCVFormat(unsigned avPixelFormat);
+ static bool CVPixelFormatFromQtFormat(QVideoFrame::PixelFormat qtFormat, unsigned &conv);
+
+private:
+ void setResolution(const QSize &resolution);
+ void setFramerate(qreal minFPS, qreal maxFPS, bool useActive);
+ void setPixelFormat(QVideoFrame::PixelFormat newFormat);
+ AVCaptureDeviceFormat *findBestFormatMatch(const QCameraViewfinderSettings &settings) const;
+ QList<QVideoFrame::PixelFormat> viewfinderPixelFormats() const;
+ bool convertPixelFormatIfSupported(QVideoFrame::PixelFormat format, unsigned &avfFormat) const;
+ bool applySettings(const QCameraViewfinderSettings &settings);
+ QCameraViewfinderSettings requestedSettings() const;
+
+ AVCaptureConnection *videoConnection() const;
+
private Q_SLOTS:
void updateStatus();
private:
+ friend class AVFCameraSession;
AVFCameraSession *m_session;
+ AVFCameraService *m_service;
+ QCameraViewfinderSettings m_settings;
QCamera::State m_state;
QCamera::Status m_lastStatus;
diff --git a/src/plugins/avfoundation/camera/avfcameracontrol.mm b/src/plugins/avfoundation/camera/avfcameracontrol.mm
index 50a218a33..b36e4935d 100644
--- a/src/plugins/avfoundation/camera/avfcameracontrol.mm
+++ b/src/plugins/avfoundation/camera/avfcameracontrol.mm
@@ -41,12 +41,16 @@
#include "avfcameracontrol.h"
#include "avfcamerasession.h"
#include "avfcameraservice.h"
+#include "avfcamerautility.h"
+#include "avfcamerarenderercontrol.h"
+#include "qabstractvideosurface.h"
QT_USE_NAMESPACE
AVFCameraControl::AVFCameraControl(AVFCameraService *service, QObject *parent)
: QCameraControl(parent)
, m_session(service->session())
+ , m_service(service)
, m_state(QCamera::UnloadedState)
, m_lastStatus(QCamera::UnloadedStatus)
, m_captureMode(QCamera::CaptureStillImage)
@@ -151,4 +155,382 @@ void AVFCameraControl::unlock(QCamera::LockTypes locks)
Q_UNUSED(locks);
}
+
+namespace {
+
+bool qt_framerates_sane(const QCameraViewfinderSettings &settings)
+{
+ const qreal minFPS = settings.minimumFrameRate();
+ const qreal maxFPS = settings.maximumFrameRate();
+
+ if (minFPS < 0. || maxFPS < 0.)
+ return false;
+
+ return !maxFPS || maxFPS >= minFPS;
+}
+
+}
+
+QList<QCameraViewfinderSettings> AVFCameraControl::supportedViewfinderSettings() const
+{
+ QList<QCameraViewfinderSettings> supportedSettings;
+
+ AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
+ if (!captureDevice) {
+ qDebugCamera() << Q_FUNC_INFO << "no capture device found";
+ return supportedSettings;
+ }
+
+ QVector<AVFPSRange> framerates;
+
+ QVector<QVideoFrame::PixelFormat> pixelFormats(viewfinderPixelFormats());
+
+ if (!pixelFormats.size())
+ pixelFormats << QVideoFrame::Format_Invalid; // The default value.
+
+ if (!captureDevice.formats || !captureDevice.formats.count) {
+ qDebugCamera() << Q_FUNC_INFO << "no capture device formats found";
+ return supportedSettings;
+ }
+
+ const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(captureDevice,
+ m_service->session()->defaultCodec()));
+ for (int i = 0; i < formats.size(); ++i) {
+ AVCaptureDeviceFormat *format = formats[i];
+
+ const QSize res(qt_device_format_resolution(format));
+ if (res.isNull() || !res.isValid())
+ continue;
+ const QSize par(qt_device_format_pixel_aspect_ratio(format));
+ if (par.isNull() || !par.isValid())
+ continue;
+
+ framerates = qt_device_format_framerates(format);
+ if (!framerates.size())
+ framerates << AVFPSRange(); // The default value.
+
+ for (int i = 0; i < pixelFormats.size(); ++i) {
+ for (int j = 0; j < framerates.size(); ++j) {
+ QCameraViewfinderSettings newSet;
+ newSet.setResolution(res);
+ newSet.setPixelAspectRatio(par);
+ newSet.setPixelFormat(pixelFormats[i]);
+ newSet.setMinimumFrameRate(framerates[j].first);
+ newSet.setMaximumFrameRate(framerates[j].second);
+ supportedSettings << newSet;
+ }
+ }
+ }
+
+ return supportedSettings;
+}
+
+QCameraViewfinderSettings AVFCameraControl::viewfinderSettings() const
+{
+ QCameraViewfinderSettings settings = m_settings;
+
+ AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
+ if (!captureDevice) {
+ qDebugCamera() << Q_FUNC_INFO << "no capture device found";
+ return settings;
+ }
+
+ if (m_service->session()->state() != QCamera::LoadedState &&
+ m_service->session()->state() != QCamera::ActiveState) {
+ return settings;
+ }
+
+ if (!captureDevice.activeFormat) {
+ qDebugCamera() << Q_FUNC_INFO << "no active capture device format";
+ return settings;
+ }
+
+ const QSize res(qt_device_format_resolution(captureDevice.activeFormat));
+ const QSize par(qt_device_format_pixel_aspect_ratio(captureDevice.activeFormat));
+ if (res.isNull() || !res.isValid() || par.isNull() || !par.isValid()) {
+ qDebugCamera() << Q_FUNC_INFO << "failed to obtain resolution/pixel aspect ratio";
+ return settings;
+ }
+
+ settings.setResolution(res);
+ settings.setPixelAspectRatio(par);
+
+ const AVFPSRange fps = qt_current_framerates(captureDevice, videoConnection());
+ settings.setMinimumFrameRate(fps.first);
+ settings.setMaximumFrameRate(fps.second);
+
+ AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
+ if (videoOutput) {
+ NSObject *obj = [videoOutput.videoSettings objectForKey:(id)kCVPixelBufferPixelFormatTypeKey];
+ if (obj && [obj isKindOfClass:[NSNumber class]]) {
+ NSNumber *nsNum = static_cast<NSNumber *>(obj);
+ settings.setPixelFormat(QtPixelFormatFromCVFormat([nsNum unsignedIntValue]));
+ }
+ }
+
+ return settings;
+}
+
+void AVFCameraControl::setViewfinderSettings(const QCameraViewfinderSettings &settings)
+{
+ if (m_settings == settings)
+ return;
+
+ m_settings = settings;
+#if defined(Q_OS_IOS)
+ bool active = m_service->session()->state() == QCamera::ActiveState;
+ if (active)
+ [m_service->session()->captureSession() beginConfiguration];
+ applySettings(m_settings);
+ if (active)
+ [m_service->session()->captureSession() commitConfiguration];
+#else
+ applySettings(m_settings);
+#endif
+}
+
+QVideoFrame::PixelFormat AVFCameraControl::QtPixelFormatFromCVFormat(unsigned avPixelFormat)
+{
+ // BGRA <-> ARGB "swap" is intentional:
+ // to work correctly with GL_RGBA, color swap shaders
+ // (in QSG node renderer etc.).
+ switch (avPixelFormat) {
+ case kCVPixelFormatType_32ARGB:
+ return QVideoFrame::Format_BGRA32;
+ case kCVPixelFormatType_32BGRA:
+ return QVideoFrame::Format_ARGB32;
+ case kCVPixelFormatType_24RGB:
+ return QVideoFrame::Format_RGB24;
+ case kCVPixelFormatType_24BGR:
+ return QVideoFrame::Format_BGR24;
+ case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
+ case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
+ return QVideoFrame::Format_NV12;
+ case kCVPixelFormatType_422YpCbCr8:
+ return QVideoFrame::Format_UYVY;
+ case kCVPixelFormatType_422YpCbCr8_yuvs:
+ return QVideoFrame::Format_YUYV;
+ default:
+ return QVideoFrame::Format_Invalid;
+ }
+}
+
+bool AVFCameraControl::CVPixelFormatFromQtFormat(QVideoFrame::PixelFormat qtFormat, unsigned &conv)
+{
+ // BGRA <-> ARGB "swap" is intentional:
+ // to work correctly with GL_RGBA, color swap shaders
+ // (in QSG node renderer etc.).
+ switch (qtFormat) {
+ case QVideoFrame::Format_ARGB32:
+ conv = kCVPixelFormatType_32BGRA;
+ break;
+ case QVideoFrame::Format_BGRA32:
+ conv = kCVPixelFormatType_32ARGB;
+ break;
+ case QVideoFrame::Format_NV12:
+ conv = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
+ break;
+ case QVideoFrame::Format_UYVY:
+ conv = kCVPixelFormatType_422YpCbCr8;
+ break;
+ case QVideoFrame::Format_YUYV:
+ conv = kCVPixelFormatType_422YpCbCr8_yuvs;
+ break;
+ // These two formats below are not supported
+ // by QSGVideoNodeFactory_RGB, so for now I have to
+ // disable them.
+ /*
+ case QVideoFrame::Format_RGB24:
+ conv = kCVPixelFormatType_24RGB;
+ break;
+ case QVideoFrame::Format_BGR24:
+ conv = kCVPixelFormatType_24BGR;
+ break;
+ */
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+AVCaptureDeviceFormat *AVFCameraControl::findBestFormatMatch(const QCameraViewfinderSettings &settings) const
+{
+ AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
+ if (!captureDevice || settings.isNull())
+ return nil;
+
+ const QSize &resolution = settings.resolution();
+ if (!resolution.isNull() && resolution.isValid()) {
+ // Either the exact match (including high resolution for images on iOS)
+ // or a format with a resolution close to the requested one.
+ return qt_find_best_resolution_match(captureDevice, resolution,
+ m_service->session()->defaultCodec(), false);
+ }
+
+ // No resolution requested, what about framerates?
+ if (!qt_framerates_sane(settings)) {
+ qDebugCamera() << Q_FUNC_INFO << "invalid framerate requested (min/max):"
+ << settings.minimumFrameRate() << settings.maximumFrameRate();
+ return nil;
+ }
+
+ const qreal minFPS(settings.minimumFrameRate());
+ const qreal maxFPS(settings.maximumFrameRate());
+ if (minFPS || maxFPS)
+ return qt_find_best_framerate_match(captureDevice,
+ m_service->session()->defaultCodec(),
+ maxFPS ? maxFPS : minFPS);
+ // Ignore PAR for the moment (PAR without resolution can
+ // pick a format with really bad resolution).
+ // No need to test pixel format, just return settings.
+
+ return nil;
+}
+
+QVector<QVideoFrame::PixelFormat> AVFCameraControl::viewfinderPixelFormats() const
+{
+ QVector<QVideoFrame::PixelFormat> qtFormats;
+
+ AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
+ if (!videoOutput) {
+ qDebugCamera() << Q_FUNC_INFO << "no video output found";
+ return qtFormats;
+ }
+
+ NSArray *pixelFormats = [videoOutput availableVideoCVPixelFormatTypes];
+
+ for (NSObject *obj in pixelFormats) {
+ if (![obj isKindOfClass:[NSNumber class]])
+ continue;
+
+ NSNumber *formatAsNSNumber = static_cast<NSNumber *>(obj);
+ // It's actually FourCharCode (== UInt32):
+ const QVideoFrame::PixelFormat qtFormat(QtPixelFormatFromCVFormat([formatAsNSNumber unsignedIntValue]));
+ if (qtFormat != QVideoFrame::Format_Invalid
+ && !qtFormats.contains(qtFormat)) { // Can happen, for example, with 8BiPlanar existing in video/full range.
+ qtFormats << qtFormat;
+ }
+ }
+
+ return qtFormats;
+}
+
+bool AVFCameraControl::convertPixelFormatIfSupported(QVideoFrame::PixelFormat qtFormat,
+ unsigned &avfFormat)const
+{
+ AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
+ if (!videoOutput)
+ return false;
+
+ unsigned conv = 0;
+ if (!CVPixelFormatFromQtFormat(qtFormat, conv))
+ return false;
+
+ NSArray *formats = [videoOutput availableVideoCVPixelFormatTypes];
+ if (!formats || !formats.count)
+ return false;
+
+ if (m_service->videoOutput()->surface()) {
+ const QAbstractVideoSurface *surface = m_service->videoOutput()->surface();
+ QAbstractVideoBuffer::HandleType h = m_service->videoOutput()->supportsTextures()
+ ? QAbstractVideoBuffer::GLTextureHandle
+ : QAbstractVideoBuffer::NoHandle;
+ if (!surface->supportedPixelFormats(h).contains(qtFormat))
+ return false;
+ }
+
+ bool found = false;
+ for (NSObject *obj in formats) {
+ if (![obj isKindOfClass:[NSNumber class]])
+ continue;
+
+ NSNumber *nsNum = static_cast<NSNumber *>(obj);
+ if ([nsNum unsignedIntValue] == conv) {
+ avfFormat = conv;
+ found = true;
+ }
+ }
+
+ return found;
+}
+
+bool AVFCameraControl::applySettings(const QCameraViewfinderSettings &settings)
+{
+ if (m_service->session()->state() != QCamera::LoadedState &&
+ m_service->session()->state() != QCamera::ActiveState) {
+ return false;
+ }
+
+ AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
+ if (!captureDevice)
+ return false;
+
+ bool activeFormatChanged = false;
+
+ AVCaptureDeviceFormat *match = findBestFormatMatch(settings);
+ if (match) {
+ activeFormatChanged = qt_set_active_format(captureDevice, match, false);
+ } else {
+ qDebugCamera() << Q_FUNC_INFO << "matching device format not found";
+ // We still can update the pixel format at least.
+ }
+
+ AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
+ if (videoOutput) {
+ unsigned avfPixelFormat = 0;
+ if (!convertPixelFormatIfSupported(settings.pixelFormat(), avfPixelFormat)) {
+ // If the the pixel format is not specified or invalid, pick the preferred video surface
+ // format, or if no surface is set, the preferred capture device format
+
+ const QVector<QVideoFrame::PixelFormat> deviceFormats = viewfinderPixelFormats();
+ QAbstractVideoSurface *surface = m_service->videoOutput()->surface();
+ QVideoFrame::PixelFormat pickedFormat = deviceFormats.first();
+ if (surface) {
+ pickedFormat = QVideoFrame::Format_Invalid;
+ QAbstractVideoBuffer::HandleType h = m_service->videoOutput()->supportsTextures()
+ ? QAbstractVideoBuffer::GLTextureHandle
+ : QAbstractVideoBuffer::NoHandle;
+ QList<QVideoFrame::PixelFormat> surfaceFormats = surface->supportedPixelFormats(h);
+ for (int i = 0; i < surfaceFormats.count(); ++i) {
+ const QVideoFrame::PixelFormat surfaceFormat = surfaceFormats.at(i);
+ if (deviceFormats.contains(surfaceFormat)) {
+ pickedFormat = surfaceFormat;
+ break;
+ }
+ }
+ }
+
+ CVPixelFormatFromQtFormat(pickedFormat, avfPixelFormat);
+ }
+
+ NSMutableDictionary *videoSettings = [NSMutableDictionary dictionaryWithCapacity:1];
+ [videoSettings setObject:[NSNumber numberWithUnsignedInt:avfPixelFormat]
+ forKey:(id)kCVPixelBufferPixelFormatTypeKey];
+
+ const AVFConfigurationLock lock(captureDevice);
+ if (!lock)
+ qWarning("Failed to set active format (lock failed)");
+
+ videoOutput.videoSettings = videoSettings;
+ }
+
+ qt_set_framerate_limits(captureDevice, videoConnection(), settings.minimumFrameRate(), settings.maximumFrameRate());
+
+ return activeFormatChanged;
+}
+
+QCameraViewfinderSettings AVFCameraControl::requestedSettings() const
+{
+ return m_settings;
+}
+
+AVCaptureConnection *AVFCameraControl::videoConnection() const
+{
+ if (!m_service->videoOutput() || !m_service->videoOutput()->videoDataOutput())
+ return nil;
+
+ return [m_service->videoOutput()->videoDataOutput() connectionWithMediaType:AVMediaTypeVideo];
+}
+
#include "moc_avfcameracontrol.cpp"
diff --git a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm
index ac9173449..98cbf3df4 100644
--- a/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm
+++ b/src/plugins/avfoundation/camera/avfcamerarenderercontrol.mm
@@ -37,7 +37,6 @@
**
****************************************************************************/
-#include "avfcameraviewfindersettingscontrol.h"
#include "private/qabstractvideobuffer_p.h"
#include "avfcamerarenderercontrol.h"
#include "avfcamerasession.h"
@@ -251,7 +250,7 @@ private:
int width = CVPixelBufferGetWidth(imageBuffer);
int height = CVPixelBufferGetHeight(imageBuffer);
QVideoFrame::PixelFormat format =
- AVFCameraViewfinderSettingsControl::QtPixelFormatFromCVFormat(CVPixelBufferGetPixelFormatType(imageBuffer));
+ AVFCameraControl::QtPixelFormatFromCVFormat(CVPixelBufferGetPixelFormatType(imageBuffer));
if (format == QVideoFrame::Format_Invalid)
return;
diff --git a/src/plugins/avfoundation/camera/avfcameraservice.h b/src/plugins/avfoundation/camera/avfcameraservice.h
index 12fa728a9..2c5bfedce 100644
--- a/src/plugins/avfoundation/camera/avfcameraservice.h
+++ b/src/plugins/avfoundation/camera/avfcameraservice.h
@@ -59,7 +59,6 @@ class AVFCameraDeviceControl;
class AVFAudioInputSelectorControl;
class AVFCameraFocusControl;
class AVFCameraExposureControl;
-class AVFCameraViewfinderSettingsControl;
class AVFImageEncoderControl;
class AVFMediaRecorderControl;
class AVFMediaRecorderControlIOS;
@@ -88,7 +87,6 @@ public:
AVFCameraFocusControl *cameraFocusControl() const { return m_cameraFocusControl; }
AVFCameraExposureControl *cameraExposureControl() const {return m_cameraExposureControl; }
AVFCameraRendererControl *videoOutput() const {return m_videoOutput; }
- AVFCameraViewfinderSettingsControl *viewfinderSettingsControl() const {return m_viewfinderSettingsControl; }
AVFImageEncoderControl *imageEncoderControl() const {return m_imageEncoderControl; }
AVFAudioEncoderSettingsControl *audioEncoderSettingsControl() const { return m_audioEncoderSettingsControl; }
AVFVideoEncoderSettingsControl *videoEncoderSettingsControl() const {return m_videoEncoderSettingsControl; }
@@ -105,7 +103,6 @@ private:
AVFImageCaptureControl *m_imageCaptureControl;
AVFCameraFocusControl *m_cameraFocusControl;
AVFCameraExposureControl *m_cameraExposureControl;
- AVFCameraViewfinderSettingsControl *m_viewfinderSettingsControl;
AVFImageEncoderControl *m_imageEncoderControl;
AVFAudioEncoderSettingsControl *m_audioEncoderSettingsControl;
AVFVideoEncoderSettingsControl *m_videoEncoderSettingsControl;
diff --git a/src/plugins/avfoundation/camera/avfcameraservice.mm b/src/plugins/avfoundation/camera/avfcameraservice.mm
index 46366a76c..29ac6b07f 100644
--- a/src/plugins/avfoundation/camera/avfcameraservice.mm
+++ b/src/plugins/avfoundation/camera/avfcameraservice.mm
@@ -54,7 +54,6 @@
#include "avfmediavideoprobecontrol.h"
#include "avfcamerafocuscontrol.h"
#include "avfcameraexposurecontrol.h"
-#include "avfcameraviewfindersettingscontrol.h"
#include "avfimageencodercontrol.h"
#include "avfaudioencodersettingscontrol.h"
#include "avfvideoencodersettingscontrol.h"
@@ -95,7 +94,6 @@ AVFCameraService::AVFCameraService(QObject *parent):
m_cameraExposureControl = new AVFCameraExposureControl(this);
#endif
- m_viewfinderSettingsControl = new AVFCameraViewfinderSettingsControl(this);
m_imageEncoderControl = new AVFImageEncoderControl(this);
m_audioEncoderSettingsControl = new AVFAudioEncoderSettingsControl(this);
m_videoEncoderSettingsControl = new AVFVideoEncoderSettingsControl(this);
@@ -130,7 +128,6 @@ AVFCameraService::~AVFCameraService()
delete m_cameraControl;
delete m_cameraFocusControl;
delete m_cameraExposureControl;
- delete m_viewfinderSettingsControl;
delete m_imageEncoderControl;
delete m_audioEncoderSettingsControl;
delete m_videoEncoderSettingsControl;
@@ -166,9 +163,6 @@ QObject *AVFCameraService::requestControl(const char *name)
if (qstrcmp(name, QCameraFocusControl_iid) == 0)
return m_cameraFocusControl;
- if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0)
- return m_viewfinderSettingsControl;
-
if (qstrcmp(name, QImageEncoderControl_iid) == 0)
return m_imageEncoderControl;
diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm
index a44a2d62a..4ffa5ad69 100644
--- a/src/plugins/avfoundation/camera/avfcamerasession.mm
+++ b/src/plugins/avfoundation/camera/avfcamerasession.mm
@@ -45,7 +45,6 @@
#include "avfcameradevicecontrol.h"
#include "avfaudioinputselectorcontrol.h"
#include "avfmediavideoprobecontrol.h"
-#include "avfcameraviewfindersettingscontrol.h"
#include "avfimageencodercontrol.h"
#include "avfcamerautility.h"
#include "avfcamerawindowcontrol.h"
@@ -280,8 +279,8 @@ void AVFCameraSession::setCapturePreviewOutput(AVFCameraWindowControl *output)
if (m_capturePreviewWindowOutput) {
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:m_captureSession];
m_capturePreviewWindowOutput->setLayer(previewLayer);
- if (AVFCameraViewfinderSettingsControl *vfControl = m_service->viewfinderSettingsControl()) {
- m_capturePreviewWindowOutput->setNativeSize(vfControl->viewfinderSettings().resolution());
+ if (auto *camera = m_service->cameraControl()) {
+ m_capturePreviewWindowOutput->setNativeSize(camera->viewfinderSettings().resolution());
}
}
}
@@ -426,9 +425,9 @@ bool AVFCameraSession::applyImageEncoderSettings()
bool AVFCameraSession::applyViewfinderSettings()
{
- if (AVFCameraViewfinderSettingsControl *vfControl = m_service->viewfinderSettingsControl()) {
+ if (auto *camera = m_service->cameraControl()) {
QCamera::CaptureModes currentMode = m_service->cameraControl()->captureMode();
- QCameraViewfinderSettings vfSettings(vfControl->requestedSettings());
+ QCameraViewfinderSettings vfSettings(camera->requestedSettings());
// Viewfinder and image capture solutions must be the same, if an image capture
// resolution is set, it takes precedence over the viewfinder resolution.
if (currentMode.testFlag(QCamera::CaptureStillImage)) {
@@ -437,10 +436,10 @@ bool AVFCameraSession::applyViewfinderSettings()
vfSettings.setResolution(imageResolution);
}
- vfControl->applySettings(vfSettings);
+ camera->applySettings(vfSettings);
if (m_capturePreviewWindowOutput)
- m_capturePreviewWindowOutput->setNativeSize(vfControl->viewfinderSettings().resolution());
+ m_capturePreviewWindowOutput->setNativeSize(camera->viewfinderSettings().resolution());
return !vfSettings.isNull();
}
diff --git a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.h b/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.h
deleted file mode 100644
index 71cc57df5..000000000
--- a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.h
+++ /dev/null
@@ -1,95 +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 AVFCAMERAVIEWFINDERSETTINGSCONTROL_H
-#define AVFCAMERAVIEWFINDERSETTINGSCONTROL_H
-
-#include <QtMultimedia/qcameraviewfindersettingscontrol.h>
-#include <QtMultimedia/qcameraviewfindersettings.h>
-#include <QtMultimedia/qvideoframe.h>
-
-#include <QtCore/qpointer.h>
-#include <QtCore/qglobal.h>
-#include <QtCore/qsize.h>
-
-@class AVCaptureDevice;
-@class AVCaptureVideoDataOutput;
-@class AVCaptureConnection;
-@class AVCaptureDeviceFormat;
-
-QT_BEGIN_NAMESPACE
-
-class AVFCameraSession;
-class AVFCameraService;
-
-class AVFCameraViewfinderSettingsControl : public QCameraViewfinderSettingsControl
-{
- Q_OBJECT
-
- friend class AVFCameraSession;
-public:
- AVFCameraViewfinderSettingsControl(AVFCameraService *service);
-
- QList<QCameraViewfinderSettings> supportedViewfinderSettings() const override;
- QCameraViewfinderSettings viewfinderSettings() const override;
- void setViewfinderSettings(const QCameraViewfinderSettings &settings) override;
-
- // "Converters":
- static QVideoFrame::PixelFormat QtPixelFormatFromCVFormat(unsigned avPixelFormat);
- static bool CVPixelFormatFromQtFormat(QVideoFrame::PixelFormat qtFormat, unsigned &conv);
-
-private:
- void setResolution(const QSize &resolution);
- void setFramerate(qreal minFPS, qreal maxFPS, bool useActive);
- void setPixelFormat(QVideoFrame::PixelFormat newFormat);
- AVCaptureDeviceFormat *findBestFormatMatch(const QCameraViewfinderSettings &settings) const;
- QList<QVideoFrame::PixelFormat> viewfinderPixelFormats() const;
- bool convertPixelFormatIfSupported(QVideoFrame::PixelFormat format, unsigned &avfFormat) const;
- bool applySettings(const QCameraViewfinderSettings &settings);
- QCameraViewfinderSettings requestedSettings() const;
-
- AVCaptureConnection *videoConnection() const;
-
- AVFCameraService *m_service;
- QCameraViewfinderSettings m_settings;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm b/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm
deleted file mode 100644
index dae22e3bc..000000000
--- a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm
+++ /dev/null
@@ -1,446 +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 "avfcameraviewfindersettingscontrol.h"
-#include "avfcamerarenderercontrol.h"
-#include "avfcamerautility.h"
-#include "avfcamerasession.h"
-#include "avfcameraservice.h"
-#include "avfcameradebug.h"
-
-#include <QtMultimedia/qabstractvideosurface.h>
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qlist.h>
-#include <private/qmultimediautils_p.h>
-
-#include <algorithm>
-
-#include <AVFoundation/AVFoundation.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace {
-
-bool qt_framerates_sane(const QCameraViewfinderSettings &settings)
-{
- const qreal minFPS = settings.minimumFrameRate();
- const qreal maxFPS = settings.maximumFrameRate();
-
- if (minFPS < 0. || maxFPS < 0.)
- return false;
-
- return !maxFPS || maxFPS >= minFPS;
-}
-
-} // Unnamed namespace.
-
-AVFCameraViewfinderSettingsControl::AVFCameraViewfinderSettingsControl(AVFCameraService *service)
- : m_service(service)
-{
- Q_ASSERT(service);
-}
-
-QList<QCameraViewfinderSettings> AVFCameraViewfinderSettingsControl::supportedViewfinderSettings() const
-{
- QList<QCameraViewfinderSettings> supportedSettings;
-
- AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
- if (!captureDevice) {
- qDebugCamera() << Q_FUNC_INFO << "no capture device found";
- return supportedSettings;
- }
-
- QVector<AVFPSRange> framerates;
-
- QVector<QVideoFrame::PixelFormat> pixelFormats(viewfinderPixelFormats());
-
- if (!pixelFormats.size())
- pixelFormats << QVideoFrame::Format_Invalid; // The default value.
-
- if (!captureDevice.formats || !captureDevice.formats.count) {
- qDebugCamera() << Q_FUNC_INFO << "no capture device formats found";
- return supportedSettings;
- }
-
- const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(captureDevice,
- m_service->session()->defaultCodec()));
- for (int i = 0; i < formats.size(); ++i) {
- AVCaptureDeviceFormat *format = formats[i];
-
- const QSize res(qt_device_format_resolution(format));
- if (res.isNull() || !res.isValid())
- continue;
- const QSize par(qt_device_format_pixel_aspect_ratio(format));
- if (par.isNull() || !par.isValid())
- continue;
-
- framerates = qt_device_format_framerates(format);
- if (!framerates.size())
- framerates << AVFPSRange(); // The default value.
-
- for (int i = 0; i < pixelFormats.size(); ++i) {
- for (int j = 0; j < framerates.size(); ++j) {
- QCameraViewfinderSettings newSet;
- newSet.setResolution(res);
- newSet.setPixelAspectRatio(par);
- newSet.setPixelFormat(pixelFormats[i]);
- newSet.setMinimumFrameRate(framerates[j].first);
- newSet.setMaximumFrameRate(framerates[j].second);
- supportedSettings << newSet;
- }
- }
- }
-
- return supportedSettings;
-}
-
-QCameraViewfinderSettings AVFCameraViewfinderSettingsControl::viewfinderSettings() const
-{
- QCameraViewfinderSettings settings = m_settings;
-
- AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
- if (!captureDevice) {
- qDebugCamera() << Q_FUNC_INFO << "no capture device found";
- return settings;
- }
-
- if (m_service->session()->state() != QCamera::LoadedState &&
- m_service->session()->state() != QCamera::ActiveState) {
- return settings;
- }
-
- if (!captureDevice.activeFormat) {
- qDebugCamera() << Q_FUNC_INFO << "no active capture device format";
- return settings;
- }
-
- const QSize res(qt_device_format_resolution(captureDevice.activeFormat));
- const QSize par(qt_device_format_pixel_aspect_ratio(captureDevice.activeFormat));
- if (res.isNull() || !res.isValid() || par.isNull() || !par.isValid()) {
- qDebugCamera() << Q_FUNC_INFO << "failed to obtain resolution/pixel aspect ratio";
- return settings;
- }
-
- settings.setResolution(res);
- settings.setPixelAspectRatio(par);
-
- const AVFPSRange fps = qt_current_framerates(captureDevice, videoConnection());
- settings.setMinimumFrameRate(fps.first);
- settings.setMaximumFrameRate(fps.second);
-
- AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
- if (videoOutput) {
- NSObject *obj = [videoOutput.videoSettings objectForKey:(id)kCVPixelBufferPixelFormatTypeKey];
- if (obj && [obj isKindOfClass:[NSNumber class]]) {
- NSNumber *nsNum = static_cast<NSNumber *>(obj);
- settings.setPixelFormat(QtPixelFormatFromCVFormat([nsNum unsignedIntValue]));
- }
- }
-
- return settings;
-}
-
-void AVFCameraViewfinderSettingsControl::setViewfinderSettings(const QCameraViewfinderSettings &settings)
-{
- if (m_settings == settings)
- return;
-
- m_settings = settings;
-#if defined(Q_OS_IOS)
- bool active = m_service->session()->state() == QCamera::ActiveState;
- if (active)
- [m_service->session()->captureSession() beginConfiguration];
- applySettings(m_settings);
- if (active)
- [m_service->session()->captureSession() commitConfiguration];
-#else
- applySettings(m_settings);
-#endif
-}
-
-QVideoFrame::PixelFormat AVFCameraViewfinderSettingsControl::QtPixelFormatFromCVFormat(unsigned avPixelFormat)
-{
- // BGRA <-> ARGB "swap" is intentional:
- // to work correctly with GL_RGBA, color swap shaders
- // (in QSG node renderer etc.).
- switch (avPixelFormat) {
- case kCVPixelFormatType_32ARGB:
- return QVideoFrame::Format_BGRA32;
- case kCVPixelFormatType_32BGRA:
- return QVideoFrame::Format_ARGB32;
- case kCVPixelFormatType_24RGB:
- return QVideoFrame::Format_RGB24;
- case kCVPixelFormatType_24BGR:
- return QVideoFrame::Format_BGR24;
- case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
- case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
- return QVideoFrame::Format_NV12;
- case kCVPixelFormatType_422YpCbCr8:
- return QVideoFrame::Format_UYVY;
- case kCVPixelFormatType_422YpCbCr8_yuvs:
- return QVideoFrame::Format_YUYV;
- default:
- return QVideoFrame::Format_Invalid;
- }
-}
-
-bool AVFCameraViewfinderSettingsControl::CVPixelFormatFromQtFormat(QVideoFrame::PixelFormat qtFormat, unsigned &conv)
-{
- // BGRA <-> ARGB "swap" is intentional:
- // to work correctly with GL_RGBA, color swap shaders
- // (in QSG node renderer etc.).
- switch (qtFormat) {
- case QVideoFrame::Format_ARGB32:
- conv = kCVPixelFormatType_32BGRA;
- break;
- case QVideoFrame::Format_BGRA32:
- conv = kCVPixelFormatType_32ARGB;
- break;
- case QVideoFrame::Format_NV12:
- conv = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
- break;
- case QVideoFrame::Format_UYVY:
- conv = kCVPixelFormatType_422YpCbCr8;
- break;
- case QVideoFrame::Format_YUYV:
- conv = kCVPixelFormatType_422YpCbCr8_yuvs;
- break;
- // These two formats below are not supported
- // by QSGVideoNodeFactory_RGB, so for now I have to
- // disable them.
- /*
- case QVideoFrame::Format_RGB24:
- conv = kCVPixelFormatType_24RGB;
- break;
- case QVideoFrame::Format_BGR24:
- conv = kCVPixelFormatType_24BGR;
- break;
- */
- default:
- return false;
- }
-
- return true;
-}
-
-AVCaptureDeviceFormat *AVFCameraViewfinderSettingsControl::findBestFormatMatch(const QCameraViewfinderSettings &settings) const
-{
- AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
- if (!captureDevice || settings.isNull())
- return nil;
-
- const QSize &resolution = settings.resolution();
- if (!resolution.isNull() && resolution.isValid()) {
- // Either the exact match (including high resolution for images on iOS)
- // or a format with a resolution close to the requested one.
- return qt_find_best_resolution_match(captureDevice, resolution,
- m_service->session()->defaultCodec(), false);
- }
-
- // No resolution requested, what about framerates?
- if (!qt_framerates_sane(settings)) {
- qDebugCamera() << Q_FUNC_INFO << "invalid framerate requested (min/max):"
- << settings.minimumFrameRate() << settings.maximumFrameRate();
- return nil;
- }
-
- const qreal minFPS(settings.minimumFrameRate());
- const qreal maxFPS(settings.maximumFrameRate());
- if (minFPS || maxFPS)
- return qt_find_best_framerate_match(captureDevice,
- m_service->session()->defaultCodec(),
- maxFPS ? maxFPS : minFPS);
- // Ignore PAR for the moment (PAR without resolution can
- // pick a format with really bad resolution).
- // No need to test pixel format, just return settings.
-
- return nil;
-}
-
-QVector<QVideoFrame::PixelFormat> AVFCameraViewfinderSettingsControl::viewfinderPixelFormats() const
-{
- QVector<QVideoFrame::PixelFormat> qtFormats;
-
- AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
- if (!videoOutput) {
- qDebugCamera() << Q_FUNC_INFO << "no video output found";
- return qtFormats;
- }
-
- NSArray *pixelFormats = [videoOutput availableVideoCVPixelFormatTypes];
-
- for (NSObject *obj in pixelFormats) {
- if (![obj isKindOfClass:[NSNumber class]])
- continue;
-
- NSNumber *formatAsNSNumber = static_cast<NSNumber *>(obj);
- // It's actually FourCharCode (== UInt32):
- const QVideoFrame::PixelFormat qtFormat(QtPixelFormatFromCVFormat([formatAsNSNumber unsignedIntValue]));
- if (qtFormat != QVideoFrame::Format_Invalid
- && !qtFormats.contains(qtFormat)) { // Can happen, for example, with 8BiPlanar existing in video/full range.
- qtFormats << qtFormat;
- }
- }
-
- return qtFormats;
-}
-
-bool AVFCameraViewfinderSettingsControl::convertPixelFormatIfSupported(QVideoFrame::PixelFormat qtFormat,
- unsigned &avfFormat)const
-{
- AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
- if (!videoOutput)
- return false;
-
- unsigned conv = 0;
- if (!CVPixelFormatFromQtFormat(qtFormat, conv))
- return false;
-
- NSArray *formats = [videoOutput availableVideoCVPixelFormatTypes];
- if (!formats || !formats.count)
- return false;
-
- if (m_service->videoOutput()->surface()) {
- const QAbstractVideoSurface *surface = m_service->videoOutput()->surface();
- QAbstractVideoBuffer::HandleType h = m_service->videoOutput()->supportsTextures()
- ? QAbstractVideoBuffer::GLTextureHandle
- : QAbstractVideoBuffer::NoHandle;
- if (!surface->supportedPixelFormats(h).contains(qtFormat))
- return false;
- }
-
- bool found = false;
- for (NSObject *obj in formats) {
- if (![obj isKindOfClass:[NSNumber class]])
- continue;
-
- NSNumber *nsNum = static_cast<NSNumber *>(obj);
- if ([nsNum unsignedIntValue] == conv) {
- avfFormat = conv;
- found = true;
- }
- }
-
- return found;
-}
-
-bool AVFCameraViewfinderSettingsControl::applySettings(const QCameraViewfinderSettings &settings)
-{
- if (m_service->session()->state() != QCamera::LoadedState &&
- m_service->session()->state() != QCamera::ActiveState) {
- return false;
- }
-
- AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice();
- if (!captureDevice)
- return false;
-
- bool activeFormatChanged = false;
-
- AVCaptureDeviceFormat *match = findBestFormatMatch(settings);
- if (match) {
- activeFormatChanged = qt_set_active_format(captureDevice, match, false);
- } else {
- qDebugCamera() << Q_FUNC_INFO << "matching device format not found";
- // We still can update the pixel format at least.
- }
-
- AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : nullptr;
- if (videoOutput) {
- unsigned avfPixelFormat = 0;
- if (!convertPixelFormatIfSupported(settings.pixelFormat(), avfPixelFormat)) {
- // If the the pixel format is not specified or invalid, pick the preferred video surface
- // format, or if no surface is set, the preferred capture device format
-
- const QVector<QVideoFrame::PixelFormat> deviceFormats = viewfinderPixelFormats();
- QAbstractVideoSurface *surface = m_service->videoOutput()->surface();
- QVideoFrame::PixelFormat pickedFormat = deviceFormats.first();
- if (surface) {
- pickedFormat = QVideoFrame::Format_Invalid;
- QAbstractVideoBuffer::HandleType h = m_service->videoOutput()->supportsTextures()
- ? QAbstractVideoBuffer::GLTextureHandle
- : QAbstractVideoBuffer::NoHandle;
- QList<QVideoFrame::PixelFormat> surfaceFormats = surface->supportedPixelFormats(h);
- for (int i = 0; i < surfaceFormats.count(); ++i) {
- const QVideoFrame::PixelFormat surfaceFormat = surfaceFormats.at(i);
- if (deviceFormats.contains(surfaceFormat)) {
- pickedFormat = surfaceFormat;
- break;
- }
- }
- }
-
- CVPixelFormatFromQtFormat(pickedFormat, avfPixelFormat);
- }
-
- NSMutableDictionary *videoSettings = [NSMutableDictionary dictionaryWithCapacity:1];
- [videoSettings setObject:[NSNumber numberWithUnsignedInt:avfPixelFormat]
- forKey:(id)kCVPixelBufferPixelFormatTypeKey];
-
- const AVFConfigurationLock lock(captureDevice);
- if (!lock)
- qWarning("Failed to set active format (lock failed)");
-
- videoOutput.videoSettings = videoSettings;
- }
-
- qt_set_framerate_limits(captureDevice, videoConnection(), settings.minimumFrameRate(), settings.maximumFrameRate());
-
- return activeFormatChanged;
-}
-
-QCameraViewfinderSettings AVFCameraViewfinderSettingsControl::requestedSettings() const
-{
- return m_settings;
-}
-
-AVCaptureConnection *AVFCameraViewfinderSettingsControl::videoConnection() const
-{
- if (!m_service->videoOutput() || !m_service->videoOutput()->videoDataOutput())
- return nil;
-
- return [m_service->videoOutput()->videoDataOutput() connectionWithMediaType:AVMediaTypeVideo];
-}
-
-QT_END_NAMESPACE
-
-#include "moc_avfcameraviewfindersettingscontrol.cpp"
diff --git a/src/plugins/avfoundation/camera/avfimageencodercontrol.mm b/src/plugins/avfoundation/camera/avfimageencodercontrol.mm
index 93de3e63c..104fb3c52 100644
--- a/src/plugins/avfoundation/camera/avfimageencodercontrol.mm
+++ b/src/plugins/avfoundation/camera/avfimageencodercontrol.mm
@@ -37,7 +37,6 @@
**
****************************************************************************/
-#include "avfcameraviewfindersettingscontrol.h"
#include "avfimageencodercontrol.h"
#include "avfimagecapturecontrol.h"
#include "avfcamerautility.h"
diff --git a/src/plugins/avfoundation/camera/camera.pro b/src/plugins/avfoundation/camera/camera.pro
index ba01b3974..841e5a592 100644
--- a/src/plugins/avfoundation/camera/camera.pro
+++ b/src/plugins/avfoundation/camera/camera.pro
@@ -36,7 +36,6 @@ HEADERS += \
avfcamerafocuscontrol.h \
avfcameraexposurecontrol.h \
avfcamerautility.h \
- avfcameraviewfindersettingscontrol.h \
avfimageencodercontrol.h \
avfvideoencodersettingscontrol.h \
avfmediacontainercontrol.h \
@@ -58,7 +57,6 @@ OBJECTIVE_SOURCES += \
avfcamerafocuscontrol.mm \
avfcameraexposurecontrol.mm \
avfcamerautility.mm \
- avfcameraviewfindersettingscontrol.mm \
avfimageencodercontrol.mm \
avfvideoencodersettingscontrol.mm \
avfmediacontainercontrol.mm \
diff --git a/src/plugins/gstreamer/camerabin/CMakeLists.txt b/src/plugins/gstreamer/camerabin/CMakeLists.txt
index c7f4b0d10..9584979b3 100644
--- a/src/plugins/gstreamer/camerabin/CMakeLists.txt
+++ b/src/plugins/gstreamer/camerabin/CMakeLists.txt
@@ -22,8 +22,6 @@ qt_internal_add_plugin(CameraBinServicePlugin
camerabinserviceplugin.cpp camerabinserviceplugin.h
camerabinsession.cpp camerabinsession.h
camerabinvideoencoder.cpp camerabinvideoencoder.h
- camerabinviewfindersettings.cpp camerabinviewfindersettings.h
- camerabinviewfindersettings2.cpp camerabinviewfindersettings2.h
camerabinzoom.cpp camerabinzoom.h
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/src/plugins/gstreamer/camerabin/camerabin.pro b/src/plugins/gstreamer/camerabin/camerabin.pro
index ac1b6e28a..8f354d799 100644
--- a/src/plugins/gstreamer/camerabin/camerabin.pro
+++ b/src/plugins/gstreamer/camerabin/camerabin.pro
@@ -24,7 +24,6 @@ HEADERS += \
$$PWD/camerabinmetadata.h \
$$PWD/camerabinvideoencoder.h \
$$PWD/camerabincapturebufferformat.h \
- $$PWD/camerabinviewfindersettings.h \
SOURCES += \
$$PWD/camerabinserviceplugin.cpp \
@@ -39,7 +38,6 @@ SOURCES += \
$$PWD/camerabinmetadata.cpp \
$$PWD/camerabinrecorder.cpp \
$$PWD/camerabinvideoencoder.cpp \
- $$PWD/camerabinviewfindersettings.cpp \
$$PWD/camerabincapturebufferformat.cpp \
qtConfig(gstreamer_photography) {
diff --git a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp b/src/plugins/gstreamer/camerabin/camerabincontrol.cpp
index 4b9708725..a02e9ab72 100644
--- a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabincontrol.cpp
@@ -414,4 +414,19 @@ void CameraBinControl::unlockWhiteBalance(
emit lockStatusChanged(QCamera::LockWhiteBalance, status, reason);
}
+QList<QCameraViewfinderSettings> CameraBinControl::supportedViewfinderSettings() const
+{
+ return m_session->supportedViewfinderSettings();
+}
+
+QCameraViewfinderSettings CameraBinControl::viewfinderSettings() const
+{
+ return m_session->viewfinderSettings();
+}
+
+void CameraBinControl::setViewfinderSettings(const QCameraViewfinderSettings &settings)
+{
+ m_session->setViewfinderSettings(settings);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/camerabin/camerabincontrol.h b/src/plugins/gstreamer/camerabin/camerabincontrol.h
index 4b72e3d14..20039bb72 100644
--- a/src/plugins/gstreamer/camerabin/camerabincontrol.h
+++ b/src/plugins/gstreamer/camerabin/camerabincontrol.h
@@ -77,6 +77,11 @@ public:
void searchAndLock(QCamera::LockTypes locks) override;
void unlock(QCamera::LockTypes locks) override;
+ QList<QCameraViewfinderSettings> supportedViewfinderSettings() const override;
+
+ QCameraViewfinderSettings viewfinderSettings() const override;
+ void setViewfinderSettings(const QCameraViewfinderSettings &settings) override;
+
public slots:
void reloadLater();
void setViewfinderColorSpaceConversion(bool enabled);
diff --git a/src/plugins/gstreamer/camerabin/camerabinservice.cpp b/src/plugins/gstreamer/camerabin/camerabinservice.cpp
index bad3d6151..1006c4ce7 100644
--- a/src/plugins/gstreamer/camerabin/camerabinservice.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinservice.cpp
@@ -56,7 +56,6 @@
#include "camerabinimagecapture.h"
#include "camerabinimageprocessing.h"
#include "camerabincapturebufferformat.h"
-#include "camerabinviewfindersettings.h"
#include <private/qgstreamerbushelper_p.h>
#include <private/qgstutils_p.h>
@@ -75,8 +74,7 @@
QT_BEGIN_NAMESPACE
CameraBinService::CameraBinService(GstElementFactory *sourceFactory, QObject *parent)
- : QMediaService(parent),
- m_viewfinderSettingsControl(0)
+ : QMediaService(parent)
{
m_captureSession = 0;
m_metaDataControl = 0;
@@ -208,12 +206,6 @@ QObject *CameraBinService::requestControl(const char *name)
if (qstrcmp(name, QCameraCaptureBufferFormatControl_iid) == 0)
return m_captureSession->captureBufferFormatControl();
- if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0) {
- if (!m_viewfinderSettingsControl)
- m_viewfinderSettingsControl = new CameraBinViewfinderSettings(m_captureSession);
- return m_viewfinderSettingsControl;
- }
-
return 0;
}
diff --git a/src/plugins/gstreamer/camerabin/camerabinservice.h b/src/plugins/gstreamer/camerabin/camerabinservice.h
index 153b487a8..0fae02121 100644
--- a/src/plugins/gstreamer/camerabin/camerabinservice.h
+++ b/src/plugins/gstreamer/camerabin/camerabinservice.h
@@ -60,7 +60,6 @@ class QGstreamerElementFactory;
class CameraBinMetaData;
class CameraBinImageCapture;
class CameraBinMetaData;
-class CameraBinViewfinderSettings;
class CameraBinService : public QMediaService
{
@@ -92,8 +91,6 @@ private:
QGstreamerVideoWidgetControl *m_videoWidgetControl;
#endif
CameraBinImageCapture *m_imageCaptureControl;
-
- CameraBinViewfinderSettings *m_viewfinderSettingsControl;
};
QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp
deleted file mode 100644
index eb7d73062..000000000
--- a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp
+++ /dev/null
@@ -1,73 +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 "camerabinviewfindersettings.h"
-#include "camerabinsession.h"
-
-QT_BEGIN_NAMESPACE
-
-CameraBinViewfinderSettings::CameraBinViewfinderSettings(CameraBinSession *session)
- : QCameraViewfinderSettingsControl(session)
- , m_session(session)
-{
-
-}
-
-CameraBinViewfinderSettings::~CameraBinViewfinderSettings()
-{
-
-}
-
-QList<QCameraViewfinderSettings> CameraBinViewfinderSettings::supportedViewfinderSettings() const
-{
- return m_session->supportedViewfinderSettings();
-}
-
-QCameraViewfinderSettings CameraBinViewfinderSettings::viewfinderSettings() const
-{
- return m_session->viewfinderSettings();
-}
-
-void CameraBinViewfinderSettings::setViewfinderSettings(const QCameraViewfinderSettings &settings)
-{
- m_session->setViewfinderSettings(settings);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h
deleted file mode 100644
index 38b119778..000000000
--- a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.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 CAMERABINVIEWFINDERSETTINGS_H
-#define CAMERABINVIEWFINDERSETTINGS_H
-
-#include <qcameraviewfindersettingscontrol.h>
-
-QT_BEGIN_NAMESPACE
-
-class CameraBinSession;
-
-class CameraBinViewfinderSettings : public QCameraViewfinderSettingsControl
-{
- Q_OBJECT
-public:
- CameraBinViewfinderSettings(CameraBinSession *session);
- ~CameraBinViewfinderSettings();
-
- QList<QCameraViewfinderSettings> supportedViewfinderSettings() const override;
-
- QCameraViewfinderSettings viewfinderSettings() const override;
- void setViewfinderSettings(const QCameraViewfinderSettings &settings) override;
-
-private:
- CameraBinSession *m_session;
-};
-
-QT_END_NAMESPACE
-
-#endif // CAMERABINVIEWFINDERSETTINGS_H
diff --git a/tests/auto/unit/qcamera/CMakeLists.txt b/tests/auto/unit/qcamera/CMakeLists.txt
index 4fd2fb931..64b3f034a 100644
--- a/tests/auto/unit/qcamera/CMakeLists.txt
+++ b/tests/auto/unit/qcamera/CMakeLists.txt
@@ -13,7 +13,6 @@ qt_add_test(tst_qcamera
../qmultimedia_common/mockcameraimagecapturecontrol.h
../qmultimedia_common/mockcameraimageprocessingcontrol.h
../qmultimedia_common/mockcameraservice.h
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
../qmultimedia_common/mockimageencodercontrol.h
../qmultimedia_common/mockmediaobject.h
../qmultimedia_common/mockmediaservice.h
diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp
index b8606167e..8838ba8f3 100644
--- a/tests/auto/unit/qcamera/tst_qcamera.cpp
+++ b/tests/auto/unit/qcamera/tst_qcamera.cpp
@@ -1042,7 +1042,7 @@ private:
void tst_QCamera::testSupportedViewfinderSettings_data()
{
- // see mockcameraviewfindersettingscontrol.h for expected values
+ // see mockcameracontrol.h for expected values
ViewfinderSettingsBuilder builder;
@@ -1140,14 +1140,14 @@ void tst_QCamera::testSupportedViewfinderSettings()
QList<QCameraViewfinderSettings> actualSupportedSettings = QCamera().supportedViewfinderSettings(settings);
QCOMPARE(actualSupportedSettings.size(), expectedSupportedSettings.size());
for (int i = 0; i < expectedSupportedSettings.size(); ++i) {
- QCameraViewfinderSettings expectedSettings = mockCameraService->mockViewfinderSettingsControl->supportedSettings.at(expectedSupportedSettings.at(i));
+ QCameraViewfinderSettings expectedSettings = mockCameraService->mockControl->supportedSettings.at(expectedSupportedSettings.at(i));
QCOMPARE(actualSupportedSettings.at(i), expectedSettings);
}
}
void tst_QCamera::testSupportedViewfinderResolutions_data()
{
- // see mockcameraviewfindersettingscontrol.h for expected values
+ // see mockcameracontrol.h for expected values
using SizeList = QList<QSize>;
ViewfinderSettingsBuilder builder;
@@ -1254,7 +1254,7 @@ void tst_QCamera::testSupportedViewfinderResolutions()
void tst_QCamera::testSupportedViewfinderFrameRateRanges_data()
{
- // see mockcameraviewfindersettingscontrol.h for expected values
+ // see mockcameracontrol.h for expected values
using RangeList = QList<QCamera::FrameRateRange>;
ViewfinderSettingsBuilder builder;
@@ -1333,7 +1333,7 @@ void tst_QCamera::testSupportedViewfinderFrameRateRanges()
void tst_QCamera::testSupportedViewfinderPixelFormats_data()
{
- // see mockcameraviewfindersettingscontrol.h for expected values
+ // see mockcameracontrol.h for expected values
using FormatList = QList<QVideoFrame::PixelFormat>;
ViewfinderSettingsBuilder builder;
diff --git a/tests/auto/unit/qcameraimagecapture/CMakeLists.txt b/tests/auto/unit/qcameraimagecapture/CMakeLists.txt
index 751b2b763..fc91a2561 100644
--- a/tests/auto/unit/qcameraimagecapture/CMakeLists.txt
+++ b/tests/auto/unit/qcameraimagecapture/CMakeLists.txt
@@ -13,7 +13,6 @@ qt_add_test(tst_qcameraimagecapture
../qmultimedia_common/mockcameraimagecapturecontrol.h
../qmultimedia_common/mockcameraimageprocessingcontrol.h
../qmultimedia_common/mockcameraservice.h
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
../qmultimedia_common/mockimageencodercontrol.h
../qmultimedia_common/mockmediaobject.h
../qmultimedia_common/mockmediaservice.h
diff --git a/tests/auto/unit/qcamerainfo/CMakeLists.txt b/tests/auto/unit/qcamerainfo/CMakeLists.txt
index 83d0c2b87..b3d8507da 100644
--- a/tests/auto/unit/qcamerainfo/CMakeLists.txt
+++ b/tests/auto/unit/qcamerainfo/CMakeLists.txt
@@ -13,7 +13,6 @@ qt_add_test(tst_qcamerainfo
../qmultimedia_common/mockcameraimagecapturecontrol.h
../qmultimedia_common/mockcameraimageprocessingcontrol.h
../qmultimedia_common/mockcameraservice.h
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
../qmultimedia_common/mockimageencodercontrol.h
../qmultimedia_common/mockmediaobject.h
../qmultimedia_common/mockmediaservice.h
diff --git a/tests/auto/unit/qcameraviewfinder/CMakeLists.txt b/tests/auto/unit/qcameraviewfinder/CMakeLists.txt
index 022019f27..d532ae9bd 100644
--- a/tests/auto/unit/qcameraviewfinder/CMakeLists.txt
+++ b/tests/auto/unit/qcameraviewfinder/CMakeLists.txt
@@ -13,7 +13,6 @@ qt_add_test(tst_qcameraviewfinder
../qmultimedia_common/mockcameraimagecapturecontrol.h
../qmultimedia_common/mockcameraimageprocessingcontrol.h
../qmultimedia_common/mockcameraservice.h
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
../qmultimedia_common/mockimageencodercontrol.h
../qmultimedia_common/mockmediaobject.h
../qmultimedia_common/mockmediaservice.h
diff --git a/tests/auto/unit/qcamerawidgets/CMakeLists.txt b/tests/auto/unit/qcamerawidgets/CMakeLists.txt
index 6b228bf7c..06de46b14 100644
--- a/tests/auto/unit/qcamerawidgets/CMakeLists.txt
+++ b/tests/auto/unit/qcamerawidgets/CMakeLists.txt
@@ -13,7 +13,6 @@ qt_add_test(tst_qcamerawidgets
../qmultimedia_common/mockcameraimagecapturecontrol.h
../qmultimedia_common/mockcameraimageprocessingcontrol.h
../qmultimedia_common/mockcameraservice.h
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
../qmultimedia_common/mockimageencodercontrol.h
../qmultimedia_common/mockmediaobject.h
../qmultimedia_common/mockmediaservice.h
diff --git a/tests/auto/unit/qdeclarativecamera/CMakeLists.txt b/tests/auto/unit/qdeclarativecamera/CMakeLists.txt
index 9eec6604c..ef69cecaa 100644
--- a/tests/auto/unit/qdeclarativecamera/CMakeLists.txt
+++ b/tests/auto/unit/qdeclarativecamera/CMakeLists.txt
@@ -15,7 +15,6 @@ qt_add_test(tst_qdeclarativecamera
../qmultimedia_common/mockcameraimagecapturecontrol.h
../qmultimedia_common/mockcameraimageprocessingcontrol.h
../qmultimedia_common/mockcameraservice.h
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
../qmultimedia_common/mockimageencodercontrol.h
../qmultimedia_common/mockmediaobject.h
../qmultimedia_common/mockmediaservice.h
diff --git a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml b/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
index 20cee5d2f..0841d4ec1 100644
--- a/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
+++ b/tests/auto/unit/qdeclarativecamera/tst_qdeclarativecamera.qml
@@ -141,7 +141,7 @@ TestCase {
}
function test_supportedViewfinderResolutions_data() {
- // see mockcameraviewfindersettingscontrol.h for expected values
+ // see mockcameracontrol.h for expected values
return [
{
@@ -229,7 +229,7 @@ TestCase {
}
function test_supportedViewfinderFrameRateRanges_data() {
- // see mockcameraviewfindersettingscontrol.h for expected values
+ // see mockcameracontrol.h for expected values
return [
{
tag: "all",
diff --git a/tests/auto/unit/qdeclarativemultimediaglobal/CMakeLists.txt b/tests/auto/unit/qdeclarativemultimediaglobal/CMakeLists.txt
index 5d7911dbe..0145c3608 100644
--- a/tests/auto/unit/qdeclarativemultimediaglobal/CMakeLists.txt
+++ b/tests/auto/unit/qdeclarativemultimediaglobal/CMakeLists.txt
@@ -15,7 +15,6 @@ qt_add_test(tst_qdeclarativemultimediaglobal
../qmultimedia_common/mockcameraimagecapturecontrol.h
../qmultimedia_common/mockcameraimageprocessingcontrol.h
../qmultimedia_common/mockcameraservice.h
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
../qmultimedia_common/mockimageencodercontrol.h
../qmultimedia_common/mockmediaobject.h
../qmultimedia_common/mockmediaservice.h
diff --git a/tests/auto/unit/qmultimedia_common/mockcamera.pri b/tests/auto/unit/qmultimedia_common/mockcamera.pri
index 0c439f5ab..5ec343a57 100644
--- a/tests/auto/unit/qmultimedia_common/mockcamera.pri
+++ b/tests/auto/unit/qmultimedia_common/mockcamera.pri
@@ -13,8 +13,7 @@ HEADERS *= \
../qmultimedia_common/mockcameracapturebuffercontrol.h \
../qmultimedia_common/mockimageencodercontrol.h \
../qmultimedia_common/mockcameracontrol.h \
- ../qmultimedia_common/mockvideodeviceselectorcontrol.h \
- ../qmultimedia_common/mockcameraviewfindersettingscontrol.h
+ ../qmultimedia_common/mockvideodeviceselectorcontrol.h
include(mockvideo.pri)
diff --git a/tests/auto/unit/qmultimedia_common/mockcameracontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracontrol.h
index fb686f92f..3c8172be4 100644
--- a/tests/auto/unit/qmultimedia_common/mockcameracontrol.h
+++ b/tests/auto/unit/qmultimedia_common/mockcameracontrol.h
@@ -44,6 +44,48 @@ public:
m_status(QCamera::UnloadedStatus),
m_propertyChangesSupported(false)
{
+ QCameraViewfinderSettings s;
+ s.setResolution(640, 480);
+ s.setMinimumFrameRate(30);
+ s.setMaximumFrameRate(30);
+ s.setPixelFormat(QVideoFrame::Format_NV12);
+ s.setPixelAspectRatio(1, 1);
+ supportedSettings.append(s);
+
+ s.setResolution(1280, 720);
+ s.setMinimumFrameRate(10);
+ s.setMaximumFrameRate(10);
+ s.setPixelFormat(QVideoFrame::Format_NV12);
+ s.setPixelAspectRatio(1, 1);
+ supportedSettings.append(s);
+
+ s.setResolution(1920, 1080);
+ s.setMinimumFrameRate(5);
+ s.setMaximumFrameRate(10);
+ s.setPixelFormat(QVideoFrame::Format_BGR32);
+ s.setPixelAspectRatio(2, 1);
+ supportedSettings.append(s);
+
+ s.setResolution(1280, 720);
+ s.setMinimumFrameRate(10);
+ s.setMaximumFrameRate(10);
+ s.setPixelFormat(QVideoFrame::Format_YV12);
+ s.setPixelAspectRatio(1, 1);
+ supportedSettings.append(s);
+
+ s.setResolution(1280, 720);
+ s.setMinimumFrameRate(30);
+ s.setMaximumFrameRate(30);
+ s.setPixelFormat(QVideoFrame::Format_YV12);
+ s.setPixelAspectRatio(1, 1);
+ supportedSettings.append(s);
+
+ s.setResolution(320, 240);
+ s.setMinimumFrameRate(30);
+ s.setMaximumFrameRate(30);
+ s.setPixelFormat(QVideoFrame::Format_NV12);
+ s.setPixelAspectRatio(1, 1);
+ supportedSettings.append(s);
}
~MockCameraControl() {}
@@ -155,6 +197,24 @@ public:
}
}
+ QCameraViewfinderSettings viewfinderSettings() const
+ {
+ return settings;
+ }
+
+ void setViewfinderSettings(const QCameraViewfinderSettings &s)
+ {
+ settings = s;
+ }
+
+ QList<QCameraViewfinderSettings> supportedViewfinderSettings() const
+ {
+ return supportedSettings;
+ }
+
+ QCameraViewfinderSettings settings;
+ QList<QCameraViewfinderSettings> supportedSettings;
+
/* helper method to emit the signal with LockChangeReason */
void setLockChangeReason (QCamera::LockChangeReason lockChangeReason)
{
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraservice.h b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
index 5d680a45c..2a83215ef 100644
--- a/tests/auto/unit/qmultimedia_common/mockcameraservice.h
+++ b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
@@ -41,7 +41,6 @@
#include "../qmultimedia_common/mockvideorenderercontrol.h"
#include "../qmultimedia_common/mockvideowindowcontrol.h"
#include "../qmultimedia_common/mockvideodeviceselectorcontrol.h"
-#include "../qmultimedia_common/mockcameraviewfindersettingscontrol.h"
class MockSimpleCameraService : public QMediaService
{
@@ -87,7 +86,6 @@ public:
rendererControl = new MockVideoRendererControl(this);
windowControl = new MockVideoWindowControl(this);
mockVideoDeviceSelectorControl = new MockVideoDeviceSelectorControl(this);
- mockViewfinderSettingsControl = new MockCameraViewfinderSettingsControl(this);
rendererRef = 0;
windowRef = 0;
}
@@ -135,10 +133,6 @@ public:
}
}
- if (qstrcmp(iid, QCameraViewfinderSettingsControl_iid) == 0) {
- return mockViewfinderSettingsControl;
- }
-
return 0;
}
@@ -160,7 +154,6 @@ public:
MockVideoRendererControl *rendererControl;
MockVideoWindowControl *windowControl;
MockVideoDeviceSelectorControl *mockVideoDeviceSelectorControl;
- MockCameraViewfinderSettingsControl *mockViewfinderSettingsControl;
int rendererRef;
int windowRef;
};
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h
deleted file mode 100644
index de334eb55..000000000
--- a/tests/auto/unit/qmultimedia_common/mockcameraviewfindersettingscontrol.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOCKCAMERAVIEWFINDERSETTINGSCONTROL_H
-#define MOCKCAMERAVIEWFINDERSETTINGSCONTROL_H
-
-#include "qcameraviewfindersettingscontrol.h"
-
-class MockCameraViewfinderSettingsControl : public QCameraViewfinderSettingsControl
-{
- Q_OBJECT
-public:
- MockCameraViewfinderSettingsControl(QObject *parent = 0):
- QCameraViewfinderSettingsControl(parent)
- {
- QCameraViewfinderSettings s;
- s.setResolution(640, 480);
- s.setMinimumFrameRate(30);
- s.setMaximumFrameRate(30);
- s.setPixelFormat(QVideoFrame::Format_NV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(1280, 720);
- s.setMinimumFrameRate(10);
- s.setMaximumFrameRate(10);
- s.setPixelFormat(QVideoFrame::Format_NV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(1920, 1080);
- s.setMinimumFrameRate(5);
- s.setMaximumFrameRate(10);
- s.setPixelFormat(QVideoFrame::Format_BGR32);
- s.setPixelAspectRatio(2, 1);
- supportedSettings.append(s);
-
- s.setResolution(1280, 720);
- s.setMinimumFrameRate(10);
- s.setMaximumFrameRate(10);
- s.setPixelFormat(QVideoFrame::Format_YV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(1280, 720);
- s.setMinimumFrameRate(30);
- s.setMaximumFrameRate(30);
- s.setPixelFormat(QVideoFrame::Format_YV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
-
- s.setResolution(320, 240);
- s.setMinimumFrameRate(30);
- s.setMaximumFrameRate(30);
- s.setPixelFormat(QVideoFrame::Format_NV12);
- s.setPixelAspectRatio(1, 1);
- supportedSettings.append(s);
- }
-
- ~MockCameraViewfinderSettingsControl() {}
-
- QCameraViewfinderSettings viewfinderSettings() const
- {
- return settings;
- }
-
- void setViewfinderSettings(const QCameraViewfinderSettings &s)
- {
- settings = s;
- }
-
- QList<QCameraViewfinderSettings> supportedViewfinderSettings() const
- {
- return supportedSettings;
- }
-
- QCameraViewfinderSettings settings;
- QList<QCameraViewfinderSettings> supportedSettings;
-};
-
-#endif // MOCKCAMERAVIEWFINDERSETTINGSCONTROL_H