From: Andrew Knight Date: Thu, 11 Dec 2014 07:48:52 +0000 (+0200) Subject: winrt: Fix camera auto rotation X-Git-Tag: v5.4.1~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=791febc1d3bfc1ec39f4379214ec5fb473ddaeb5;p=platform%2Fupstream%2Fqtmultimedia.git winrt: Fix camera auto rotation There is no Windows Runtime API to find the camera sensor rotation, so assume that phones always have a camera mounting of 270 degrees. Tablet and webcams remain mounted at the default (0 degrees). As the frame is not flipped automatically by the system, the scan line direction is set to BottomToTop for front-facing cameras to achieve compatibility with other platforms. Task-number: QTBUG-41066 Change-Id: Icf17ecd4aca9fa9d5b24d94e5b21b63ee6f21f28 Reviewed-by: Oliver Wolff Reviewed-by: Yoann Lopes --- diff --git a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp index 175fec1..be04362 100644 --- a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp +++ b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp @@ -310,6 +310,16 @@ void QWinRTAbstractVideoRendererControl::setSize(const QSize &size) d->dirtyState = TextureDirty; } +void QWinRTAbstractVideoRendererControl::setScanLineDirection(QVideoSurfaceFormat::Direction scanLineDirection) +{ + Q_D(QWinRTAbstractVideoRendererControl); + + if (d->format.scanLineDirection() == scanLineDirection) + return; + + d->format.setScanLineDirection(scanLineDirection); +} + void QWinRTAbstractVideoRendererControl::setActive(bool active) { Q_D(QWinRTAbstractVideoRendererControl); diff --git a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.h b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.h index 86a7b15..b06b18a 100644 --- a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.h +++ b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.h @@ -43,6 +43,7 @@ #define QWINRTABSTRACTVIDEORENDERERCONTROL_H #include +#include struct ID3D11Device; struct ID3D11Texture2D; @@ -63,6 +64,8 @@ public: QSize size() const; void setSize(const QSize &size); + void setScanLineDirection(QVideoSurfaceFormat::Direction direction); + void setActive(bool active); virtual bool render(ID3D11Texture2D *texture) = 0; diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp index 619e973..f4e57b4 100644 --- a/src/plugins/winrt/qwinrtcameracontrol.cpp +++ b/src/plugins/winrt/qwinrtcameracontrol.cpp @@ -677,6 +677,9 @@ HRESULT QWinRTCameraControl::initialize() return E_FAIL; } + if (d->videoDeviceSelector->cameraPosition(deviceName) == QCamera::FrontFace) + d->videoRenderer->setScanLineDirection(QVideoSurfaceFormat::BottomToTop); + ComPtr 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 8058c3d..969ef6f 100644 --- a/src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp +++ b/src/plugins/winrt/qwinrtvideodeviceselectorcontrol.cpp @@ -337,7 +337,17 @@ QCamera::Position QWinRTVideoDeviceSelectorControl::cameraPosition(const QString int QWinRTVideoDeviceSelectorControl::cameraOrientation(const QString &deviceName) { +#ifdef Q_OS_WINPHONE + switch (cameraPosition(deviceName)) { + case QCamera::FrontFace: + case QCamera::BackFace: + return 270; + default: + break; + } +#else Q_UNUSED(deviceName); +#endif return 0; }