From d4eab96dfdd53468c4ff94b8b8ad88619bad8f4d Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 29 Nov 2022 09:11:46 -0500 Subject: [PATCH] MT#55283 fix `single-codec` with odd codec order Usually supplemental RTP types (DTMF) are listed after the primary audio codecs. In the case of the order being reversed, fix `single-codec` so that it doesn't strip the actual audio codec that is listed after the DTMF type. Change-Id: I1b03b89e31bebf4de303b643dcf08d2ffb90ebaf --- daemon/codec.c | 15 +++++++---- t/auto-daemon-tests.pl | 59 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 0efe4869d..9dc6fd691 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -4744,6 +4744,11 @@ void codec_store_answer(struct codec_store *dst, struct codec_store *src, struct struct rtp_payload_type *pt = l->data; struct codec_handler *h = codec_handler_get(src_media, pt->payload_type, dst_media, NULL); + + bool is_supp = false; + if (pt->codec_def && pt->codec_def->supplemental) + is_supp = true; + if (!h || h->dest_pt.payload_type == -1) { // passthrough or missing if (pt->for_transcoding) @@ -4757,8 +4762,9 @@ void codec_store_answer(struct codec_store *dst, struct codec_store *src, struct " (%i) is passthrough", STR_FMT(&pt->encoding_with_params), pt->payload_type); + if (!is_supp) + num_codecs++; codec_store_add_end(dst, pt); - num_codecs++; } else ilogs(codec, LOG_DEBUG, "Skipping passthrough codec " STR_FORMAT @@ -4770,9 +4776,7 @@ void codec_store_answer(struct codec_store *dst, struct codec_store *src, struct } // supp codecs are handled in-line with their main media codecs - bool is_supp = false; - if (pt->codec_def && pt->codec_def->supplemental) { - is_supp = true; + if (is_supp) { if (pt->for_transcoding) continue; if (is_codec_touched(dst, pt)) @@ -4804,7 +4808,8 @@ void codec_store_answer(struct codec_store *dst, struct codec_store *src, struct codec_store_add_end(dst, pt); else codec_store_add_end(dst, &h->dest_pt); - num_codecs++; + if (!is_supp) + num_codecs++; } // handle associated supplemental codecs diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index db4480923..cff468bb3 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -6329,6 +6329,65 @@ SDP +new_call; + +offer('single-codec w telephone-event in wrong order', { + ICE => 'remove', + flags => [], + }, < 'remove', + flags => ['single codec'], + }, <