compositor: Set blend functions in ::negotiated_caps() instead of ::fixate_caps()
authorSebastian Dröge <sebastian@centricular.com>
Tue, 3 May 2016 08:11:24 +0000 (11:11 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 3 May 2016 13:53:25 +0000 (16:53 +0300)
The latter should not change any state but just fixate the caps, while the
former is always called when srcpads caps are decided.

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

gst/compositor/compositor.c

index 07311b3..100316b 100644 (file)
@@ -954,17 +954,25 @@ _fixate_caps (GstVideoAggregator * vagg, GstCaps * caps)
       best_fps_d);
   ret = gst_caps_fixate (ret);
 
-  if (best_width > 0 && best_height > 0) {
-    GstVideoInfo v_info;
+  return ret;
+}
 
-    gst_video_info_from_caps (&v_info, ret);
-    if (!set_functions (GST_COMPOSITOR (vagg), &v_info)) {
-      GST_ERROR_OBJECT (vagg, "Failed to setup vfuncs");
-      return NULL;
-    }
+static gboolean
+_negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps)
+{
+  GstVideoInfo v_info;
+
+  GST_DEBUG_OBJECT (vagg, "Negotiated caps %" GST_PTR_FORMAT, caps);
+
+  if (!gst_video_info_from_caps (&v_info, caps))
+    return FALSE;
+
+  if (!set_functions (GST_COMPOSITOR (vagg), &v_info)) {
+    GST_ERROR_OBJECT (vagg, "Failed to setup vfuncs");
+    return FALSE;
   }
 
-  return ret;
+  return TRUE;
 }
 
 static GstFlowReturn
@@ -1096,6 +1104,7 @@ gst_compositor_class_init (GstCompositorClass * klass)
   agg_class->sinkpads_type = GST_TYPE_COMPOSITOR_PAD;
   agg_class->sink_query = _sink_query;
   videoaggregator_class->fixate_caps = _fixate_caps;
+  videoaggregator_class->negotiated_caps = _negotiated_caps;
   videoaggregator_class->aggregate_frames = gst_compositor_aggregate_frames;
 
   g_object_class_install_property (gobject_class, PROP_BACKGROUND,