summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartlomiej Moskal <bartlomiej.moskal@qt.io>2023-02-28 14:27:50 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-03-01 11:08:15 +0000
commitc7dad1bb909aecb62398a29024aa8416ae59b066 (patch)
tree91cb40140046dca5f30d2203228233859142f6d5
parente7b383e243c27bc39e47b3b732bd436832271704 (diff)
downloadqtmultimedia-c7dad1bb909aecb62398a29024aa8416ae59b066.tar.gz
Android: Fix stretched camera view in portrait mode
The camera view in portrait mode was displayed as landscape. After 579a0423b8b3c62c582a706d338a9eb1bcd788a3 commit, the resolution is not transposed if it is not in supported preview sizes. That is the expected way for camera preview size, but video output resolution need to be transposed anyway. This commit rotates the resolution of the video output in portrait mode, even if the camera resolution is not rotated due to unsupported size. Fixes: QTBUG-110975 Fixes: QTBUG-111266 Fixes: QTBUG-111421 Fixes: QTBUG-107173 Change-Id: I773fb8d0df1b616c6af8db9a8d7ad785da8295ee Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit 8d5683e85c0d85e31b6ea6d4caf1769737e558b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/android/common/qandroidvideooutput_p.h2
-rw-r--r--src/plugins/multimedia/android/mediacapture/qandroidcamerasession.cpp19
2 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/multimedia/android/common/qandroidvideooutput_p.h b/src/plugins/multimedia/android/common/qandroidvideooutput_p.h
index cc7e2413e..b9a3bc4d6 100644
--- a/src/plugins/multimedia/android/common/qandroidvideooutput_p.h
+++ b/src/plugins/multimedia/android/common/qandroidvideooutput_p.h
@@ -44,6 +44,7 @@ public:
virtual void start() { }
virtual void stop() { }
virtual void reset() { }
+ virtual QSize getVideoSize() const { return QSize(0, 0); }
Q_SIGNALS:
void readyChanged(bool);
@@ -67,6 +68,7 @@ public:
void setVideoSize(const QSize &) override;
void stop() override;
void reset() override;
+ QSize getVideoSize() const override { return m_nativeSize; }
void setSubtitle(const QString &subtitle);
private Q_SLOTS:
diff --git a/src/plugins/multimedia/android/mediacapture/qandroidcamerasession.cpp b/src/plugins/multimedia/android/mediacapture/qandroidcamerasession.cpp
index fa756b610..d6aee3aff 100644
--- a/src/plugins/multimedia/android/mediacapture/qandroidcamerasession.cpp
+++ b/src/plugins/multimedia/android/mediacapture/qandroidcamerasession.cpp
@@ -290,25 +290,30 @@ void QAndroidCameraSession::applyResolution(const QSize &captureSize, bool resta
// -- Set values on camera
// fix the resolution of output based on the orientation
- QSize outputResolution = adjustedViewfinderResolution;
+ QSize cameraOutputResolution = adjustedViewfinderResolution;
+ QSize videoOutputResolution = adjustedViewfinderResolution;
+ QSize currentVideoOutputResolution = m_videoOutput ? m_videoOutput->getVideoSize() : QSize(0, 0);
const int rotation = currentCameraRotation();
// only transpose if it's valid for the preview
- if ((rotation == 90 || rotation == 270) && previewSizes.contains(outputResolution.transposed()))
- outputResolution.transpose();
+ if (rotation == 90 || rotation == 270) {
+ videoOutputResolution.transpose();
+ if (previewSizes.contains(cameraOutputResolution.transposed()))
+ cameraOutputResolution.transpose();
+ }
- if (currentViewfinderResolution != outputResolution
+ if (currentViewfinderResolution != cameraOutputResolution
+ || (m_videoOutput && currentVideoOutputResolution != videoOutputResolution)
|| currentPreviewFormat != adjustedPreviewFormat || currentFpsRange.min != adjustedFps.min
|| currentFpsRange.max != adjustedFps.max) {
-
if (m_videoOutput) {
- m_videoOutput->setVideoSize(outputResolution);
+ m_videoOutput->setVideoSize(videoOutputResolution);
}
// if preview is started, we have to stop it first before changing its size
if (m_previewStarted && restartPreview)
m_camera->stopPreview();
- m_camera->setPreviewSize(outputResolution);
+ m_camera->setPreviewSize(cameraOutputResolution);
m_camera->setPreviewFormat(adjustedPreviewFormat);
m_camera->setPreviewFpsRange(adjustedFps);