From 825c1cd47af72aaa6e762e92237ebd6ec77f3651 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 16 Jul 2019 10:02:08 +0300 Subject: [PATCH] audioaggregator: If we don't have a GstAudioAggregatorConvertPad, don't assume that we can actually convert --- gst-libs/gst/audio/gstaudioaggregator.c | 60 ++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/audio/gstaudioaggregator.c b/gst-libs/gst/audio/gstaudioaggregator.c index 013e41f..062d8c2 100644 --- a/gst-libs/gst/audio/gstaudioaggregator.c +++ b/gst-libs/gst/audio/gstaudioaggregator.c @@ -613,6 +613,62 @@ gst_audio_aggregator_sink_getcaps (GstPad * pad, GstAggregator * agg, GstCaps *sink_caps; GstStructure *s, *s2; + GST_INFO_OBJECT (pad, "Getting caps with filter %" GST_PTR_FORMAT, filter); + GST_DEBUG_OBJECT (pad, "sink template caps : %" GST_PTR_FORMAT, + sink_template_caps); + GST_DEBUG_OBJECT (pad, "downstream caps %" GST_PTR_FORMAT, downstream_caps); + + if (!GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD (pad)) { + /* If we already have a configured pad, assume that we can only configure + * to the very same format filtered with the template caps and continue + * with the result of that as the template caps */ + + if (first_configured_pad) { + GstCaps *first_configured_caps = + gst_audio_info_to_caps (&first_configured_pad->info); + GstCaps *tmp; + + tmp = + gst_caps_intersect_full (sink_template_caps, first_configured_caps, + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (first_configured_caps); + gst_caps_unref (sink_template_caps); + sink_template_caps = tmp; + + gst_object_unref (first_configured_pad); + } + + /* If we have downstream caps, filter them against our template caps or + * the filtered first configured pad caps from above */ + if (downstream_caps) { + sink_caps = + gst_caps_intersect_full (sink_template_caps, downstream_caps, + GST_CAPS_INTERSECT_FIRST); + } else { + sink_caps = gst_caps_ref (sink_template_caps); + } + + if (filter) { + GstCaps *tmp = gst_caps_intersect_full (sink_caps, filter, + GST_CAPS_INTERSECT_FIRST); + + gst_caps_unref (sink_caps); + sink_caps = tmp; + } + + gst_caps_unref (sink_template_caps); + + if (downstream_caps) + gst_caps_unref (downstream_caps); + + GST_INFO_OBJECT (pad, "returned sink caps : %" GST_PTR_FORMAT, sink_caps); + + return sink_caps; + } + + /* Else we have a GstAudioAggregatorConvertPad and convert between all + * formats except for the sample rate, which has to match */ + sink_template_caps = gst_caps_make_writable (sink_template_caps); s = gst_caps_get_structure (sink_template_caps, 0); @@ -646,10 +702,6 @@ gst_audio_aggregator_sink_getcaps (GstPad * pad, GstAggregator * agg, sink_caps = filter ? gst_caps_intersect (sink_template_caps, filter) : gst_caps_ref (sink_template_caps); - GST_INFO_OBJECT (pad, "Getting caps with filter %" GST_PTR_FORMAT, filter); - GST_DEBUG_OBJECT (pad, "sink template caps : %" GST_PTR_FORMAT, - sink_template_caps); - GST_DEBUG_OBJECT (pad, "downstream caps %" GST_PTR_FORMAT, downstream_caps); GST_INFO_OBJECT (pad, "returned sink caps : %" GST_PTR_FORMAT, sink_caps); gst_caps_unref (sink_template_caps); -- 2.7.4