From 95f819109fca03fc0a0f66168fcc6d5aae08dcac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 31 Mar 2013 11:46:28 +0200 Subject: [PATCH] eglglessink: Use gst_element_get_context() wherever possible --- ext/eglgles/gsteglglessink.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c index e8f966e564..5ba9b7897d 100644 --- a/ext/eglgles/gsteglglessink.c +++ b/ext/eglgles/gsteglglessink.c @@ -1542,9 +1542,17 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink) GST_OBJECT_LOCK (eglglessink); if (eglglessink->eglglesctx.set_display) { + GstContext * context; + eglglessink->eglglesctx.display = gst_egl_display_ref (eglglessink->eglglesctx.set_display); GST_OBJECT_UNLOCK (eglglessink); + context = gst_element_get_context (GST_ELEMENT_CAST (eglglessink)); + if (!context) + context = gst_context_new (); + context = gst_context_make_writable (context); + gst_context_set_egl_display (context, eglglessink->eglglesctx.display); + gst_element_set_context (GST_ELEMENT_CAST (eglglessink), context); } else { GstContext *context; @@ -1562,6 +1570,13 @@ gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink) msg = gst_message_new_have_context (GST_OBJECT (eglglessink), context); gst_element_post_message (GST_ELEMENT_CAST (eglglessink), msg); + + context = gst_element_get_context (GST_ELEMENT_CAST (eglglessink)); + if (!context) + context = gst_context_new (); + context = gst_context_make_writable (context); + gst_context_set_egl_display (context, eglglessink->eglglesctx.display); + gst_element_set_context (GST_ELEMENT_CAST (eglglessink), context); } if (!eglInitialize (gst_egl_display_get (eglglessink->eglglesctx.display), @@ -2618,20 +2633,24 @@ static void gst_eglglessink_set_context (GstElement * element, GstContext * context) { GstEglGlesSink *eglglessink; - GstStructure *s; GstEGLDisplay *display = NULL; eglglessink = GST_EGLGLESSINK (element); - s = (GstStructure *) gst_context_get_structure (context); - if (gst_structure_get (s, GST_EGL_DISPLAY_CONTEXT_TYPE, GST_TYPE_EGL_DISPLAY, - &display, NULL)) { + if (gst_context_get_egl_display (context, &display)) { GST_OBJECT_LOCK (eglglessink); if (eglglessink->eglglesctx.set_display) gst_egl_display_unref (eglglessink->eglglesctx.set_display); eglglessink->eglglesctx.set_display = display; GST_OBJECT_UNLOCK (eglglessink); } + + GST_OBJECT_LOCK (eglglessink); + context = gst_context_make_writable (context); + gst_context_set_egl_display (context, eglglessink->eglglesctx.display); + GST_OBJECT_UNLOCK (eglglessink); + + GST_ELEMENT_CLASS (parent_class)->set_context (element, context); } static gboolean