plugins: fix context query handling
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Wed, 4 Nov 2015 20:38:42 +0000 (21:38 +0100)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Mon, 9 Nov 2015 15:18:19 +0000 (16:18 +0100)
The current context query handling design is flawed: the function
gst_vaapi_reply_to_query() returns FALSE either if the query is not a
GST_CONTEXT_QUERY of if the query could not be handled correctly. But the
pad query function should handle differently each case.

This patch changes the gst_vaapi_reply_to_query() for
gst_vaapi_handle_context_query() and changes it usage in all the vaapi plugins
to match the correct context query handling.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
https://bugzilla.gnome.org/show_bug.cgi?id=757598

gst/vaapi/gstvaapidecode.c
gst/vaapi/gstvaapiencode.c
gst/vaapi/gstvaapipluginutil.c
gst/vaapi/gstvaapipluginutil.h
gst/vaapi/gstvaapipostproc.c
gst/vaapi/gstvaapisink.c

index 6be9eb1..7bec7b8 100644 (file)
@@ -1057,11 +1057,6 @@ gst_vaapidecode_sink_query (GstVideoDecoder * vdec, GstQuery * query)
   GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec);
   GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (decode);
 
-  if (gst_vaapi_reply_to_query (query, plugin->display)) {
-    GST_DEBUG_OBJECT (decode, "sharing display %p", plugin->display);
-    return TRUE;
-  }
-
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_CAPS:{
       GstCaps *caps, *filter = NULL;
@@ -1080,6 +1075,10 @@ gst_vaapidecode_sink_query (GstVideoDecoder * vdec, GstQuery * query)
       gst_caps_unref (caps);
       break;
     }
+    case GST_QUERY_CONTEXT:{
+      ret = gst_vaapi_handle_context_query (query, plugin->display);
+      break;
+    }
     default:{
 #if GST_CHECK_VERSION(1,4,0)
       ret = GST_VIDEO_DECODER_CLASS (gst_vaapidecode_parent_class)->sink_query
@@ -1105,11 +1104,6 @@ gst_vaapidecode_src_query (GstVideoDecoder * vdec, GstQuery * query)
   GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec);
   GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (decode);
 
-  if (gst_vaapi_reply_to_query (query, plugin->display)) {
-    GST_DEBUG_OBJECT (decode, "sharing display %p", plugin->display);
-    return TRUE;
-  }
-
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_CAPS:{
       GstCaps *caps, *filter = NULL;
@@ -1128,6 +1122,10 @@ gst_vaapidecode_src_query (GstVideoDecoder * vdec, GstQuery * query)
       gst_caps_unref (caps);
       break;
     }
+    case GST_QUERY_CONTEXT:{
+      ret = gst_vaapi_handle_context_query (query, plugin->display);
+      break;
+    }
     default:{
 #if GST_CHECK_VERSION(1,4,0)
       ret = GST_VIDEO_DECODER_CLASS (gst_vaapidecode_parent_class)->src_query
index 88c5549..1415441 100644 (file)
@@ -66,8 +66,8 @@ gst_vaapiencode_query (GstPad * pad, GstObject * parent, GstQuery * query)
 
   GST_INFO_OBJECT (plugin, "query type %s", GST_QUERY_TYPE_NAME (query));
 
-  if (gst_vaapi_reply_to_query (query, plugin->display))
-    success = TRUE;
+  if (GST_QUERY_TYPE (query) == GST_QUERY_CONTEXT)
+    success = gst_vaapi_handle_context_query (query, plugin->display);
   else if (GST_PAD_IS_SINK (pad))
     success = plugin->sinkpad_query (plugin->sinkpad, parent, query);
   else
index 00babbe..74f311b 100644 (file)
@@ -255,13 +255,12 @@ gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type)
 }
 
 gboolean
-gst_vaapi_reply_to_query (GstQuery * query, GstVaapiDisplay * display)
+gst_vaapi_handle_context_query (GstQuery * query, GstVaapiDisplay * display)
 {
   const gchar *type = NULL;
   GstContext *context, *old_context;
 
-  if (GST_QUERY_TYPE (query) != GST_QUERY_CONTEXT)
-    return FALSE;
+  g_return_val_if_fail (query != NULL, FALSE);
 
   if (!display)
     return FALSE;
index 4ca8225..d46f2db 100644 (file)
@@ -35,7 +35,7 @@ gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type);
 
 G_GNUC_INTERNAL
 gboolean
-gst_vaapi_reply_to_query (GstQuery * query, GstVaapiDisplay * display);
+gst_vaapi_handle_context_query (GstQuery * query, GstVaapiDisplay * display);
 
 G_GNUC_INTERNAL
 gboolean
index fc8c7cb..38fa9b5 100644 (file)
@@ -1286,11 +1286,13 @@ gst_vaapipostproc_query (GstBaseTransform * trans, GstPadDirection direction,
 {
   GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
 
-  if (gst_vaapi_reply_to_query (query,
-          GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc))) {
-    GST_DEBUG_OBJECT (postproc, "sharing display %p",
-        GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc));
-    return TRUE;
+  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",
+          GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc));
+      return TRUE;
+    }
   }
 
   return
index b148cac..7ff8401 100644 (file)
@@ -1447,15 +1447,20 @@ 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);
+  gboolean ret = FALSE;
 
-  GST_INFO_OBJECT (sink, "query type %s", GST_QUERY_TYPE_NAME (query));
-
-  if (gst_vaapi_reply_to_query (query, GST_VAAPI_PLUGIN_BASE_DISPLAY (sink))) {
-    GST_DEBUG ("sharing display %p", GST_VAAPI_PLUGIN_BASE_DISPLAY (sink));
-    return TRUE;
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_CONTEXT:
+      ret = gst_vaapi_handle_context_query (query, plugin->display);
+      break;
+    default:
+      ret = GST_BASE_SINK_CLASS (gst_vaapisink_parent_class)->query (base_sink,
+          query);
+      break;
   }
-  return GST_BASE_SINK_CLASS (gst_vaapisink_parent_class)->query (base_sink,
-      query);
+
+  return ret;
 }
 
 static void