summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-01-27 11:36:59 +0100
committerPaul Wicking <paul.wicking@qt.io>2020-01-30 11:46:33 +0000
commitd931c6c68f13285d0ca09831fd78ff757ca05fe4 (patch)
tree930d3b3e4bfa4f619db39f32e0966bfd6e2ab6c0
parent81e0861c60899c14395903b053b1045210740a43 (diff)
Make video surfaces constant
Video surface property for QVideoWidget, QGprahicsVideoItem and QDeclarativeVideoOutput should be CONSTANT and kept the same value while the object is alive. Note, currently this property can be suddenly changed, when videoSurface is mixed/used together with source property. To keep the patch simple, this will be fixed in next commits. Change-Id: I80046524a70bcb70bb45e7f1bbae74bff1b3b0f2 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/multimediawidgets/qgraphicsvideoitem.h2
-rw-r--r--src/multimediawidgets/qvideowidget.h2
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput.cpp20
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput_p.h2
4 files changed, 8 insertions, 18 deletions
diff --git a/src/multimediawidgets/qgraphicsvideoitem.h b/src/multimediawidgets/qgraphicsvideoitem.h
index de73458fd..5c71ee651 100644
--- a/src/multimediawidgets/qgraphicsvideoitem.h
+++ b/src/multimediawidgets/qgraphicsvideoitem.h
@@ -60,7 +60,7 @@ class Q_MULTIMEDIAWIDGETS_EXPORT QGraphicsVideoItem : public QGraphicsObject, pu
Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
Q_PROPERTY(QSizeF size READ size WRITE setSize)
Q_PROPERTY(QSizeF nativeSize READ nativeSize NOTIFY nativeSizeChanged)
- Q_PROPERTY(QAbstractVideoSurface* videoSurface READ videoSurface)
+ Q_PROPERTY(QAbstractVideoSurface* videoSurface READ videoSurface CONSTANT)
public:
explicit QGraphicsVideoItem(QGraphicsItem *parent = nullptr);
~QGraphicsVideoItem();
diff --git a/src/multimediawidgets/qvideowidget.h b/src/multimediawidgets/qvideowidget.h
index c5abe2ce3..fdf93330b 100644
--- a/src/multimediawidgets/qvideowidget.h
+++ b/src/multimediawidgets/qvideowidget.h
@@ -63,7 +63,7 @@ class Q_MULTIMEDIAWIDGETS_EXPORT QVideoWidget : public QWidget, public QMediaBin
Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged)
Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged)
Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
- Q_PROPERTY(QAbstractVideoSurface* videoSurface READ videoSurface)
+ Q_PROPERTY(QAbstractVideoSurface* videoSurface READ videoSurface CONSTANT)
public:
explicit QVideoWidget(QWidget *parent = nullptr);
diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
index 128d0a616..81dc3fcb3 100644
--- a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
+++ b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
@@ -138,7 +138,7 @@ QDeclarativeVideoOutput::QDeclarativeVideoOutput(QQuickItem *parent) :
{
initResource();
setFlag(ItemHasContents, true);
- m_backend.reset(new QDeclarativeVideoRendererBackend(this));
+ createBackend(nullptr);
}
QDeclarativeVideoOutput::~QDeclarativeVideoOutput()
@@ -161,7 +161,7 @@ QDeclarativeVideoOutput::~QDeclarativeVideoOutput()
QAbstractVideoSurface *QDeclarativeVideoOutput::videoSurface() const
{
- return m_backend->videoSurface();
+ return m_backend ? m_backend->videoSurface() : nullptr;
}
/*!
@@ -223,21 +223,10 @@ void QDeclarativeVideoOutput::setSource(QObject *source)
}
m_sourceType = MediaObjectSource;
-#if QT_CONFIG(opengl)
} else if (metaObject->indexOfProperty("videoSurface") != -1) {
- // Make sure our backend is a QDeclarativeVideoRendererBackend
- m_backend.reset();
- createBackend(0);
- Q_ASSERT(m_backend);
-#ifndef QT_NO_DYNAMIC_CAST
- Q_ASSERT(dynamic_cast<QDeclarativeVideoRendererBackend *>(m_backend.data()));
-#endif
- QAbstractVideoSurface * const surface = m_backend->videoSurface();
- Q_ASSERT(surface);
m_source.data()->setProperty("videoSurface",
- QVariant::fromValue<QAbstractVideoSurface*>(surface));
+ QVariant::fromValue<QAbstractVideoSurface *>(videoSurface()));
m_sourceType = VideoSurfaceSource;
-#endif
} else {
m_sourceType = NoSource;
}
@@ -259,7 +248,8 @@ bool QDeclarativeVideoOutput::createBackend(QMediaService *service)
const auto instances = videoBackendFactoryLoader()->instances(QLatin1String("declarativevideobackend"));
for (QObject *instance : instances) {
if (QDeclarativeVideoBackendFactoryInterface *plugin = qobject_cast<QDeclarativeVideoBackendFactoryInterface*>(instance)) {
- m_backend.reset(plugin->create(this));
+ if (!m_backend)
+ m_backend.reset(plugin->create(this));
if (m_backend && m_backend->init(service)) {
backendAvailable = true;
break;
diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h b/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h
index 9e826d0ff..d14731c91 100644
--- a/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h
+++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h
@@ -81,7 +81,7 @@ class Q_MULTIMEDIAQUICK_EXPORT QDeclarativeVideoOutput : public QQuickItem
Q_PROPERTY(QRectF contentRect READ contentRect NOTIFY contentRectChanged)
Q_PROPERTY(QQmlListProperty<QAbstractVideoFilter> filters READ filters);
Q_PROPERTY(FlushMode flushMode READ flushMode WRITE setFlushMode NOTIFY flushModeChanged REVISION 13)
- Q_PROPERTY(QAbstractVideoSurface* videoSurface READ videoSurface REVISION 15)
+ Q_PROPERTY(QAbstractVideoSurface* videoSurface READ videoSurface CONSTANT REVISION 15)
Q_ENUMS(FlushMode)
Q_ENUMS(FillMode)