playsink: improve GL context sharing

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>
This commit is contained in:
Enrique Ocaña González 2022-03-28 18:43:27 +02:00 committed by Víctor Manuel Jáquez Leal
parent 656baad90f
commit 2a30f1038a

View file

@ -1471,11 +1471,18 @@ static GstElement *
try_element (GstPlaySink * playsink, GstElement * element, gboolean unref) try_element (GstPlaySink * playsink, GstElement * element, gboolean unref)
{ {
GstStateChangeReturn ret; GstStateChangeReturn ret;
GstBus *element_bus;
if (element) { 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); ret = gst_element_set_state (element, GST_STATE_READY);
if (ret == GST_STATE_CHANGE_FAILURE) { if (ret == GST_STATE_CHANGE_FAILURE) {
GST_DEBUG_OBJECT (playsink, "failed state change.."); GST_DEBUG_OBJECT (playsink, "failed state change..");
gst_element_set_bus (element, NULL);
gst_element_set_state (element, GST_STATE_NULL); gst_element_set_state (element, GST_STATE_NULL);
if (unref) if (unref)
gst_object_unref (element); gst_object_unref (element);