From b7180ebaf6856d96643dd3a94153e9db637ba06e Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Wed, 5 May 2010 11:21:31 +0200 Subject: glfilter/glmixer/gltestsrc/glupload: throw an element error if no parent bin Fixes bug #602153 --- gst-libs/gst/gl/gstglfilter.c | 17 +++++++++++++---- gst-libs/gst/gl/gstglmixer.c | 21 +++++++++++++++------ gst/gl/gstgltestsrc.c | 31 +++++++++++++++++++++++-------- gst/gl/gstglupload.c | 17 +++++++++++++---- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index 2f0e6ec..bec8cbc 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -238,11 +238,20 @@ gst_gl_filter_start (GstBaseTransform * bt) GstGLFilter *filter = GST_GL_FILTER (bt); GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter); GstElement *parent = GST_ELEMENT (gst_element_get_parent (filter)); - GstStructure *structure = - gst_structure_new (gst_element_get_name (filter), NULL); - GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure); + GstStructure *structure = NULL; + GstQuery *query = NULL; + gboolean isPerformed = FALSE; - gboolean isPerformed = gst_element_query (parent, query); + if (!parent) { + GST_ELEMENT_ERROR (filter, CORE, STATE_CHANGE, (NULL), + ("A parent bin is required")); + return FALSE; + } + + structure = gst_structure_new (gst_element_get_name (filter), NULL); + query = gst_query_new_application (GST_QUERY_CUSTOM, structure); + + isPerformed = gst_element_query (parent, query); if (isPerformed) { const GValue *id_value = diff --git a/gst-libs/gst/gl/gstglmixer.c b/gst-libs/gst/gl/gstglmixer.c index 4c60083..476a02f 100644 --- a/gst-libs/gst/gl/gstglmixer.c +++ b/gst-libs/gst/gl/gstglmixer.c @@ -609,10 +609,10 @@ gst_gl_mixer_query (GstPad * pad, GstQuery * query) /* id_value is set by upstream element of itself when going * to paused state */ const GValue *id_value = - gst_structure_get_value (structure, "gstgldisplay"); + gst_structure_get_value (structure, "gstgldisplay"); foreign_display = GST_GL_DISPLAY (g_value_get_pointer (id_value)); } - + foreign_gl_context = gst_gl_display_get_internal_gl_context (foreign_display); @@ -1243,12 +1243,21 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition) gint i = 0; GstElement *parent = GST_ELEMENT (gst_element_get_parent (mix)); - GstStructure *structure = - gst_structure_new (gst_element_get_name (mix), NULL); - GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure); + GstStructure *structure = NULL; + GstQuery *query = NULL; + gboolean isPerformed = FALSE; + + if (!parent) { + GST_ELEMENT_ERROR (mix, CORE, STATE_CHANGE, (NULL), + ("A parent bin is required")); + return FALSE; + } + + structure = gst_structure_new (gst_element_get_name (mix), NULL); + query = gst_query_new_application (GST_QUERY_CUSTOM, structure); /* retrieve the gldisplay that is owned by gl elements after the gl mixer */ - gboolean isPerformed = gst_element_query (parent, query); + isPerformed = gst_element_query (parent, query); if (isPerformed) { const GValue *id_value = diff --git a/gst/gl/gstgltestsrc.c b/gst/gl/gstgltestsrc.c index eb5b383..ec17ff6 100644 --- a/gst/gl/gstgltestsrc.c +++ b/gst/gl/gstgltestsrc.c @@ -1,4 +1,4 @@ -/* +/* * GStreamer * Copyright (C) <1999> Erik Walthinsen * Copyright (C) 2002,2007 David A. Schleef @@ -188,7 +188,7 @@ gst_gl_test_src_init (GstGLTestSrc * src, GstGLTestSrcClass * g_class) /* we operate in time */ gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); gst_base_src_set_live (GST_BASE_SRC (src), FALSE); - + gst_pad_set_query_function (pad, GST_DEBUG_FUNCPTR (gst_gl_test_src_src_query)); } @@ -312,7 +312,9 @@ gst_gl_test_src_src_query (GstPad * pad, GstQuery * query) case GST_QUERY_CUSTOM: { GstStructure *structure = gst_query_get_structure (query); - res = g_strcmp0 (gst_element_get_name (parent), gst_structure_get_name (structure)) == 0; + res = + g_strcmp0 (gst_element_get_name (parent), + gst_structure_get_name (structure)) == 0; break; } default: @@ -383,6 +385,7 @@ gst_gl_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps) gltestsrc->width, gltestsrc->height, gltestsrc->rate_numerator, gltestsrc->rate_denominator); + gst_gl_display_gen_fbo (gltestsrc->display, gltestsrc->width, gltestsrc->height, &gltestsrc->fbo, &gltestsrc->depthbuffer); } @@ -614,16 +617,28 @@ gst_gl_test_src_start (GstBaseSrc * basesrc) { GstGLTestSrc *src = GST_GL_TEST_SRC (basesrc); GstElement *parent = GST_ELEMENT (gst_element_get_parent (src)); - GstStructure *structure = gst_structure_new (gst_element_get_name (src), NULL); - GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure); + GstStructure *structure = NULL; + GstQuery *query = NULL; + gboolean isPerformed = FALSE; + + if (!parent) { + GST_ELEMENT_ERROR (src, CORE, STATE_CHANGE, (NULL), + ("A parent bin is required")); + return FALSE; + } + + structure = gst_structure_new (gst_element_get_name (src), NULL); + query = gst_query_new_application (GST_QUERY_CUSTOM, structure); - gboolean isPerformed = gst_element_query (parent, query); + isPerformed = gst_element_query (parent, query); if (isPerformed) { - const GValue *id_value = gst_structure_get_value (structure, "gstgldisplay"); + const GValue *id_value = + gst_structure_get_value (structure, "gstgldisplay"); if (G_VALUE_HOLDS_POINTER (id_value)) /* at least one gl element is before in our gl chain */ - src->display = g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value))); + src->display = + g_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value))); else { /* this gl filter is a sink in terms of the gl chain */ src->display = gst_gl_display_new (); diff --git a/gst/gl/gstglupload.c b/gst/gl/gstglupload.c index 818ef73..4c9badc 100644 --- a/gst/gl/gstglupload.c +++ b/gst/gl/gstglupload.c @@ -273,11 +273,20 @@ gst_gl_upload_start (GstBaseTransform * bt) { GstGLUpload *upload = GST_GL_UPLOAD (bt); GstElement *parent = GST_ELEMENT (gst_element_get_parent (upload)); - GstStructure *structure = - gst_structure_new (gst_element_get_name (upload), NULL); - GstQuery *query = gst_query_new_application (GST_QUERY_CUSTOM, structure); + GstStructure *structure = NULL; + GstQuery *query = NULL; + gboolean isPerformed = FALSE; + + if (!parent) { + GST_ELEMENT_ERROR (upload, CORE, STATE_CHANGE, (NULL), + ("A parent bin is required")); + return FALSE; + } + + structure = gst_structure_new (gst_element_get_name (upload), NULL); + query = gst_query_new_application (GST_QUERY_CUSTOM, structure); - gboolean isPerformed = gst_element_query (parent, query); + isPerformed = gst_element_query (parent, query); if (isPerformed) { const GValue *id_value = -- cgit v1.2.3