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>
This commit is contained in:
@@ -39,6 +39,8 @@
|
|||||||
#include "qwinrtvideodeviceselectorcontrol.h"
|
#include "qwinrtvideodeviceselectorcontrol.h"
|
||||||
#include "qwinrtcameraimagecapturecontrol.h"
|
#include "qwinrtcameraimagecapturecontrol.h"
|
||||||
#include "qwinrtimageencodercontrol.h"
|
#include "qwinrtimageencodercontrol.h"
|
||||||
|
#include "qwinrtcamerafocuscontrol.h"
|
||||||
|
#include "qwinrtcameralockscontrol.h"
|
||||||
|
|
||||||
#include <QtCore/qfunctions_winrt.h>
|
#include <QtCore/qfunctions_winrt.h>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
@@ -51,6 +53,7 @@
|
|||||||
#include <windows.devices.enumeration.h>
|
#include <windows.devices.enumeration.h>
|
||||||
#include <windows.media.capture.h>
|
#include <windows.media.capture.h>
|
||||||
#include <windows.storage.streams.h>
|
#include <windows.storage.streams.h>
|
||||||
|
#include <windows.media.devices.h>
|
||||||
|
|
||||||
#ifdef Q_OS_WINPHONE
|
#ifdef Q_OS_WINPHONE
|
||||||
#include <Windows.Security.ExchangeActiveSyncProvisioning.h>
|
#include <Windows.Security.ExchangeActiveSyncProvisioning.h>
|
||||||
@@ -76,10 +79,99 @@ QT_BEGIN_NAMESPACE
|
|||||||
RETURN_VOID_IF_FAILED(msg); \
|
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) {
|
inline uint qHash (const QSize &key) {
|
||||||
return key.width() * key.height();
|
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
|
class CriticalSectionLocker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -454,12 +546,16 @@ public:
|
|||||||
|
|
||||||
ComPtr<IMediaEncodingProfile> encodingProfile;
|
ComPtr<IMediaEncodingProfile> encodingProfile;
|
||||||
ComPtr<MediaSink> mediaSink;
|
ComPtr<MediaSink> mediaSink;
|
||||||
|
ComPtr<IFocusControl> focusControl;
|
||||||
|
ComPtr<IRegionsOfInterestControl> regionsOfInterestControl;
|
||||||
|
|
||||||
QSize size;
|
QSize size;
|
||||||
QPointer<QWinRTCameraVideoRendererControl> videoRenderer;
|
QPointer<QWinRTCameraVideoRendererControl> videoRenderer;
|
||||||
QPointer<QWinRTVideoDeviceSelectorControl> videoDeviceSelector;
|
QPointer<QWinRTVideoDeviceSelectorControl> videoDeviceSelector;
|
||||||
QPointer<QWinRTCameraImageCaptureControl> imageCaptureControl;
|
QPointer<QWinRTCameraImageCaptureControl> imageCaptureControl;
|
||||||
QPointer<QWinRTImageEncoderControl> imageEncoderControl;
|
QPointer<QWinRTImageEncoderControl> imageEncoderControl;
|
||||||
|
QPointer<QWinRTCameraFocusControl> cameraFocusControl;
|
||||||
|
QPointer<QWinRTCameraLocksControl> cameraLocksControl;
|
||||||
};
|
};
|
||||||
|
|
||||||
QWinRTCameraControl::QWinRTCameraControl(QObject *parent)
|
QWinRTCameraControl::QWinRTCameraControl(QObject *parent)
|
||||||
@@ -478,6 +574,8 @@ QWinRTCameraControl::QWinRTCameraControl(QObject *parent)
|
|||||||
d->videoDeviceSelector = new QWinRTVideoDeviceSelectorControl(this);
|
d->videoDeviceSelector = new QWinRTVideoDeviceSelectorControl(this);
|
||||||
d->imageCaptureControl = new QWinRTCameraImageCaptureControl(this);
|
d->imageCaptureControl = new QWinRTCameraImageCaptureControl(this);
|
||||||
d->imageEncoderControl = new QWinRTImageEncoderControl(this);
|
d->imageEncoderControl = new QWinRTImageEncoderControl(this);
|
||||||
|
d->cameraFocusControl = new QWinRTCameraFocusControl(this);
|
||||||
|
d->cameraLocksControl = new QWinRTCameraLocksControl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWinRTCameraControl::~QWinRTCameraControl()
|
QWinRTCameraControl::~QWinRTCameraControl()
|
||||||
@@ -524,6 +622,10 @@ void QWinRTCameraControl::setState(QCamera::State state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QCameraFocus::FocusModes focusMode = d->cameraFocusControl->focusMode();
|
||||||
|
if (setFocus(focusMode) && focusMode == QCameraFocus::ContinuousFocus)
|
||||||
|
focus();
|
||||||
|
|
||||||
d->state = QCamera::ActiveState;
|
d->state = QCamera::ActiveState;
|
||||||
emit stateChanged(d->state);
|
emit stateChanged(d->state);
|
||||||
d->status = QCamera::ActiveStatus;
|
d->status = QCamera::ActiveStatus;
|
||||||
@@ -668,6 +770,18 @@ QImageEncoderControl *QWinRTCameraControl::imageEncoderControl() const
|
|||||||
return d->imageEncoderControl;
|
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
|
IMediaCapture *QWinRTCameraControl::handle() const
|
||||||
{
|
{
|
||||||
Q_D(const QWinRTCameraControl);
|
Q_D(const QWinRTCameraControl);
|
||||||
@@ -749,6 +863,26 @@ HRESULT QWinRTCameraControl::initialize()
|
|||||||
|
|
||||||
ComPtr<IVideoDeviceController> videoDeviceController;
|
ComPtr<IVideoDeviceController> videoDeviceController;
|
||||||
hr = d->capture->get_VideoDeviceController(&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);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
ComPtr<IMediaDeviceController> deviceController;
|
ComPtr<IMediaDeviceController> deviceController;
|
||||||
hr = videoDeviceController.As(&deviceController);
|
hr = videoDeviceController.As(&deviceController);
|
||||||
@@ -831,6 +965,278 @@ HRESULT QWinRTCameraControl::initialize()
|
|||||||
return hr;
|
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(), ®ionOfInterestObject);
|
||||||
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
|
hr = regionOfInterestObject.As(®ionOfInterest);
|
||||||
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
|
ComPtr<IRegionOfInterest2> regionOfInterest2;
|
||||||
|
hr = regionOfInterestObject.As(®ionOfInterest2);
|
||||||
|
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 QWinRTCameraControl::onCaptureFailed(IMediaCapture *, IMediaCaptureFailedEventArgs *args)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@@ -854,4 +1260,9 @@ HRESULT QWinRTCameraControl::onRecordLimitationExceeded(IMediaCapture *)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QWinRTCameraControl::emitError(int errorCode, const QString &errorString)
|
||||||
|
{
|
||||||
|
emit error(errorCode, errorString);
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class QVideoRendererControl;
|
|||||||
class QVideoDeviceSelectorControl;
|
class QVideoDeviceSelectorControl;
|
||||||
class QCameraImageCaptureControl;
|
class QCameraImageCaptureControl;
|
||||||
class QImageEncoderControl;
|
class QImageEncoderControl;
|
||||||
|
class QCameraFocusControl;
|
||||||
|
class QCameraLocksControl;
|
||||||
|
|
||||||
class QWinRTCameraControlPrivate;
|
class QWinRTCameraControlPrivate;
|
||||||
class QWinRTCameraControl : public QCameraControl
|
class QWinRTCameraControl : public QCameraControl
|
||||||
@@ -85,15 +87,26 @@ public:
|
|||||||
QVideoDeviceSelectorControl *videoDeviceSelector() const;
|
QVideoDeviceSelectorControl *videoDeviceSelector() const;
|
||||||
QCameraImageCaptureControl *imageCaptureControl() const;
|
QCameraImageCaptureControl *imageCaptureControl() const;
|
||||||
QImageEncoderControl *imageEncoderControl() const;
|
QImageEncoderControl *imageEncoderControl() const;
|
||||||
|
QCameraFocusControl *cameraFocusControl() const;
|
||||||
|
QCameraLocksControl *cameraLocksControl() const;
|
||||||
|
|
||||||
ABI::Windows::Media::Capture::IMediaCapture *handle() 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:
|
private slots:
|
||||||
void onBufferRequested();
|
void onBufferRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HRESULT enumerateDevices();
|
HRESULT enumerateDevices();
|
||||||
HRESULT initialize();
|
HRESULT initialize();
|
||||||
|
HRESULT initializeFocus();
|
||||||
HRESULT onCaptureFailed(ABI::Windows::Media::Capture::IMediaCapture *,
|
HRESULT onCaptureFailed(ABI::Windows::Media::Capture::IMediaCapture *,
|
||||||
ABI::Windows::Media::Capture::IMediaCaptureFailedEventArgs *);
|
ABI::Windows::Media::Capture::IMediaCaptureFailedEventArgs *);
|
||||||
HRESULT onRecordLimitationExceeded(ABI::Windows::Media::Capture::IMediaCapture *);
|
HRESULT onRecordLimitationExceeded(ABI::Windows::Media::Capture::IMediaCapture *);
|
||||||
|
|||||||
273
src/plugins/winrt/qwinrtcamerafocuscontrol.cpp
Normal file
273
src/plugins/winrt/qwinrtcamerafocuscontrol.cpp
Normal file
@@ -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
|
||||||
77
src/plugins/winrt/qwinrtcamerafocuscontrol.h
Normal file
77
src/plugins/winrt/qwinrtcamerafocuscontrol.h
Normal file
@@ -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
|
||||||
@@ -179,6 +179,7 @@ int QWinRTCameraImageCaptureControl::capture(const QString &fileName)
|
|||||||
qErrnoWarning("Camera photo capture failed.");
|
qErrnoWarning("Camera photo capture failed.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
emit captureQueueChanged(false);
|
||||||
d->requests.insert(request.op.Get(), request);
|
d->requests.insert(request.op.Get(), request);
|
||||||
|
|
||||||
hr = request.op->put_Completed(Callback<IAsyncActionCompletedHandler>(
|
hr = request.op->put_Completed(Callback<IAsyncActionCompletedHandler>(
|
||||||
@@ -199,6 +200,7 @@ void QWinRTCameraImageCaptureControl::cancelCapture()
|
|||||||
info->Cancel();
|
info->Cancel();
|
||||||
it = d->requests.erase(it);
|
it = d->requests.erase(it);
|
||||||
}
|
}
|
||||||
|
emit captureQueueChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT QWinRTCameraImageCaptureControl::onCaptureCompleted(IAsyncAction *asyncInfo, AsyncStatus status)
|
HRESULT QWinRTCameraImageCaptureControl::onCaptureCompleted(IAsyncAction *asyncInfo, AsyncStatus status)
|
||||||
@@ -209,7 +211,7 @@ HRESULT QWinRTCameraImageCaptureControl::onCaptureCompleted(IAsyncAction *asyncI
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
CaptureRequest request = d->requests.take(asyncInfo);
|
CaptureRequest request = d->requests.take(asyncInfo);
|
||||||
|
emit captureQueueChanged(d->requests.isEmpty());
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
if (status == Error) {
|
if (status == Error) {
|
||||||
hr = asyncInfo->GetResults();
|
hr = asyncInfo->GetResults();
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ public:
|
|||||||
int capture(const QString &fileName) Q_DECL_OVERRIDE;
|
int capture(const QString &fileName) Q_DECL_OVERRIDE;
|
||||||
void cancelCapture() Q_DECL_OVERRIDE;
|
void cancelCapture() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void captureQueueChanged(bool isEmpty);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HRESULT onCaptureCompleted(ABI::Windows::Foundation::IAsyncAction *,
|
HRESULT onCaptureCompleted(ABI::Windows::Foundation::IAsyncAction *,
|
||||||
ABI::Windows::Foundation::AsyncStatus);
|
ABI::Windows::Foundation::AsyncStatus);
|
||||||
|
|||||||
125
src/plugins/winrt/qwinrtcameralockscontrol.cpp
Normal file
125
src/plugins/winrt/qwinrtcameralockscontrol.cpp
Normal file
@@ -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
|
||||||
66
src/plugins/winrt/qwinrtcameralockscontrol.h
Normal file
66
src/plugins/winrt/qwinrtcameralockscontrol.h
Normal file
@@ -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
|
||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <QtMultimedia/QVideoRendererControl>
|
#include <QtMultimedia/QVideoRendererControl>
|
||||||
#include <QtMultimedia/QVideoDeviceSelectorControl>
|
#include <QtMultimedia/QVideoDeviceSelectorControl>
|
||||||
#include <QtMultimedia/QImageEncoderControl>
|
#include <QtMultimedia/QImageEncoderControl>
|
||||||
|
#include <QtMultimedia/QCameraFocusControl>
|
||||||
|
#include <QtMultimedia/QCameraLocksControl>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@@ -69,34 +71,34 @@ QMediaControl *QWinRTCameraService::requestControl(const char *name)
|
|||||||
d->cameraControl = new QWinRTCameraControl(this);
|
d->cameraControl = new QWinRTCameraControl(this);
|
||||||
return d->cameraControl;
|
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 (qstrcmp(name, QCameraInfoControl_iid) == 0) {
|
||||||
if (!d->cameraInfoControl)
|
if (!d->cameraInfoControl)
|
||||||
d->cameraInfoControl = new QWinRTCameraInfoControl(this);
|
d->cameraInfoControl = new QWinRTCameraInfoControl(this);
|
||||||
return d->cameraInfoControl;
|
return d->cameraInfoControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0) {
|
if (!d->cameraControl)
|
||||||
if (d->cameraControl)
|
return nullptr;
|
||||||
return d->cameraControl->imageCaptureControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qstrcmp(name, QImageEncoderControl_iid) == 0) {
|
if (qstrcmp(name, QVideoRendererControl_iid) == 0)
|
||||||
if (d->cameraControl)
|
return d->cameraControl->videoRenderer();
|
||||||
return d->cameraControl->imageEncoderControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Q_NULLPTR;
|
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 nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWinRTCameraService::releaseControl(QMediaControl *control)
|
void QWinRTCameraService::releaseControl(QMediaControl *control)
|
||||||
|
|||||||
@@ -10,30 +10,34 @@ LIBS += -lmfplat -lmfuuid -loleaut32 -ld3d11 -lruntimeobject
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
qwinrtabstractvideorenderercontrol.h \
|
qwinrtabstractvideorenderercontrol.h \
|
||||||
qwinrtcameracontrol.h \
|
qwinrtcameracontrol.h \
|
||||||
qwinrtcamerainfocontrol.h \
|
qwinrtcamerafocuscontrol.h \
|
||||||
qwinrtcameraimagecapturecontrol.h \
|
qwinrtcameraimagecapturecontrol.h \
|
||||||
|
qwinrtcamerainfocontrol.h \
|
||||||
|
qwinrtcameralockscontrol.h \
|
||||||
qwinrtcameraservice.h \
|
qwinrtcameraservice.h \
|
||||||
qwinrtcameravideorenderercontrol.h \
|
qwinrtcameravideorenderercontrol.h \
|
||||||
|
qwinrtimageencodercontrol.h \
|
||||||
qwinrtmediaplayercontrol.h \
|
qwinrtmediaplayercontrol.h \
|
||||||
qwinrtmediaplayerservice.h \
|
qwinrtmediaplayerservice.h \
|
||||||
qwinrtplayerrenderercontrol.h \
|
qwinrtplayerrenderercontrol.h \
|
||||||
qwinrtserviceplugin.h \
|
qwinrtserviceplugin.h \
|
||||||
qwinrtvideodeviceselectorcontrol.h \
|
qwinrtvideodeviceselectorcontrol.h
|
||||||
qwinrtimageencodercontrol.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
qwinrtabstractvideorenderercontrol.cpp \
|
qwinrtabstractvideorenderercontrol.cpp \
|
||||||
qwinrtcameracontrol.cpp \
|
qwinrtcameracontrol.cpp \
|
||||||
qwinrtcamerainfocontrol.cpp \
|
qwinrtcamerafocuscontrol.cpp \
|
||||||
qwinrtcameraimagecapturecontrol.cpp \
|
qwinrtcameraimagecapturecontrol.cpp \
|
||||||
|
qwinrtcamerainfocontrol.cpp \
|
||||||
|
qwinrtcameralockscontrol.cpp \
|
||||||
qwinrtcameraservice.cpp \
|
qwinrtcameraservice.cpp \
|
||||||
qwinrtcameravideorenderercontrol.cpp \
|
qwinrtcameravideorenderercontrol.cpp \
|
||||||
|
qwinrtimageencodercontrol.cpp \
|
||||||
qwinrtmediaplayercontrol.cpp \
|
qwinrtmediaplayercontrol.cpp \
|
||||||
qwinrtmediaplayerservice.cpp \
|
qwinrtmediaplayerservice.cpp \
|
||||||
qwinrtplayerrenderercontrol.cpp \
|
qwinrtplayerrenderercontrol.cpp \
|
||||||
qwinrtserviceplugin.cpp \
|
qwinrtserviceplugin.cpp \
|
||||||
qwinrtvideodeviceselectorcontrol.cpp \
|
qwinrtvideodeviceselectorcontrol.cpp
|
||||||
qwinrtimageencodercontrol.cpp
|
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
winrt.json
|
winrt.json
|
||||||
|
|||||||
Reference in New Issue
Block a user