summaryrefslogtreecommitdiffstats
path: root/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-03-18 14:42:35 +0100
committerLars Knoll <lars.knoll@qt.io>2021-04-06 08:08:40 +0000
commitf67cea4dd9c2ba44c85267962655235c6143a966 (patch)
tree4590d90f6f37e21a37cdd05c8e5d55193365b67e /src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
parent782711418999c8e1f5914e805124ba7014687f93 (diff)
Fix QML video rendering
Use the new QVideoSink class to get the video frames. Fix some APIs, so that we correctly connect VideoOutput and MediaPlayer. Change-Id: I65a0d045988c46a917f70dfb922c1bbdb32f6511 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qtmultimediaquicktools/qdeclarativevideooutput.cpp')
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
index 1cd331279..68d03bb95 100644
--- a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
+++ b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
@@ -46,6 +46,8 @@
#include <QtMultimedia/qmediacapturesession.h>
#include <private/qfactoryloader_p.h>
#include <QtCore/qloggingcategory.h>
+#include <qvideosink.h>
+
static void initResource() {
Q_INIT_RESOURCE(qtmultimediaquicktools);
@@ -157,9 +159,9 @@ QDeclarativeVideoOutput::~QDeclarativeVideoOutput()
\sa source
*/
-QAbstractVideoSurface *QDeclarativeVideoOutput::videoSurface() const
+QVideoSink *QDeclarativeVideoOutput::videoSink() const
{
- return m_backend ? m_backend->videoSurface() : nullptr;
+ return m_backend ? m_backend->videoSink() : nullptr;
}
/*!
@@ -186,9 +188,9 @@ void QDeclarativeVideoOutput::setSource(QObject *source)
}
if (QMediaCaptureSession *s = qobject_cast<QMediaCaptureSession *>(source)) {
- s->setVideoPreview(videoSurface());
+ s->setVideoPreview(videoSink());
} else if (QMediaPlayer *p = qobject_cast<QMediaPlayer *>(source)) {
- p->setVideoOutput(videoSurface());
+ p->setVideoOutput(videoSink());
}
emit sourceChanged();
}
@@ -238,12 +240,13 @@ void QDeclarativeVideoOutput::setFillMode(FillMode mode)
emit fillModeChanged(mode);
}
-void QDeclarativeVideoOutput::_q_updateNativeSize()
+void QDeclarativeVideoOutput::_q_newFrame(const QVideoFrame &frame)
{
if (!m_backend)
return;
- QSize size = m_backend->nativeSize();
+ m_backend->present(frame);
+ QSize size = frame.size();
if (!qIsDefaultAspect(m_orientation)) {
size.transpose();
}
@@ -289,12 +292,8 @@ void QDeclarativeVideoOutput::_q_updateGeometry()
m_contentRect.moveCenter(rect.center());
}
- if (m_backend) {
- if (!m_backend->videoSurface() || m_backend->videoSurface()->isActive())
- m_backend->updateGeometry();
- else
- m_geometryDirty = true;
- }
+ if (m_backend)
+ m_backend->updateGeometry();
if (m_contentRect != oldContentRect)