From 19b509268517d0a16601d51d381daa42941df2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 4 Nov 2013 19:58:35 +0100 Subject: [PATCH] eglglessink: Query upstream first to get a EGLDisplay --- ext/eglgles/gstegladaptation_egl.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/ext/eglgles/gstegladaptation_egl.c b/ext/eglgles/gstegladaptation_egl.c index 91a43e5ef7..de90792191 100644 --- a/ext/eglgles/gstegladaptation_egl.c +++ b/ext/eglgles/gstegladaptation_egl.c @@ -136,6 +136,7 @@ gst_egl_adaptation_init_exts (GstEglAdaptationContext * ctx) gboolean gst_egl_adaptation_init_display (GstEglAdaptationContext * ctx) { + GstQuery *query; GstMessage *msg; EGLDisplay display; GST_DEBUG_OBJECT (ctx->element, "Enter EGL initial configuration"); @@ -145,10 +146,23 @@ gst_egl_adaptation_init_display (GstEglAdaptationContext * ctx) goto HANDLE_ERROR; } - msg = - gst_message_new_need_context (GST_OBJECT_CAST (ctx->element), - GST_EGL_DISPLAY_CONTEXT_TYPE); - gst_element_post_message (GST_ELEMENT_CAST (ctx->element), msg); + if (!ctx->set_display) { + query = gst_query_new_context (GST_EGL_DISPLAY_CONTEXT_TYPE); + if (gst_pad_peer_query (GST_BASE_SINK_PAD (ctx->element), query)) { + GstContext *context; + + gst_query_parse_context (query, &context); + gst_context_get_egl_display (context, &ctx->set_display); + } + gst_query_unref (query); + } + + if (!ctx->set_display) { + msg = + gst_message_new_need_context (GST_OBJECT_CAST (ctx->element), + GST_EGL_DISPLAY_CONTEXT_TYPE); + gst_element_post_message (GST_ELEMENT_CAST (ctx->element), msg); + } GST_OBJECT_LOCK (ctx->element); if (!ctx->set_display) { @@ -166,6 +180,8 @@ gst_egl_adaptation_init_display (GstEglAdaptationContext * ctx) context = gst_context_new_egl_display (ctx->display, FALSE); msg = gst_message_new_have_context (GST_OBJECT (ctx->element), context); gst_element_post_message (GST_ELEMENT_CAST (ctx->element), msg); + } else { + ctx->display = gst_egl_display_ref (ctx->set_display); } if (!eglInitialize (gst_egl_display_get (ctx->display),