playsink: improve GL context sharing
authorEnrique Ocaña González <eocanha@igalia.com>
Mon, 28 Mar 2022 16:43:27 +0000 (18:43 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 30 Mar 2022 15:32:19 +0000 (15:32 +0000)
Configure playsink tried element with the bus of the main pipeline.
That tried element can be a gl video sink, which would benefit from being
able to propagate context messages to the main pipeline and have other
internal pipeline elements configured with it. Having different elements
configured with the same GL context allows them to share buffers with
video/x-raw(memory:GLMemory) caps and achieving zero-copy.

Thanks to Alicia Boya García <aboya@igalia.com> for her work co-debugging
the issue and contributing to find a solution.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2056>

subprojects/gst-plugins-base/gst/playback/gstplaysink.c

index 31251d6..a870613 100644 (file)
@@ -1471,11 +1471,18 @@ static GstElement *
 try_element (GstPlaySink * playsink, GstElement * element, gboolean unref)
 {
   GstStateChangeReturn ret;
+  GstBus *element_bus;
 
   if (element) {
+    element_bus = gst_element_get_bus (element);
+    g_assert (!element_bus);
+    gst_element_set_bus (element, GST_BIN_CAST (playsink)->child_bus);
+
     ret = gst_element_set_state (element, GST_STATE_READY);
+
     if (ret == GST_STATE_CHANGE_FAILURE) {
       GST_DEBUG_OBJECT (playsink, "failed state change..");
+      gst_element_set_bus (element, NULL);
       gst_element_set_state (element, GST_STATE_NULL);
       if (unref)
         gst_object_unref (element);