diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2024-03-09 13:23:40 +0100 |
---|---|---|
committer | Artem Dyomin <artem.dyomin@qt.io> | 2024-03-13 14:58:25 +0100 |
commit | 721cd63b7d8600b2f2801a32e047f6ce24b47e51 (patch) | |
tree | 1d6ab3cb0282c4e28150fa9dfde38a278d85865b /src/multimedia/platform | |
parent | f6d6ec8f6223bc4b66ba94e8337da42201e4e318 (diff) |
Fix size of QVideoSink when the video is rotated
The size of QVideoSink impacts on sizeHint of QVideoWidget,
and it can be taken by users for their own size hints.
All renderers draw rotated videos like this: if the frame size is
AxB, and the rotation is 90 degrees, the rendering size becomes BxA.
Let's keep QVideoSink::videoSize consistent.
Added a function to qtmm utilities to get rotates size.
Pick-to: 6.7 6.6 6.5
Change-Id: Ia0cb6f43a598820007fac8178104631a80d96dfb
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Diffstat (limited to 'src/multimedia/platform')
-rw-r--r-- | src/multimedia/platform/qplatformvideosink.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/multimedia/platform/qplatformvideosink.cpp b/src/multimedia/platform/qplatformvideosink.cpp index 268291da2..abf82af0f 100644 --- a/src/multimedia/platform/qplatformvideosink.cpp +++ b/src/multimedia/platform/qplatformvideosink.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qplatformvideosink_p.h" +#include "qmultimediautils_p.h" QT_BEGIN_NAMESPACE @@ -36,10 +37,14 @@ void QPlatformVideoSink::setVideoFrame(const QVideoFrame &frame) return; m_currentVideoFrame = frame; m_currentVideoFrame.setSubtitleText(m_subtitleText); - sizeChanged = m_nativeSize != frame.size(); - m_nativeSize = frame.size(); + const auto size = qRotatedFrameSize(frame); + if (size != m_nativeSize) { + m_nativeSize = size; + sizeChanged = true; + } } + // emit signals outside the mutex to avoid deadlocks on the user side if (sizeChanged) emit m_sink->videoSizeChanged(); emit m_sink->videoFrameChanged(frame); |