From af5e0d04852e5efc1ebd9d099f3906bc66a62338 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Thu, 10 Mar 2016 11:47:24 +0100 Subject: AVFoundation: re-apply viewfinder settings on mode changes. Since the active viewfinder resolution can be overridden by the image and video capture resolutions, we need to re-evaluate the viewfinder settings whenever the capture mode changes. Change-Id: Ibdb7a070585cf67ebb2fcfb95ccbdd105f5f41cf Reviewed-by: Christian Stromme --- .../avfoundation/camera/avfcamerasession.mm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/plugins/avfoundation/camera/avfcamerasession.mm') diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm index eac1b44ec..9e7c28755 100644 --- a/src/plugins/avfoundation/camera/avfcamerasession.mm +++ b/src/plugins/avfoundation/camera/avfcamerasession.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. @@ -286,8 +286,8 @@ void AVFCameraSession::setState(QCamera::State newState) m_defaultCodec = 0; defaultCodec(); - bool activeFormatSet = applyImageEncoderSettings(); - activeFormatSet |= applyViewfinderSettings(); + bool activeFormatSet = applyImageEncoderSettings() + | applyViewfinderSettings(); [m_captureSession commitConfiguration]; @@ -338,6 +338,17 @@ void AVFCameraSession::processSessionStopped() } } +void AVFCameraSession::onCaptureModeChanged(QCamera::CaptureModes mode) +{ + Q_UNUSED(mode) + + const QCamera::State s = state(); + if (s == QCamera::LoadedState || s == QCamera::ActiveState) { + applyImageEncoderSettings(); + applyViewfinderSettings(); + } +} + void AVFCameraSession::attachVideoInputDevice() { //Attach video input device: @@ -381,11 +392,12 @@ bool AVFCameraSession::applyImageEncoderSettings() bool AVFCameraSession::applyViewfinderSettings() { if (AVFCameraViewfinderSettingsControl2 *vfControl = m_service->viewfinderSettingsControl2()) { + QCamera::CaptureModes currentMode = m_service->cameraControl()->captureMode(); 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->requestedSettings().resolution()); + if (currentMode.testFlag(QCamera::CaptureStillImage)) { + const QSize imageResolution(m_service->imageEncoderControl()->requestedSettings().resolution()); if (!imageResolution.isNull() && imageResolution.isValid()) vfSettings.setResolution(imageResolution); } -- cgit v1.2.1