/** * gst_gl_query_local_gl_context: * @element: a #GstElement to query from * @direction: the #GstPadDirection to query * @context_ptr: (inout): location containing the current and/or resulting * #GstGLContext * * Performs a GST_QUERY_CONTEXT query of type "gst.gl.local_context" on all * #GstPads in @element of @direction for the local OpenGL context used by * GStreamer elements. * * Returns: whether @context_ptr contains a #GstGLContext */ gboolean gst_gl_query_local_gl_context (GstElement * element, GstPadDirection direction, GstGLContext ** context_ptr) { GstQuery *query; GstContext *context; const GstStructure *s; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (context_ptr != NULL, FALSE); if (*context_ptr) return TRUE; query = gst_query_new_context ("gst.gl.local_context"); if (gst_gl_run_query (GST_ELEMENT (element), query, direction)) { gst_query_parse_context (query, &context); if (context) { s = gst_context_get_structure (context); gst_structure_get (s, "context", GST_TYPE_GL_CONTEXT, context_ptr, NULL); } } gst_query_unref (query); return *context_ptr != NULL; }
static void _gst_context_query (GstElement * element, const gchar * display_type) { GstQuery *query; GstContext *ctxt; _init_context_debug (); /* 2a) Query downstream with GST_QUERY_CONTEXT for the context and * check if downstream already has a context of the specific type * 2b) Query upstream as above. */ query = gst_query_new_context (display_type); if (gst_gl_run_query (element, query, GST_PAD_SRC)) { gst_query_parse_context (query, &ctxt); GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "found context (%p) in downstream query", ctxt); gst_element_set_context (element, ctxt); } else if (gst_gl_run_query (element, query, GST_PAD_SINK)) { gst_query_parse_context (query, &ctxt); GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "found context (%p) in upstream query", ctxt); gst_element_set_context (element, ctxt); } else { /* 3) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with * the required context type and afterwards check if a * usable context was set now as in 1). The message could * be handled by the parent bins of the element and the * application. */ GstMessage *msg; GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "posting need context message"); msg = gst_message_new_need_context (GST_OBJECT_CAST (element), display_type); gst_element_post_message (element, msg); } /* * Whomever responds to the need-context message performs a * GstElement::set_context() with the required context in which the element * is required to update the display_ptr or call gst_gl_handle_set_context(). */ gst_query_unref (query); }
static gboolean _find_local_gl_context (GstGLStereoSplit * split) { GstQuery *query; GstContext *context; const GstStructure *s; if (split->context) return TRUE; query = gst_query_new_context ("gst.gl.local_context"); if (!split->context && gst_gl_run_query (GST_ELEMENT (split), query, GST_PAD_SRC)) { gst_query_parse_context (query, &context); if (context) { s = gst_context_get_structure (context); gst_structure_get (s, "context", GST_GL_TYPE_CONTEXT, &split->context, NULL); } } if (!split->context && gst_gl_run_query (GST_ELEMENT (split), query, GST_PAD_SINK)) { gst_query_parse_context (query, &context); if (context) { s = gst_context_get_structure (context); gst_structure_get (s, "context", GST_GL_TYPE_CONTEXT, &split->context, NULL); } } GST_DEBUG_OBJECT (split, "found local context %p", split->context); gst_query_unref (query); if (split->context) return TRUE; return FALSE; }