2013-05-22 16:07:52 +00:00
|
|
|
/*
|
|
|
|
* gstvaapivideocontext.c - GStreamer/VA video context
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-05-22 16:07:52 +00:00
|
|
|
* Copyright (C) 2011-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2013-05-22 16:07:52 +00:00
|
|
|
* Copyright (C) 2013 Igalia
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2015-04-03 14:08:30 +00:00
|
|
|
#include "gstcompat.h"
|
2013-05-22 16:07:52 +00:00
|
|
|
#include "gstvaapivideocontext.h"
|
2016-06-02 17:57:08 +00:00
|
|
|
#if USE_GST_GL_HELPERS
|
|
|
|
# include <gst/gl/gl.h>
|
|
|
|
#endif
|
2017-07-05 06:31:55 +00:00
|
|
|
#if USE_X11
|
|
|
|
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
|
|
|
#endif
|
2017-11-08 04:27:06 +00:00
|
|
|
#if USE_WAYLAND
|
|
|
|
#include <gst/vaapi/gstvaapidisplay_wayland.h>
|
|
|
|
#endif
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2013-12-21 05:22:30 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2015-10-30 10:18:47 +00:00
|
|
|
static void
|
|
|
|
_init_context_debug (void)
|
|
|
|
{
|
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
static volatile gsize _init = 0;
|
|
|
|
|
|
|
|
if (g_once_init_enter (&_init)) {
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT");
|
|
|
|
g_once_init_leave (&_init, 1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-11-04 19:29:03 +00:00
|
|
|
void
|
|
|
|
gst_vaapi_video_context_set_display (GstContext * context,
|
|
|
|
GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
|
|
|
structure = gst_context_writable_structure (context);
|
|
|
|
gst_structure_set (structure, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME,
|
2016-10-13 03:53:17 +00:00
|
|
|
GST_TYPE_VAAPI_DISPLAY, display, NULL);
|
2015-11-04 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2015-10-23 09:17:01 +00:00
|
|
|
GstContext *
|
|
|
|
gst_vaapi_video_context_new_with_display (GstVaapiDisplay * display,
|
|
|
|
gboolean persistent)
|
2013-05-22 16:07:52 +00:00
|
|
|
{
|
2013-12-21 05:22:30 +00:00
|
|
|
GstContext *context;
|
|
|
|
|
|
|
|
context = gst_context_new (GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME, persistent);
|
2015-11-04 19:29:03 +00:00
|
|
|
gst_vaapi_video_context_set_display (context, display);
|
2013-12-21 05:22:30 +00:00
|
|
|
return context;
|
2013-05-22 16:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
gst_vaapi_video_context_get_display (GstContext * context, gboolean app_context,
|
2013-12-21 05:22:30 +00:00
|
|
|
GstVaapiDisplay ** display_ptr)
|
2013-05-22 16:07:52 +00:00
|
|
|
{
|
2013-12-21 05:22:30 +00:00
|
|
|
const GstStructure *structure;
|
2016-08-02 13:48:25 +00:00
|
|
|
const gchar *type;
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
GstVaapiDisplay *display = NULL;
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2013-12-21 05:22:30 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CONTEXT (context), FALSE);
|
2016-08-02 13:48:25 +00:00
|
|
|
|
|
|
|
type = gst_context_get_context_type (context);
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2017-07-05 06:31:55 +00:00
|
|
|
if (!g_strcmp0 (type, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME)) {
|
|
|
|
structure = gst_context_get_structure (context);
|
|
|
|
return gst_structure_get (structure, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME,
|
|
|
|
GST_TYPE_VAAPI_DISPLAY, display_ptr, NULL);
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (app_context && !g_strcmp0 (type, GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME)) {
|
2017-07-05 06:31:55 +00:00
|
|
|
VADisplay va_display = NULL;
|
|
|
|
structure = gst_context_get_structure (context);
|
|
|
|
|
|
|
|
if (gst_structure_get (structure, "va-display", G_TYPE_POINTER, &va_display,
|
|
|
|
NULL)) {
|
|
|
|
#if USE_X11
|
|
|
|
Display *x11_display = NULL;
|
|
|
|
if (gst_structure_get (structure, "x11-display", G_TYPE_POINTER,
|
|
|
|
&x11_display, NULL)) {
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
display =
|
2017-07-05 06:31:55 +00:00
|
|
|
gst_vaapi_display_x11_new_with_va_display (va_display, x11_display);
|
|
|
|
}
|
|
|
|
#endif
|
2017-11-08 04:27:06 +00:00
|
|
|
#if USE_WAYLAND
|
|
|
|
if (!display) {
|
|
|
|
struct wl_display *wl_display = NULL;
|
|
|
|
if (gst_structure_get (structure, "wl-display", G_TYPE_POINTER,
|
|
|
|
&wl_display, NULL)) {
|
|
|
|
display =
|
|
|
|
gst_vaapi_display_wayland_new_with_va_display (va_display,
|
|
|
|
wl_display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
|
|
|
|
_init_context_debug ();
|
|
|
|
|
|
|
|
if (!display) {
|
|
|
|
GST_CAT_WARNING (GST_CAT_CONTEXT,
|
|
|
|
"Cannot create GstVaapiDisplay if only VADisplay is provided");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
GST_CAT_INFO (GST_CAT_CONTEXT,
|
|
|
|
"new display with context %" GST_PTR_FORMAT, display);
|
|
|
|
*display_ptr = display;
|
|
|
|
return TRUE;
|
2017-07-05 06:31:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2013-05-22 16:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-12-21 05:22:30 +00:00
|
|
|
context_pad_query (const GValue * item, GValue * value, gpointer user_data)
|
2013-05-22 16:07:52 +00:00
|
|
|
{
|
2013-12-21 05:22:30 +00:00
|
|
|
GstPad *const pad = g_value_get_object (item);
|
|
|
|
GstQuery *const query = user_data;
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2013-12-21 05:22:30 +00:00
|
|
|
if (gst_pad_peer_query (pad, query)) {
|
|
|
|
g_value_set_boolean (value, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2015-10-30 10:18:47 +00:00
|
|
|
_init_context_debug ();
|
2013-12-21 05:22:30 +00:00
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, pad, "context pad peer query failed");
|
|
|
|
return TRUE;
|
2013-05-22 16:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2015-11-04 18:02:34 +00:00
|
|
|
_gst_context_run_query (GstElement * element, GstQuery * query,
|
|
|
|
GstPadDirection direction)
|
2013-05-22 16:07:52 +00:00
|
|
|
{
|
2013-12-21 05:22:30 +00:00
|
|
|
GstIteratorFoldFunction const func = context_pad_query;
|
|
|
|
GstIterator *it;
|
|
|
|
GValue res = { 0 };
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2013-12-21 05:22:30 +00:00
|
|
|
g_value_init (&res, G_TYPE_BOOLEAN);
|
|
|
|
g_value_set_boolean (&res, FALSE);
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2015-11-04 18:02:34 +00:00
|
|
|
/* Ask neighbour */
|
|
|
|
if (direction == GST_PAD_SRC)
|
|
|
|
it = gst_element_iterate_src_pads (element);
|
|
|
|
else
|
|
|
|
it = gst_element_iterate_sink_pads (element);
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2013-12-21 05:22:30 +00:00
|
|
|
while (gst_iterator_fold (it, func, &res, query) == GST_ITERATOR_RESYNC)
|
|
|
|
gst_iterator_resync (it);
|
|
|
|
gst_iterator_free (it);
|
2013-10-01 10:09:44 +00:00
|
|
|
|
2013-12-21 05:22:30 +00:00
|
|
|
return g_value_get_boolean (&res);
|
2013-05-22 16:07:52 +00:00
|
|
|
}
|
|
|
|
|
2015-11-04 18:02:34 +00:00
|
|
|
static gboolean
|
|
|
|
_gst_context_get_from_query (GstElement * element, GstQuery * query,
|
|
|
|
GstPadDirection direction)
|
|
|
|
{
|
|
|
|
GstContext *ctxt;
|
|
|
|
|
|
|
|
if (!_gst_context_run_query (element, query, direction))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gst_query_parse_context (query, &ctxt);
|
2016-06-24 10:05:24 +00:00
|
|
|
if (!ctxt)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-11-04 18:02:34 +00:00
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
|
|
|
|
"found context (%" GST_PTR_FORMAT ") in %s query", ctxt,
|
|
|
|
direction == GST_PAD_SRC ? "downstream" : "upstream");
|
|
|
|
gst_element_set_context (element, ctxt);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gst_context_query (GstElement * element, const gchar * context_type)
|
2013-05-22 16:07:52 +00:00
|
|
|
{
|
2013-12-21 05:22:30 +00:00
|
|
|
GstQuery *query;
|
|
|
|
GstMessage *msg;
|
|
|
|
|
2015-10-30 10:18:47 +00:00
|
|
|
_init_context_debug ();
|
2013-12-21 05:22:30 +00:00
|
|
|
|
|
|
|
/* 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 */
|
2015-11-04 18:02:34 +00:00
|
|
|
query = gst_query_new_context (context_type);
|
|
|
|
if (_gst_context_get_from_query (element, query, GST_PAD_SRC))
|
|
|
|
goto found;
|
|
|
|
if (_gst_context_get_from_query (element, query, GST_PAD_SINK))
|
|
|
|
goto found;
|
|
|
|
|
|
|
|
/* 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), context_type);
|
2017-12-06 21:11:25 +00:00
|
|
|
if (!gst_element_post_message (element, msg))
|
2015-10-28 11:55:18 +00:00
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "No bus attached");
|
2013-12-21 05:22:30 +00:00
|
|
|
|
2015-11-04 18:02:34 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
found:
|
2013-12-21 05:22:30 +00:00
|
|
|
gst_query_unref (query);
|
2013-05-22 16:07:52 +00:00
|
|
|
}
|
|
|
|
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
static gboolean
|
|
|
|
_gst_vaapi_sink_find_context (GstElement * element)
|
|
|
|
{
|
|
|
|
GstQuery *query;
|
|
|
|
GstMessage *msg;
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
/* 1. Query upstream for an already created GstVaapiDisplay */
|
|
|
|
query = gst_query_new_context (GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME);
|
|
|
|
found = _gst_context_get_from_query (element, query, GST_PAD_SINK);
|
|
|
|
gst_query_unref (query);
|
|
|
|
if (found)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* 2. Post a GST_MESSAGE_NEED_CONTEXT message on the bus with a
|
|
|
|
* gst.vaapi.app.Display context from the application */
|
|
|
|
msg = gst_message_new_need_context (GST_OBJECT_CAST (element),
|
|
|
|
GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME);
|
|
|
|
if (!gst_element_post_message (element, msg)) {
|
|
|
|
_init_context_debug ();
|
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "No bus attached");
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-10-30 11:27:16 +00:00
|
|
|
gboolean
|
|
|
|
gst_vaapi_video_context_prepare (GstElement * element,
|
|
|
|
GstVaapiDisplay ** display_ptr)
|
2015-11-04 18:02:34 +00:00
|
|
|
{
|
2015-10-30 11:27:16 +00:00
|
|
|
g_return_val_if_fail (element != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (display_ptr != NULL, FALSE);
|
2015-11-04 18:02:34 +00:00
|
|
|
|
|
|
|
/* 1) Check if the element already has a context of the specific
|
2015-10-30 11:27:16 +00:00
|
|
|
* type.
|
|
|
|
*/
|
|
|
|
if (*display_ptr) {
|
2017-12-01 19:21:54 +00:00
|
|
|
GST_LOG_OBJECT (element, "already have a display %" GST_PTR_FORMAT,
|
|
|
|
*display_ptr);
|
2015-10-30 11:27:16 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2015-11-04 18:02:34 +00:00
|
|
|
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
if (GST_IS_VIDEO_SINK (element)) {
|
|
|
|
if (!_gst_vaapi_sink_find_context (element) && *display_ptr) {
|
|
|
|
/* Propagate if display was created from application */
|
|
|
|
gst_vaapi_video_context_propagate (element, *display_ptr);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_gst_context_query (element, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME);
|
|
|
|
}
|
2015-11-04 18:02:34 +00:00
|
|
|
|
2017-07-05 06:31:55 +00:00
|
|
|
if (*display_ptr) {
|
2017-12-01 19:21:54 +00:00
|
|
|
GST_LOG_OBJECT (element, "found a display %" GST_PTR_FORMAT, *display_ptr);
|
2017-07-05 06:31:55 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
vaapivideocontext: only vaapisink process app context
gst.vaapi.app.Display context is made for applications that will
provide the VA display and the native display to used by the
pipeline, when are using vaapisink as overlay. There are no use
case for encoders, decoders, neither for the postprocessor.
In the case of the vaapisink, it shall query for gst.vaapi.Display
upstream first, and then, if there is no reply,
gst.vaapi.app.Display context will be posted in the bus for the
application. If the application replies, a GstVaapiDisplay object
is instantiated given the context info, otherwise a
GstVaapiDisplay is created with the normal algorithm to guess the
graphics platform. Either way, the instantiated GstVaapiDisplay
is propagated among the pipeline and the have-message bus message.
Also only vaapisink will process the gst.vaapi.app.Display, if
and only if, it doesn't have a display already set. This is
caused because if vaapisink is in a bin (playsink, for example)
the need-context is posted twice, leading to an error state.
https://bugzilla.gnome.org/show_bug.cgi?id=790999
2017-11-29 10:02:03 +00:00
|
|
|
return FALSE;
|
2015-11-04 18:02:34 +00:00
|
|
|
}
|
|
|
|
|
2013-10-01 10:09:44 +00:00
|
|
|
/* 5) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT message
|
|
|
|
on the bus. */
|
2013-05-22 16:07:52 +00:00
|
|
|
void
|
2013-12-21 05:22:30 +00:00
|
|
|
gst_vaapi_video_context_propagate (GstElement * element,
|
|
|
|
GstVaapiDisplay * display)
|
2013-05-22 16:07:52 +00:00
|
|
|
{
|
2013-12-21 05:22:30 +00:00
|
|
|
GstContext *context;
|
|
|
|
GstMessage *msg;
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2013-12-21 05:22:30 +00:00
|
|
|
context = gst_vaapi_video_context_new_with_display (display, FALSE);
|
2015-10-30 11:33:48 +00:00
|
|
|
gst_element_set_context (element, context);
|
2013-05-22 16:07:52 +00:00
|
|
|
|
2015-10-30 10:18:47 +00:00
|
|
|
_init_context_debug ();
|
2013-12-21 05:22:30 +00:00
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
|
2017-12-01 19:21:54 +00:00
|
|
|
"posting `have-context' (%p) message with display %" GST_PTR_FORMAT,
|
2013-12-21 05:22:30 +00:00
|
|
|
context, display);
|
|
|
|
msg = gst_message_new_have_context (GST_OBJECT_CAST (element), context);
|
2015-10-28 11:55:18 +00:00
|
|
|
if (!gst_element_post_message (element, msg))
|
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "No bus attached");
|
2013-05-22 16:07:52 +00:00
|
|
|
}
|
2016-06-02 17:57:08 +00:00
|
|
|
|
2017-10-04 09:52:32 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_find_gl_local_context:
|
|
|
|
* @element: the #GstElement where the search begins
|
|
|
|
* @gl_context_ptr: the pointer where the GstGL context is going to be
|
|
|
|
* stored
|
|
|
|
*
|
|
|
|
* Query the pipeline, downstream and upstream for a GstGL context
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if found; otherwise %FALSE
|
|
|
|
**/
|
2016-06-02 17:57:08 +00:00
|
|
|
gboolean
|
|
|
|
gst_vaapi_find_gl_local_context (GstElement * element,
|
2018-04-26 16:15:47 +00:00
|
|
|
GstObject ** gl_context_ptr)
|
2016-06-02 17:57:08 +00:00
|
|
|
{
|
|
|
|
#if USE_GST_GL_HELPERS
|
2018-04-26 16:15:47 +00:00
|
|
|
GstGLContext **context_ptr = (GstGLContext **) gl_context_ptr;
|
|
|
|
|
|
|
|
if (gst_gl_query_local_gl_context (element, GST_PAD_SRC, context_ptr))
|
|
|
|
return TRUE;
|
|
|
|
if (gst_gl_query_local_gl_context (element, GST_PAD_SINK, context_ptr))
|
2016-06-02 17:57:08 +00:00
|
|
|
return TRUE;
|
|
|
|
#endif
|
|
|
|
return FALSE;
|
|
|
|
}
|