summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-05-17 18:23:49 +0200
committerLars Knoll <lars.knoll@qt.io>2021-05-18 08:45:00 +0000
commit1955e9f3fb527a8e1a33f51e0a50b7627a1ac8fe (patch)
tree82d17a8167eb45b8410d96ee4c5d27730a26484e /src
parentb22138591fd65b012ae8267f053a64092a797737 (diff)
Merge the QPlatformCameraFocus class into QPlatformCamera
Adjust the backend API while we're at it, so that the base class does some of the state management and signal emissions. Slight cleanups of the code in the different backends. Change-Id: Ie246da060260c5aeb6af54e7414deb0395b0cdf1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/multimedia/qmldir1
-rw-r--r--src/multimedia/CMakeLists.txt6
-rw-r--r--src/multimedia/camera/qcamera.cpp53
-rw-r--r--src/multimedia/camera/qcamera_p.h5
-rw-r--r--src/multimedia/platform/android/mediacapture/qandroidcameracontrol.cpp178
-rw-r--r--src/multimedia/platform/android/mediacapture/qandroidcameracontrol_p.h21
-rw-r--r--src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol.cpp283
-rw-r--r--src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol_p.h113
-rw-r--r--src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp3
-rw-r--r--src/multimedia/platform/android/mediacapture/qandroidcamerasession_p.h3
-rw-r--r--src/multimedia/platform/darwin/camera/avfcamera.mm235
-rw-r--r--src/multimedia/platform/darwin/camera/avfcamera_p.h13
-rw-r--r--src/multimedia/platform/darwin/camera/avfcamerafocus.mm351
-rw-r--r--src/multimedia/platform/darwin/camera/avfcamerafocus_p.h103
-rw-r--r--src/multimedia/platform/darwin/camera/avfcameraservice.mm1
-rw-r--r--src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera.cpp54
-rw-r--r--src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera_p.h8
-rw-r--r--src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus.cpp144
-rw-r--r--src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus_p.h94
-rw-r--r--src/multimedia/platform/qplatformcamera.cpp50
-rw-r--r--src/multimedia/platform/qplatformcamera_p.h37
-rw-r--r--src/multimedia/platform/qplatformcamerafocus.cpp244
-rw-r--r--src/multimedia/platform/qplatformcamerafocus_p.h103
-rw-r--r--src/multimedia/platform/windows/mediacapture/qwindowscamera.cpp8
-rw-r--r--src/multimedia/platform/windows/mediacapture/qwindowscamera_p.h1
-rw-r--r--src/multimedia/platform/windows/mediacapture/qwindowscamerafocus.cpp90
-rw-r--r--src/multimedia/platform/windows/mediacapture/qwindowscamerafocus_p.h83
-rw-r--r--src/multimedia/platform/windows/mediacapture/qwindowscamerasession.cpp8
-rw-r--r--src/multimedia/platform/windows/mediacapture/qwindowscamerasession_p.h3
29 files changed, 583 insertions, 1713 deletions
diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir
index 387cb3c14..028587088 100644
--- a/src/imports/multimedia/qmldir
+++ b/src/imports/multimedia/qmldir
@@ -4,4 +4,3 @@ classname QMultimediaDeclarativeModule
typeinfo plugins.qmltypes
prefer :/qt-project.org/imports/QtMultimedia/
Video 5.0 Video.qml
-
diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt
index 3da633f8d..a8097ca4e 100644
--- a/src/multimedia/CMakeLists.txt
+++ b/src/multimedia/CMakeLists.txt
@@ -32,7 +32,6 @@ qt_internal_add_module(Multimedia
platform/qplatformaudiodecoder.cpp platform/qplatformaudiodecoder_p.h
platform/qplatformcamera.cpp platform/qplatformcamera_p.h
platform/qplatformcameraexposure.cpp platform/qplatformcameraexposure_p.h
- platform/qplatformcamerafocus.cpp platform/qplatformcamerafocus_p.h
platform/qplatformcameraimagecapture.cpp platform/qplatformcameraimagecapture_p.h
platform/qplatformcameraimageprocessing.cpp platform/qplatformcameraimageprocessing_p.h
platform/qplatformmediacapture.cpp platform/qplatformmediacapture_p.h
@@ -156,8 +155,6 @@ qt_internal_extend_target(Multimedia CONDITION WIN32
platform/windows/mediacapture/qwindowscamera.cpp
platform/windows/mediacapture/qwindowscameraexposure.cpp
platform/windows/mediacapture/qwindowscameraexposure_p.h
- platform/windows/mediacapture/qwindowscamerafocus.cpp
- platform/windows/mediacapture/qwindowscamerafocus_p.h
platform/windows/mediacapture/qwindowscameraimagecapture.cpp
platform/windows/mediacapture/qwindowscameraimagecapture_p.h
platform/windows/mediacapture/qwindowscameraimageprocessing.cpp
@@ -236,7 +233,6 @@ qt_internal_extend_target(Multimedia CONDITION QT_FEATURE_gstreamer
platform/gstreamer/mediacapture/qgstreamercamera.cpp platform/gstreamer/mediacapture/qgstreamercamera_p.h
platform/gstreamer/mediacapture/qgstreamercameraimageprocessing.cpp platform/gstreamer/mediacapture/qgstreamercameraimageprocessing_p.h
platform/gstreamer/mediacapture/qgstreamercameraexposure.cpp platform/gstreamer/mediacapture/qgstreamercameraexposure_p.h
- platform/gstreamer/mediacapture/qgstreamercamerafocus.cpp platform/gstreamer/mediacapture/qgstreamercamerafocus_p.h
platform/gstreamer/mediacapture/qgstreamermediacapture.cpp platform/gstreamer/mediacapture/qgstreamermediacapture_p.h
platform/gstreamer/mediacapture/qgstreamercameraimagecapture.cpp platform/gstreamer/mediacapture/qgstreamercameraimagecapture_p.h
platform/gstreamer/mediacapture/qgstreamermediaencoder.cpp platform/gstreamer/mediacapture/qgstreamermediaencoder_p.h
@@ -316,7 +312,6 @@ qt_internal_extend_target(Multimedia CONDITION ANDROID
platform/android/common/qandroidvideooutput.cpp platform/android/common/qandroidvideooutput_p.h
platform/android/mediacapture/qandroidcameracontrol.cpp platform/android/mediacapture/qandroidcameracontrol_p.h
platform/android/mediacapture/qandroidcameraexposurecontrol.cpp platform/android/mediacapture/qandroidcameraexposurecontrol_p.h
- platform/android/mediacapture/qandroidcamerafocuscontrol.cpp platform/android/mediacapture/qandroidcamerafocuscontrol_p.h
platform/android/mediacapture/qandroidcameraimagecapturecontrol.cpp platform/android/mediacapture/qandroidcameraimagecapturecontrol_p.h
platform/android/mediacapture/qandroidcameraimageprocessingcontrol.cpp platform/android/mediacapture/qandroidcameraimageprocessingcontrol_p.h
platform/android/mediacapture/qandroidcamerasession.cpp platform/android/mediacapture/qandroidcamerasession_p.h
@@ -410,7 +405,6 @@ qt_internal_extend_target(Multimedia CONDITION APPLE AND NOT TVOS AND NOT WATCHO
platform/darwin/camera/avfcamera.mm platform/darwin/camera/avfcamera_p.h
platform/darwin/camera/avfcameradebug_p.h
platform/darwin/camera/avfcameraexposure.mm platform/darwin/camera/avfcameraexposure_p.h
- platform/darwin/camera/avfcamerafocus.mm platform/darwin/camera/avfcamerafocus_p.h
platform/darwin/camera/avfcameraimageprocessing.mm platform/darwin/camera/avfcameraimageprocessing_p.h
platform/darwin/camera/avfcamerarenderer.mm platform/darwin/camera/avfcamerarenderer_p.h
platform/darwin/camera/avfcameraservice.mm platform/darwin/camera/avfcameraservice_p.h
diff --git a/src/multimedia/camera/qcamera.cpp b/src/multimedia/camera/qcamera.cpp
index 0e5f4878d..8202248d5 100644
--- a/src/multimedia/camera/qcamera.cpp
+++ b/src/multimedia/camera/qcamera.cpp
@@ -43,7 +43,6 @@
#include <qcamerainfo.h>
#include <private/qplatformcamera_p.h>
#include <private/qplatformcameraexposure_p.h>
-#include <private/qplatformcamerafocus_p.h>
#include <private/qplatformcameraimageprocessing_p.h>
#include <private/qplatformcameraimagecapture_p.h>
#include <private/qplatformmediaintegration_p.h>
@@ -128,15 +127,6 @@ void QCameraPrivate::init()
q->connect(control, SIGNAL(activeChanged(bool)), q, SIGNAL(activeChanged(bool)));
q->connect(control, SIGNAL(error(int,QString)), q, SLOT(_q_error(int,QString)));
- focusControl = control->focusControl();
-
- if (focusControl) {
- q->connect(focusControl, SIGNAL(minimumZoomFactorChanged(float)),
- q, SIGNAL(minimumZoomFactorChanged(float)));
- q->connect(focusControl, SIGNAL(maximumZoomFactorChanged(float)),
- q, SIGNAL(maximumZoomFactorChanged(float)));
- }
-
exposureControl = control->exposureControl();
if (exposureControl) {
q->connect(exposureControl, SIGNAL(actualValueChanged(int)),
@@ -480,15 +470,15 @@ void QCamera::setCameraFormat(const QCameraFormat &format)
QCamera::FocusMode QCamera::focusMode() const
{
Q_D(const QCamera);
- return d->focusControl ? d->focusControl->focusMode() : QCamera::FocusModeAuto;
+ return d->control ? d->control->focusMode() : QCamera::FocusModeAuto;
}
void QCamera::setFocusMode(QCamera::FocusMode mode)
{
Q_D(QCamera);
- if (!d->focusControl || d->focusControl->focusMode() == mode)
+ if (!d->control || d->control->focusMode() == mode)
return;
- d->focusControl->setFocusMode(mode);
+ d->control->setFocusMode(mode);
emit focusModeChanged();
}
@@ -499,7 +489,7 @@ void QCamera::setFocusMode(QCamera::FocusMode mode)
bool QCamera::isFocusModeSupported(FocusMode mode) const
{
Q_D(const QCamera);
- return d->focusControl ? d->focusControl->isFocusModeSupported(mode) : false;
+ return d->control ? d->control->isFocusModeSupported(mode) : false;
}
/*!
@@ -508,7 +498,7 @@ bool QCamera::isFocusModeSupported(FocusMode mode) const
QPointF QCamera::focusPoint() const
{
Q_D(const QCamera);
- return d->focusControl ? d->focusControl->focusPoint() : QPointF(-1., -1.);
+ return d->control ? d->control->focusPoint() : QPointF(-1., -1.);
}
@@ -524,23 +514,21 @@ QPointF QCamera::focusPoint() const
QPointF QCamera::customFocusPoint() const
{
Q_D(const QCamera);
- return d->customFocusPoint;
+ return d->control ? d->control->customFocusPoint() : QPointF{-1., -1.};
}
void QCamera::setCustomFocusPoint(const QPointF &point)
{
Q_D(QCamera);
- if (!d->focusControl || d->customFocusPoint == point)
+ if (!d->control)
return;
- d->customFocusPoint = point;
- d->focusControl->setCustomFocusPoint(point);
- Q_EMIT customFocusPointChanged();
+ d->control->setCustomFocusPoint(point);
}
bool QCamera::isCustomFocusPointSupported() const
{
Q_D(const QCamera);
- return d->focusControl ? d->focusControl->isCustomFocusPointSupported() : false;
+ return d->control ? d->control->isCustomFocusPointSupported() : false;
}
/*!
@@ -553,15 +541,15 @@ bool QCamera::isCustomFocusPointSupported() const
*/
void QCamera::setFocusDistance(float d)
{
- if (!d_func()->focusControl || focusMode() != FocusModeManual)
+ if (!d_func()->control || focusMode() != FocusModeManual)
return;
- d_func()->focusControl->setFocusDistance(d);
+ d_func()->control->setFocusDistance(d);
}
float QCamera::focusDistance() const
{
- if (d_func()->focusControl)
- return d_func()->focusControl->focusDistance();
+ if (d_func()->control && focusMode() == FocusModeManual)
+ return d_func()->control->focusDistance();
return 0.;
}
@@ -574,7 +562,7 @@ float QCamera::focusDistance() const
float QCamera::maximumZoomFactor() const
{
Q_D(const QCamera);
- return d->focusControl ? d->focusControl->zoomFactorRange().max : 1.;
+ return d->control ? d->control->maxZoomFactor() : 1.;
}
/*!
@@ -586,7 +574,7 @@ float QCamera::maximumZoomFactor() const
float QCamera::minimumZoomFactor() const
{
Q_D(const QCamera);
- return d->focusControl ? d->focusControl->zoomFactorRange().min : 1.;
+ return d->control ? d->control->minZoomFactor() : 1.;
}
/*!
@@ -595,7 +583,8 @@ float QCamera::minimumZoomFactor() const
*/
float QCamera::zoomFactor() const
{
- return d_func()->zoomFactor;
+ Q_D(const QCamera);
+ return d->control ? d->control->zoomFactor() : 1.;
}
void QCamera::setZoomFactor(float factor)
@@ -616,12 +605,10 @@ void QCamera::zoomTo(float factor, float rate)
rate = 0.;
Q_D(QCamera);
- if (!d->focusControl)
+ if (!d->control)
return;
- factor = qBound(minimumZoomFactor(), factor, maximumZoomFactor());
- d->zoomFactor = factor;
- d->focusControl->zoomTo(factor, rate);
- emit zoomFactorChanged(factor);
+ factor = qBound(d->control->minZoomFactor(), factor, d->control->maxZoomFactor());
+ d->control->zoomTo(factor, rate);
}
/*!
diff --git a/src/multimedia/camera/qcamera_p.h b/src/multimedia/camera/qcamera_p.h
index ee11bc946..61f4dfe1b 100644
--- a/src/multimedia/camera/qcamera_p.h
+++ b/src/multimedia/camera/qcamera_p.h
@@ -59,7 +59,6 @@
QT_BEGIN_NAMESPACE
class QPlatformCamera;
-class QPlatformCameraFocus;
class QPlatformCameraExposure;
class QPlatformCameraImageProcessing;
class QPlatformMediaCaptureSession;
@@ -86,10 +85,6 @@ public:
QCameraInfo cameraInfo;
QCameraFormat cameraFormat;
- QPlatformCameraFocus *focusControl = nullptr;
- float zoomFactor = 1.;
- QPointF customFocusPoint{-1, -1};
-
QPlatformCameraExposure *exposureControl = nullptr;
QPlatformCameraImageProcessing *imageControl = nullptr;
diff --git a/src/multimedia/platform/android/mediacapture/qandroidcameracontrol.cpp b/src/multimedia/platform/android/mediacapture/qandroidcameracontrol.cpp
index cd7e80411..a8eb9ec16 100644
--- a/src/multimedia/platform/android/mediacapture/qandroidcameracontrol.cpp
+++ b/src/multimedia/platform/android/mediacapture/qandroidcameracontrol.cpp
@@ -40,13 +40,13 @@
#include "qandroidcameracontrol_p.h"
#include "qandroidcamerasession_p.h"
#include "qandroidcameraexposurecontrol_p.h"
-#include "qandroidcamerafocuscontrol_p.h"
#include "qandroidcameraimageprocessingcontrol_p.h"
#include "qandroidcameravideorenderercontrol_p.h"
#include "qandroidcaptureservice_p.h"
#include <qmediadevices.h>
#include <qcamerainfo.h>
#include <qtimer.h>
+#include "qandroidmultimediautils_p.h"
QT_BEGIN_NAMESPACE
@@ -119,11 +119,6 @@ void QAndroidCameraControl::setCaptureSession(QPlatformMediaCaptureSession *sess
}
-QPlatformCameraFocus *QAndroidCameraControl::focusControl()
-{
- return m_cameraSession->focusControl();
-}
-
QPlatformCameraExposure *QAndroidCameraControl::exposureControl()
{
return m_cameraSession->exposureControl();
@@ -134,4 +129,175 @@ QPlatformCameraImageProcessing *QAndroidCameraControl::imageProcessingControl()
return m_cameraSession->imageProcessingControl();
}
+
+void QAndroidCameraControl::setFocusMode(QCamera::FocusMode mode)
+{
+ if (!m_cameraSession->camera())
+ return;
+
+ if (isFocusModeSupported(mode)) {
+ QString focusMode;
+
+ switch (mode) {
+ case QCamera::FocusModeHyperfocal:
+ focusMode = QLatin1String("edof");
+ break;
+ case QCamera::FocusModeInfinity: // not 100%, but close
+ focusMode = QLatin1String("infinity");
+ break;
+ case QCamera::FocusModeManual:
+ focusMode = QLatin1String("fixed");
+ break;
+ case QCamera::FocusModeAutoNear:
+ focusMode = QLatin1String("macro");
+ break;
+ case QCamera::FocusModeAuto:
+ case QCamera::FocusModeAutoFar:
+ if (1) { // ###?
+ focusMode = QLatin1String("continuous-video");
+ } else {
+ focusMode = QLatin1String("continuous-picture");
+ }
+ break;
+ }
+
+ m_cameraSession->camera()->setFocusMode(focusMode);
+
+ // reset focus position
+ m_cameraSession->camera()->cancelAutoFocus();
+
+ focusModeChanged(mode);
+ }
+}
+
+bool QAndroidCameraControl::isFocusModeSupported(QCamera::FocusMode mode) const
+{
+ return m_cameraSession->camera() ? m_supportedFocusModes.contains(mode) : false;
+}
+
+void QAndroidCameraControl::onCameraOpened()
+{
+ connect(m_cameraSession->camera(), SIGNAL(previewSizeChanged()),
+ this, SLOT(setCameraFocusArea()));
+
+ m_supportedFocusModes.clear();
+ m_continuousPictureFocusSupported = false;
+ m_continuousVideoFocusSupported = false;
+ m_focusPointSupported = false;
+
+ QStringList focusModes = m_cameraSession->camera()->getSupportedFocusModes();
+ for (int i = 0; i < focusModes.size(); ++i) {
+ const QString &focusMode = focusModes.at(i);
+ if (focusMode == QLatin1String("continuous-picture")) {
+ m_supportedFocusModes << QCamera::FocusModeAuto;
+ m_continuousPictureFocusSupported = true;
+ } else if (focusMode == QLatin1String("continuous-video")) {
+ m_supportedFocusModes << QCamera::FocusModeAuto;
+ m_continuousVideoFocusSupported = true;
+ } else if (focusMode == QLatin1String("edof")) {
+ m_supportedFocusModes << QCamera::FocusModeHyperfocal;
+ } else if (focusMode == QLatin1String("fixed")) {
+ m_supportedFocusModes << QCamera::FocusModeManual;
+ } else if (focusMode == QLatin1String("infinity")) {
+ m_supportedFocusModes << QCamera::FocusModeInfinity;
+ } else if (focusMode == QLatin1String("macro")) {
+ m_supportedFocusModes << QCamera::FocusModeAutoNear;
+ }
+ }
+
+ if (m_cameraSession->camera()->getMaxNumFocusAreas() > 0)
+ m_focusPointSupported = true;
+
+ auto m = focusMode();
+ if (!m_supportedFocusModes.contains(m))
+ m = QCamera::FocusModeAuto;
+
+ setFocusMode(m);
+ setCustomFocusPoint(focusPoint());
+
+ if (m_cameraSession->camera()->isZoomSupported()) {
+ m_zoomRatios = m_cameraSession->camera()->getZoomRatios();
+ qreal maxZoom = m_zoomRatios.last() / qreal(100);
+ if (m_maximumZoom != maxZoom) {
+ m_maximumZoom = maxZoom;
+ }
+ zoomTo(1, -1);
+ } else {
+ m_zoomRatios.clear();
+ m_maximumZoom = 1.0;
+ }
+}
+
+//void QAndroidCameraFocusControl::onCameraCaptureModeChanged()
+//{
+// if (m_session->camera() && m_focusMode == QCamera::FocusModeAudio) {
+// QString focusMode;
+// if ((m_session->captureMode().testFlag(QCamera::CaptureVideo) && m_continuousVideoFocusSupported)
+// || !m_continuousPictureFocusSupported) {
+// focusMode = QLatin1String("continuous-video");
+// } else {
+// focusMode = QLatin1String("continuous-picture");
+// }
+// m_session->camera()->setFocusMode(focusMode);
+// m_session->camera()->cancelAutoFocus();
+// }
+//}
+
+static QRect adjustedArea(const QRectF &area)
+{
+ // Qt maps focus points in the range (0.0, 0.0) -> (1.0, 1.0)
+ // Android maps focus points in the range (-1000, -1000) -> (1000, 1000)
+ // Converts an area in Qt coordinates to Android coordinates
+ return QRect(-1000 + qRound(area.x() * 2000),
+ -1000 + qRound(area.y() * 2000),
+ qRound(area.width() * 2000),
+ qRound(area.height() * 2000))
+ .intersected(QRect(-1000, -1000, 2000, 2000));
+}
+
+void QAndroidCameraControl::setCameraFocusArea()
+{
+ QList<QRect> areas;
+ auto focusPoint = customFocusPoint();
+ if (QRectF(0., 0., 1., 1.).contains(focusPoint)) {
+ // in FocusPointAuto mode, leave the area list empty
+ // to let the driver choose the focus point.
+ QSize viewportSize = m_cameraSession->camera()->previewSize();
+
+ if (!viewportSize.isValid())
+ return;
+
+ // Set up a 50x50 pixel focus area around the focal point
+ QSizeF focusSize(50.f / viewportSize.width(), 50.f / viewportSize.height());
+ float x = qBound(qreal(0),
+ focusPoint.x() - (focusSize.width() / 2),
+ 1.f - focusSize.width());
+ float y = qBound(qreal(0),
+ focusPoint.y() - (focusSize.height() / 2),
+ 1.f - focusSize.height());
+
+ QRectF area(QPointF(x, y), focusSize);
+
+ areas.append(adjustedArea(area));
+ }
+ m_cameraSession->camera()->setFocusAreas(areas);
+}
+
+void QAndroidCameraControl::zoomTo(float factor, float rate)
+{
+ Q_UNUSED(rate);
+
+ if (zoomFactor() == factor)
+ return;
+
+ if (!m_cameraSession->camera())
+ return;
+
+ factor = qBound(qreal(1), factor, maxZoomFactor());
+ int validZoomIndex = qt_findClosestValue(m_zoomRatios, qRound(factor * 100));
+ float newZoom = m_zoomRatios.at(validZoomIndex) / qreal(100);
+ m_cameraSession->camera()->setZoom(validZoomIndex);
+ zoomFactorChanged(newZoom);
+}
+
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/android/mediacapture/qandroidcameracontrol_p.h b/src/multimedia/platform/android/mediacapture/qandroidcameracontrol_p.h
index 3c22039a3..1c9927dc2 100644
--- a/src/multimedia/platform/android/mediacapture/qandroidcameracontrol_p.h
+++ b/src/multimedia/platform/android/mediacapture/qandroidcameracontrol_p.h
@@ -76,16 +76,33 @@ public:
void setCaptureSession(QPlatformMediaCaptureSession *session) override;
- QPlatformCameraFocus *focusControl() override;
QPlatformCameraExposure *exposureControl() override;
QPlatformCameraImageProcessing *imageProcessingControl() override;
+ void setFocusMode(QCamera::FocusMode mode) override;
+ bool isFocusModeSupported(QCamera::FocusMode mode) const override;
+
+ void zoomTo(float factor, float rate) override;
+
+private Q_SLOTS:
+ void onCameraOpened();
+ void setCameraFocusArea();
+
private:
QAndroidCameraSession *m_cameraSession = nullptr;
QAndroidCaptureService *m_service = nullptr;
- QTimer *m_recalculateTimer;
+ QTimer *m_recalculateTimer = nullptr;
+
+ QList<QCamera::FocusMode> m_supportedFocusModes;
+ bool m_continuousPictureFocusSupported = false;
+ bool m_continuousVideoFocusSupported = false;
+ bool m_focusPointSupported = false;
+
+ float m_maximumZoom;
+ QList<int> m_zoomRatios;
};
+
QT_END_NAMESPACE
#endif // QANDROIDCAMERACONTROL_H
diff --git a/src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol.cpp b/src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol.cpp
deleted file mode 100644
index d95941430..000000000
--- a/src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qandroidcamerafocuscontrol_p.h"
-
-#include "qandroidcamerasession_p.h"
-#include "androidcamera_p.h"
-
-#include "qandroidmultimediautils_p.h"
-#include <qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-static QRect adjustedArea(const QRectF &area)
-{
- // Qt maps focus points in the range (0.0, 0.0) -> (1.0, 1.0)
- // Android maps focus points in the range (-1000, -1000) -> (1000, 1000)
- // Converts an area in Qt coordinates to Android coordinates
- return QRect(-1000 + qRound(area.x() * 2000),
- -1000 + qRound(area.y() * 2000),
- qRound(area.width() * 2000),
- qRound(area.height() * 2000))
- .intersected(QRect(-1000, -1000, 2000, 2000));
-}
-
-QAndroidCameraFocusControl::QAndroidCameraFocusControl(QAndroidCameraSession *session)
- : QPlatformCameraFocus()
- , m_session(session)
- , m_focusMode(QCamera::FocusModeAuto)
- , m_focusPoint(0.5, 0.5)
- , m_continuousPictureFocusSupported(false)
- , m_continuousVideoFocusSupported(false)
-{
- connect(m_session, SIGNAL(opened()),
- this, SLOT(onCameraOpened()));
-}
-
-QCamera::FocusMode QAndroidCameraFocusControl::focusMode() const
-{
- return m_focusMode;
-}
-
-void QAndroidCameraFocusControl::setFocusMode(QCamera::FocusMode mode)
-{
- if (!m_session->camera()) {
- setFocusModeHelper(mode);
- return;
- }
-
- if (isFocusModeSupported(mode)) {
- QString focusMode;
-
- switch (mode) {
- case QCamera::FocusModeHyperfocal:
- focusMode = QLatin1String("edof");
- break;
- case QCamera::FocusModeInfinity: // not 100%, but close
- focusMode = QLatin1String("infinity");
- break;
- case QCamera::FocusModeManual:
- focusMode = QLatin1String("fixed");
- break;
- case QCamera::FocusModeAutoNear:
- focusMode = QLatin1String("macro");
- break;
- case QCamera::FocusModeAuto:
- case QCamera::FocusModeAutoFar:
- if (1) { // ###?
- focusMode = QLatin1String("continuous-video");
- } else {
- focusMode = QLatin1String("continuous-picture");
- }
- break;
- }
-
- m_session->camera()->setFocusMode(focusMode);
-
- // reset focus position
- m_session->camera()->cancelAutoFocus();
-
- setFocusModeHelper(mode);
- }
-}
-
-bool QAndroidCameraFocusControl::isFocusModeSupported(QCamera::FocusMode mode) const
-{
- return m_session->camera() ? m_supportedFocusModes.contains(mode) : false;
-}
-
-bool QAndroidCameraFocusControl::isCustomFocusPointSupported() const
-{
- return m_focusPointSupported;
-}
-
-QPointF QAndroidCameraFocusControl::focusPoint() const
-{
- return m_focusPoint;
-}
-
-void QAndroidCameraFocusControl::setCustomFocusPoint(const QPointF &point)
-{
- if (m_focusPoint != point) {
- m_focusPoint = point;
- emit customFocusPointChanged(m_focusPoint);
- }
-
- if (m_session->camera())
- setCameraFocusArea();
-}
-
-void QAndroidCameraFocusControl::onCameraOpened()
-{
- connect(m_session->camera(), SIGNAL(previewSizeChanged()),
- this, SLOT(onViewportSizeChanged()));
- connect(m_session->camera(), SIGNAL(autoFocusStarted()),
- this, SLOT(onAutoFocusStarted()));
- connect(m_session->camera(), SIGNAL(autoFocusComplete(bool)),
- this, SLOT(onAutoFocusComplete(bool)));
-
- m_supportedFocusModes.clear();
- m_continuousPictureFocusSupported = false;
- m_continuousVideoFocusSupported = false;
- m_focusPointSupported = false;
-
- QStringList focusModes = m_session->camera()->getSupportedFocusModes();
- for (int i = 0; i < focusModes.size(); ++i) {
- const QString &focusMode = focusModes.at(i);
- if (focusMode == QLatin1String("continuous-picture")) {
- m_supportedFocusModes << QCamera::FocusModeAuto;
- m_continuousPictureFocusSupported = true;
- } else if (focusMode == QLatin1String("continuous-video")) {
- m_supportedFocusModes << QCamera::FocusModeAuto;
- m_continuousVideoFocusSupported = true;
- } else if (focusMode == QLatin1String("edof")) {
- m_supportedFocusModes << QCamera::FocusModeHyperfocal;
- } else if (focusMode == QLatin1String("fixed")) {
- m_supportedFocusModes << QCamera::FocusModeManual;
- } else if (focusMode == QLatin1String("infinity")) {
- m_supportedFocusModes << QCamera::FocusModeInfinity;
- } else if (focusMode == QLatin1String("macro")) {
- m_supportedFocusModes << QCamera::FocusModeAutoNear;
- }
- }
-
- if (m_session->camera()->getMaxNumFocusAreas() > 0)
- m_focusPointSupported = true;
-
- if (!m_supportedFocusModes.contains(m_focusMode))
- setFocusModeHelper(QCamera::FocusModeAuto);
-
- setFocusMode(m_focusMode);
- setCustomFocusPoint(m_focusPoint);
-
- if (m_session->camera()->isZoomSupported()) {
- m_zoomRatios = m_session->camera()->getZoomRatios();
- qreal maxZoom = m_zoomRatios.last() / qreal(100);
- if (m_maximumZoom != maxZoom) {
- m_maximumZoom = maxZoom;
- }
- zoomTo(1, -1);
- } else {
- m_zoomRatios.clear();
- m_maximumZoom = 1.0;
- }
-}
-
-void QAndroidCameraFocusControl::setCameraFocusArea()
-{
- QList<QRect> areas;
- if (QRectF(0., 0., 1., 1.).contains(m_focusPoint)) {
- // in FocusPointAuto mode, leave the area list empty
- // to let the driver choose the focus point.
- QSize viewportSize = m_session->camera()->previewSize();
-
- if (!viewportSize.isValid())
- return;
-
- // Set up a 50x50 pixel focus area around the focal point
- QSizeF focusSize(50.f / viewportSize.width(), 50.f / viewportSize.height());
- float x = qBound(qreal(0),
- m_focusPoint.x() - (focusSize.width() / 2),
- 1.f - focusSize.width());
- float y = qBound(qreal(0),
- m_focusPoint.y() - (focusSize.height() / 2),
- 1.f - focusSize.height());
-
- QRectF area(QPointF(x, y), focusSize);
-
- areas.append(adjustedArea(area));
- }
- m_session->camera()->setFocusAreas(areas);
-}
-
-void QAndroidCameraFocusControl::onViewportSizeChanged()
-{
- setCameraFocusArea();
-}
-
-void QAndroidCameraFocusControl::onCameraCaptureModeChanged()
-{
-// if (m_session->camera() && m_focusMode == QCamera::FocusModeAudio) {
-// QString focusMode;
-// if ((m_session->captureMode().testFlag(QCamera::CaptureVideo) && m_continuousVideoFocusSupported)
-// || !m_continuousPictureFocusSupported) {
-// focusMode = QLatin1String("continuous-video");
-// } else {
-// focusMode = QLatin1String("continuous-picture");
-// }
-// m_session->camera()->setFocusMode(focusMode);
-// m_session->camera()->cancelAutoFocus();
-// }
-}
-
-void QAndroidCameraFocusControl::onAutoFocusStarted()
-{
-}
-
-void QAndroidCameraFocusControl::onAutoFocusComplete(bool /*success*/)
-{
-}
-
-
-QAndroidCameraFocusControl::ZoomRange QAndroidCameraFocusControl::zoomFactorRange() const
-{
- return { 1., m_maximumZoom };
-}
-
-void QAndroidCameraFocusControl::zoomTo(float factor, float rate)
-{
- Q_UNUSED(rate);
-
- if (!qFuzzyCompare(m_requestedZoom, factor)) {
- m_requestedZoom = factor;
- }
-
- if (m_session->camera()) {
- factor = qBound(qreal(1), factor, m_maximumZoom);
- int validZoomIndex = qt_findClosestValue(m_zoomRatios, qRound(factor * 100));
- float newZoom = m_zoomRatios.at(validZoomIndex) / qreal(100);
- if (!qFuzzyCompare(m_currentZoom, newZoom)) {
- m_session->camera()->setZoom(validZoomIndex);
- m_currentZoom = newZoom;
- }
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol_p.h b/src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol_p.h
deleted file mode 100644
index ca9e23725..000000000
--- a/src/multimedia/platform/android/mediacapture/qandroidcamerafocuscontrol_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QANDROIDCAMERAFOCUSCONTROL_H
-#define QANDROIDCAMERAFOCUSCONTROL_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qplatformcamerafocus_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QAndroidCameraSession;
-
-class QAndroidCameraFocusControl : public QPlatformCameraFocus
-{
- Q_OBJECT
-public:
- explicit QAndroidCameraFocusControl(QAndroidCameraSession *session);
-
- QCamera::FocusMode focusMode() const override;
- void setFocusMode(QCamera::FocusMode mode) override;
- bool isFocusModeSupported(QCamera::FocusMode mode) const override;
-
- bool isCustomFocusPointSupported() const override;
- QPointF focusPoint() const override;
- void setCustomFocusPoint(const QPointF &point) override;
-
- ZoomRange zoomFactorRange() const override;
- void zoomTo(float newZoomFactor, float rate) override;
-
-private Q_SLOTS:
- void onCameraOpened();
- void onViewportSizeChanged();
- void onCameraCaptureModeChanged();
- void onAutoFocusStarted();
- void onAutoFocusComplete(bool success);
-
-private:
- inline void setFocusModeHelper(QCamera::FocusMode mode)
- {
- if (m_focusMode != mode) {
- m_focusMode = mode;
- emit focusModeChanged(mode);
- }
- }
-
- void setCameraFocusArea();
-
- QAndroidCameraSession *m_session;
-
- QCamera::FocusMode m_focusMode;
- QPointF m_focusPoint;
-
- QList<QCamera::FocusMode> m_supportedFocusModes;
- bool m_continuousPictureFocusSupported;
- bool m_continuousVideoFocusSupported;
- bool m_focusPointSupported = false;
-
- float m_maximumZoom;
- QList<int> m_zoomRatios;
- float m_requestedZoom;
- float m_currentZoom;
-};
-
-QT_END_NAMESPACE
-
-#endif // QANDROIDCAMERAFOCUSCONTROL_H
diff --git a/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp b/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp
index a72d4803c..81e208a2a 100644
--- a/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp
+++ b/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp
@@ -46,7 +46,6 @@
#include "qandroidmultimediautils_p.h"
#include "qandroidcameravideorenderercontrol_p.h"
#include "qandroidcameraexposurecontrol_p.h"
-#include "qandroidcamerafocuscontrol_p.h"
#include "qandroidcameraimageprocessingcontrol_p.h"
#include <qvideosink.h>
#include <QtConcurrent/qtconcurrentrun.h>
@@ -81,7 +80,6 @@ QAndroidCameraSession::QAndroidCameraSession(QObject *parent)
AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM));
m_cameraExposureControl = new QAndroidCameraExposureControl(this);
- m_cameraFocusControl = new QAndroidCameraFocusControl(this);
m_cameraImageProcessingControl = new QAndroidCameraImageProcessingControl(this);
if (qApp) {
@@ -93,7 +91,6 @@ QAndroidCameraSession::QAndroidCameraSession(QObject *parent)
QAndroidCameraSession::~QAndroidCameraSession()
{
delete m_cameraExposureControl;
- delete m_cameraFocusControl;
delete m_cameraImageProcessingControl;
delete m_renderer;
diff --git a/src/multimedia/platform/android/mediacapture/qandroidcamerasession_p.h b/src/multimedia/platform/android/mediacapture/qandroidcamerasession_p.h
index 5bace963f..69a2d8864 100644
--- a/src/multimedia/platform/android/mediacapture/qandroidcamerasession_p.h
+++ b/src/multimedia/platform/android/mediacapture/qandroidcamerasession_p.h
@@ -64,7 +64,6 @@ QT_BEGIN_NAMESPACE
class QAndroidVideoOutput;
class QAndroidCameraExposureControl;
-class QAndroidCameraFocusControl;
class QAndroidCameraImageProcessingControl;
class QAndroidCameraVideoRendererControl;
class QVideoSink;
@@ -113,7 +112,6 @@ public:
void setPreviewCallback(PreviewCallback *callback);
bool requestRecordingPermission();
- QAndroidCameraFocusControl *focusControl() { return m_cameraFocusControl; }
QAndroidCameraExposureControl *exposureControl() { return m_cameraExposureControl; }
QAndroidCameraImageProcessingControl *imageProcessingControl() { return m_cameraImageProcessingControl; }
@@ -183,7 +181,6 @@ private:
QAndroidCameraVideoRendererControl *m_renderer = nullptr;
QAndroidCameraExposureControl *m_cameraExposureControl;
- QAndroidCameraFocusControl *m_cameraFocusControl;
QAndroidCameraImageProcessingControl *m_cameraImageProcessingControl;
QImageEncoderSettings m_requestedImageSettings;
diff --git a/src/multimedia/platform/darwin/camera/avfcamera.mm b/src/multimedia/platform/darwin/camera/avfcamera.mm
index 52baadc31..b780e207a 100644
--- a/src/multimedia/platform/darwin/camera/avfcamera.mm
+++ b/src/multimedia/platform/darwin/camera/avfcamera.mm
@@ -44,7 +44,6 @@
#include "avfcamerautility_p.h"
#include "avfcamerarenderer_p.h"
#include "avfcameraexposure_p.h"
-#include "avfcamerafocus_p.h"
#include "avfcameraimageprocessing_p.h"
#include <qmediacapturesession.h>
@@ -57,7 +56,6 @@ AVFCamera::AVFCamera(QCamera *camera)
{
Q_ASSERT(camera);
- m_cameraFocusControl = new AVFCameraFocus(this);
m_cameraImageProcessingControl = new AVFCameraImageProcessing(this);
m_cameraExposureControl = nullptr;
#ifdef Q_OS_IOS
@@ -67,7 +65,6 @@ AVFCamera::AVFCamera(QCamera *camera)
AVFCamera::~AVFCamera()
{
- delete m_cameraFocusControl;
delete m_cameraExposureControl;
delete m_cameraImageProcessingControl;
}
@@ -90,6 +87,8 @@ void AVFCamera::setActive(bool active)
Q_EMIT activeChanged(m_active);
updateStatus();
+ if (active)
+ updateCameraConfiguration();
}
QCamera::Status AVFCamera::status() const
@@ -166,11 +165,6 @@ AVCaptureDevice *AVFCamera::device() const
return device;
}
-QPlatformCameraFocus *AVFCamera::focusControl()
-{
- return m_cameraFocusControl;
-}
-
QPlatformCameraExposure *AVFCamera::exposureControl()
{
return m_cameraExposureControl;
@@ -181,4 +175,229 @@ QPlatformCameraImageProcessing *AVFCamera::imageProcessingControl()
return m_cameraImageProcessingControl;
}
+#ifdef Q_OS_IOS
+namespace
+{
+
+bool qt_focus_mode_supported(QCamera::FocusMode mode)
+{
+ // Check if QCamera::FocusMode has counterpart in AVFoundation.
+
+ // AVFoundation has 'Manual', 'Auto' and 'Continuous',
+ // where 'Manual' is actually 'Locked' + writable property 'lensPosition'.
+ return mode == QCamera::FocusModeAuto
+ || mode == QCamera::FocusModeManual;
+}
+
+AVCaptureFocusMode avf_focus_mode(QCamera::FocusMode requestedMode)
+{
+ switch (requestedMode) {
+ case QCamera::FocusModeHyperfocal:
+ case QCamera::FocusModeInfinity:
+ case QCamera::FocusModeManual:
+ return AVCaptureFocusModeLocked;
+ default:
+ return AVCaptureFocusModeContinuousAutoFocus;
+ }
+
+}
+
+}
+#endif
+
+void AVFCamera::setFocusMode(QCamera::FocusMode mode)
+{
+#ifdef Q_OS_IOS
+ if (focusMode() == mode)
+ return;
+
+ AVCaptureDevice *captureDevice = device();
+ if (!captureDevice) {
+ if (qt_focus_mode_supported(mode)) {
+ focusModeChanged(mode);
+ } else {
+ qDebugCamera() << Q_FUNC_INFO
+ << "focus mode not supported";
+ }
+ return;
+ }
+
+ if (isFocusModeSupported(mode)) {
+ const AVFConfigurationLock lock(captureDevice);
+ if (!lock) {
+ qDebugCamera() << Q_FUNC_INFO
+ << "failed to lock for configuration";
+ return;
+ }
+
+ captureDevice.focusMode = avf_focus_mode(mode);
+ m_focusMode = mode;
+ } else {
+ qDebugCamera() << Q_FUNC_INFO << "focus mode not supported";
+ return;
+ }
+
+ Q_EMIT focusModeChanged(m_focusMode);
+#else
+ Q_UNUSED(mode);
+#endif
+}
+
+bool AVFCamera::isFocusModeSupported(QCamera::FocusMode mode) const
+{
+#ifdef Q_OS_IOS
+ AVCaptureDevice *captureDevice = device();
+ if (captureDevice) {
+ AVCaptureFocusMode avMode = avf_focus_mode(mode);
+ switch (mode) {
+ case QCamera::FocusModeAuto:
+ case QCamera::FocusModeHyperfocal:
+ case QCamera::FocusModeInfinity:
+ case QCamera::FocusModeManual:
+ return [captureDevice isFocusModeSupported:avMode];
+ case QCamera::FocusModeAutoNear:
+ Q_FALLTHROUGH();
+ case QCamera::FocusModeAutoFar:
+ return captureDevice.autoFocusRangeRestrictionSupported
+ && [captureDevice isFocusModeSupported:avMode];
+ }
+ }
+#endif
+ return mode == QCamera::FocusModeAuto; // stupid builtin webcam doesn't do any focus handling, but hey it's usually focused :)
+}
+
+void AVFCamera::setCustomFocusPoint(const QPointF &point)
+{
+ if (customFocusPoint() == point)
+ return;
+
+ if (!QRectF(0.f, 0.f, 1.f, 1.f).contains(point)) {
+ // ### release custom focus point, tell the camera to focus where it wants...
+ qDebugCamera() << Q_FUNC_INFO << "invalid focus point (out of range)";
+ return;
+ }
+
+ AVCaptureDevice *captureDevice = device();
+ if (!captureDevice)
+ return;
+
+ if ([captureDevice isFocusPointOfInterestSupported]) {
+ const AVFConfigurationLock lock(captureDevice);
+ if (!lock) {
+ qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
+ return;
+ }
+
+ const CGPoint focusPOI = CGPointMake(point.x(), point.y());
+ [captureDevice setFocusPointOfInterest:focusPOI];
+ if (focusMode() != QCamera::FocusModeAuto)
+ [captureDevice setFocusMode:AVCaptureFocusModeAutoFocus];
+
+ customFocusPointChanged(point);
+ }
+}
+
+bool AVFCamera::isCustomFocusPointSupported() const
+{
+ return true;
+}
+
+void AVFCamera::setFocusDistance(float d)
+{
+#ifdef Q_OS_IOS
+ AVCaptureDevice *captureDevice = device();
+ if (!captureDevice)
+ return;
+
+ if (captureDevice.lockingFocusWithCustomLensPositionSupported) {
+ qDebugCamera() << Q_FUNC_INFO << "Setting custom focus distance not supported\n";
+ return;
+ }
+
+ {
+ AVFConfigurationLock lock(captureDevice);
+ if (!lock) {
+ qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
+ return;
+ }
+ [captureDevice setFocusModeLockedWithLensPosition:d completionHandler:nil];
+ }
+ focusDistanceChanged(d);
+#else
+ Q_UNUSED(d);
+#endif
+}
+
+void AVFCamera::updateCameraConfiguration()
+{
+ AVCaptureDevice *captureDevice = device();
+ if (!captureDevice) {
+ qDebugCamera() << Q_FUNC_INFO << "capture device is nil in 'active' state";
+ return;
+ }
+
+ const AVFConfigurationLock lock(captureDevice);
+ if (!lock) {
+ qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
+ return;
+ }
+
+ if ([captureDevice isFocusPointOfInterestSupported]) {
+ auto point = customFocusPoint();
+ const CGPoint focusPOI = CGPointMake(point.x(), point.y());
+ [captureDevice setFocusPointOfInterest:focusPOI];
+ }
+
+#ifdef Q_OS_IOS
+ if (m_focusMode != QCamera::FocusModeAuto) {
+ const AVCaptureFocusMode avMode = avf_focus_mode(m_focusMode);
+ if (captureDevice.focusMode != avMode) {
+ if ([captureDevice isFocusModeSupported:avMode]) {
+ [captureDevice setFocusMode:avMode];
+ } else {
+ qDebugCamera() << Q_FUNC_INFO << "focus mode not supported";
+ }
+ }
+ }
+
+ if (!captureDevice.activeFormat) {
+ qDebugCamera() << Q_FUNC_INFO << "camera state is active, but active format is nil";
+ return;
+ }
+
+ minimumZoomFactorChanged(captureDevice.minAvailableVideoZoomFactor);
+ maximumZoomFactorChanged(captureDevice.maxAvailableVideoZoomFactor);
+
+ captureDevice.videoZoomFactor = m_zoomFactor;
+#endif
+}
+
+void AVFCamera::zoomTo(float factor, float rate)
+{
+ Q_UNUSED(factor);
+ Q_UNUSED(rate);
+
+#ifdef Q_OS_IOS
+ if (zoomFactor() == factor)
+ return;
+
+ AVCaptureDevice *captureDevice = device();
+ if (!captureDevice || !captureDevice.activeFormat)
+ return;
+
+ factor = qBound(captureDevice.minAvailableVideoZoomFactor, factor, captureDevice.maxAvailableVideoZoomFactor);
+
+ const AVFConfigurationLock lock(captureDevice);
+ if (!lock) {
+ qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
+ return;
+ }
+
+ if (rate < 0)
+ captureDevice.videoZoomFactor = foom;
+ else
+ [AVCaptureDevice rampToVideoZoomFactor:factor withRate:rate];
+#endif
+}
+
#include "moc_avfcamera_p.cpp"
diff --git a/src/multimedia/platform/darwin/camera/avfcamera_p.h b/src/multimedia/platform/darwin/camera/avfcamera_p.h
index 4660c6576..710cd8038 100644
--- a/src/multimedia/platform/darwin/camera/avfcamera_p.h
+++ b/src/multimedia/platform/darwin/camera/avfcamera_p.h
@@ -60,7 +60,6 @@ QT_BEGIN_NAMESPACE
class AVFCameraSession;
class AVFCameraService;
class AVFCameraSession;
-class AVFCameraFocus;
class AVFCameraExposure;
class AVFCameraImageProcessing;
@@ -85,10 +84,17 @@ public:
void setCaptureSession(QPlatformMediaCaptureSession *) override;
- QPlatformCameraFocus *focusControl() override;
QPlatformCameraExposure *exposureControl() override;
QPlatformCameraImageProcessing *imageProcessingControl() override;
+ void setFocusMode(QCamera::FocusMode mode) override;
+ bool isFocusModeSupported(QCamera::FocusMode mode) const override;
+
+ void setCustomFocusPoint(const QPointF &point) override;
+ bool isCustomFocusPointSupported() const override;
+
+ void setFocusDistance(float d) override;
+ void zoomTo(float factor, float rate) override;
AVCaptureConnection *videoConnection() const;
AVCaptureDevice *device() const;
@@ -97,11 +103,12 @@ private Q_SLOTS:
void updateStatus();
private:
+ void updateCameraConfiguration();
+
friend class AVFCameraSession;
AVFCameraService *m_service = nullptr;
AVFCameraSession *m_session = nullptr;
- AVFCameraFocus *m_cameraFocusControl;
AVFCameraImageProcessing *m_cameraImageProcessingControl;
AVFCameraExposure *m_cameraExposureControl;
diff --git a/src/multimedia/platform/darwin/camera/avfcamerafocus.mm b/src/multimedia/platform/darwin/camera/avfcamerafocus.mm
deleted file mode 100644
index ab430894d..000000000
--- a/src/multimedia/platform/darwin/camera/avfcamerafocus.mm
+++ /dev/null
@@ -1,351 +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 "avfcamerafocus_p.h"
-#include "avfcamerautility_p.h"
-#include "avfcamera_p.h"
-#include "avfcameradebug_p.h"
-
-#include <QtCore/qdebug.h>
-
-#include <AVFoundation/AVFoundation.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace {
-
-bool qt_focus_mode_supported(QCamera::FocusMode mode)
-{
- // Check if QCamera::FocusMode has counterpart in AVFoundation.
-
- // AVFoundation has 'Manual', 'Auto' and 'Continuous',
- // where 'Manual' is actually 'Locked' + writable property 'lensPosition'.
- return mode == QCamera::FocusModeAuto
- || mode == QCamera::FocusModeManual;
-}
-
-AVCaptureFocusMode avf_focus_mode(QCamera::FocusMode requestedMode)
-{
- switch (requestedMode) {
- case QCamera::FocusModeHyperfocal:
- case QCamera::FocusModeInfinity:
- case QCamera::FocusModeManual:
- return AVCaptureFocusModeLocked;
- default:
- return AVCaptureFocusModeContinuousAutoFocus;
- }
-
-}
-
-}
-
-AVFCameraFocus::AVFCameraFocus(AVFCamera *camera)
- : QPlatformCameraFocus(camera),
- m_camera(camera),
- m_focusMode(QCamera::FocusModeAuto),
- m_customFocusPoint(0.5f, 0.5f),
- m_actualFocusPoint(m_customFocusPoint)
-{
- Q_ASSERT(m_camera);
- connect(m_camera, SIGNAL(activeChanged(bool)), SLOT(cameraActiveChanged(bool)));
-}
-
-QCamera::FocusMode AVFCameraFocus::focusMode() const
-{
- return m_focusMode;
-}
-
-void AVFCameraFocus::setFocusMode(QCamera::FocusMode mode)
-{
- if (m_focusMode == mode)
- return;
-
- AVCaptureDevice *captureDevice = m_camera->device();
- if (!captureDevice) {
- if (qt_focus_mode_supported(mode)) {
- m_focusMode = mode;
- Q_EMIT focusModeChanged(m_focusMode);
- } else {
- qDebugCamera() << Q_FUNC_INFO
- << "focus mode not supported";
- }
- return;
- }
-
- if (isFocusModeSupported(mode)) {
- const AVFConfigurationLock lock(captureDevice);
- if (!lock) {
- qDebugCamera() << Q_FUNC_INFO
- << "failed to lock for configuration";
- return;
- }
-
- captureDevice.focusMode = avf_focus_mode(mode);
- m_focusMode = mode;
- } else {
- qDebugCamera() << Q_FUNC_INFO << "focus mode not supported";
- return;
- }
-
- Q_EMIT focusModeChanged(m_focusMode);
-}
-
-bool AVFCameraFocus::isFocusModeSupported(QCamera::FocusMode mode) const
-{
- AVCaptureDevice *captureDevice = m_camera->device();
- if (!captureDevice)
- return false;
-
-#ifdef Q_OS_IOS
- AVCaptureFocusMode avMode = avf_focus_mode(mode);
- switch (mode) {
- case QCamera::FocusModeAuto:
- case QCamera::FocusModeHyperfocal:
- case QCamera::FocusModeInfinity:
- case QCamera::FocusModeManual:
- return [captureDevice isFocusModeSupported:avMode];
- case QCamera::FocusModeAutoNear:
- Q_FALLTHROUGH();
- case QCamera::FocusModeAutoFar:
- return captureDevice.autoFocusRangeRestrictionSupported
- && [captureDevice isFocusModeSupported:avMode];
- }
-#else
- return mode == QCamera::FocusModeAuto; // stupid builtin webcam doesn't do any focus handling, but hey it's usually focused :)
-#endif
-}
-
-QPointF AVFCameraFocus::focusPoint() const
-{
- return m_customFocusPoint;
-}
-
-void AVFCameraFocus::setCustomFocusPoint(const QPointF &point)
-{
- if (m_customFocusPoint == point)
- return;
-
- if (!QRectF(0.f, 0.f, 1.f, 1.f).contains(point)) {
- // ### release custom focus point, tell the camera to focus where it wants...
- qDebugCamera() << Q_FUNC_INFO << "invalid focus point (out of range)";
- return;
- }
-
- m_customFocusPoint = point;
- Q_EMIT customFocusPointChanged(m_customFocusPoint);
-
- AVCaptureDevice *captureDevice = m_camera->device();
- if (!captureDevice)
- return;
-
- if ([captureDevice isFocusPointOfInterestSupported]) {
- const AVFConfigurationLock lock(captureDevice);
- if (!lock) {
- qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
- return;
- }
-
- m_actualFocusPoint = m_customFocusPoint;
- const CGPoint focusPOI = CGPointMake(point.x(), point.y());
- [captureDevice setFocusPointOfInterest:focusPOI];
- if (m_focusMode != QCamera::FocusModeAuto)
- [captureDevice setFocusMode:AVCaptureFocusModeAutoFocus];
- } else {
- qDebugCamera() << Q_FUNC_INFO << "focus point of interest not supported";
- return;
- }
-}
-
-bool AVFCameraFocus::isCustomFocusPointSupported() const
-{
- return true;
-}
-
-void AVFCameraFocus::setFocusDistance(float d)
-{
-#ifdef Q_OS_IOS
- AVCaptureDevice *captureDevice = m_camera->device();
- if (!captureDevice)
- return;
-
- if (captureDevice.lockingFocusWithCustomLensPositionSupported) {
- qDebugCamera() << Q_FUNC_INFO << "Setting custom focus distance not supported\n";
- return;
- }
-
- const bool lock = [captureDevice lockForConfiguration:nil];
- if (!lock) {
- qDebugCamera() << Q_FUNC_INFO << "Failed to lock a capture device for configuration\n";
- return;
- }
-
- [captureDevice setFocusModeLockedWithLensPosition:d completionHandler:nil];
-#else
- Q_UNUSED(d);
-#endif
-}
-
-float AVFCameraFocus::focusDistance() const
-{
-#ifdef Q_OS_IOS
- AVCaptureDevice *captureDevice = m_camera->device();
- if (!captureDevice)
- return 1.;
- return captureDevice.lensPosition;
-#else
- return 1.;
-#endif
-}
-
-void AVFCameraFocus::cameraActiveChanged(bool active)
-{
- if (!active)
- return;
-
- AVCaptureDevice *captureDevice = m_camera->device();
- if (!captureDevice) {
- qDebugCamera() << Q_FUNC_INFO << "capture device is nil in 'active' state";
- return;
- }
-
- const AVFConfigurationLock lock(captureDevice);
- if (m_customFocusPoint != m_actualFocusPoint) {
- if (![captureDevice isFocusPointOfInterestSupported]) {
- qDebugCamera() << Q_FUNC_INFO
- << "focus point of interest not supported";
- return;
- }
-
- if (!lock) {
- qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
- return;
- }
-
- m_actualFocusPoint = m_customFocusPoint;
- const CGPoint focusPOI = CGPointMake(m_customFocusPoint.x(), m_customFocusPoint.y());
- [captureDevice setFocusPointOfInterest:focusPOI];
- }
-
- if (m_focusMode != QCamera::FocusModeAuto) {
- const AVCaptureFocusMode avMode = avf_focus_mode(m_focusMode);
- if (captureDevice.focusMode != avMode) {
- if (![captureDevice isFocusModeSupported:avMode]) {
- qDebugCamera() << Q_FUNC_INFO << "focus mode not supported";
- return;
- }
-
- if (!lock) {
- qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
- return;
- }
-
- [captureDevice setFocusMode:avMode];
- }
- }
-
-#ifdef Q_OS_IOS
- const bool isActive = m_camera->isActive();
- if (!isActive) {
- if (m_maxZoomFactor > 1.) {
- m_maxZoomFactor = 1.;
- emit maximumZoomFactorChanged(1.);
- }
- return;
- }
-
- if (!captureDevice || !captureDevice.activeFormat) {
- qDebugCamera() << Q_FUNC_INFO << "camera state is active, but"
- << "video capture device and/or active format is nil";
- return;
- }
-
- if (captureDevice.activeFormat.videoMaxZoomFactor > 1.) {
- if (!qFuzzyCompare(m_maxZoomFactor, captureDevice.activeFormat.videoMaxZoomFactor)) {
- m_maxZoomFactor = captureDevice.activeFormat.videoMaxZoomFactor;
- emit maximumZoomFactorChanged(m_maxZoomFactor);
- }
- } else if (!qFuzzyCompare(m_maxZoomFactor, CGFloat(1.))) {
- m_maxZoomFactor = 1.;
-
- emit maximumZoomFactorChanged(1.);
- }
-
- captureDevice.videoZoomFactor = m_zoomFactor;
-#endif
-}
-
-AVFCameraFocus::ZoomRange AVFCameraFocus::zoomFactorRange() const
-{
- return { 1., (float)m_maxZoomFactor };
-}
-
-void AVFCameraFocus::zoomTo(float factor, float rate)
-{
- Q_UNUSED(factor);
- Q_UNUSED(rate);
-
-#ifdef QOS_IOS
- if (qFuzzyCompare(CGFloat(factor), m_zoomFactor))
- return;
-
- m_requestedZoomFactor = factor;
- Q_EMIT requestedDigitalZoomChanged(digital);
-
- AVCaptureDevice *captureDevice = m_camera->device();
- if (!captureDevice || !captureDevice.activeFormat)
- return;
-
- m_zoomFactor = qBound(CGFloat(1.), factor, captureDevice.activeFormat.videoMaxZoomFactor);
-
- const AVFConfigurationLock lock(captureDevice);
- if (!lock) {
- qDebugCamera() << Q_FUNC_INFO << "failed to lock for configuration";
- return;
- }
-
- if (rate < 0)
- captureDevice.videoZoomFactor = clampedZoom;
- else
- [AVCaptureDevice rampToVideoZoomFactor:factor withRate:rate];
-#endif
-}
-
-QT_END_NAMESPACE
-
-#include "moc_avfcamerafocus_p.cpp"
diff --git a/src/multimedia/platform/darwin/camera/avfcamerafocus_p.h b/src/multimedia/platform/darwin/camera/avfcamerafocus_p.h
deleted file mode 100644
index 2f4adf5fa..000000000
--- a/src/multimedia/platform/darwin/camera/avfcamerafocus_p.h
+++ /dev/null
@@ -1,103 +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 AVFCAMERAFOCUS_H
-#define AVFCAMERAFOCUS_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qglobal.h>
-
-#include <private/qplatformcamerafocus_p.h>
-
-#include <AVFoundation/AVFoundation.h>
-
-class AVFCamera;
-
-@class AVCaptureDevice;
-
-QT_BEGIN_NAMESPACE
-
-class AVFCameraFocus : public QPlatformCameraFocus
-{
- Q_OBJECT
-public:
- explicit AVFCameraFocus(AVFCamera *camera);
-
- QCamera::FocusMode focusMode() const override;
- void setFocusMode(QCamera::FocusMode mode) override;
- bool isFocusModeSupported(QCamera::FocusMode mode) const override;
-
- QPointF focusPoint() const override;
- void setCustomFocusPoint(const QPointF &point) override;
- bool isCustomFocusPointSupported() const override;
-
- void setFocusDistance(float) override;
- float focusDistance() const override;
-
- ZoomRange zoomFactorRange() const override;
- void zoomTo(float newZoomFactor, float rate = -1.) override;
-
-private Q_SLOTS:
- void cameraActiveChanged(bool active);
-
-private:
- AVFCamera *m_camera;
- QCamera::FocusMode m_focusMode;
- QPointF m_customFocusPoint;
- QPointF m_actualFocusPoint;
-
- CGFloat m_maxZoomFactor;
- CGFloat m_zoomFactor;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // AVFCAMERAFOCUS_H
diff --git a/src/multimedia/platform/darwin/camera/avfcameraservice.mm b/src/multimedia/platform/darwin/camera/avfcameraservice.mm
index a12a476ac..4d5021076 100644
--- a/src/multimedia/platform/darwin/camera/avfcameraservice.mm
+++ b/src/multimedia/platform/darwin/camera/avfcameraservice.mm
@@ -46,7 +46,6 @@
#include "avfcameraimagecapture_p.h"
#include "avfcamerarenderer_p.h"
#include "avfcameraimagecapture_p.h"
-#include "avfcamerafocus_p.h"
#include "avfcameraexposure_p.h"
#include "avfcameraimageprocessing_p.h"
#include "avfmediaencoder_p.h"
diff --git a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera.cpp b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera.cpp
index 8cdadac71..1b837bd8a 100644
--- a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera.cpp
+++ b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera.cpp
@@ -44,7 +44,6 @@
#include <private/qgstreamermediadevices_p.h>
#include <private/qgstreamerintegration_p.h>
#include <private/qgstreamercameraexposure_p.h>
-#include <private/qgstreamercamerafocus_p.h>
#include <private/qgstreamercameraimageprocessing_p.h>
#include <qmediacapturesession.h>
@@ -185,14 +184,57 @@ QPlatformCameraImageProcessing *QGstreamerCamera::imageProcessingControl()
return imageProcessing;
}
-QPlatformCameraFocus *QGstreamerCamera::focusControl()
+QPlatformCameraExposure *QGstreamerCamera::exposureControl()
{
- return focus;
+ return exposure;
}
-QPlatformCameraExposure *QGstreamerCamera::exposureControl()
+void QGstreamerCamera::setFocusMode(QCamera::FocusMode mode)
{
- return exposure;
+ if (mode == focusMode())
+ return;
+
+#if QT_CONFIG(gstreamer_photography)
+ auto p = photography();
+ if (p) {
+ GstPhotographyFocusMode photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL;
+
+ switch (mode) {
+ case QCamera::FocusModeAutoNear:
+ photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_MACRO;
+ break;
+ case QCamera::FocusModeAutoFar:
+ // not quite, but hey :)
+ Q_FALLTHROUGH();
+ case QCamera::FocusModeHyperfocal:
+ photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_HYPERFOCAL;
+ break;
+ case QCamera::FocusModeInfinity:
+ photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_INFINITY;
+ break;
+ case QCamera::FocusModeManual:
+ photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_MANUAL;
+ break;
+ default: // QCamera::FocusModeAuto:
+ break;
+ }
+
+ if (gst_photography_set_focus_mode(p, photographyMode))
+ focusModeChanged(mode);
+ }
+#endif
+}
+
+bool QGstreamerCamera::isFocusModeSupported(QCamera::FocusMode mode) const
+{
+ Q_UNUSED(mode);
+
+#if QT_CONFIG(gstreamer_photography)
+ if (photography())
+ return true;
+#endif
+
+ return false;
}
GstColorBalance *QGstreamerCamera::colorBalance() const
@@ -204,7 +246,7 @@ GstColorBalance *QGstreamerCamera::colorBalance() const
}
#if QT_CONFIG(gstreamer_photography)
-GstPhotography *QGstreamerCamera::photography()
+GstPhotography *QGstreamerCamera::photography() const
{
if (!gstCamera.isNull() && GST_IS_PHOTOGRAPHY(gstCamera.element()))
return GST_PHOTOGRAPHY(gstCamera.element());
diff --git a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera_p.h b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera_p.h
index 660649ee4..0714bc10a 100644
--- a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera_p.h
+++ b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamera_p.h
@@ -59,7 +59,6 @@
#include <gst/video/colorbalance.h>
QT_BEGIN_NAMESPACE
-class QGstreamerCameraFocus;
class QGstreamerCameraExposure;
class QGstreamerImageProcessing;
@@ -83,11 +82,13 @@ public:
void setPipeline(const QGstPipeline &pipeline) { gstPipeline = pipeline; }
QPlatformCameraImageProcessing *imageProcessingControl() override;
- QPlatformCameraFocus *focusControl() override;
QPlatformCameraExposure *exposureControl() override;
+ void setFocusMode(QCamera::FocusMode mode) override;
+ bool isFocusModeSupported(QCamera::FocusMode mode) const override;
+
#if QT_CONFIG(gstreamer_photography)
- GstPhotography *photography();
+ GstPhotography *photography() const;
#endif
QString v4l2Device() const { return m_v4l2Device; }
bool isV4L2Camera() const { return !m_v4l2Device.isEmpty(); }
@@ -97,7 +98,6 @@ public:
private:
QGstreamerMediaCapture *m_session = nullptr;
- QGstreamerCameraFocus *focus = nullptr;
QGstreamerCameraExposure *exposure = nullptr;
QGstreamerImageProcessing *imageProcessing = nullptr;
diff --git a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus.cpp b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus.cpp
deleted file mode 100644
index b5919bca8..000000000
--- a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus.cpp
+++ /dev/null
@@ -1,144 +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 "qgstreamercamerafocus_p.h"
-#include "qgstreamercamera_p.h"
-
-#include <QDebug>
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qmetaobject.h>
-
-#include <private/qgstutils_p.h>
-
-#define ZOOM_PROPERTY "zoom"
-#define MAX_ZOOM_PROPERTY "max-zoom"
-
-//#define CAMERABIN_DEBUG 1
-
-QT_BEGIN_NAMESPACE
-
-QGstreamerCameraFocus::QGstreamerCameraFocus(QGstreamerCamera *session)
- : QPlatformCameraFocus(session),
- m_camera(session),
- m_focusMode(QCamera::FocusModeAuto)
-{
-#if QT_CONFIG(gstreamer_photography)
- auto photography = m_camera->photography();
- if (photography)
- gst_photography_set_focus_mode(m_camera->photography(), GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL);
-#endif
-}
-
-QGstreamerCameraFocus::~QGstreamerCameraFocus()
-{
-}
-
-QCamera::FocusMode QGstreamerCameraFocus::focusMode() const
-{
- return m_focusMode;
-}
-
-void QGstreamerCameraFocus::setFocusMode(QCamera::FocusMode mode)
-{
- if (mode == m_focusMode)
- return;
-
-#if QT_CONFIG(gstreamer_photography)
- auto photography = m_camera->photography();
- if (photography) {
- GstPhotographyFocusMode photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL;
-
- switch (mode) {
- case QCamera::FocusModeAutoNear:
- photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_MACRO;
- break;
- case QCamera::FocusModeAutoFar:
- // not quite, but hey :)
- Q_FALLTHROUGH();
- case QCamera::FocusModeHyperfocal:
- photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_HYPERFOCAL;
- break;
- case QCamera::FocusModeInfinity:
- photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_INFINITY;
- break;
- case QCamera::FocusModeManual:
- photographyMode = GST_PHOTOGRAPHY_FOCUS_MODE_MANUAL;
- break;
- default: // QCamera::FocusModeAuto:
- break;
- }
-
- if (gst_photography_set_focus_mode(photography, photographyMode)) {
- m_focusMode = mode;
- emit focusModeChanged(m_focusMode);
- }
- }
-#endif
-}
-
-bool QGstreamerCameraFocus::isFocusModeSupported(QCamera::FocusMode mode) const
-{
- Q_UNUSED(mode);
-
-#if QT_CONFIG(gstreamer_photography)
- auto photography = m_camera->photography();
- if (photography)
- return true;
-#endif
-
- return false;
-}
-
-QPlatformCameraFocus::ZoomRange QGstreamerCameraFocus::zoomFactorRange() const
-{
- // We do some heuristics here and support zooming in until a
- // resolution of 320x240 or max 4x
-
- return { 1., 1. };
-}
-
-
-void QGstreamerCameraFocus::zoomTo(float newZoomFactor, float /*rate*/)
-{
- auto range = zoomFactorRange();
- newZoomFactor = qBound(range.min, newZoomFactor, range.max);
- // #### Now do the zooming
-}
-
-QT_END_NAMESPACE
diff --git a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus_p.h b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus_p.h
deleted file mode 100644
index e9dd069d5..000000000
--- a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercamerafocus_p.h
+++ /dev/null
@@ -1,94 +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 CAMERABINFOCUSCONTROL_H
-#define CAMERABINFOCUSCONTROL_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qcamera.h>
-#include <private/qplatformcamerafocus_p.h>
-
-#include <private/qgstreamerbufferprobe_p.h>
-
-#include <qbasictimer.h>
-#include <qlist.h>
-#include <qmutex.h>
-
-#include <gst/gst.h>
-#include <glib.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGstreamerCamera;
-
-class QGstreamerCameraFocus : public QPlatformCameraFocus
-{
- Q_OBJECT
-
-public:
- QGstreamerCameraFocus(QGstreamerCamera *session);
- virtual ~QGstreamerCameraFocus();
-
- QCamera::FocusMode focusMode() const override;
- void setFocusMode(QCamera::FocusMode mode) override;
- bool isFocusModeSupported(QCamera::FocusMode mode) const override;
-
- ZoomRange zoomFactorRange() const override;
- void zoomTo(float newZoomFactor, float rate) override;
-
-private:
- QGstreamerCamera *m_camera;
- QCamera::FocusMode m_focusMode;
- float requestedZoomFactor = 1.;
- float maxZoomFactor = 1.;
-};
-
-QT_END_NAMESPACE
-
-#endif // CAMERABINFOCUSCONTROL_H
diff --git a/src/multimedia/platform/qplatformcamera.cpp b/src/multimedia/platform/qplatformcamera.cpp
index d9a3b5b9d..cf2170fa0 100644
--- a/src/multimedia/platform/qplatformcamera.cpp
+++ b/src/multimedia/platform/qplatformcamera.cpp
@@ -165,6 +165,56 @@ void QPlatformCamera::statusChanged(QCamera::Status s)
emit m_camera->statusChanged(s);
}
+void QPlatformCamera::minimumZoomFactorChanged(float factor)
+{
+ if (m_minZoom == factor)
+ return;
+ m_minZoom = factor;
+ emit m_camera->minimumZoomFactorChanged(factor);
+}
+
+void QPlatformCamera::maximumZoomFactorChanged(float factor)
+{
+ if (m_maxZoom == factor)
+ return;
+ m_maxZoom = factor;
+ emit m_camera->maximumZoomFactorChanged(factor);
+}
+
+void QPlatformCamera::focusModeChanged(QCamera::FocusMode mode)
+{
+ if (m_focusMode == mode)
+ return;
+ m_focusMode = mode;
+ emit m_camera->focusModeChanged();
+}
+
+void QPlatformCamera::customFocusPointChanged(const QPointF &point)
+{
+ if (m_customFocusPoint == point)
+ return;
+ m_customFocusPoint = point;
+ emit m_camera->customFocusPointChanged();
+}
+
+
+void QPlatformCamera::zoomFactorChanged(float zoom)
+{
+ if (m_zoomFactor == zoom)
+ return;
+ m_zoomFactor = zoom;
+ emit m_camera->zoomFactorChanged(zoom);
+}
+
+
+void QPlatformCamera::focusDistanceChanged(float d)
+{
+ if (m_focusDistance == d)
+ return;
+ m_focusDistance = d;
+ emit m_camera->focusDistanceChanged(m_focusDistance);
+}
+
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/qplatformcamera_p.h b/src/multimedia/platform/qplatformcamera_p.h
index 6f2face7a..d5d3721f9 100644
--- a/src/multimedia/platform/qplatformcamera_p.h
+++ b/src/multimedia/platform/qplatformcamera_p.h
@@ -58,9 +58,6 @@
QT_BEGIN_NAMESPACE
-// Required for QDoc workaround
-class QString;
-class QPlatformCameraFocus;
class QPlatformCameraExposure;
class QPlatformCameraImageProcessing;
@@ -79,11 +76,37 @@ public:
virtual void setCaptureSession(QPlatformMediaCaptureSession *) {}
- virtual QPlatformCameraFocus *focusControl() { return nullptr; }
virtual QPlatformCameraExposure *exposureControl() { return nullptr; }
virtual QPlatformCameraImageProcessing *imageProcessingControl() { return nullptr; }
+ virtual bool isFocusModeSupported(QCamera::FocusMode mode) const { return mode == QCamera::FocusModeAuto; }
+ virtual void setFocusMode(QCamera::FocusMode /*mode*/) {}
+
+ virtual bool isCustomFocusPointSupported() const { return false; }
+ virtual void setCustomFocusPoint(const QPointF &/*point*/) {}
+
+ virtual void setFocusDistance(float) {}
+
+ // smaller 0: zoom instantly, rate in power-of-two/sec
+ virtual void zoomTo(float /*newZoomFactor*/, float /*rate*/ = -1.) {}
+
+ QCamera::FocusMode focusMode() const { return m_focusMode; }
+ QPointF focusPoint() const { return m_customFocusPoint; }
+
+ float minZoomFactor() const { return m_minZoom; }
+ float maxZoomFactor() const { return m_maxZoom; }
+ float zoomFactor() const { return m_zoomFactor; }
+ QPointF customFocusPoint() const { return m_customFocusPoint; }
+ float focusDistance() const { return m_focusDistance; }
+
void statusChanged(QCamera::Status);
+ void minimumZoomFactorChanged(float factor);
+ void maximumZoomFactorChanged(float);
+ void focusModeChanged(QCamera::FocusMode mode);
+ void customFocusPointChanged(const QPointF &point);
+ void focusDistanceChanged(float d);
+ void zoomFactorChanged(float zoom);
+
Q_SIGNALS:
void activeChanged(bool);
void error(int error, const QString &errorString);
@@ -95,6 +118,12 @@ protected:
private:
QCamera *m_camera = nullptr;
QCamera::Status m_status = QCamera::InactiveStatus;
+ QCamera::FocusMode m_focusMode = QCamera::FocusModeAuto;
+ float m_minZoom = 1.;
+ float m_maxZoom = 1.;
+ float m_zoomFactor = 1.;
+ float m_focusDistance = 1.;
+ QPointF m_customFocusPoint{.5, .5};
};
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/qplatformcamerafocus.cpp b/src/multimedia/platform/qplatformcamerafocus.cpp
deleted file mode 100644
index 174705d1e..000000000
--- a/src/multimedia/platform/qplatformcamerafocus.cpp
+++ /dev/null
@@ -1,244 +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 "qplatformcamerafocus_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QPlatformCameraFocus
- \obsolete
-
-
- \brief The QPlatformCameraFocus class supplies control for
- focusing related camera parameters.
-
- \inmodule QtMultimedia
- \ingroup multimedia_control
-
- \sa QCamera
-*/
-
-/*!
- Constructs a camera control object with \a parent.
-*/
-
-QPlatformCameraFocus::QPlatformCameraFocus(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- \fn QCamera::FocusMode QPlatformCameraFocus::focusMode() const
-
- Returns the focus mode being used.
-*/
-
-
-/*!
- \fn void QPlatformCameraFocus::setFocusMode(QCamera::FocusMode mode)
-
- Set the focus mode to \a mode.
-*/
-
-
-/*!
- \fn bool QPlatformCameraFocus::isFocusModeSupported(QCamera::FocusMode mode) const
-
- Returns true if focus \a mode is supported.
-*/
-
-/*!
- \fn QPlatformCameraFocus::focusPointMode() const
-
- Returns the camera focus point selection mode.
-*/
-
-/*!
- \fn QPlatformCameraFocus::setFocusPointMode(QCamera::FocusPointMode mode)
-
- Sets the camera focus point selection \a mode.
-*/
-
-/*!
- \fn QPlatformCameraFocus::isFocusPointModeSupported(QCamera::FocusPointMode mode) const
-
- Returns true if the camera focus point \a mode is supported.
-*/
-
-/*!
- \fn QPlatformCameraFocus::customFocusPoint() const
-
- Return the position of custom focus point, in relative frame coordinates:
- QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center.
-
- Custom focus point is used only in FocusPointCustom focus mode.
-*/
-
-/*!
- \fn QPlatformCameraFocus::setCustomFocusPoint(const QPointF &point)
-
- Sets the custom focus \a point.
-
- \sa QPlatformCameraFocus::customFocusPoint()
-*/
-
-/*!
- \fn void QPlatformCameraFocus::focusModeChanged(QCamera::FocusMode mode)
-
- Signal is emitted when the focus \a mode is changed,
- usually in result of QPlatformCameraFocus::setFocusMode call or capture mode changes.
-
- \sa QPlatformCameraFocus::focusMode(), QPlatformCameraFocus::setFocusMode()
-*/
-
-/*!
- \fn void QPlatformCameraFocus::focusPointModeChanged(QCamera::FocusPointMode mode)
-
- Signal is emitted when the focus point \a mode is changed,
- usually in result of QPlatformCameraFocus::setFocusPointMode call or capture mode changes.
-
- \sa QPlatformCameraFocus::focusPointMode(), QPlatformCameraFocus::setFocusPointMode()
-*/
-
-/*!
- \fn void QPlatformCameraFocus::customFocusPointChanged(const QPointF &point)
-
- Signal is emitted when the custom focus \a point is changed.
-
- \sa QPlatformCameraFocus::customFocusPoint(), QPlatformCameraFocus::setCustomFocusPoint()
-*/
-
-/*!
- \fn qreal QPlatformCameraFocus::maximumOpticalZoom() const
-
- Returns the maximum optical zoom value, or 1.0 if optical zoom is not supported.
-*/
-
-
-/*!
- \fn qreal QPlatformCameraFocus::maximumDigitalZoom() const
-
- Returns the maximum digital zoom value, or 1.0 if digital zoom is not supported.
-*/
-
-
-/*!
- \fn qreal QPlatformCameraFocus::requestedOpticalZoom() const
-
- Return the requested optical zoom value.
-*/
-
-/*!
- \fn qreal QPlatformCameraFocus::requestedDigitalZoom() const
-
- Return the requested digital zoom value.
-*/
-
-/*!
- \fn qreal QPlatformCameraFocus::currentOpticalZoom() const
-
- Return the current optical zoom value.
-*/
-
-/*!
- \fn qreal QPlatformCameraFocus::currentDigitalZoom() const
-
- Return the current digital zoom value.
-*/
-
-/*!
- \fn void QPlatformCameraFocus::zoomTo(qreal optical, qreal digital)
-
- Sets \a optical and \a digital zoom values.
-
- Zooming can be asynchronous with value changes reported with
- currentDigitalZoomChanged() and currentOpticalZoomChanged() signals.
-
- The backend should expect and correctly handle frequent zoomTo() calls
- during zoom animations or slider movements.
-*/
-
-
-/*!
- \fn void QPlatformCameraFocus::currentOpticalZoomChanged(qreal zoom)
-
- Signal emitted when the current optical \a zoom value changed.
-*/
-
-/*!
- \fn void QPlatformCameraFocus::currentDigitalZoomChanged(qreal zoom)
-
- Signal emitted when the current digital \a zoom value changed.
-*/
-
-/*!
- \fn void QPlatformCameraFocus::requestedOpticalZoomChanged(qreal zoom)
-
- Signal emitted when the requested optical \a zoom value changed.
-*/
-
-/*!
- \fn void QPlatformCameraFocus::requestedDigitalZoomChanged(qreal zoom)
-
- Signal emitted when the requested digital \a zoom value changed.
-*/
-
-
-/*!
- \fn void QPlatformCameraFocus::maximumOpticalZoomChanged(qreal zoom)
-
- Signal emitted when the maximum supported optical \a zoom value changed.
-
- The maximum supported zoom value can depend on other camera settings,
- like focusing mode.
-*/
-
-/*!
- \fn void QPlatformCameraFocus::maximumDigitalZoomChanged(qreal zoom)
-
- Signal emitted when the maximum supported digital \a zoom value changed.
-
- The maximum supported zoom value can depend on other camera settings,
- like capture mode or resolution.
-*/
-
-QT_END_NAMESPACE
-
-#include "moc_qplatformcamerafocus_p.cpp"
diff --git a/src/multimedia/platform/qplatformcamerafocus_p.h b/src/multimedia/platform/qplatformcamerafocus_p.h
deleted file mode 100644
index f6eb88f71..000000000
--- a/src/multimedia/platform/qplatformcamerafocus_p.h
+++ /dev/null
@@ -1,103 +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 QCAMERAFOCUSCONTROL_H
-#define QCAMERAFOCUSCONTROL_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qobject.h>
-#include <QtMultimedia/qtmultimediaglobal.h>
-
-#include <QtMultimedia/qcamera.h>
-
-QT_BEGIN_NAMESPACE
-
-// Required for QDoc workaround
-class QString;
-
-class Q_MULTIMEDIA_EXPORT QPlatformCameraFocus : public QObject
-{
- Q_OBJECT
-
-public:
- virtual QCamera::FocusMode focusMode() const = 0;
- virtual void setFocusMode(QCamera::FocusMode mode) = 0;
- virtual bool isFocusModeSupported(QCamera::FocusMode mode) const = 0;
-
- virtual bool isCustomFocusPointSupported() const { return false; }
- virtual void setCustomFocusPoint(const QPointF &/*point*/) {}
- virtual QPointF focusPoint() const { return {-1., -1.}; }
-
- virtual void setFocusDistance(float) {}
- virtual float focusDistance() const { return 0.; }
-
- struct ZoomRange {
- float min;
- float max;
- };
-
- virtual ZoomRange zoomFactorRange() const = 0;
- // smaller 0: zoom instantly, rate in power-of-two/sec
- virtual void zoomTo(float newZoomFactor, float rate = -1.) = 0;
-
-Q_SIGNALS:
- void focusModeChanged(QCamera::FocusMode mode);
- void customFocusPointChanged(const QPointF &point);
- void minimumZoomFactorChanged(float);
- void maximumZoomFactorChanged(float);
-
-protected:
- explicit QPlatformCameraFocus(QObject *parent = nullptr);
-};
-
-QT_END_NAMESPACE
-
-
-#endif // QCAMERAFOCUSCONTROL_H
-
diff --git a/src/multimedia/platform/windows/mediacapture/qwindowscamera.cpp b/src/multimedia/platform/windows/mediacapture/qwindowscamera.cpp
index f4efc4b65..6475dccf0 100644
--- a/src/multimedia/platform/windows/mediacapture/qwindowscamera.cpp
+++ b/src/multimedia/platform/windows/mediacapture/qwindowscamera.cpp
@@ -41,7 +41,6 @@
#include "qwindowscamerasession_p.h"
#include "qwindowscameraexposure_p.h"
-#include "qwindowscamerafocus_p.h"
#include "qwindowscameraimageprocessing_p.h"
#include "qwindowsmediacapture_p.h"
#include <qcamerainfo.h>
@@ -123,13 +122,6 @@ void QWindowsCamera::setCaptureSession(QPlatformMediaCaptureSession *session)
m_cameraSession->setActiveCamera(m_cameraInfo);
}
-QPlatformCameraFocus *QWindowsCamera::focusControl()
-{
- if (!m_cameraSession)
- return nullptr;
- return m_cameraSession->focusControl();
-}
-
QPlatformCameraExposure *QWindowsCamera::exposureControl()
{
if (!m_cameraSession)
diff --git a/src/multimedia/platform/windows/mediacapture/qwindowscamera_p.h b/src/multimedia/platform/windows/mediacapture/qwindowscamera_p.h
index 4b9729800..29df07130 100644
--- a/src/multimedia/platform/windows/mediacapture/qwindowscamera_p.h
+++ b/src/multimedia/platform/windows/mediacapture/qwindowscamera_p.h
@@ -74,7 +74,6 @@ public:
void setCaptureSession(QPlatformMediaCaptureSession *) override;
- QPlatformCameraFocus *focusControl() override;
QPlatformCameraExposure *exposureControl() override;
QPlatformCameraImageProcessing *imageProcessingControl() override;
diff --git a/src/multimedia/platform/windows/mediacapture/qwindowscamerafocus.cpp b/src/multimedia/platform/windows/mediacapture/qwindowscamerafocus.cpp
deleted file mode 100644
index eecda095e..000000000
--- a/src/multimedia/platform/windows/mediacapture/qwindowscamerafocus.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 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 "qwindowscamerafocus_p.h"
-
-#include "qwindowscamerasession_p.h"
-#include "qwindowscamera_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QWindowsCameraFocus::QWindowsCameraFocus(QWindowsCameraSession *session)
- : m_session(session)
-{
- Q_ASSERT(m_session);
-}
-
-QCamera::FocusMode QWindowsCameraFocus::focusMode() const
-{
- return QCamera::FocusModeAuto;
-}
-
-void QWindowsCameraFocus::setFocusMode(QCamera::FocusMode mode)
-{
-}
-
-bool QWindowsCameraFocus::isFocusModeSupported(QCamera::FocusMode mode) const
-{
- return false;
-}
-
-bool QWindowsCameraFocus::isCustomFocusPointSupported() const
-{
- return false;
-}
-
-QPointF QWindowsCameraFocus::focusPoint() const
-{
- return QPointF(0.5, 0.5);
-}
-
-void QWindowsCameraFocus::setCustomFocusPoint(const QPointF &point)
-{
-}
-
-QWindowsCameraFocus::ZoomRange QWindowsCameraFocus::zoomFactorRange() const
-{
- return { 1.0, 1.0 };
-}
-
-void QWindowsCameraFocus::zoomTo(float factor, float rate)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/multimedia/platform/windows/mediacapture/qwindowscamerafocus_p.h b/src/multimedia/platform/windows/mediacapture/qwindowscamerafocus_p.h
deleted file mode 100644
index cb91e21a3..000000000
--- a/src/multimedia/platform/windows/mediacapture/qwindowscamerafocus_p.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 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 QWINDOWSCAMERAFOCUS_H
-#define QWINDOWSCAMERAFOCUS_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qplatformcamerafocus_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWindowsCameraSession;
-
-class QWindowsCameraFocus : public QPlatformCameraFocus
-{
- Q_OBJECT
-public:
- explicit QWindowsCameraFocus(QWindowsCameraSession *session);
-
- QCamera::FocusMode focusMode() const override;
- void setFocusMode(QCamera::FocusMode mode) override;
- bool isFocusModeSupported(QCamera::FocusMode mode) const override;
-
- bool isCustomFocusPointSupported() const override;
- QPointF focusPoint() const override;
- void setCustomFocusPoint(const QPointF &point) override;
-
- ZoomRange zoomFactorRange() const override;
- void zoomTo(float newZoomFactor, float rate) override;
-
-private:
- QWindowsCameraSession *m_session;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSCAMERAFOCUS_H
diff --git a/src/multimedia/platform/windows/mediacapture/qwindowscamerasession.cpp b/src/multimedia/platform/windows/mediacapture/qwindowscamerasession.cpp
index 2557a74f1..87f8742a9 100644
--- a/src/multimedia/platform/windows/mediacapture/qwindowscamerasession.cpp
+++ b/src/multimedia/platform/windows/mediacapture/qwindowscamerasession.cpp
@@ -40,7 +40,6 @@
#include "qwindowscamerasession_p.h"
#include "qwindowscamerareader_p.h"
-#include "qwindowscamerafocus_p.h"
#include "qwindowscameraexposure_p.h"
#include "qwindowscameraimageprocessing_p.h"
#include "qwindowsmultimediautils_p.h"
@@ -54,7 +53,6 @@ QWindowsCameraSession::QWindowsCameraSession(QObject *parent)
{
m_cameraReader = new QWindowsCameraReader(this);
m_cameraExposure = new QWindowsCameraExposure(this);
- m_cameraFocus = new QWindowsCameraFocus(this);
m_cameraImageProcessing = new QWindowsCameraImageProcessing(this);
connect(m_cameraReader, SIGNAL(streamingStarted()), this, SLOT(handleStreamingStarted()));
connect(m_cameraReader, SIGNAL(streamingStopped()), this, SLOT(handleStreamingStopped()));
@@ -66,7 +64,6 @@ QWindowsCameraSession::QWindowsCameraSession(QObject *parent)
QWindowsCameraSession::~QWindowsCameraSession()
{
delete m_cameraImageProcessing;
- delete m_cameraFocus;
delete m_cameraExposure;
delete m_cameraReader;
}
@@ -130,11 +127,6 @@ void QWindowsCameraSession::setVideoSink(QVideoSink *surface)
m_cameraReader->setSurface(surface);
}
-QWindowsCameraFocus *QWindowsCameraSession::focusControl()
-{
- return m_cameraFocus;
-}
-
QWindowsCameraExposure *QWindowsCameraSession::exposureControl()
{
return m_cameraExposure;
diff --git a/src/multimedia/platform/windows/mediacapture/qwindowscamerasession_p.h b/src/multimedia/platform/windows/mediacapture/qwindowscamerasession_p.h
index 46f3d9ac5..893036dd8 100644
--- a/src/multimedia/platform/windows/mediacapture/qwindowscamerasession_p.h
+++ b/src/multimedia/platform/windows/mediacapture/qwindowscamerasession_p.h
@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
class QVideoSink;
class QWindowsCameraReader;
class QWindowsCameraExposure;
-class QWindowsCameraFocus;
class QWindowsCameraImageProcessing;
class QWindowsCameraSession : public QObject
@@ -86,7 +85,6 @@ public:
void setVideoSink(QVideoSink *surface);
- QWindowsCameraFocus *focusControl();
QWindowsCameraExposure *exposureControl();
QWindowsCameraImageProcessing *imageProcessingControl();
@@ -117,7 +115,6 @@ private:
QCameraInfo m_activeCameraInfo;
QWindowsCameraReader *m_cameraReader = nullptr;
QWindowsCameraExposure *m_cameraExposure = nullptr;
- QWindowsCameraFocus *m_cameraFocus = nullptr;
QWindowsCameraImageProcessing *m_cameraImageProcessing = nullptr;
QImageEncoderSettings m_imageEncoderSettings;
QMediaEncoderSettings m_mediaEncoderSettings;