vaapisink: return caps template if no display
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Wed, 15 Jun 2016 18:19:27 +0000 (20:19 +0200)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Thu, 16 Jun 2016 11:18:15 +0000 (13:18 +0200)
If vaapisink received a caps query before getting a VA display, it returned
only the surfaces related caps. This behavior broke the autovideosink
negotiation.

This patch returns the pad's template caps if no VA display, otherwise the
caps are crafted as before.

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

gst/vaapi/gstvaapisink.c

index ea825cb..472b873 100644 (file)
@@ -1215,34 +1215,31 @@ static GstCaps *
 gst_vaapisink_get_caps_impl (GstBaseSink * base_sink)
 {
   GstVaapiSink *const sink = GST_VAAPISINK_CAST (base_sink);
-  GstCaps *out_caps, *raw_caps;
+  GstCaps *out_caps, *raw_caps, *feature_caps;
   static const char surface_caps_str[] =
       GST_VAAPI_MAKE_SURFACE_CAPS ";"
       GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE
       "," GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION,
       "{ ENCODED, NV12, I420, YV12 }");
+  GstCapsFeatures *const features = gst_caps_features_new
+      (GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, NULL);
 
-  out_caps = gst_caps_from_string (surface_caps_str);
+  if (!GST_VAAPI_PLUGIN_BASE_DISPLAY (sink))
+    return gst_static_pad_template_get_caps (&gst_vaapisink_sink_factory);
 
-  if (GST_VAAPI_PLUGIN_BASE_DISPLAY (sink)) {
-    raw_caps =
-        gst_vaapi_plugin_base_get_allowed_raw_caps (GST_VAAPI_PLUGIN_BASE
-        (sink));
-    if (raw_caps) {
-      GstCaps *feature_caps;
-      GstCapsFeatures *const features =
-          gst_caps_features_new
-          (GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, NULL);
+  out_caps = gst_caps_from_string (surface_caps_str);
+  raw_caps =
+      gst_vaapi_plugin_base_get_allowed_raw_caps (GST_VAAPI_PLUGIN_BASE (sink));
+  if (!raw_caps)
+    return out_caps;
 
-      out_caps = gst_caps_make_writable (out_caps);
+  out_caps = gst_caps_make_writable (out_caps);
+  gst_caps_append (out_caps, gst_caps_copy (raw_caps));
 
-      gst_caps_append (out_caps, gst_caps_copy (raw_caps));
+  feature_caps = gst_caps_copy (raw_caps);
+  gst_caps_set_features (feature_caps, 0, features);
+  gst_caps_append (out_caps, feature_caps);
 
-      feature_caps = gst_caps_copy (raw_caps);
-      gst_caps_set_features (feature_caps, 0, features);
-      gst_caps_append (out_caps, feature_caps);
-    }
-  }
   return out_caps;
 }