diff --git a/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c b/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c index 1bf537c9f3..a6613a103f 100644 --- a/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c +++ b/subprojects/gst-plugins-bad/ext/wayland/gstwaylandsink.c @@ -365,35 +365,62 @@ gst_wayland_sink_set_display_from_context (GstWaylandSink * self, } static gboolean -gst_wayland_sink_find_display (GstWaylandSink * self) +gst_wayland_sink_query_context (GstWaylandSink * self, const gchar * type) { GstQuery *query; + gboolean ret; + + query = gst_query_new_context (type); + ret = gst_pad_peer_query (GST_VIDEO_SINK_PAD (self), query); + + if (ret) { + GstContext *context = NULL; + gst_query_parse_context (query, &context); + gst_wayland_sink_set_display_from_context (self, context); + } + + gst_query_unref (query); + return ret; +} + +static gboolean +gst_wayland_sink_post_need_context (GstWaylandSink * self, const gchar * type) +{ GstMessage *msg; - GstContext *context = NULL; + + /* now ask the application to set the display handle */ + msg = gst_message_new_need_context (GST_OBJECT_CAST (self), type); + + g_mutex_unlock (&self->display_lock); + gst_element_post_message (GST_ELEMENT_CAST (self), msg); + /* at this point we expect gst_wayland_sink_set_context + * to get called and fill self->display */ + g_mutex_lock (&self->display_lock); + + return self->display != NULL; +} + +static gboolean +gst_wayland_sink_find_display (GstWaylandSink * self) +{ GError *error = NULL; gboolean ret = TRUE; g_mutex_lock (&self->display_lock); if (!self->display) { - /* first query upstream for the needed display handle */ - query = gst_query_new_context (GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE); - if (gst_pad_peer_query (GST_VIDEO_SINK_PAD (self), query)) { - gst_query_parse_context (query, &context); - gst_wayland_sink_set_display_from_context (self, context); + if (!gst_wayland_sink_query_context (self, + GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE)) { + gst_wayland_sink_query_context (self, + GST_WL_DISPLAY_HANDLE_LEGACY_CONTEXT_TYPE); } - gst_query_unref (query); if (G_LIKELY (!self->display)) { - /* now ask the application to set the display handle */ - msg = gst_message_new_need_context (GST_OBJECT_CAST (self), - GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE); - - g_mutex_unlock (&self->display_lock); - gst_element_post_message (GST_ELEMENT_CAST (self), msg); - /* at this point we expect gst_wayland_sink_set_context - * to get called and fill self->display */ - g_mutex_lock (&self->display_lock); + if (!gst_wayland_sink_post_need_context (self, + GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE)) { + gst_wayland_sink_post_need_context (self, + GST_WL_DISPLAY_HANDLE_LEGACY_CONTEXT_TYPE); + } if (!self->display) { /* if the application didn't set a display, let's create it ourselves */ @@ -480,7 +507,9 @@ gst_wayland_sink_set_context (GstElement * element, GstContext * context) GstWaylandSink *self = GST_WAYLAND_SINK (element); if (gst_context_has_context_type (context, - GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE)) { + GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE) || + gst_context_has_context_type (context, + GST_WL_DISPLAY_HANDLE_LEGACY_CONTEXT_TYPE)) { g_mutex_lock (&self->display_lock); if (G_LIKELY (!self->display)) { gst_wayland_sink_set_display_from_context (self, context); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.c b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.c index 43fd1df6be..e0f0496bf3 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.c @@ -33,7 +33,8 @@ gst_is_wl_display_handle_need_context_message (GstMessage * msg) if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_NEED_CONTEXT && gst_message_parse_context_type (msg, &type)) { - return !g_strcmp0 (type, GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE); + return !g_strcmp0 (type, GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE) || + !g_strcmp0 (type, GST_WL_DISPLAY_HANDLE_LEGACY_CONTEXT_TYPE); } return FALSE; @@ -60,6 +61,7 @@ gst_wl_display_handle_context_get_handle (GstContext * context) s = gst_context_get_structure (context); if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL)) return display; + /* backward compatibility */ if (gst_structure_get (s, "handle", G_TYPE_POINTER, &display, NULL)) return display; return NULL; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.h b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.h index a7b703394f..e7b802b952 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlcontext.h @@ -26,7 +26,10 @@ G_BEGIN_DECLS /* The type of GstContext used to pass the wl_display pointer * from the application to the sink */ -#define GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE "GstWlDisplayHandleContextType" +#define GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE "GstWaylandDisplayHandleContextType" + +/* Accidental naming, used for implementing backward compatibility */ +#define GST_WL_DISPLAY_HANDLE_LEGACY_CONTEXT_TYPE "GstWlDisplayHandleContextType" GST_WL_API gboolean gst_is_wl_display_handle_need_context_message (GstMessage * msg);