plugins: handle GL params through context query

If the element instantiated the GL display and context, they should
handle them too through the context query.

https://bugzilla.gnome.org/show_bug.cgi?id=777409
This commit is contained in:
Víctor Manuel Jáquez Leal 2017-01-27 12:10:54 +01:00
parent 0968ce468d
commit c9bd45f05d
6 changed files with 29 additions and 21 deletions

View file

@ -1197,12 +1197,11 @@ static gboolean
gst_vaapidecode_sink_query (GstVideoDecoder * vdec, GstQuery * query)
{
gboolean ret = TRUE;
GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec);
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (decode);
GstElement *const element = GST_ELEMENT (vdec);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:{
ret = gst_vaapi_handle_context_query (query, plugin->display);
ret = gst_vaapi_handle_context_query (element, query);
break;
}
default:{
@ -1218,8 +1217,7 @@ static gboolean
gst_vaapidecode_src_query (GstVideoDecoder * vdec, GstQuery * query)
{
gboolean ret = TRUE;
GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec);
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (decode);
GstElement *const element = GST_ELEMENT (vdec);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CAPS:{
@ -1240,7 +1238,7 @@ gst_vaapidecode_src_query (GstVideoDecoder * vdec, GstQuery * query)
break;
}
case GST_QUERY_CONTEXT:{
ret = gst_vaapi_handle_context_query (query, plugin->display);
ret = gst_vaapi_handle_context_query (element, query);
break;
}
default:{

View file

@ -63,11 +63,11 @@ static gboolean
gst_vaapiencode_sink_query (GstVideoEncoder * encoder, GstQuery * query)
{
gboolean ret = TRUE;
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (encoder);
GstElement *const element = GST_ELEMENT (encoder);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
ret = gst_vaapi_handle_context_query (query, plugin->display);
ret = gst_vaapi_handle_context_query (element, query);
break;
default:
ret = GST_VIDEO_ENCODER_CLASS (gst_vaapiencode_parent_class)->sink_query
@ -82,11 +82,11 @@ static gboolean
gst_vaapiencode_src_query (GstVideoEncoder * encoder, GstQuery * query)
{
gboolean ret = TRUE;
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (encoder);
GstElement *const element = GST_ELEMENT (encoder);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
ret = gst_vaapi_handle_context_query (query, plugin->display);
ret = gst_vaapi_handle_context_query (element, query);
break;
default:
ret = GST_VIDEO_ENCODER_CLASS (gst_vaapiencode_parent_class)->src_query

View file

@ -297,14 +297,25 @@ gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type)
}
gboolean
gst_vaapi_handle_context_query (GstQuery * query, GstVaapiDisplay * display)
gst_vaapi_handle_context_query (GstElement * element, GstQuery * query)
{
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
const gchar *type = NULL;
GstContext *context, *old_context;
g_return_val_if_fail (query != NULL, FALSE);
if (!display)
#if USE_GST_GL_HELPERS
if (plugin->gl_display && plugin->gl_context && plugin->gl_other_context) {
if (gst_gl_handle_context_query (element, query,
(GstGLDisplay *) plugin->gl_display,
(GstGLContext *) plugin->gl_context,
(GstGLContext *) plugin->gl_other_context))
return TRUE;
}
#endif
if (!plugin->display)
return FALSE;
if (!gst_query_parse_context_type (query, &type))
@ -316,9 +327,9 @@ gst_vaapi_handle_context_query (GstQuery * query, GstVaapiDisplay * display)
gst_query_parse_context (query, &old_context);
if (old_context) {
context = gst_context_copy (old_context);
gst_vaapi_video_context_set_display (context, display);
gst_vaapi_video_context_set_display (context, plugin->display);
} else {
context = gst_vaapi_video_context_new_with_display (display, FALSE);
context = gst_vaapi_video_context_new_with_display (plugin->display, FALSE);
}
gst_query_set_context (query, context);

View file

@ -35,7 +35,7 @@ gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type);
G_GNUC_INTERNAL
gboolean
gst_vaapi_handle_context_query (GstQuery * query, GstVaapiDisplay * display);
gst_vaapi_handle_context_query (GstElement * element, GstQuery * query);
G_GNUC_INTERNAL
gboolean

View file

@ -1334,11 +1334,11 @@ gst_vaapipostproc_query (GstBaseTransform * trans,
GstPadDirection direction, GstQuery * query)
{
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
GstElement *const element = GST_ELEMENT (trans);
if (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT) {
if (gst_vaapi_handle_context_query (query,
GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc))) {
GST_DEBUG_OBJECT (postproc, "sharing display %p",
if (gst_vaapi_handle_context_query (element, query)) {
GST_DEBUG_OBJECT (postproc, "sharing display %" GST_PTR_FORMAT,
GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc));
return TRUE;
}

View file

@ -1520,13 +1520,12 @@ gst_vaapisink_propose_allocation (GstBaseSink * base_sink, GstQuery * query)
static gboolean
gst_vaapisink_query (GstBaseSink * base_sink, GstQuery * query)
{
GstVaapiSink *const sink = GST_VAAPISINK_CAST (base_sink);
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (sink);
GstElement *const element = GST_ELEMENT (base_sink);
gboolean ret = FALSE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
ret = gst_vaapi_handle_context_query (query, plugin->display);
ret = gst_vaapi_handle_context_query (element, query);
break;
default:
ret = GST_BASE_SINK_CLASS (gst_vaapisink_parent_class)->query (base_sink,