gst/adder/gstadder.c: Make getcaps more robust by not using the proxycaps function...
authorWim Taymans <wim.taymans@gmail.com>
Tue, 3 Jul 2007 11:52:47 +0000 (11:52 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 3 Jul 2007 11:52:47 +0000 (11:52 +0000)
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_sink_getcaps),
(gst_adder_request_new_pad):
Make getcaps more robust by not using the proxycaps function. This makes
sure that we don't end up recursively calling getcaps upstream.
See #316248.

ChangeLog
common
gst/adder/gstadder.c

index 325b001..90797c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,12 @@
-2007-06-29  Wim Taymans,,,  <set EMAIL_ADDRESS environment variable>
+2007-07-03  Wim Taymans  <wim.taymans@gmail.com>
+
+       * gst/adder/gstadder.c: (gst_adder_sink_getcaps),
+       (gst_adder_request_new_pad):
+       Make getcaps more robust by not using the proxycaps function. This makes
+       sure that we don't end up recursively calling getcaps upstream.
+       See #316248.
+
+2007-06-29  Wim Taymans  <wim.taymans@gmail.com>
 
        * gst/audioconvert/audioconvert.c:
        Include math.h to fix compilation.
diff --git a/common b/common
index e6a9941..5167bce 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit e6a9941c662289c0743e5d8f4150458a664226f2
+Subproject commit 5167bced491ffe62251c62d6c5e7b9a7541e97e5
index 23ced05..1b6c7c7 100644 (file)
@@ -161,6 +161,41 @@ MAKE_FUNC_NC (add_float64, gdouble, gdouble)
 MAKE_FUNC_NC (add_float32, gfloat, gfloat)
 /* *INDENT-ON* */
 
+/* we can only accept caps that we and downstream can handle. */
+static GstCaps *
+gst_adder_sink_getcaps (GstPad * pad)
+{
+  GstAdder *adder;
+  GstCaps *result, *peercaps, *sinkcaps;
+
+  adder = GST_ADDER (GST_PAD_PARENT (pad));
+
+  GST_OBJECT_LOCK (adder);
+  /* get the downstream possible caps */
+  peercaps = gst_pad_peer_get_caps (adder->srcpad);
+  /* get the allowed caps on this sinkpad, we use the fixed caps function so
+   * that it does not call recursively in this function. */
+  sinkcaps = gst_pad_get_fixed_caps_func (pad);
+  if (peercaps) {
+    /* if the peer has caps, intersect */
+    GST_DEBUG_OBJECT (adder, "intersecting peer and template caps");
+    result = gst_caps_intersect (peercaps, sinkcaps);
+    gst_caps_unref (peercaps);
+    gst_caps_unref (sinkcaps);
+  } else {
+    /* the peer has no caps (or there is no peer), just use the allowed caps
+     * of this sinkpad. */
+    GST_DEBUG_OBJECT (adder, "no peer caps, using sinkcaps");
+    result = sinkcaps;
+  }
+  GST_OBJECT_UNLOCK (adder);
+
+  return result;
+}
+
+/* the first caps we receive on any of the sinkpads will define the caps for all
+ * the other sinkpads because we can only mix streams with the same caps.
+ * */
 static gboolean
 gst_adder_setcaps (GstPad * pad, GstCaps * caps)
 {
@@ -603,7 +638,7 @@ gst_adder_request_new_pad (GstElement * element, GstPadTemplate * templ,
   g_free (name);
 
   gst_pad_set_getcaps_function (newpad,
-      GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+      GST_DEBUG_FUNCPTR (gst_adder_sink_getcaps));
   gst_pad_set_setcaps_function (newpad, GST_DEBUG_FUNCPTR (gst_adder_setcaps));
   gst_collect_pads_add_pad (adder->collect, newpad, sizeof (GstCollectData));