summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <peng.wu@intopalo.com>2015-08-06 16:33:39 +0300
committerAndrew Knight <andrew.knight@intopalo.com>2015-08-10 12:12:49 +0000
commit5cec451c10e73785c95fb236cbae7205a9a661d0 (patch)
treed1a9abd7c6a1eb8dc4345fa565d10a5777509721 /src
parentef3695a009c7cb5cfda2bbe4f2e0480b0334a631 (diff)
winrt: Add camera focus and focus lock controls
[ChangLog][multimedia][winrt] The winrt backend now supports camera focus and focus lock for Windows Phone. Task-Id: QTBUG-46120 Change-Id: Idb222798284d887a6e90a4986c69274e0ef765f5 Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.cpp411
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.h13
-rw-r--r--src/plugins/winrt/qwinrtcamerafocuscontrol.cpp273
-rw-r--r--src/plugins/winrt/qwinrtcamerafocuscontrol.h77
-rw-r--r--src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp4
-rw-r--r--src/plugins/winrt/qwinrtcameraimagecapturecontrol.h3
-rw-r--r--src/plugins/winrt/qwinrtcameralockscontrol.cpp125
-rw-r--r--src/plugins/winrt/qwinrtcameralockscontrol.h66
-rw-r--r--src/plugins/winrt/qwinrtcameraservice.cpp42
-rw-r--r--src/plugins/winrt/winrt.pro16
10 files changed, 1003 insertions, 27 deletions
diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp
index 9013416fe..833054c6e 100644
--- a/src/plugins/winrt/qwinrtcameracontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameracontrol.cpp
@@ -39,6 +39,8 @@
#include "qwinrtvideodeviceselectorcontrol.h"
#include "qwinrtcameraimagecapturecontrol.h"
#include "qwinrtimageencodercontrol.h"
+#include "qwinrtcamerafocuscontrol.h"
+#include "qwinrtcameralockscontrol.h"
#include <QtCore/qfunctions_winrt.h>
#include <QtCore/QCoreApplication>
@@ -51,6 +53,7 @@
#include <windows.devices.enumeration.h>
#include <windows.media.capture.h>
#include <windows.storage.streams.h>
+#include <windows.media.devices.h>
#ifdef Q_OS_WINPHONE
#include <Windows.Security.ExchangeActiveSyncProvisioning.h>
@@ -76,10 +79,99 @@ QT_BEGIN_NAMESPACE
RETURN_VOID_IF_FAILED(msg); \
}
+#define FOCUS_RECT_SIZE 0.01f
+#define FOCUS_RECT_HALF_SIZE 0.005f // FOCUS_RECT_SIZE / 2
+#define FOCUS_RECT_BOUNDARY 1.0f
+#define FOCUS_RECT_POSITION_MIN 0.0f
+#define FOCUS_RECT_POSITION_MAX 0.995f // FOCUS_RECT_BOUNDARY - FOCUS_RECT_HALF_SIZE
+
inline uint qHash (const QSize &key) {
return key.width() * key.height();
}
+template<typename T, size_t typeSize> struct CustomPropertyValue;
+
+inline static ComPtr<IPropertyValueStatics> propertyValueStatics()
+{
+ ComPtr<IPropertyValueStatics> valueStatics;
+ GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(), &valueStatics);
+ return valueStatics;
+}
+
+template <typename T>
+struct CustomPropertyValue<T, 4>
+{
+ static ComPtr<IReference<T>> create(T value)
+ {
+ ComPtr<IInspectable> propertyValueObject;
+ HRESULT hr = propertyValueStatics()->CreateUInt32(value, &propertyValueObject);
+ ComPtr<IReference<UINT32>> uint32Object;
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = propertyValueObject.As(&uint32Object);
+ Q_ASSERT_SUCCEEDED(hr);
+ return reinterpret_cast<IReference<T> *>(uint32Object.Get());
+ }
+};
+
+template <typename T>
+struct CustomPropertyValue<T, 8>
+{
+ static ComPtr<IReference<T>> create(T value)
+ {
+ ComPtr<IInspectable> propertyValueObject;
+ HRESULT hr = propertyValueStatics()->CreateUInt64(value, &propertyValueObject);
+ ComPtr<IReference<UINT64>> uint64Object;
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = propertyValueObject.As(&uint64Object);
+ Q_ASSERT_SUCCEEDED(hr);
+ return reinterpret_cast<IReference<T> *>(uint64Object.Get());
+ }
+};
+
+// Required camera point focus
+class WindowsRegionOfInterestIterableIterator : public RuntimeClass<IIterator<RegionOfInterest *>>
+{
+public:
+ explicit WindowsRegionOfInterestIterableIterator(const ComPtr<IRegionOfInterest> &item)
+ {
+ regionOfInterest = item;
+ }
+ HRESULT __stdcall get_Current(IRegionOfInterest **current)
+ {
+ *current = regionOfInterest.Detach();
+ return S_OK;
+ }
+ HRESULT __stdcall get_HasCurrent(boolean *hasCurrent)
+ {
+ *hasCurrent = true;
+ return S_OK;
+ }
+ HRESULT __stdcall MoveNext(boolean *hasCurrent)
+ {
+ *hasCurrent = false;
+ return S_OK;
+ }
+private:
+ ComPtr<IRegionOfInterest> regionOfInterest;
+};
+
+class WindowsRegionOfInterestIterable : public RuntimeClass<IIterable<RegionOfInterest *>>
+{
+public:
+ explicit WindowsRegionOfInterestIterable(const ComPtr<IRegionOfInterest> &item)
+ {
+ regionOfInterest = item;
+ }
+ HRESULT __stdcall First(IIterator<RegionOfInterest *> **first)
+ {
+ ComPtr<WindowsRegionOfInterestIterableIterator> iterator = Make<WindowsRegionOfInterestIterableIterator>(regionOfInterest);
+ *first = iterator.Detach();
+ return S_OK;
+ }
+private:
+ ComPtr<IRegionOfInterest> regionOfInterest;
+};
+
class CriticalSectionLocker
{
public:
@@ -454,12 +546,16 @@ public:
ComPtr<IMediaEncodingProfile> encodingProfile;
ComPtr<MediaSink> mediaSink;
+ ComPtr<IFocusControl> focusControl;
+ ComPtr<IRegionsOfInterestControl> regionsOfInterestControl;
QSize size;
QPointer<QWinRTCameraVideoRendererControl> videoRenderer;
QPointer<QWinRTVideoDeviceSelectorControl> videoDeviceSelector;
QPointer<QWinRTCameraImageCaptureControl> imageCaptureControl;
QPointer<QWinRTImageEncoderControl> imageEncoderControl;
+ QPointer<QWinRTCameraFocusControl> cameraFocusControl;
+ QPointer<QWinRTCameraLocksControl> cameraLocksControl;
};
QWinRTCameraControl::QWinRTCameraControl(QObject *parent)
@@ -478,6 +574,8 @@ QWinRTCameraControl::QWinRTCameraControl(QObject *parent)
d->videoDeviceSelector = new QWinRTVideoDeviceSelectorControl(this);
d->imageCaptureControl = new QWinRTCameraImageCaptureControl(this);
d->imageEncoderControl = new QWinRTImageEncoderControl(this);
+ d->cameraFocusControl = new QWinRTCameraFocusControl(this);
+ d->cameraLocksControl = new QWinRTCameraLocksControl(this);
}
QWinRTCameraControl::~QWinRTCameraControl()
@@ -524,6 +622,10 @@ void QWinRTCameraControl::setState(QCamera::State state)
return;
}
+ QCameraFocus::FocusModes focusMode = d->cameraFocusControl->focusMode();
+ if (setFocus(focusMode) && focusMode == QCameraFocus::ContinuousFocus)
+ focus();
+
d->state = QCamera::ActiveState;
emit stateChanged(d->state);
d->status = QCamera::ActiveStatus;
@@ -668,6 +770,18 @@ QImageEncoderControl *QWinRTCameraControl::imageEncoderControl() const
return d->imageEncoderControl;
}
+QCameraFocusControl *QWinRTCameraControl::cameraFocusControl() const
+{
+ Q_D(const QWinRTCameraControl);
+ return d->cameraFocusControl;
+}
+
+QCameraLocksControl *QWinRTCameraControl::cameraLocksControl() const
+{
+ Q_D(const QWinRTCameraControl);
+ return d->cameraLocksControl;
+}
+
IMediaCapture *QWinRTCameraControl::handle() const
{
Q_D(const QWinRTCameraControl);
@@ -749,6 +863,26 @@ HRESULT QWinRTCameraControl::initialize()
ComPtr<IVideoDeviceController> videoDeviceController;
hr = d->capture->get_VideoDeviceController(&videoDeviceController);
+ ComPtr<IAdvancedVideoCaptureDeviceController2> advancedVideoDeviceController;
+ hr = videoDeviceController.As(&advancedVideoDeviceController);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = advancedVideoDeviceController->get_FocusControl(&d->focusControl);
+ Q_ASSERT_SUCCEEDED(hr);
+
+ boolean isFocusSupported;
+ hr = d->focusControl->get_Supported(&isFocusSupported);
+ Q_ASSERT_SUCCEEDED(hr);
+ if (isFocusSupported) {
+ hr = advancedVideoDeviceController->get_RegionsOfInterestControl(&d->regionsOfInterestControl);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = initializeFocus();
+ Q_ASSERT_SUCCEEDED(hr);
+ } else {
+ d->cameraFocusControl->setSupportedFocusMode(0);
+ d->cameraFocusControl->setSupportedFocusPointMode(QSet<QCameraFocus::FocusPointMode>());
+ }
+ d->cameraLocksControl->initialize();
+
Q_ASSERT_SUCCEEDED(hr);
ComPtr<IMediaDeviceController> deviceController;
hr = videoDeviceController.As(&deviceController);
@@ -831,6 +965,278 @@ HRESULT QWinRTCameraControl::initialize()
return hr;
}
+#ifdef Q_OS_WINPHONE
+
+HRESULT QWinRTCameraControl::initializeFocus()
+{
+ Q_D(QWinRTCameraControl);
+ ComPtr<IFocusControl2> focusControl2;
+ HRESULT hr = d->focusControl.As(&focusControl2);
+ Q_ASSERT_SUCCEEDED(hr);
+ ComPtr<IVectorView<enum FocusMode>> focusModes;
+ hr = focusControl2->get_SupportedFocusModes(&focusModes);
+ if (FAILED(hr)) {
+ d->cameraFocusControl->setSupportedFocusMode(0);
+ d->cameraFocusControl->setSupportedFocusPointMode(QSet<QCameraFocus::FocusPointMode>());
+ qErrnoWarning(hr, "Failed to get camera supported focus mode list");
+ return hr;
+ }
+ quint32 size;
+ hr = focusModes->get_Size(&size);
+ Q_ASSERT_SUCCEEDED(hr);
+ QCameraFocus::FocusModes supportedModeFlag = 0;
+ for (quint32 i = 0; i < size; ++i) {
+ FocusMode mode;
+ hr = focusModes->GetAt(i, &mode);
+ Q_ASSERT_SUCCEEDED(hr);
+ switch (mode) {
+ case FocusMode_Continuous:
+ supportedModeFlag |= QCameraFocus::ContinuousFocus;
+ break;
+ case FocusMode_Single:
+ supportedModeFlag |= QCameraFocus::AutoFocus;
+ break;
+ default:
+ break;
+ }
+ }
+
+ ComPtr<IVectorView<enum AutoFocusRange>> focusRange;
+ hr = focusControl2->get_SupportedFocusRanges(&focusRange);
+ if (FAILED(hr)) {
+ qErrnoWarning(hr, "Failed to get camera supported focus range list");
+ } else {
+ hr = focusRange->get_Size(&size);
+ Q_ASSERT_SUCCEEDED(hr);
+ for (quint32 i = 0; i < size; ++i) {
+ AutoFocusRange range;
+ hr = focusRange->GetAt(i, &range);
+ Q_ASSERT_SUCCEEDED(hr);
+ switch (range) {
+ case AutoFocusRange_Macro:
+ supportedModeFlag |= QCameraFocus::MacroFocus;
+ break;
+ case AutoFocusRange_FullRange:
+ supportedModeFlag |= QCameraFocus::InfinityFocus;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ d->cameraFocusControl->setSupportedFocusMode(supportedModeFlag);
+ if (!d->regionsOfInterestControl) {
+ d->cameraFocusControl->setSupportedFocusPointMode(QSet<QCameraFocus::FocusPointMode>());
+ return S_OK;
+ }
+ boolean isRegionsfocusSupported = false;
+ hr = d->regionsOfInterestControl->get_AutoFocusSupported(&isRegionsfocusSupported);
+ Q_ASSERT_SUCCEEDED(hr);
+ UINT32 maxRegions;
+ hr = d->regionsOfInterestControl->get_MaxRegions(&maxRegions);
+ Q_ASSERT_SUCCEEDED(hr);
+ if (!isRegionsfocusSupported || maxRegions == 0) {
+ d->cameraFocusControl->setSupportedFocusPointMode(QSet<QCameraFocus::FocusPointMode>());
+ return S_OK;
+ }
+ QSet<QCameraFocus::FocusPointMode> supportedFocusPointModes;
+ supportedFocusPointModes << QCameraFocus::FocusPointCustom
+ << QCameraFocus::FocusPointCenter
+ << QCameraFocus::FocusPointAuto;
+ d->cameraFocusControl->setSupportedFocusPointMode(supportedFocusPointModes);
+ return S_OK;
+}
+
+bool QWinRTCameraControl::setFocus(QCameraFocus::FocusModes modes)
+{
+ Q_D(QWinRTCameraControl);
+ if (d->status == QCamera::UnloadedStatus)
+ return false;
+
+ ComPtr<IFocusSettings> focusSettings;
+ ComPtr<IInspectable> focusSettingsObject;
+ HRESULT hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Media_Devices_FocusSettings).Get(), &focusSettingsObject);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = focusSettingsObject.As(&focusSettings);
+ Q_ASSERT_SUCCEEDED(hr);
+ FocusMode mode;
+ if (modes.testFlag(QCameraFocus::ContinuousFocus)) {
+ mode = FocusMode_Continuous;
+ } else if (modes.testFlag(QCameraFocus::AutoFocus)
+ || modes.testFlag(QCameraFocus::MacroFocus)
+ || modes.testFlag(QCameraFocus::InfinityFocus)) {
+ // The Macro and infinity focus modes are only supported in auto focus mode on WinRT.
+ // QML camera focus doesn't support combined focus flags settings. In the case of macro
+ // and infinity Focus modes, the auto focus setting is applied.
+ mode = FocusMode_Single;
+ } else {
+ emit error(QCamera::NotSupportedFeatureError, QStringLiteral("Unsupported camera focus modes."));
+ return false;
+ }
+ hr = focusSettings->put_Mode(mode);
+ Q_ASSERT_SUCCEEDED(hr);
+ AutoFocusRange range = AutoFocusRange_Normal;
+ if (modes.testFlag(QCameraFocus::MacroFocus))
+ range = AutoFocusRange_Macro;
+ else if (modes.testFlag(QCameraFocus::InfinityFocus))
+ range = AutoFocusRange_FullRange;
+ hr = focusSettings->put_AutoFocusRange(range);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = focusSettings->put_WaitForFocus(true);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = focusSettings->put_DisableDriverFallback(false);
+ Q_ASSERT_SUCCEEDED(hr);
+
+ ComPtr<IFocusControl2> focusControl2;
+ hr = d->focusControl.As(&focusControl2);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = focusControl2->Configure(focusSettings.Get());
+ RETURN_FALSE_IF_FAILED("Failed to configure camera focus control");
+ return true;
+}
+
+bool QWinRTCameraControl::setFocusPoint(const QPointF &focusPoint)
+{
+ Q_D(QWinRTCameraControl);
+ if (focusPoint.x() < FOCUS_RECT_POSITION_MIN || focusPoint.x() > FOCUS_RECT_BOUNDARY) {
+ emit error(QCamera::CameraError, QStringLiteral("Focus horizontal location should be between 0.0 and 1.0."));
+ return false;
+ }
+
+ if (focusPoint.y() < FOCUS_RECT_POSITION_MIN || focusPoint.y() > FOCUS_RECT_BOUNDARY) {
+ emit error(QCamera::CameraError, QStringLiteral("Focus vertical location should be between 0.0 and 1.0."));
+ return false;
+ }
+
+ ABI::Windows::Foundation::Rect rect;
+ rect.X = qBound<float>(FOCUS_RECT_POSITION_MIN, focusPoint.x() - FOCUS_RECT_HALF_SIZE, FOCUS_RECT_POSITION_MAX);
+ rect.Y = qBound<float>(FOCUS_RECT_POSITION_MIN, focusPoint.y() - FOCUS_RECT_HALF_SIZE, FOCUS_RECT_POSITION_MAX);
+ rect.Width = (rect.X + FOCUS_RECT_SIZE) < FOCUS_RECT_BOUNDARY ? FOCUS_RECT_SIZE : FOCUS_RECT_BOUNDARY - rect.X;
+ rect.Height = (rect.Y + FOCUS_RECT_SIZE) < FOCUS_RECT_BOUNDARY ? FOCUS_RECT_SIZE : FOCUS_RECT_BOUNDARY - rect.Y;
+
+ ComPtr<IRegionOfInterest> regionOfInterest;
+ ComPtr<IInspectable> regionOfInterestObject;
+ HRESULT hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Media_Devices_RegionOfInterest).Get(), &regionOfInterestObject);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = regionOfInterestObject.As(&regionOfInterest);
+ Q_ASSERT_SUCCEEDED(hr);
+ ComPtr<IRegionOfInterest2> regionOfInterest2;
+ hr = regionOfInterestObject.As(&regionOfInterest2);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = regionOfInterest2->put_BoundsNormalized(true);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = regionOfInterest2->put_Weight(1);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = regionOfInterest2->put_Type(RegionOfInterestType_Unknown);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = regionOfInterest->put_AutoFocusEnabled(true);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = regionOfInterest->put_Bounds(rect);
+ Q_ASSERT_SUCCEEDED(hr);
+
+ ComPtr<WindowsRegionOfInterestIterable> regionOfInterestIterable = Make<WindowsRegionOfInterestIterable>(regionOfInterest);
+ ComPtr<IAsyncAction> op;
+ hr = d->regionsOfInterestControl->SetRegionsAsync(regionOfInterestIterable.Get(), &op);
+ Q_ASSERT_SUCCEEDED(hr);
+ return QWinRTFunctions::await(op) == S_OK;
+}
+
+bool QWinRTCameraControl::focus()
+{
+ Q_D(QWinRTCameraControl);
+ if (!d->focusControl)
+ return false;
+ ComPtr<IAsyncAction> op;
+ HRESULT hr = d->focusControl->FocusAsync(&op);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = QWinRTFunctions::await(op);
+ Q_ASSERT_SUCCEEDED(hr);
+ return hr == S_OK;
+}
+
+void QWinRTCameraControl::clearFocusPoint()
+{
+ Q_D(QWinRTCameraControl);
+ if (!d->focusControl)
+ return;
+ ComPtr<IAsyncAction> op;
+ HRESULT hr = d->regionsOfInterestControl->ClearRegionsAsync(&op);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = QWinRTFunctions::await(op);
+ Q_ASSERT_SUCCEEDED(hr);
+}
+
+bool QWinRTCameraControl::lockFocus()
+{
+ Q_D(QWinRTCameraControl);
+ if (!d->focusControl)
+ return false;
+ ComPtr<IFocusControl2> focusControl2;
+ HRESULT hr = d->focusControl.As(&focusControl2);
+ Q_ASSERT_SUCCEEDED(hr);
+ ComPtr<IAsyncAction> op;
+ hr = focusControl2->LockAsync(&op);
+ Q_ASSERT_SUCCEEDED(hr);
+ return QWinRTFunctions::await(op) == S_OK;
+}
+
+bool QWinRTCameraControl::unlockFocus()
+{
+ Q_D(QWinRTCameraControl);
+ if (!d->focusControl)
+ return false;
+ ComPtr<IFocusControl2> focusControl2;
+ HRESULT hr = d->focusControl.As(&focusControl2);
+ Q_ASSERT_SUCCEEDED(hr);
+ ComPtr<IAsyncAction> op;
+ hr = focusControl2->UnlockAsync(&op);
+ Q_ASSERT_SUCCEEDED(hr);
+ return QWinRTFunctions::await(op) == S_OK;
+}
+
+#else // Q_OS_WINPHONE
+
+HRESULT QWinRTCameraControl::initializeFocus()
+{
+ Q_D(QWinRTCameraControl);
+ d->cameraFocusControl->setSupportedFocusMode(0);
+ d->cameraFocusControl->setSupportedFocusPointMode(QSet<QCameraFocus::FocusPointMode>());
+ return S_OK;
+}
+
+bool QWinRTCameraControl::setFocus(QCameraFocus::FocusModes modes)
+{
+ Q_UNUSED(modes)
+ return false;
+}
+
+bool QWinRTCameraControl::setFocusPoint(const QPointF &focusPoint)
+{
+ Q_UNUSED(focusPoint)
+ return false;
+}
+
+bool QWinRTCameraControl::focus()
+{
+ return false;
+}
+
+void QWinRTCameraControl::clearFocusPoint()
+{
+}
+
+bool QWinRTCameraControl::lockFocus()
+{
+ return false;
+}
+
+bool QWinRTCameraControl::unlockFocus()
+{
+ return false;
+}
+
+#endif // !Q_OS_WINPHONE
+
HRESULT QWinRTCameraControl::onCaptureFailed(IMediaCapture *, IMediaCaptureFailedEventArgs *args)
{
HRESULT hr;
@@ -854,4 +1260,9 @@ HRESULT QWinRTCameraControl::onRecordLimitationExceeded(IMediaCapture *)
return S_OK;
}
+void QWinRTCameraControl::emitError(int errorCode, const QString &errorString)
+{
+ emit error(errorCode, errorString);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/winrt/qwinrtcameracontrol.h b/src/plugins/winrt/qwinrtcameracontrol.h
index 307667eb1..ac1c922a4 100644
--- a/src/plugins/winrt/qwinrtcameracontrol.h
+++ b/src/plugins/winrt/qwinrtcameracontrol.h
@@ -61,6 +61,8 @@ class QVideoRendererControl;
class QVideoDeviceSelectorControl;
class QCameraImageCaptureControl;
class QImageEncoderControl;
+class QCameraFocusControl;
+class QCameraLocksControl;
class QWinRTCameraControlPrivate;
class QWinRTCameraControl : public QCameraControl
@@ -85,15 +87,26 @@ public:
QVideoDeviceSelectorControl *videoDeviceSelector() const;
QCameraImageCaptureControl *imageCaptureControl() const;
QImageEncoderControl *imageEncoderControl() const;
+ QCameraFocusControl *cameraFocusControl() const;
+ QCameraLocksControl *cameraLocksControl() const;
ABI::Windows::Media::Capture::IMediaCapture *handle() const;
+ bool setFocus(QCameraFocus::FocusModes mode);
+ bool setFocusPoint(const QPointF &point);
+ bool focus();
+ void clearFocusPoint();
+ void emitError(int errorCode, const QString &errorString);
+ bool lockFocus();
+ bool unlockFocus();
+
private slots:
void onBufferRequested();
private:
HRESULT enumerateDevices();
HRESULT initialize();
+ HRESULT initializeFocus();
HRESULT onCaptureFailed(ABI::Windows::Media::Capture::IMediaCapture *,
ABI::Windows::Media::Capture::IMediaCaptureFailedEventArgs *);
HRESULT onRecordLimitationExceeded(ABI::Windows::Media::Capture::IMediaCapture *);
diff --git a/src/plugins/winrt/qwinrtcamerafocuscontrol.cpp b/src/plugins/winrt/qwinrtcamerafocuscontrol.cpp
new file mode 100644
index 000000000..7eda823dd
--- /dev/null
+++ b/src/plugins/winrt/qwinrtcamerafocuscontrol.cpp
@@ -0,0 +1,273 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwinrtcamerafocuscontrol.h"
+#include "qwinrtcameraimagecapturecontrol.h"
+#include "qwinrtcameracontrol.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWinRTCameraFocusControlPrivate
+{
+public:
+ QCameraFocus::FocusModes focusModes;
+ QCameraFocus::FocusModes supportedFocusModes;
+ QCameraFocus::FocusPointMode focusPointMode;
+ QSet<QCameraFocus::FocusPointMode> supportedFocusPointModes;
+ QPointF focusPoint;
+ bool focusModeInitialized;
+ bool focusPointModeInitialized;
+ bool imageCaptureIdle;
+};
+
+QWinRTCameraFocusControl::QWinRTCameraFocusControl(QWinRTCameraControl *parent)
+ : QCameraFocusControl(parent), d_ptr(new QWinRTCameraFocusControlPrivate)
+{
+ Q_D(QWinRTCameraFocusControl);
+ d->focusModeInitialized = false;
+ d->focusPointModeInitialized = false;
+ d->focusModes = QCameraFocus::ContinuousFocus;
+ d->focusPointMode = QCameraFocus::FocusPointAuto;
+ d->imageCaptureIdle = true;
+ QWinRTCameraImageCaptureControl *imageCaptureControl = static_cast<QWinRTCameraImageCaptureControl *>(parent->imageCaptureControl());
+ Q_ASSERT(imageCaptureControl);
+ connect(imageCaptureControl, &QWinRTCameraImageCaptureControl::captureQueueChanged,
+ this, &QWinRTCameraFocusControl::imageCaptureQueueChanged, Qt::QueuedConnection);
+}
+
+QCameraFocus::FocusModes QWinRTCameraFocusControl::focusMode() const
+{
+ Q_D(const QWinRTCameraFocusControl);
+ return d->focusModes;
+}
+
+void QWinRTCameraFocusControl::setFocusMode(QCameraFocus::FocusModes modes)
+{
+ QMetaObject::invokeMethod(this, "applyFocusMode", Qt::QueuedConnection, Q_ARG(QCameraFocus::FocusModes, modes));
+}
+
+bool QWinRTCameraFocusControl::isFocusModeSupported(QCameraFocus::FocusModes modes) const
+{
+ Q_D(const QWinRTCameraFocusControl);
+ return (d->focusModeInitialized && modes) ? !((d->supportedFocusModes & modes) ^ modes) : false;
+}
+
+QCameraFocus::FocusPointMode QWinRTCameraFocusControl::focusPointMode() const
+{
+ Q_D(const QWinRTCameraFocusControl);
+ return d->focusPointMode;
+}
+
+void QWinRTCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode)
+{
+ QMetaObject::invokeMethod(this, "applyFocusPointMode", Qt::QueuedConnection, Q_ARG(QCameraFocus::FocusPointMode, mode));
+}
+
+bool QWinRTCameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const
+{
+ Q_D(const QWinRTCameraFocusControl);
+ return d->supportedFocusPointModes.contains(mode);
+}
+
+QPointF QWinRTCameraFocusControl::customFocusPoint() const
+{
+ Q_D(const QWinRTCameraFocusControl);
+ return d->focusPoint;
+}
+
+void QWinRTCameraFocusControl::setCustomFocusPoint(const QPointF &point)
+{
+ QMetaObject::invokeMethod(this, "applyFocusCustomPoint", Qt::QueuedConnection, Q_ARG(const QPointF, point));
+}
+
+QCameraFocusZoneList QWinRTCameraFocusControl::focusZones() const
+{
+ return QCameraFocusZoneList();
+}
+
+void QWinRTCameraFocusControl::setSupportedFocusMode(QCameraFocus::FocusModes modes)
+{
+ Q_D(QWinRTCameraFocusControl);
+ d->supportedFocusModes = modes;
+ d->focusModeInitialized = true;
+ if (isFocusModeSupported(d->focusModes))
+ return;
+ d->focusModes = 0;
+ if (!modes) {
+ emit focusModeChanged(d->focusModes);
+ return;
+ }
+ if (isFocusModeSupported(QCameraFocus::ContinuousFocus))
+ d->focusModes = QCameraFocus::ContinuousFocus;
+ else if (isFocusModeSupported(QCameraFocus::AutoFocus))
+ d->focusModes = QCameraFocus::AutoFocus;
+ else if (isFocusModeSupported(QCameraFocus::ManualFocus))
+ d->focusModes = QCameraFocus::ManualFocus;
+ emit focusModeChanged(d->focusModes);
+}
+
+void QWinRTCameraFocusControl::setSupportedFocusPointMode(const QSet<QCameraFocus::FocusPointMode> &supportedFocusPointModes)
+{
+ Q_D(QWinRTCameraFocusControl);
+ d->supportedFocusPointModes = supportedFocusPointModes;
+ d->focusPointModeInitialized = true;
+
+ if (supportedFocusPointModes.isEmpty()) {
+ if (d->focusPointMode != QCameraFocus::FocusPointAuto) {
+ d->focusPointMode = QCameraFocus::FocusPointAuto;
+ emit focusPointModeChanged(d->focusPointMode);
+ }
+ return;
+ }
+
+ if (isFocusPointModeSupported(d->focusPointMode))
+ return;
+
+ if (isFocusPointModeSupported(QCameraFocus::FocusPointCenter))
+ d->focusPointMode = QCameraFocus::FocusPointCenter;
+ else if (isFocusPointModeSupported(QCameraFocus::FocusPointAuto))
+ d->focusPointMode = QCameraFocus::FocusPointAuto;
+ else if (isFocusPointModeSupported(QCameraFocus::FocusPointCustom))
+ d->focusPointMode = QCameraFocus::FocusPointCustom;
+ else if (isFocusPointModeSupported(QCameraFocus::FocusPointFaceDetection))
+ d->focusPointMode = QCameraFocus::FocusPointFaceDetection;
+ emit focusPointModeChanged(d->focusPointMode);
+}
+
+void QWinRTCameraFocusControl::imageCaptureQueueChanged(bool isEmpty)
+{
+ Q_D(QWinRTCameraFocusControl);
+ d->imageCaptureIdle = isEmpty;
+}
+
+void QWinRTCameraFocusControl::applyFocusCustomPoint(const QPointF &point)
+{
+ Q_D(QWinRTCameraFocusControl);
+ if (d->focusPointMode != QCameraFocus::FocusPointCustom) {
+ QWinRTCameraControl *cameraControl = static_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ cameraControl->emitError(QCamera::InvalidRequestError, QStringLiteral("Custom focus point can be set only in FocusPointCustom focus mode."));
+ return;
+ }
+ if (d->focusPoint == point)
+ return;
+ if (changeFocusCustomPoint(point)) {
+ d->focusPoint = point;
+ emit customFocusPointChanged(point);
+ }
+}
+
+void QWinRTCameraFocusControl::applyFocusMode(QCameraFocus::FocusModes modes)
+{
+ Q_D(QWinRTCameraFocusControl);
+ if (d->focusModes == modes)
+ return;
+ QWinRTCameraControl *cameraControl = static_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ if (!modes) {
+ cameraControl->emitError(QCamera::InvalidRequestError, QStringLiteral("Can't set empty camera focus modes."));
+ return;
+ }
+ if (!d->focusModeInitialized) {
+ d->focusModes = modes;
+ emit focusModeChanged(modes);
+ return;
+ }
+ if (!isFocusModeSupported(modes)) {
+ cameraControl->emitError(QCamera::NotSupportedFeatureError, QStringLiteral("Unsupported camera focus modes."));
+ return;
+ }
+ if (modes.testFlag(QCameraFocus::ContinuousFocus)) {
+ if (QCameraFocus::FocusPointCustom == d->focusPointMode) {
+ cameraControl->emitError(QCamera::NotSupportedFeatureError,
+ QStringLiteral("Unsupported camera focus modes: ContinuousFocus with FocusPointCustom."));
+ return;
+ } else if (!d->imageCaptureIdle) {
+ cameraControl->emitError(QCamera::NotSupportedFeatureError,
+ QStringLiteral("Can't set ContinuousFocus camera focus mode while capturing image."));
+ return;
+ }
+ }
+ if (!cameraControl->setFocus(modes))
+ return;
+ if (modes.testFlag(QCameraFocus::ContinuousFocus) || d->focusModes.testFlag(QCameraFocus::ContinuousFocus))
+ cameraControl->focus();
+ d->focusModes = modes;
+ emit focusModeChanged(modes);
+}
+
+void QWinRTCameraFocusControl::applyFocusPointMode(QCameraFocus::FocusPointMode mode)
+{
+ Q_D(QWinRTCameraFocusControl);
+ if (d->focusPointMode == mode)
+ return;
+
+ if (!d->focusModeInitialized) {
+ d->focusPointMode = mode;
+ emit focusPointModeChanged(mode);
+ return;
+ }
+ QWinRTCameraControl *cameraControl = static_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ if (!d->supportedFocusPointModes.contains(mode)) {
+ cameraControl->emitError(QCamera::NotSupportedFeatureError, QStringLiteral("Unsupported camera point focus mode."));
+ return;
+ }
+ if (QCameraFocus::FocusPointCenter == mode || QCameraFocus::FocusPointAuto == mode)
+ d->focusPoint = QPointF(0.5, 0.5);
+ // Don't apply focus point focus settings if camera is in continuous focus mode
+ if (!d->focusModes.testFlag(QCameraFocus::ContinuousFocus)) {
+ changeFocusCustomPoint(d->focusPoint);
+ } else if (QCameraFocus::FocusPointCustom == mode) {
+ cameraControl->emitError(QCamera::NotSupportedFeatureError, QStringLiteral("Unsupported camera focus modes: ContinuousFocus with FocusPointCustom."));
+ return;
+ }
+ d->focusPointMode = mode;
+ emit focusPointModeChanged(mode);
+}
+
+bool QWinRTCameraFocusControl::changeFocusCustomPoint(const QPointF &point)
+{
+ Q_D(QWinRTCameraFocusControl);
+ if (!d->focusPointModeInitialized || point.isNull())
+ return true;
+ QWinRTCameraControl *cameraControl = static_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ cameraControl->clearFocusPoint();
+ return cameraControl->setFocusPoint(point);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/winrt/qwinrtcamerafocuscontrol.h b/src/plugins/winrt/qwinrtcamerafocuscontrol.h
new file mode 100644
index 000000000..4862c0115
--- /dev/null
+++ b/src/plugins/winrt/qwinrtcamerafocuscontrol.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINRTCAMERAFOCUSCONTROL_H
+#define QWINRTCAMERAFOCUSCONTROL_H
+#include <qcamerafocuscontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWinRTCameraControl;
+class QWinRTCameraFocusControlPrivate;
+class QWinRTCameraFocusControl : public QCameraFocusControl
+{
+ Q_OBJECT
+public:
+ explicit QWinRTCameraFocusControl(QWinRTCameraControl *parent);
+
+ QCameraFocus::FocusModes focusMode() const Q_DECL_OVERRIDE;
+ void setFocusMode(QCameraFocus::FocusModes mode) Q_DECL_OVERRIDE;
+ bool isFocusModeSupported(QCameraFocus::FocusModes mode) const Q_DECL_OVERRIDE;
+ QCameraFocus::FocusPointMode focusPointMode() const Q_DECL_OVERRIDE;
+ void setFocusPointMode(QCameraFocus::FocusPointMode mode) Q_DECL_OVERRIDE;
+ bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const Q_DECL_OVERRIDE;
+ QPointF customFocusPoint() const Q_DECL_OVERRIDE;
+ void setCustomFocusPoint(const QPointF &point) Q_DECL_OVERRIDE;
+ QCameraFocusZoneList focusZones() const Q_DECL_OVERRIDE;
+
+ void setSupportedFocusMode(QCameraFocus::FocusModes flag);
+ void setSupportedFocusPointMode(const QSet<QCameraFocus::FocusPointMode> &supportedFocusPointModes);
+
+private slots:
+ void imageCaptureQueueChanged(bool isEmpty);
+
+private:
+ Q_INVOKABLE void applyFocusCustomPoint(const QPointF &point);
+ Q_INVOKABLE void applyFocusMode(QCameraFocus::FocusModes modes);
+ Q_INVOKABLE void applyFocusPointMode(QCameraFocus::FocusPointMode mode);
+ bool changeFocusCustomPoint(const QPointF &point);
+
+ QScopedPointer<QWinRTCameraFocusControlPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QWinRTCameraFocusControl)
+};
+
+#endif // QWINRTCAMERAFOCUSCONTROL_H
diff --git a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
index 55f553778..ae67e33f4 100644
--- a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
@@ -179,6 +179,7 @@ int QWinRTCameraImageCaptureControl::capture(const QString &fileName)
qErrnoWarning("Camera photo capture failed.");
return -1;
}
+ emit captureQueueChanged(false);
d->requests.insert(request.op.Get(), request);
hr = request.op->put_Completed(Callback<IAsyncActionCompletedHandler>(
@@ -199,6 +200,7 @@ void QWinRTCameraImageCaptureControl::cancelCapture()
info->Cancel();
it = d->requests.erase(it);
}
+ emit captureQueueChanged(true);
}
HRESULT QWinRTCameraImageCaptureControl::onCaptureCompleted(IAsyncAction *asyncInfo, AsyncStatus status)
@@ -209,7 +211,7 @@ HRESULT QWinRTCameraImageCaptureControl::onCaptureCompleted(IAsyncAction *asyncI
return S_OK;
CaptureRequest request = d->requests.take(asyncInfo);
-
+ emit captureQueueChanged(d->requests.isEmpty());
HRESULT hr;
if (status == Error) {
hr = asyncInfo->GetResults();
diff --git a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.h b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.h
index dc8802552..1fbdccf6b 100644
--- a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.h
+++ b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.h
@@ -68,6 +68,9 @@ public:
int capture(const QString &fileName) Q_DECL_OVERRIDE;
void cancelCapture() Q_DECL_OVERRIDE;
+signals:
+ void captureQueueChanged(bool isEmpty);
+
private:
HRESULT onCaptureCompleted(ABI::Windows::Foundation::IAsyncAction *,
ABI::Windows::Foundation::AsyncStatus);
diff --git a/src/plugins/winrt/qwinrtcameralockscontrol.cpp b/src/plugins/winrt/qwinrtcameralockscontrol.cpp
new file mode 100644
index 000000000..e429c5ff1
--- /dev/null
+++ b/src/plugins/winrt/qwinrtcameralockscontrol.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCameraFocusControl>
+
+#include "qwinrtcameralockscontrol.h"
+#include "qwinrtcameracontrol.h"
+
+QT_BEGIN_NAMESPACE
+
+QWinRTCameraLocksControl::QWinRTCameraLocksControl(QObject *parent)
+ : QCameraLocksControl(parent)
+ , m_supportedLocks(QCamera::NoLock)
+ , m_focusLockStatus(QCamera::Unlocked)
+{
+}
+
+QCamera::LockTypes QWinRTCameraLocksControl::supportedLocks() const
+{
+ return m_supportedLocks;
+}
+
+QCamera::LockStatus QWinRTCameraLocksControl::lockStatus(QCamera::LockType lock) const
+{
+ switch (lock) {
+ case QCamera::LockFocus:
+ return m_focusLockStatus;
+ case QCamera::LockExposure:
+ case QCamera::LockWhiteBalance:
+ default:
+ return QCamera::Unlocked;
+ }
+}
+
+void QWinRTCameraLocksControl::searchAndLock(QCamera::LockTypes locks)
+{
+ if (locks.testFlag(QCamera::LockFocus)) {
+ QMetaObject::invokeMethod(this, "searchAndLockFocus", Qt::QueuedConnection);
+ } else {
+ QWinRTCameraControl *cameraControl = qobject_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ cameraControl->emitError(QCamera::InvalidRequestError, QStringLiteral("Unsupported camera lock type."));
+ }
+}
+
+void QWinRTCameraLocksControl::unlock(QCamera::LockTypes locks)
+{
+ if (locks.testFlag(QCamera::LockFocus))
+ QMetaObject::invokeMethod(this, "unlockFocus", Qt::QueuedConnection);
+}
+
+void QWinRTCameraLocksControl::initialize()
+{
+ QWinRTCameraControl *cameraControl = qobject_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ QCameraFocusControl *focusControl = cameraControl->cameraFocusControl();
+ Q_ASSERT(focusControl);
+ if (focusControl->isFocusModeSupported(QCameraFocus::AutoFocus))
+ m_supportedLocks |= QCamera::LockFocus;
+}
+
+void QWinRTCameraLocksControl::searchAndLockFocus()
+{
+ if (QCamera::Locked == m_focusLockStatus)
+ unlockFocus();
+ QWinRTCameraControl *cameraControl = qobject_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ QCameraFocusControl *focusControl = cameraControl->cameraFocusControl();
+ Q_ASSERT(focusControl);
+ if (focusControl->focusMode().testFlag(QCameraFocus::ContinuousFocus)) {
+ cameraControl->emitError(QCamera::NotSupportedFeatureError, QStringLiteral("Camera can't lock focus in continuous focus mode."));
+ } else {
+ m_focusLockStatus = QCamera::Searching;
+ emit lockStatusChanged(QCamera::LockFocus, m_focusLockStatus, QCamera::LockAcquired);
+ cameraControl->focus();
+ cameraControl->lockFocus();
+ m_focusLockStatus = QCamera::Locked;
+ emit lockStatusChanged(QCamera::LockFocus, m_focusLockStatus, QCamera::LockAcquired);
+ }
+}
+
+void QWinRTCameraLocksControl::unlockFocus()
+{
+ if (QCamera::Unlocked == m_focusLockStatus)
+ return;
+ QWinRTCameraControl *cameraControl = qobject_cast<QWinRTCameraControl *>(parent());
+ Q_ASSERT(cameraControl);
+ cameraControl->unlockFocus();
+ m_focusLockStatus = QCamera::Unlocked;
+ emit lockStatusChanged(QCamera::LockFocus, m_focusLockStatus, QCamera::UserRequest);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/winrt/qwinrtcameralockscontrol.h b/src/plugins/winrt/qwinrtcameralockscontrol.h
new file mode 100644
index 000000000..5a7b57c11
--- /dev/null
+++ b/src/plugins/winrt/qwinrtcameralockscontrol.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINRTCAMERALOCKSCONTROL_H
+#define QWINRTCAMERALOCKSCONTROL_H
+
+#include <QCameraLocksControl>
+
+QT_BEGIN_NAMESPACE
+
+class QWinRTCameraControl;
+class QWinRTCameraLocksControl : public QCameraLocksControl
+{
+ Q_OBJECT
+public:
+ explicit QWinRTCameraLocksControl(QObject *parent);
+
+ QCamera::LockTypes supportedLocks() const Q_DECL_OVERRIDE;
+ QCamera::LockStatus lockStatus(QCamera::LockType lock) const Q_DECL_OVERRIDE;
+ void searchAndLock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
+ void unlock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
+ void initialize();
+
+private:
+ Q_INVOKABLE void searchAndLockFocus();
+ Q_INVOKABLE void unlockFocus();
+ QCamera::LockTypes m_supportedLocks;
+ QCamera::LockStatus m_focusLockStatus;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINRTCAMERALOCKSCONTROL_H
diff --git a/src/plugins/winrt/qwinrtcameraservice.cpp b/src/plugins/winrt/qwinrtcameraservice.cpp
index be67b4742..a4d292242 100644
--- a/src/plugins/winrt/qwinrtcameraservice.cpp
+++ b/src/plugins/winrt/qwinrtcameraservice.cpp
@@ -45,6 +45,8 @@
#include <QtMultimedia/QVideoRendererControl>
#include <QtMultimedia/QVideoDeviceSelectorControl>
#include <QtMultimedia/QImageEncoderControl>
+#include <QtMultimedia/QCameraFocusControl>
+#include <QtMultimedia/QCameraLocksControl>
QT_BEGIN_NAMESPACE
@@ -69,34 +71,34 @@ QMediaControl *QWinRTCameraService::requestControl(const char *name)
d->cameraControl = new QWinRTCameraControl(this);
return d->cameraControl;
}
-
- if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
- if (d->cameraControl)
- return d->cameraControl->videoRenderer();
- }
-
- if (qstrcmp(name, QVideoDeviceSelectorControl_iid) == 0) {
- if (d->cameraControl)
- return d->cameraControl->videoDeviceSelector();
- }
-
if (qstrcmp(name, QCameraInfoControl_iid) == 0) {
if (!d->cameraInfoControl)
d->cameraInfoControl = new QWinRTCameraInfoControl(this);
return d->cameraInfoControl;
}
- if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0) {
- if (d->cameraControl)
- return d->cameraControl->imageCaptureControl();
- }
+ if (!d->cameraControl)
+ return nullptr;
- if (qstrcmp(name, QImageEncoderControl_iid) == 0) {
- if (d->cameraControl)
- return d->cameraControl->imageEncoderControl();
- }
+ if (qstrcmp(name, QVideoRendererControl_iid) == 0)
+ return d->cameraControl->videoRenderer();
+
+ if (qstrcmp(name, QVideoDeviceSelectorControl_iid) == 0)
+ return d->cameraControl->videoDeviceSelector();
+
+ if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0)
+ return d->cameraControl->imageCaptureControl();
+
+ if (qstrcmp(name, QImageEncoderControl_iid) == 0)
+ return d->cameraControl->imageEncoderControl();
+
+ if (qstrcmp(name, QCameraFocusControl_iid) == 0)
+ return d->cameraControl->cameraFocusControl();
+
+ if (qstrcmp(name, QCameraLocksControl_iid) == 0)
+ return d->cameraControl->cameraLocksControl();
- return Q_NULLPTR;
+ return nullptr;
}
void QWinRTCameraService::releaseControl(QMediaControl *control)
diff --git a/src/plugins/winrt/winrt.pro b/src/plugins/winrt/winrt.pro
index 58c2371f9..3ccce818a 100644
--- a/src/plugins/winrt/winrt.pro
+++ b/src/plugins/winrt/winrt.pro
@@ -10,30 +10,34 @@ LIBS += -lmfplat -lmfuuid -loleaut32 -ld3d11 -lruntimeobject
HEADERS += \
qwinrtabstractvideorenderercontrol.h \
qwinrtcameracontrol.h \
- qwinrtcamerainfocontrol.h \
+ qwinrtcamerafocuscontrol.h \
qwinrtcameraimagecapturecontrol.h \
+ qwinrtcamerainfocontrol.h \
+ qwinrtcameralockscontrol.h \
qwinrtcameraservice.h \
qwinrtcameravideorenderercontrol.h \
+ qwinrtimageencodercontrol.h \
qwinrtmediaplayercontrol.h \
qwinrtmediaplayerservice.h \
qwinrtplayerrenderercontrol.h \
qwinrtserviceplugin.h \
- qwinrtvideodeviceselectorcontrol.h \
- qwinrtimageencodercontrol.h
+ qwinrtvideodeviceselectorcontrol.h
SOURCES += \
qwinrtabstractvideorenderercontrol.cpp \
qwinrtcameracontrol.cpp \
- qwinrtcamerainfocontrol.cpp \
+ qwinrtcamerafocuscontrol.cpp \
qwinrtcameraimagecapturecontrol.cpp \
+ qwinrtcamerainfocontrol.cpp \
+ qwinrtcameralockscontrol.cpp \
qwinrtcameraservice.cpp \
qwinrtcameravideorenderercontrol.cpp \
+ qwinrtimageencodercontrol.cpp \
qwinrtmediaplayercontrol.cpp \
qwinrtmediaplayerservice.cpp \
qwinrtplayerrenderercontrol.cpp \
qwinrtserviceplugin.cpp \
- qwinrtvideodeviceselectorcontrol.cpp \
- qwinrtimageencodercontrol.cpp
+ qwinrtvideodeviceselectorcontrol.cpp
OTHER_FILES += \
winrt.json