mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
plugins: query upstream element for a GstContext.
Fix gst_vaapi_video_context_prepare() to also query upstream elements for a valid GstContext. Improve comments regarding the steps used to lookup or build that context, thus conforming to the GstContext API recommendations. https://bugzilla.gnome.org/show_bug.cgi?id=709112 Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
parent
6b3c08a729
commit
b56144e924
1 changed files with 33 additions and 12 deletions
|
@ -98,7 +98,15 @@ run_context_query(GstElement *element, GstQuery *query)
|
|||
gst_iterator_resync(it);
|
||||
gst_iterator_free(it);
|
||||
|
||||
/* Ignore upstream neighbours */
|
||||
if (g_value_get_boolean(&res))
|
||||
return TRUE;
|
||||
|
||||
/* If none, ask upstream neighbour (auto-plugged case) */
|
||||
it = gst_element_iterate_sink_pads(element);
|
||||
while (gst_iterator_fold(it, func, &res, query) == GST_ITERATOR_RESYNC)
|
||||
gst_iterator_resync(it);
|
||||
gst_iterator_free(it);
|
||||
|
||||
return g_value_get_boolean(&res);
|
||||
}
|
||||
|
||||
|
@ -107,12 +115,23 @@ gst_vaapi_video_context_prepare(GstElement *element, const gchar **types)
|
|||
{
|
||||
GstContext *context;
|
||||
GstQuery *query;
|
||||
GstMessage *msg;
|
||||
|
||||
if (!GST_CAT_CONTEXT)
|
||||
GST_DEBUG_CATEGORY_GET(GST_CAT_CONTEXT, "GST_CONTEXT");
|
||||
|
||||
/* (2) Query downstream with GST_QUERY_CONTEXT for the context and
|
||||
check if downstream already has a context of the specified type */
|
||||
/* 1) Check if the element already has a context of the specific
|
||||
* type, i.e. it was previously set via
|
||||
* gst_element_set_context(). */
|
||||
/* This was already done by the caller of this function:
|
||||
* gst_vaapi_ensure_display() */
|
||||
|
||||
/* 2) Query downstream with GST_QUERY_CONTEXT for the context and
|
||||
check if downstream already has a context of the specific
|
||||
type */
|
||||
/* 3) Query upstream with GST_QUERY_CONTEXT for the context and
|
||||
check if upstream already has a context of the specific
|
||||
type */
|
||||
context = NULL;
|
||||
query = gst_query_new_context(GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME);
|
||||
if (run_context_query(element, query)) {
|
||||
|
@ -122,24 +141,26 @@ gst_vaapi_video_context_prepare(GstElement *element, const gchar **types)
|
|||
gst_element_set_context(element, context);
|
||||
}
|
||||
else {
|
||||
/* (3) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with
|
||||
the required context types 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;
|
||||
|
||||
/* 4) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with
|
||||
the required context types and afterwards check if an
|
||||
usable context was set now as in 1). The message could
|
||||
be handled by the parent bins of the element and the
|
||||
application. */
|
||||
GST_CAT_INFO_OBJECT(GST_CAT_CONTEXT, element,
|
||||
"posting `need-context' message");
|
||||
msg = gst_message_new_need_context(GST_OBJECT_CAST(element),
|
||||
GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME);
|
||||
gst_element_post_message(element, msg);
|
||||
|
||||
/* The check of an usable context is done by the caller:
|
||||
gst_vaapi_ensure_display() */
|
||||
}
|
||||
|
||||
gst_query_unref(query);
|
||||
}
|
||||
|
||||
/* (4) Create context by itself and post a GST_MESSAGE_HAVE_CONTEXT
|
||||
message and send a GST_EVENT_CONTEXT event downstream, thus
|
||||
containing the complete context information at this time */
|
||||
/* 5) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT message
|
||||
on the bus. */
|
||||
void
|
||||
gst_vaapi_video_context_propagate(GstElement *element, GstVaapiDisplay *display)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue