summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-09-10 10:12:32 +0200
committerLars Knoll <lars.knoll@qt.io>2021-09-10 11:24:18 +0200
commit0de80f19158d849b83426aacfaca289264751586 (patch)
tree0107cb3f5cda6e05dc9cc2bf3746bdbb2fdbc76c /src/multimedia
parent62e92cf60bfd43dba4a9910453aec9489daa9d36 (diff)
Fix orientation of the created video while recording
Lock the orientation of a video once we start recording. Changing it's resolution or aspect ratio in the middle of a recording is not possible and would also look rather weird. Pick-to: 6.2 6.2.0 Change-Id: Ibea27c6a9a603a2ac73e53d242305782e0adf5d5 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/platform/darwin/camera/avfmediaencoder.mm3
-rw-r--r--src/multimedia/video/qvideooutputorientationhandler.cpp5
-rw-r--r--src/multimedia/video/qvideooutputorientationhandler_p.h4
3 files changed, 12 insertions, 0 deletions
diff --git a/src/multimedia/platform/darwin/camera/avfmediaencoder.mm b/src/multimedia/platform/darwin/camera/avfmediaencoder.mm
index c34503277..83e9c6d3d 100644
--- a/src/multimedia/platform/darwin/camera/avfmediaencoder.mm
+++ b/src/multimedia/platform/darwin/camera/avfmediaencoder.mm
@@ -520,6 +520,8 @@ void AVFMediaEncoder::record(QMediaEncoderSettings &settings)
applySettings(settings);
+ QVideoOutputOrientationHandler::setIsRecording(true);
+
// We stop session now so that no more frames for renderer's queue
// generated, will restart in assetWriterStarted.
[session stopRunning];
@@ -578,6 +580,7 @@ void AVFMediaEncoder::stop()
// Do not check the camera status, we can stop if we started.
stopWriter();
}
+ QVideoOutputOrientationHandler::setIsRecording(false);
}
diff --git a/src/multimedia/video/qvideooutputorientationhandler.cpp b/src/multimedia/video/qvideooutputorientationhandler.cpp
index e21efb37d..2a6781b47 100644
--- a/src/multimedia/video/qvideooutputorientationhandler.cpp
+++ b/src/multimedia/video/qvideooutputorientationhandler.cpp
@@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE
+bool QVideoOutputOrientationHandler::m_isRecording = false;
+
QVideoOutputOrientationHandler::QVideoOutputOrientationHandler(QObject *parent)
: QObject(parent)
, m_currentOrientation(0)
@@ -63,6 +65,9 @@ int QVideoOutputOrientationHandler::currentOrientation() const
void QVideoOutputOrientationHandler::screenOrientationChanged(Qt::ScreenOrientation orientation)
{
+ if (m_isRecording)
+ return;
+
const QScreen *screen = QGuiApplication::primaryScreen();
const int angle = (360 - screen->angleBetween(screen->nativeOrientation(), orientation)) % 360;
diff --git a/src/multimedia/video/qvideooutputorientationhandler_p.h b/src/multimedia/video/qvideooutputorientationhandler_p.h
index d04a781ab..604564571 100644
--- a/src/multimedia/video/qvideooutputorientationhandler_p.h
+++ b/src/multimedia/video/qvideooutputorientationhandler_p.h
@@ -65,6 +65,9 @@ public:
int currentOrientation() const;
+ static void setIsRecording(bool isRecording) { m_isRecording = isRecording; }
+ static bool isRecording() { return m_isRecording; }
+
Q_SIGNALS:
void orientationChanged(int angle);
@@ -73,6 +76,7 @@ private Q_SLOTS:
private:
int m_currentOrientation;
+ static bool m_isRecording;
};
QT_END_NAMESPACE