wayland: Fix ABI break in WL context type name

While transforming the internals of waylandsink into a library, the
context type name was accidentally changed, causing an ABI break. Change
it back to its original (as used by the libgstgl), and add support for
the misnamed version as a backward compatibility measure.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7482>
This commit is contained in:
Nicolas Dufresne 2024-09-09 16:27:43 -04:00 committed by GStreamer Marge Bot
parent 9f898f839c
commit a3bd3d676d
3 changed files with 54 additions and 20 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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);