vaapipostproc: return caps template if no display
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Wed, 29 Jun 2016 11:57:02 +0000 (13:57 +0200)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Wed, 29 Jun 2016 12:05:18 +0000 (14:05 +0200)
This patch is a fix for my bad review of commit 6d73ca8d. The element should
be able to return the available raw caps handled by the VA display, but that
only should happen when there a VA display. If there's none, the element
should use the caps template.

https://bugzilla.gnome.org/show_bug.cgi?id=768161

gst/vaapi/gstvaapipostproc.c

index 2a2f521..43e6582 100644 (file)
@@ -911,31 +911,27 @@ ensure_allowed_sinkpad_caps (GstVaapiPostproc * postproc)
   if (postproc->allowed_sinkpad_caps)
     return TRUE;
 
+  if (!GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc))
+    return FALSE;
+
   /* Create VA caps */
   out_caps = gst_caps_from_string (GST_VAAPI_MAKE_SURFACE_CAPS ", "
       GST_CAPS_INTERLACED_MODES);
   if (!out_caps) {
-    GST_ERROR_OBJECT (postproc, "failed to create VA sink caps");
+    GST_WARNING_OBJECT (postproc, "failed to create VA sink caps");
     return FALSE;
   }
 
-  /* Append raw video caps */
-  if (GST_VAAPI_PLUGIN_BASE (postproc)->display) {
-    raw_caps =
-        gst_vaapi_plugin_base_get_allowed_raw_caps (GST_VAAPI_PLUGIN_BASE
-        (postproc));
-  } else {
-    raw_caps =
-        gst_caps_from_string (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
-        GST_CAPS_INTERLACED_MODES);
-  }
-
-  if (raw_caps) {
-    out_caps = gst_caps_make_writable (out_caps);
-    gst_caps_append (out_caps, gst_caps_copy (raw_caps));
-  } else {
+  raw_caps = gst_vaapi_plugin_base_get_allowed_raw_caps
+      (GST_VAAPI_PLUGIN_BASE (postproc));
+  if (!raw_caps) {
+    gst_caps_unref (out_caps);
     GST_WARNING_OBJECT (postproc, "failed to create YUV sink caps");
+    return FALSE;
   }
+
+  out_caps = gst_caps_make_writable (out_caps);
+  gst_caps_append (out_caps, gst_caps_copy (raw_caps));
   postproc->allowed_sinkpad_caps = out_caps;
 
   /* XXX: append VA/VPP filters */
@@ -1011,7 +1007,7 @@ gst_vaapipostproc_transform_caps_impl (GstBaseTransform * trans,
   /* Generate the sink pad caps, that could be fixated afterwards */
   if (direction == GST_PAD_SRC) {
     if (!ensure_allowed_sinkpad_caps (postproc))
-      return NULL;
+      return gst_caps_from_string (gst_vaapipostproc_sink_caps_str);
     return gst_caps_ref (postproc->allowed_sinkpad_caps);
   }