summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2020-07-27 18:49:48 +0300
committerTim-Philipp Müller <tim@centricular.com>2020-09-27 01:13:43 +0100
commita0e7af975951127539a65b665a04c5875d64f15d (patch)
tree422c0fccc1e74f849d4cdc4f3ce8901bf73ec4f9
parenta6c947da38ae1b6429dd733b9e493c907318cfa7 (diff)
downloadgstreamer-plugins-base-a0e7af975951127539a65b665a04c5875d64f15d.tar.gz
audioaggregator: Check all downstream allowed caps structures if they support the upstream rate
Otherwise it might happen that downstream prefers a different rate (i.e. puts it into the first structure) and also supports other rates, but audioaggregator would then fail negotiation. Also this now correctly handles downstream returning a range of supported rates. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/795 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/834>
-rw-r--r--gst-libs/gst/audio/gstaudioaggregator.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gst-libs/gst/audio/gstaudioaggregator.c b/gst-libs/gst/audio/gstaudioaggregator.c
index 16e76b649..4341e3490 100644
--- a/gst-libs/gst/audio/gstaudioaggregator.c
+++ b/gst-libs/gst/audio/gstaudioaggregator.c
@@ -756,10 +756,10 @@ gst_audio_aggregator_sink_setcaps (GstAudioAggregatorPad * aaggpad,
GstAudioAggregatorPad *first_configured_pad =
gst_audio_aggregator_get_first_configured_pad (agg);
GstCaps *downstream_caps = gst_pad_get_allowed_caps (agg->srcpad);
+ GstCaps *rate_caps;
GstAudioInfo info;
gboolean ret = TRUE;
- gint downstream_rate;
- GstStructure *s;
+ gboolean downstream_supports_rate;
/* Returns NULL if there is no downstream peer */
if (!downstream_caps)
@@ -774,14 +774,18 @@ gst_audio_aggregator_sink_setcaps (GstAudioAggregatorPad * aaggpad,
GST_WARNING_OBJECT (agg, "Rejecting invalid caps: %" GST_PTR_FORMAT, caps);
return FALSE;
}
- s = gst_caps_get_structure (downstream_caps, 0);
/* TODO: handle different rates on sinkpads, a bit complex
* because offsets will have to be updated, and audio resampling
* has a latency to take into account
*/
- if ((gst_structure_get_int (s, "rate", &downstream_rate)
- && info.rate != downstream_rate) || (first_configured_pad
+ rate_caps =
+ gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, info.rate, NULL);
+ downstream_supports_rate =
+ gst_caps_can_intersect (rate_caps, downstream_caps);
+ gst_caps_unref (rate_caps);
+
+ if (!downstream_supports_rate || (first_configured_pad
&& info.rate != first_configured_pad->info.rate)) {
gst_pad_push_event (GST_PAD (aaggpad), gst_event_new_reconfigure ());
ret = FALSE;