From d42ca1fd8325fc9c789837628f197109170fba88 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 3 Jul 2007 11:52:47 +0000 Subject: [PATCH] gst/adder/gstadder.c: Make getcaps more robust by not using the proxycaps function. This makes sure that we don't end... 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 | 10 +++++++++- common | 2 +- gst/adder/gstadder.c | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 325b001..90797c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ -2007-06-29 Wim Taymans,,, +2007-07-03 Wim Taymans + + * 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 * gst/audioconvert/audioconvert.c: Include math.h to fix compilation. diff --git a/common b/common index e6a9941..5167bce 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit e6a9941c662289c0743e5d8f4150458a664226f2 +Subproject commit 5167bced491ffe62251c62d6c5e7b9a7541e97e5 diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c index 23ced05..1b6c7c7 100644 --- a/gst/adder/gstadder.c +++ b/gst/adder/gstadder.c @@ -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)); -- 2.7.4