summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.cpp3
-rw-r--r--src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp53
2 files changed, 32 insertions, 24 deletions
diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp
index 527dd6e8f..e50c09021 100644
--- a/src/plugins/winrt/qwinrtcameracontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameracontrol.cpp
@@ -950,8 +950,7 @@ HRESULT QWinRTCameraControl::initialize()
}
const QCamera::Position position = d->videoDeviceSelector->cameraPosition(deviceName);
- d->videoRenderer->setScanLineDirection(position == QCamera::BackFace ? QVideoSurfaceFormat::TopToBottom
- : QVideoSurfaceFormat::BottomToTop);
+ d->videoRenderer->setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
ComPtr<IMediaCaptureInitializationSettings> settings;
hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Media_Capture_MediaCaptureInitializationSettings).Get(),
&settings);
diff --git a/src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp b/src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp
index abe10f9a4..909d7e65b 100644
--- a/src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp
+++ b/src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp
@@ -251,6 +251,22 @@ private:
};
Q_GLOBAL_STATIC(QWinRTVideoDeviceSelectorControlGlobal, g)
+static ComPtr<IEnclosureLocation> enclosureLocation(const QString &deviceName)
+{
+ ComPtr<IEnclosureLocation> enclosureLocation;
+ int deviceIndex = g->deviceIndex.value(deviceName);
+ IDeviceInformation *deviceInfo = g->devices.value(deviceIndex).Get();
+ if (!deviceInfo)
+ return enclosureLocation;
+
+ HRESULT hr;
+ hr = deviceInfo->get_EnclosureLocation(&enclosureLocation);
+ if (FAILED(hr))
+ qErrnoWarning(hr, "Failed to get camera enclosure location");
+
+ return enclosureLocation;
+}
+
class QWinRTVideoDeviceSelectorControlPrivate
{
public:
@@ -307,20 +323,13 @@ int QWinRTVideoDeviceSelectorControl::selectedDevice() const
QCamera::Position QWinRTVideoDeviceSelectorControl::cameraPosition(const QString &deviceName)
{
- int deviceIndex = g->deviceIndex.value(deviceName);
- IDeviceInformation *deviceInfo = g->devices.value(deviceIndex).Get();
- if (!deviceInfo)
+ ComPtr<IEnclosureLocation> enclosure = enclosureLocation(deviceName);
+ if (!enclosure)
return QCamera::UnspecifiedPosition;
- ComPtr<IEnclosureLocation> enclosureLocation;
HRESULT hr;
- hr = deviceInfo->get_EnclosureLocation(&enclosureLocation);
- RETURN_IF_FAILED("Failed to get camera enclosure location", return QCamera::UnspecifiedPosition);
- if (!enclosureLocation)
- return QCamera::UnspecifiedPosition;
-
Panel panel;
- hr = enclosureLocation->get_Panel(&panel);
+ hr = enclosure->get_Panel(&panel);
RETURN_IF_FAILED("Failed to get camera panel location", return QCamera::UnspecifiedPosition);
switch (panel) {
@@ -336,18 +345,18 @@ QCamera::Position QWinRTVideoDeviceSelectorControl::cameraPosition(const QString
int QWinRTVideoDeviceSelectorControl::cameraOrientation(const QString &deviceName)
{
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
- switch (cameraPosition(deviceName)) {
- case QCamera::FrontFace:
- case QCamera::BackFace:
- return 270;
- default:
- break;
- }
-#else
- Q_UNUSED(deviceName);
-#endif
- return 0;
+ ComPtr<IEnclosureLocation> enclosure = enclosureLocation(deviceName);
+ if (!enclosure)
+ return 0;
+
+ HRESULT hr;
+ ComPtr<IEnclosureLocation2> enclosure2;
+ hr = enclosure.As(&enclosure2);
+ RETURN_IF_FAILED("Failed to cast camera enclosure location", return 0);
+ quint32 rotation;
+ hr = enclosure2->get_RotationAngleInDegreesClockwise(&rotation);
+ RETURN_IF_FAILED("Failed to get camera rotation angle", return 0);
+ return rotation;
}
QList<QByteArray> QWinRTVideoDeviceSelectorControl::deviceNames()