summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-11-29 11:02:03 +0100
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-12-01 23:11:11 +0100
commit8f5933cd80e91e8220403561672ed2e374be4053 (patch)
treec6068cc155479fe6147fffabd6df760bf8654a8a /gst
parent466c8399909fc3999ce8b9276a89d405ccdafafd (diff)
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
Diffstat (limited to 'gst')
-rw-r--r--gst/vaapi/gstvaapipluginbase.c7
-rw-r--r--gst/vaapi/gstvaapivideocontext.c69
-rw-r--r--gst/vaapi/gstvaapivideocontext.h2
3 files changed, 60 insertions, 18 deletions
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c
index e835f69e..afb9a34a 100644
--- a/gst/vaapi/gstvaapipluginbase.c
+++ b/gst/vaapi/gstvaapipluginbase.c
@@ -91,9 +91,12 @@ gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
{
GstVaapiDisplay *display = NULL;
- if (gst_vaapi_video_context_get_display (context, &display))
+ /* gst.vaapi.app.Display is only attended _if_ the element is
+ * vaapisink and it doesn't have a display set yet */
+ if (gst_vaapi_video_context_get_display (context,
+ GST_IS_VIDEO_SINK (plugin) && !plugin->display, &display)) {
plugin_set_display (plugin, display);
-
+ }
#if USE_GST_GL_HELPERS
{
GstGLDisplay *gl_display = NULL;
diff --git a/gst/vaapi/gstvaapivideocontext.c b/gst/vaapi/gstvaapivideocontext.c
index 10961e7b..a556a895 100644
--- a/gst/vaapi/gstvaapivideocontext.c
+++ b/gst/vaapi/gstvaapivideocontext.c
@@ -72,11 +72,12 @@ gst_vaapi_video_context_new_with_display (GstVaapiDisplay * display,
}
gboolean
-gst_vaapi_video_context_get_display (GstContext * context,
+gst_vaapi_video_context_get_display (GstContext * context, gboolean app_context,
GstVaapiDisplay ** display_ptr)
{
const GstStructure *structure;
const gchar *type;
+ GstVaapiDisplay *display = NULL;
g_return_val_if_fail (GST_IS_CONTEXT (context), FALSE);
@@ -86,7 +87,9 @@ gst_vaapi_video_context_get_display (GstContext * context,
structure = gst_context_get_structure (context);
return gst_structure_get (structure, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME,
GST_TYPE_VAAPI_DISPLAY, display_ptr, NULL);
- } else if (!g_strcmp0 (type, GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME)) {
+ }
+
+ if (app_context && !g_strcmp0 (type, GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME)) {
VADisplay va_display = NULL;
structure = gst_context_get_structure (context);
@@ -96,12 +99,22 @@ gst_vaapi_video_context_get_display (GstContext * context,
Display *x11_display = NULL;
if (gst_structure_get (structure, "x11-display", G_TYPE_POINTER,
&x11_display, NULL)) {
- *display_ptr =
+ display =
gst_vaapi_display_x11_new_with_va_display (va_display, x11_display);
- return TRUE;
}
#endif
- GST_WARNING ("Not support if only VADisplay provided");
+
+ _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;
}
}
@@ -211,6 +224,33 @@ found:
gst_query_unref (query);
}
+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");
+ gst_message_unref (msg);
+ }
+
+ return FALSE;
+}
+
gboolean
gst_vaapi_video_context_prepare (GstElement * element,
GstVaapiDisplay ** display_ptr)
@@ -227,22 +267,21 @@ gst_vaapi_video_context_prepare (GstElement * element,
return TRUE;
}
- _gst_context_query (element, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME);
+ 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);
+ }
if (*display_ptr) {
GST_LOG_OBJECT (element, "found a display %" GST_PTR_FORMAT, *display_ptr);
return TRUE;
}
- _gst_context_query (element, GST_VAAPI_DISPLAY_APP_CONTEXT_TYPE_NAME);
-
- if (*display_ptr) {
- GST_LOG_OBJECT (element,
- "got a display with va display from app %" GST_PTR_FORMAT,
- *display_ptr);
- }
-
- return *display_ptr != NULL;
+ return FALSE;
}
/* 5) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT message
diff --git a/gst/vaapi/gstvaapivideocontext.h b/gst/vaapi/gstvaapivideocontext.h
index 3d87754a..cdac0f9b 100644
--- a/gst/vaapi/gstvaapivideocontext.h
+++ b/gst/vaapi/gstvaapivideocontext.h
@@ -44,7 +44,7 @@ gst_vaapi_video_context_new_with_display (GstVaapiDisplay * display,
G_GNUC_INTERNAL
gboolean
-gst_vaapi_video_context_get_display (GstContext * context,
+gst_vaapi_video_context_get_display (GstContext * context, gboolean app_context,
GstVaapiDisplay ** display_ptr);
G_GNUC_INTERNAL