summaryrefslogtreecommitdiffstats
path: root/src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp')
-rw-r--r--src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp53
1 files changed, 31 insertions, 22 deletions
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()