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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7036>
This commit is contained in:
Tim-Philipp Müller 2024-06-14 16:20:31 +01:00
parent e5d2dd8e8d
commit ab61233f30
3 changed files with 10 additions and 5 deletions

View file

@ -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"
}

View file

@ -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);

View file

@ -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);