summaryrefslogtreecommitdiff
path: root/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2015-05-05 16:40:05 +0200
committerYoann Lopes <yoann.lopes@theqtcompany.com>2015-05-27 12:18:43 +0000
commit83d1255080ab2be678efbbc42e259c9681619619 (patch)
tree388001d4957d71fc672b8fda41ef022118317a12 /src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
parent008d57e1d7c8208d5ac415db5a4bdd558688d638 (diff)
downloadqtmultimedia-83d1255080ab2be678efbbc42e259c9681619619.tar.gz
Android: fix setting the camera preview resolution.
- When the video capture resolution or the image capture resolution changes, we now always set the viewfinder resolution to the highest available one with the same aspect ratio as the capture resolution. We were previously not doing anything if the new capture resolution had the same aspect ratio as the current viewfinder resolution. - Some devices don't support using a viewfinder resolution different from the video capture resolution. Make sure we handle this case. Change-Id: I8d3ab7b01c56ed78d1ca838a522ba459692fc332 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins/android/src/mediacapture/qandroidcamerasession.cpp')
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcamerasession.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
index 2ff17592b..4a64e1b1a 100644
--- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
@@ -277,26 +277,28 @@ void QAndroidCameraSession::adjustViewfinderSize(const QSize &captureSize, bool
return;
QSize currentViewfinderResolution = m_camera->previewSize();
- const qreal aspectRatio = qreal(captureSize.width()) / qreal(captureSize.height());
- if (currentViewfinderResolution.isValid() &&
- qAbs(aspectRatio - (qreal(currentViewfinderResolution.width()) / currentViewfinderResolution.height())) < 0.01) {
- return;
- }
-
QSize adjustedViewfinderResolution;
- QList<QSize> previewSizes = m_camera->getSupportedPreviewSizes();
- for (int i = previewSizes.count() - 1; i >= 0; --i) {
- const QSize &size = previewSizes.at(i);
+
+ if (m_captureMode.testFlag(QCamera::CaptureVideo) && m_camera->getPreferredPreviewSizeForVideo().isEmpty()) {
+ // According to the Android doc, if getPreferredPreviewSizeForVideo() returns null, it means
+ // the preview size cannot be different from the capture size
+ adjustedViewfinderResolution = captureSize;
+ } else {
// search for viewfinder resolution with the same aspect ratio
- if (qAbs(aspectRatio - (qreal(size.width()) / size.height())) < 0.01) {
- adjustedViewfinderResolution = size;
- break;
+ const qreal aspectRatio = qreal(captureSize.width()) / qreal(captureSize.height());
+ QList<QSize> previewSizes = m_camera->getSupportedPreviewSizes();
+ for (int i = previewSizes.count() - 1; i >= 0; --i) {
+ const QSize &size = previewSizes.at(i);
+ if (qAbs(aspectRatio - (qreal(size.width()) / size.height())) < 0.01) {
+ adjustedViewfinderResolution = size;
+ break;
+ }
}
- }
- if (!adjustedViewfinderResolution.isValid()) {
- qWarning("Cannot find a viewfinder resolution matching the capture aspect ratio.");
- return;
+ if (!adjustedViewfinderResolution.isValid()) {
+ qWarning("Cannot find a viewfinder resolution matching the capture aspect ratio.");
+ return;
+ }
}
if (currentViewfinderResolution != adjustedViewfinderResolution) {