audioaggregator: If we don't have a GstAudioAggregatorConvertPad, don't assume that we can actually convert

This commit is contained in:
Sebastian Dröge 2019-07-16 10:02:08 +03:00
parent bced52d2e8
commit 7080d216a8

View file

@ -720,6 +720,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);
@ -753,10 +809,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);