diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2021-03-25 13:20:38 +0100 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-04-21 08:26:52 +0000 |
commit | 36b794f9ff0413ac614a2d550b3d3efb7c5e3778 (patch) | |
tree | 88b3274639c66432b9551c15e59fe122ae1f1517 | |
parent | c70b41b22bfe46f60cfb392e586885e17e418979 (diff) | |
download | gstreamer-plugins-good-36b794f9ff0413ac614a2d550b3d3efb7c5e3778.tar.gz |
qmloverlay: Use first found GstGLVideoItem as widget property
GstGLVideoItem is required to render input video in the overlay's qml.
And currently qmlgloverlay requires to set this GstGLVideoItem to its widget property.
Instead of fetching GstGLVideoItem from the overlay's root object (root-item prop),
and setting it back as a widget (widget prop),
proposing to use found GstGLVideoItem in the current object hierarchy (passed in qml-scene) by default.
Also useful in Python, which solves the issue when casting gpointer <=> QQuickItem* is required.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/919>
-rw-r--r-- | ext/qt/gstqtoverlay.cc | 8 | ||||
-rw-r--r-- | tests/examples/qt/qmloverlay/overlay.py | 28 |
2 files changed, 36 insertions, 0 deletions
diff --git a/ext/qt/gstqtoverlay.cc b/ext/qt/gstqtoverlay.cc index af54ec78c..6a0e4e707 100644 --- a/ext/qt/gstqtoverlay.cc +++ b/ext/qt/gstqtoverlay.cc @@ -335,6 +335,14 @@ gst_qt_overlay_gl_start (GstGLBaseFilter * bfilter) g_object_notify (G_OBJECT (qt_overlay), "root-item"); g_signal_emit (qt_overlay, gst_qt_overlay_signals[SIGNAL_QML_SCENE_INITIALIZED], 0); + GST_OBJECT_LOCK (bfilter); + if (!qt_overlay->widget) { + QtGLVideoItem *qt_item = static_cast<QtGLVideoItem *>(root->findChild<QtGLVideoItem *> ()); + if (qt_item) + qt_overlay->widget = qt_item->getInterface(); + } + GST_OBJECT_UNLOCK (bfilter); + return TRUE; fail_renderer: diff --git a/tests/examples/qt/qmloverlay/overlay.py b/tests/examples/qt/qmloverlay/overlay.py new file mode 100644 index 000000000..bf3e18c7a --- /dev/null +++ b/tests/examples/qt/qmloverlay/overlay.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import signal +signal.signal(signal.SIGINT, signal.SIG_DFL) + +import sys +import gi +gi.require_version('Gst', '1.0') + +from gi.repository import Gst, GLib +from PySide2.QtGui import QGuiApplication +from PySide2.QtQuick import QQuickItem + +def main(args): + app = QGuiApplication(args) + Gst.init(args) + + pipeline = Gst.parse_launch("""videotestsrc ! glupload ! qmlgloverlay name=o ! gldownload ! videoconvert ! autovideosink""") + o = pipeline.get_by_name('o') + f = open('overlay.qml', 'r') + o.set_property('qml-scene', f.read()) + + pipeline.set_state(Gst.State.PLAYING) + app.exec_() + pipeline.set_state(Gst.State.NULL) + +if __name__ == '__main__': + sys.exit(main(sys.argv)) |