audioaggregator: Split getcaps() function into two

One for convert pads and one for normal sink pads.
This commit is contained in:
Sebastian Dröge 2019-07-18 08:46:42 +03:00
parent 5ebf6c2fac
commit 1ec1123178

View File

@ -724,7 +724,6 @@ gst_audio_aggregator_sink_getcaps (GstPad * pad, GstAggregator * agg,
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 */
@ -770,11 +769,25 @@ gst_audio_aggregator_sink_getcaps (GstPad * pad, GstAggregator * agg,
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.
*/
static GstCaps *
gst_audio_aggregator_convert_sink_getcaps (GstPad * pad, GstAggregator * agg,
GstCaps * filter)
{
GstAudioAggregatorPad *first_configured_pad =
gst_audio_aggregator_get_first_configured_pad (agg);
GstCaps *sink_template_caps = gst_pad_get_pad_template_caps (pad);
GstCaps *downstream_caps = gst_pad_get_allowed_caps (agg->srcpad);
GstCaps *sink_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);
/* We can convert between all formats except for the sample rate, which has
* to match. */
/* If we have a first configured pad, we can only convert everything except
* for the sample rate, so modify our template caps to have exactly that
@ -1237,7 +1250,14 @@ gst_audio_aggregator_sink_query (GstAggregator * agg, GstAggregatorPad * aggpad,
GstCaps *filter, *caps;
gst_query_parse_caps (query, &filter);
caps = gst_audio_aggregator_sink_getcaps (GST_PAD (aggpad), agg, filter);
if (GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD (aggpad)) {
caps =
gst_audio_aggregator_convert_sink_getcaps (GST_PAD (aggpad), agg,
filter);
} else {
caps =
gst_audio_aggregator_sink_getcaps (GST_PAD (aggpad), agg, filter);
}
gst_query_set_caps_result (query, caps);
gst_caps_unref (caps);
res = TRUE;