videomixer: filter caps returned from downstream with our pad template.
authorEdward Hervey <bilboed@bilboed.com>
Tue, 1 Jun 2010 18:45:29 +0000 (20:45 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Tue, 1 Jun 2010 18:45:29 +0000 (20:45 +0200)
gst/videomixer/videomixer.c

index 6725cdf..63e84a3 100644 (file)
@@ -380,6 +380,7 @@ gst_videomixer_pad_sink_getcaps (GstPad * pad)
   GstVideoMixer *mix;
   GstVideoMixerPad *mixpad;
   GstCaps *res = NULL;
+  GstCaps *tmp;
   int ncaps, i;
   GstStructure *st;
 
@@ -389,13 +390,18 @@ gst_videomixer_pad_sink_getcaps (GstPad * pad)
   if (!mixpad)
     goto beach;
 
-  res = gst_pad_peer_get_caps (mix->srcpad);
-  if (G_UNLIKELY (res == NULL)) {
+  tmp = gst_pad_peer_get_caps (mix->srcpad);
+  if (G_UNLIKELY (tmp == NULL)) {
     /* If no peer, then return template */
     res = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
     goto beach;
   }
 
+  /* Intersect with template caps, downstream might be returning formats
+   * or width/height/framerate/par combinations we don't handle */
+  res = gst_caps_intersect (tmp, gst_pad_get_pad_template_caps (pad));
+  gst_caps_unref (tmp);
+
   ncaps = gst_caps_get_size (res);
 
   /* This Upstream can only produce:
@@ -418,13 +424,6 @@ gst_videomixer_pad_sink_getcaps (GstPad * pad)
           G_MAXINT32, 1, "pixel-aspect-ratio", GST_TYPE_FRACTION, mix->par_n,
           mix->par_d, NULL);
     }
-  } else {
-    GstCaps *tmp;
-    /* If we don't have configured values, just intersect with our
-     * pad template */
-    tmp = res;
-    res = gst_caps_intersect (res, gst_pad_get_pad_template_caps (pad));
-    gst_caps_unref (tmp);
   }
   GST_VIDEO_MIXER_STATE_UNLOCK (mix);