static void gst_gl_display_context_query (GstElement * element, GstGLDisplay ** display_ptr) { GstContext *ctxt; GstQuery *query; #ifndef GST_DISABLE_GST_DEBUG if (!GST_CAT_CONTEXT) GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT"); #endif query = _gst_context_query (element, display_ptr, GST_GL_DISPLAY_CONTEXT_TYPE); gst_query_parse_context (query, &ctxt); if (ctxt && gst_context_has_context_type (ctxt, GST_GL_DISPLAY_CONTEXT_TYPE)) gst_context_get_gl_display (ctxt, display_ptr); if (*display_ptr) goto out; #if GST_GL_HAVE_WINDOW_X11 gst_query_unref (query); query = _gst_context_query (element, display_ptr, "gst.x11.display.handle"); gst_query_parse_context (query, &ctxt); if (ctxt && gst_context_has_context_type (ctxt, "gst.x11.display.handle")) { const GstStructure *s; Display *display; s = gst_context_get_structure (ctxt); if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL) && display) { *display_ptr = (GstGLDisplay *) gst_gl_display_x11_new_with_display (display); } } if (*display_ptr) goto out; #endif out: gst_query_unref (query); }
static void gst_gl_display_context_prepare (GstElement * element, GstGLDisplay ** display_ptr) { GstContext *ctxt; GstQuery *query; if (!GST_CAT_CONTEXT) GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT"); /* 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. */ ctxt = NULL; query = gst_query_new_context (GST_GL_DISPLAY_CONTEXT_TYPE); if (run_context_query (element, query, GST_PAD_SRC)) { GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "found context (%p) in downstream query", ctxt); gst_query_parse_context (query, &ctxt); } else if (run_context_query (element, query, GST_PAD_SINK)) { GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "found context (%p) in upstream query", ctxt); gst_query_parse_context (query, &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), GST_GL_DISPLAY_CONTEXT_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(). */ if (ctxt) { if (gst_context_has_context_type (ctxt, GST_GL_DISPLAY_CONTEXT_TYPE)) { gst_context_get_gl_display (ctxt, display_ptr); } } gst_query_unref (query); }
static void gst_wayland_sink_set_context (GstElement * element, GstContext * context) { GstWaylandSink *sink = GST_WAYLAND_SINK (element); if (gst_context_has_context_type (context, GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE)) { g_mutex_lock (&sink->display_lock); if (G_LIKELY (!sink->display)) gst_wayland_sink_set_display_from_context (sink, context); else GST_WARNING_OBJECT (element, "changing display handle is not supported"); g_mutex_unlock (&sink->display_lock); } if (GST_ELEMENT_CLASS (parent_class)->set_context) GST_ELEMENT_CLASS (parent_class)->set_context (element, context); }
static void gst_gl_context_query (GstElement * element, GstGLContext ** context_ptr) { GstContext *ctxt; GstQuery *query; #ifndef GST_DISABLE_GST_DEBUG if (!GST_CAT_CONTEXT) GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT"); #endif query = _gst_context_query (element, context_ptr, "gst.gl.app_context"); gst_query_parse_context (query, &ctxt); if (ctxt && gst_context_has_context_type (ctxt, "gst.gl.app_context")) { const GstStructure *s = gst_context_get_structure (ctxt); gst_structure_get (s, "context", GST_GL_TYPE_CONTEXT, context_ptr, NULL); } gst_query_unref (query); }
/** * gstbt_audio_tempo_context_get_tempo: * @ctx: the context * @bpm: beats per minute * @tpb: ticks per beat * @stpb: sub-ticks per beat * * Get values from the audio-tempo context. Pointers can be %NULL to skip them. * * Returns: %FALSE if the context if of the wrong type or any of the values were * not stored in the context. */ gboolean gstbt_audio_tempo_context_get_tempo (GstContext * ctx, guint * bpm, guint * tpb, guint * stpb) { const GstStructure *s; gboolean res = TRUE; if (!ctx) return FALSE; if (!gst_context_has_context_type (ctx, GSTBT_AUDIO_TEMPO_TYPE)) return FALSE; s = gst_context_get_structure (ctx); if (bpm) res &= gst_structure_get_uint (s, "beats-per-minute", bpm); if (tpb) res &= gst_structure_get_uint (s, "ticks-per-beat", tpb); if (stpb) res &= gst_structure_get_uint (s, "subticks-per-beat", stpb); return res; }