From ab61233f30e5a2c7e923180333bd1449b8c82023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 14 Jun 2024 16:20:31 +0100 Subject: [PATCH] rtpdtmfdepay: fix caps negotiation with audioconvert Specify "layout" field in src template to make sure it's set and gets fixated properly if the downstream element supports both interleaved and non-interleaved caps. Fixes gst_pad_set_caps: assertion 'caps != NULL && gst_caps_is_fixed (caps)' failed critical with e.g. gst-launch-1.0 rtpdtmfsrc ! rtpdtmfdepay ! audioconvert ! fakesink Not that the layout really matters in our case since we always output mono anyway, but non-interleaved requires adding AudioMeta, so this is the easiest fix. Part-of: --- .../gst-plugins-good/docs/gst_plugins_cache.json | 2 +- .../gst-plugins-good/gst/dtmf/gstrtpdtmfdepay.c | 10 +++++++--- .../gst-plugins-good/tests/check/elements/dtmf.c | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-good/docs/gst_plugins_cache.json b/subprojects/gst-plugins-good/docs/gst_plugins_cache.json index e295e94229..55c8998702 100644 --- a/subprojects/gst-plugins-good/docs/gst_plugins_cache.json +++ b/subprojects/gst-plugins-good/docs/gst_plugins_cache.json @@ -5444,7 +5444,7 @@ "presence": "always" }, "src": { - "caps": "audio/x-raw:\n format: S16LE\n rate: [ 1, 2147483647 ]\n channels: 1\n", + "caps": "audio/x-raw:\n format: S16LE\n rate: [ 1, 2147483647 ]\n channels: 1\n layout: interleaved\n", "direction": "src", "presence": "always" } diff --git a/subprojects/gst-plugins-good/gst/dtmf/gstrtpdtmfdepay.c b/subprojects/gst-plugins-good/gst/dtmf/gstrtpdtmfdepay.c index b0e39473d7..16dd455b4a 100644 --- a/subprojects/gst-plugins-good/gst/dtmf/gstrtpdtmfdepay.c +++ b/subprojects/gst-plugins-good/gst/dtmf/gstrtpdtmfdepay.c @@ -138,9 +138,11 @@ static GstStaticPadTemplate gst_rtp_dtmf_depay_src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw, " - "format = (string) \"" GST_AUDIO_NE (S16) "\", " - "rate = " GST_AUDIO_RATE_RANGE ", " "channels = (int) 1") + GST_STATIC_CAPS ("audio/x-raw, " // + "format = (string) " GST_AUDIO_NE (S16) ", " // + "rate = " GST_AUDIO_RATE_RANGE ", " // + "channels = (int) 1, " // + "layout = (string) interleaved") ); static GstStaticPadTemplate gst_rtp_dtmf_depay_sink_template = @@ -283,6 +285,8 @@ gst_rtp_dtmf_depay_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps) filtercaps); gst_caps_unref (filtercaps); + srccaps = gst_caps_truncate (srccaps); + gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (filter), srccaps); gst_caps_unref (srccaps); diff --git a/subprojects/gst-plugins-good/tests/check/elements/dtmf.c b/subprojects/gst-plugins-good/tests/check/elements/dtmf.c index c57a48c9dc..45f098454b 100644 --- a/subprojects/gst-plugins-good/tests/check/elements/dtmf.c +++ b/subprojects/gst-plugins-good/tests/check/elements/dtmf.c @@ -178,7 +178,8 @@ GST_START_TEST (test_rtpdtmfdepay) caps_out = gst_pad_get_current_caps (sink); expected_caps_out = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, GST_AUDIO_NE (S16), - "rate", G_TYPE_INT, 1000, "channels", G_TYPE_INT, 1, NULL); + "rate", G_TYPE_INT, 1000, "channels", G_TYPE_INT, 1, + "layout", G_TYPE_STRING, "interleaved", NULL); fail_unless (gst_caps_is_equal_fixed (caps_out, expected_caps_out)); gst_caps_unref (expected_caps_out); gst_caps_unref (caps_out);