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 <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Yoann Lopes
2015-11-19 15:19:23 +01:00
parent b7880782b9
commit 8dc46cef05
3 changed files with 10 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -115,6 +115,11 @@ QList<QSize> AVFImageEncoderControl::supportedResolutions(const QImageEncoderSet
return resolutions;
}
QImageEncoderSettings AVFImageEncoderControl::requestedSettings() const
{
return m_settings;
}
QImageEncoderSettings AVFImageEncoderControl::imageSettings() const
{
QImageEncoderSettings settings;