diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-08-06 09:51:53 +0200 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-08-08 10:03:44 +0200 |
commit | 73736cd52e6fd21927cb2acab3e28fdc88d08326 (patch) | |
tree | 92e685854d05f1b0df389742b6f201e1c6bccbc0 /src/gsttools/qgstvideorenderersink.cpp | |
parent | 636f46f04ba6d5c63783558ed78eb5f562179e9c (diff) |
GStreamer: Don't share video surfaces between several pipelines
qtvideosink element is available in pipelines only if QVideoRendererControl
is used, because it requires a video surface.
So if qtvideosink is used inside pipeline but a surface is not available,
created null/dummy surface to render video frames to and show
a warning about this.
Change-Id: I924d3baca994363550b7920176e29e9cd0c4dd1f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/gsttools/qgstvideorenderersink.cpp')
-rw-r--r-- | src/gsttools/qgstvideorenderersink.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/gsttools/qgstvideorenderersink.cpp b/src/gsttools/qgstvideorenderersink.cpp index c3a7a5988..597b97410 100644 --- a/src/gsttools/qgstvideorenderersink.cpp +++ b/src/gsttools/qgstvideorenderersink.cpp @@ -486,13 +486,35 @@ void QGstVideoRendererSink::base_init(gpointer g_class) GST_ELEMENT_CLASS(g_class), gst_static_pad_template_get(&sink_pad_template)); } +struct NullSurface : QAbstractVideoSurface +{ + NullSurface(QObject *parent = nullptr) : QAbstractVideoSurface(parent) { } + + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const override + { + return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB32; + } + + bool present(const QVideoFrame &) override + { + return true; + } +}; + void QGstVideoRendererSink::instance_init(GTypeInstance *instance, gpointer g_class) { + Q_UNUSED(g_class); VO_SINK(instance); - Q_UNUSED(g_class); + if (!current_surface) { + qWarning() << "Using qtvideosink element without video surface"; + static NullSurface nullSurface; + current_surface = &nullSurface; + } + sink->delegate = new QVideoSurfaceGstDelegate(current_surface); sink->delegate->moveToThread(current_surface->thread()); + current_surface = nullptr; } void QGstVideoRendererSink::finalize(GObject *object) |