From 8dc46cef05d901bb48f0d87e19a8b35b5e70757e Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Thu, 19 Nov 2015 15:19:23 +0100 Subject: AVFoundation: fix setting the camera viewfinder resolution. Image capture resolution and viewfinder resolution must be the same, with the image capture resolution taking precedence over the viewfinder resolution when both are explicitly set. The code was getting the active image capture resolution, instead of the one explicitly requested, to adjust the viewfinder resolution. That effectively made the viewfinder resolution always ignored since the active capture resolution always has a default value. Task-number: QTBUG-49170 Change-Id: I2f3d01366d83a3e28c0a1ea0109663cfdfa75963 Reviewed-by: Timur Pocheptsov --- src/plugins/avfoundation/camera/avfcamerasession.mm | 4 +++- src/plugins/avfoundation/camera/avfimageencodercontrol.h | 2 ++ src/plugins/avfoundation/camera/avfimageencodercontrol.mm | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/plugins/avfoundation') diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm index 2cb3824db..5bf841bec 100644 --- a/src/plugins/avfoundation/camera/avfcamerasession.mm +++ b/src/plugins/avfoundation/camera/avfcamerasession.mm @@ -365,8 +365,10 @@ void AVFCameraSession::applyViewfinderSettings() { if (AVFCameraViewfinderSettingsControl2 *vfControl = m_service->viewfinderSettingsControl2()) { QCameraViewfinderSettings vfSettings(vfControl->requestedSettings()); + // Viewfinder and image capture solutions must be the same, if an image capture + // resolution is set, it takes precedence over the viewfinder resolution. if (AVFImageEncoderControl *imControl = m_service->imageEncoderControl()) { - const QSize imageResolution(imControl->imageSettings().resolution()); + const QSize imageResolution(imControl->requestedSettings().resolution()); if (!imageResolution.isNull() && imageResolution.isValid()) { vfSettings.setResolution(imageResolution); vfControl->setViewfinderSettings(vfSettings); diff --git a/src/plugins/avfoundation/camera/avfimageencodercontrol.h b/src/plugins/avfoundation/camera/avfimageencodercontrol.h index fcb665a03..c805b3e21 100644 --- a/src/plugins/avfoundation/camera/avfimageencodercontrol.h +++ b/src/plugins/avfoundation/camera/avfimageencodercontrol.h @@ -62,6 +62,8 @@ public: QImageEncoderSettings imageSettings() const Q_DECL_OVERRIDE; void setImageSettings(const QImageEncoderSettings &settings) Q_DECL_OVERRIDE; + QImageEncoderSettings requestedSettings() const; + private: AVFCameraService *m_service; QImageEncoderSettings m_settings; diff --git a/src/plugins/avfoundation/camera/avfimageencodercontrol.mm b/src/plugins/avfoundation/camera/avfimageencodercontrol.mm index 36050c3a2..a5e9c0e09 100644 --- a/src/plugins/avfoundation/camera/avfimageencodercontrol.mm +++ b/src/plugins/avfoundation/camera/avfimageencodercontrol.mm @@ -115,6 +115,11 @@ QList AVFImageEncoderControl::supportedResolutions(const QImageEncoderSet return resolutions; } +QImageEncoderSettings AVFImageEncoderControl::requestedSettings() const +{ + return m_settings; +} + QImageEncoderSettings AVFImageEncoderControl::imageSettings() const { QImageEncoderSettings settings; -- cgit v1.2.1