summaryrefslogtreecommitdiffstats
path: root/src/plugins/winrt
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-07-20 15:53:34 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-07-21 14:03:11 +0200
commit7a5e3145550015c9c6c3e8232c8257099aa2480c (patch)
tree0b5623c19c6d2ac39a9d95befcadc957029a2446 /src/plugins/winrt
parent631b89ddde44dfc8b72b904d8c41368b2c02d037 (diff)
parent17d54a2eb57816dbc531feee80dbd25f835e733a (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: src/plugins/directshow/player/directshowiosource.cpp One side disintermediated filling a vector; the other reduced it to one entry. src/plugins/directshow/player/directshowiosource.h One side renamed a member, the other added another adjacent to it. src/plugins/pulseaudio/qpulseaudioengine.h One side added a header, the other replaced the next with a different header. Change-Id: I3a031975f5af43ca39cca571f215c612f640b7d6
Diffstat (limited to 'src/plugins/winrt')
-rw-r--r--src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp11
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.cpp105
2 files changed, 70 insertions, 46 deletions
diff --git a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp
index 7dd2e6557..f109dc4cb 100644
--- a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp
+++ b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp
@@ -38,6 +38,7 @@
#include <QtCore/qfunctions_winrt.h>
#include <QtCore/QGlobalStatic>
+#include <QtCore/QLoggingCategory>
#include <QtCore/QMetaMethod>
#include <QtCore/QPointer>
#include <QtGui/QOpenGLContext>
@@ -58,6 +59,8 @@ using namespace Microsoft::WRL;
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcMMVideoRender, "qt.mm.videorender")
+
#define BREAK_IF_FAILED(msg) RETURN_IF_FAILED(msg, break)
#define CONTINUE_IF_FAILED(msg) RETURN_IF_FAILED(msg, continue)
@@ -66,6 +69,7 @@ struct QWinRTVideoRendererControlGlobal
{
QWinRTVideoRendererControlGlobal()
{
+ qCDebug(lcMMVideoRender) << __FUNCTION__;
HRESULT hr;
D3D_FEATURE_LEVEL featureLevels[] =
@@ -202,6 +206,7 @@ ID3D11Device *QWinRTAbstractVideoRendererControl::d3dDevice()
// This is required so that subclasses can stop the render thread before deletion
void QWinRTAbstractVideoRendererControl::shutdown()
{
+ qCDebug(lcMMVideoRender) << __FUNCTION__;
Q_D(QWinRTAbstractVideoRendererControl);
if (d->renderThread.isRunning()) {
d->renderThread.requestInterruption();
@@ -212,6 +217,7 @@ void QWinRTAbstractVideoRendererControl::shutdown()
QWinRTAbstractVideoRendererControl::QWinRTAbstractVideoRendererControl(const QSize &size, QObject *parent)
: QVideoRendererControl(parent), d_ptr(new QWinRTAbstractVideoRendererControlPrivate)
{
+ qCDebug(lcMMVideoRender) << __FUNCTION__;
Q_D(QWinRTAbstractVideoRendererControl);
d->format = QVideoSurfaceFormat(size, QVideoFrame::Format_BGRA32,
@@ -232,6 +238,7 @@ QWinRTAbstractVideoRendererControl::QWinRTAbstractVideoRendererControl(const QSi
QWinRTAbstractVideoRendererControl::~QWinRTAbstractVideoRendererControl()
{
+ qCDebug(lcMMVideoRender) << __FUNCTION__;
Q_D(QWinRTAbstractVideoRendererControl);
CriticalSectionLocker locker(&d->mutex);
shutdown();
@@ -253,6 +260,7 @@ void QWinRTAbstractVideoRendererControl::setSurface(QAbstractVideoSurface *surfa
void QWinRTAbstractVideoRendererControl::syncAndRender()
{
+ qCDebug(lcMMVideoRender) << __FUNCTION__;
Q_D(QWinRTAbstractVideoRendererControl);
QThread *currentThread = QThread::currentThread();
@@ -334,6 +342,7 @@ void QWinRTAbstractVideoRendererControl::setScanLineDirection(QVideoSurfaceForma
void QWinRTAbstractVideoRendererControl::setActive(bool active)
{
+ qCDebug(lcMMVideoRender) << __FUNCTION__ << active;
Q_D(QWinRTAbstractVideoRendererControl);
if (d->active == active)
@@ -351,7 +360,7 @@ void QWinRTAbstractVideoRendererControl::setActive(bool active)
return;
}
- d->renderThread.requestInterruption();
+ shutdown();
if (d->surface && d->surface->isActive())
d->surface->stop();
}
diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp
index a4584487a..390364eb8 100644
--- a/src/plugins/winrt/qwinrtcameracontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameracontrol.cpp
@@ -101,7 +101,13 @@ HRESULT getMediaStreamResolutions(IMediaDeviceController *device,
ComPtr<IMediaEncodingProperties> properties;
hr = (*propertiesList)->GetAt(index, &properties);
Q_ASSERT_SUCCEEDED(hr);
- if (type == MediaStreamType_VideoRecord || type == MediaStreamType_VideoPreview) {
+ HString propertyType;
+ hr = properties->get_Type(propertyType.GetAddressOf());
+ Q_ASSERT_SUCCEEDED(hr);
+
+ const HStringReference videoRef = HString::MakeReference(L"Video");
+ const HStringReference imageRef = HString::MakeReference(L"Image");
+ if (propertyType == videoRef) {
ComPtr<IVideoEncodingProperties> videoProperties;
hr = properties.As(&videoProperties);
Q_ASSERT_SUCCEEDED(hr);
@@ -111,13 +117,10 @@ HRESULT getMediaStreamResolutions(IMediaDeviceController *device,
hr = videoProperties->get_Height(&height);
Q_ASSERT_SUCCEEDED(hr);
resolutions->append(QSize(width, height));
- } else if (type == MediaStreamType_Photo) {
+ } else if (propertyType == imageRef) {
ComPtr<IImageEncodingProperties> imageProperties;
hr = properties.As(&imageProperties);
- // Asking for Photo also returns video resolutions in addition
- // We skip those, as we are only interested in image Type
- if (FAILED(hr) || !imageProperties)
- continue;
+ Q_ASSERT_SUCCEEDED(hr);
UINT32 width, height;
hr = imageProperties->get_Width(&width);
Q_ASSERT_SUCCEEDED(hr);
@@ -1121,46 +1124,54 @@ bool QWinRTCameraControl::setFocus(QCameraFocus::FocusModes modes)
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);
+ bool result = false;
+ HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([modes, &result, d, this]() {
+ 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."));
+ result = false;
+ return S_OK;
+ }
+ 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);
+ ComPtr<IFocusControl2> focusControl2;
+ hr = d->focusControl.As(&focusControl2);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = focusControl2->Configure(focusSettings.Get());
+ result = SUCCEEDED(hr);
+ RETURN_OK_IF_FAILED("Failed to configure camera focus control");
+ return S_OK;
+ });
Q_ASSERT_SUCCEEDED(hr);
- hr = focusControl2->Configure(focusSettings.Get());
- RETURN_FALSE_IF_FAILED("Failed to configure camera focus control");
- return true;
+ Q_UNUSED(hr); // Silence release build
+ return result;
}
bool QWinRTCameraControl::setFocusPoint(const QPointF &focusPoint)
@@ -1224,7 +1235,11 @@ bool QWinRTCameraControl::focus()
if (!d->focusControl || status == AsyncStatus::Started)
return false;
- hr = d->focusControl->FocusAsync(&d->focusOperation);
+ QEventDispatcherWinRT::runOnXamlThread([&d, &hr]() {
+ hr = d->focusControl->FocusAsync(&d->focusOperation);
+ Q_ASSERT_SUCCEEDED(hr);
+ return S_OK;
+ });
const long errorCode = HRESULT_CODE(hr);
if (errorCode == ERROR_OPERATION_IN_PROGRESS
|| errorCode == ERROR_WRITE_PROTECT) {