summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2019-07-18 08:46:42 +0300
committerTim-Philipp Müller <tim@centricular.com>2019-08-10 21:21:05 +0100
commit737c87a38aac49c776b3b1f667f1b99b212faa3c (patch)
tree3e54fa6073d6a617605fec80f281f5570da39e07
parent92b29b8fb6422808f6d510818ef2bc21c72c7198 (diff)
downloadgstreamer-plugins-base-737c87a38aac49c776b3b1f667f1b99b212faa3c.tar.gz
audioaggregator: Split getcaps() function into two
One for convert pads and one for normal sink pads.
-rw-r--r--gst-libs/gst/audio/gstaudioaggregator.c108
1 files changed, 64 insertions, 44 deletions
diff --git a/gst-libs/gst/audio/gstaudioaggregator.c b/gst-libs/gst/audio/gstaudioaggregator.c
index 75ce86284..0e6db73a1 100644
--- a/gst-libs/gst/audio/gstaudioaggregator.c
+++ b/gst-libs/gst/audio/gstaudioaggregator.c
@@ -617,57 +617,70 @@ 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 */
-
- 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 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 (filter) {
- GstCaps *tmp = gst_caps_intersect_full (sink_caps, filter,
- GST_CAPS_INTERSECT_FIRST);
-
- gst_caps_unref (sink_caps);
- sink_caps = tmp;
- }
+ 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;
- if (downstream_caps)
- gst_caps_unref (downstream_caps);
+ gst_object_unref (first_configured_pad);
+ }
- GST_INFO_OBJECT (pad, "returned sink caps : %" GST_PTR_FORMAT, sink_caps);
+ /* 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);
- return sink_caps;
+ gst_caps_unref (sink_caps);
+ sink_caps = tmp;
}
- /* Else we have a GstAudioAggregatorConvertPad and convert between all
- * formats except for the sample rate, which has to match.
- */
+ 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;
+}
+
+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
@@ -1127,7 +1140,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;