From 38d0f1504a2ba4cab723205894d199875362bc67 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 27 Apr 2026 10:05:03 -0400 Subject: [PATCH] MT#55283 extend search for compatible codec Change-Id: Ib1b9e08e65ff26c544d7deff99ab3c7d57cb4673 --- daemon/codec.c | 11 ++++++++ t/auto-daemon-tests.pl | 61 +++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 939bfc38b..aefbf79cb 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -6135,6 +6135,17 @@ static void codec_store_add_q(struct codec_store *cs, const str_q *offer, struct } GQueue *orig_list = orig ? t_hash_table_lookup(orig->codec_names, codec) : NULL; if (!orig_list || !orig_list->length || cs->strip_full) { + // check for a compatible entry on opposite side + if (orig) { + codec_store_find_matching_codecs(NULL, &pt_match, orig, codec, pt); + if (pt_match) { + ilogs(codec, LOG_DEBUG, "Adding previously existing codec " STR_FORMAT, + STR_FMT(&pt_match->encoding_with_full_params)); + codec_touched(cs, pt_match); + codec_store_add_order(cs, pt_match); + continue; + } + } ilogs(codec, LOG_DEBUG, "Adding codec " STR_FORMAT " for transcoding", STR_FMT(codec)); diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index c891aee42..1fb467bff 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -7947,11 +7947,11 @@ o=- 2405046764736097547 2405046764736097550 IN IP4 192.168.178.104 s=SDP data c=IN IP4 192.168.178.104 t=0 0 -m=audio 15028 RTP/AVP 0 8 97 98 96 +m=audio 15028 RTP/AVP 0 8 99 98 96 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 -a=rtpmap:97 opus/48000/2 -a=fmtp:97 stereo=0; sprop-stereo=0; useinbandfec=1 +a=rtpmap:99 opus/48000/2 +a=fmtp:99 stereo=0; sprop-stereo=0; useinbandfec=1 a=rtpmap:98 telephone-event/48000 a=fmtp:98 0-15 a=rtpmap:96 telephone-event/8000 @@ -16027,17 +16027,16 @@ v=0 o=- 3816337545 3816337545 IN IP4 ims.example.com s=- t=0 0 -m=audio PORT RTP/AVP 9 97 108 8 96 98 101 +m=audio PORT RTP/AVP 9 111 108 8 96 97 101 c=IN IP4 203.0.113.1 a=rtpmap:9 G722/8000 -a=rtpmap:97 opus/48000 -a=fmtp:97 useinbandfec=1 +a=rtpmap:111 opus/48000 a=rtpmap:108 speex/16000 a=rtpmap:8 PCMA/8000 a=rtpmap:96 telephone-event/8000 a=fmtp:96 0-15 -a=rtpmap:98 telephone-event/16000 -a=fmtp:98 0-15 +a=rtpmap:97 telephone-event/16000 +a=fmtp:97 0-15 a=rtpmap:101 telephone-event/48000 a=fmtp:101 0-15 a=sendrecv @@ -16142,13 +16141,13 @@ v=0 o=- 1545997027 1 IN IP4 203.0.113.1 s=tester t=0 0 -m=audio PORT RTP/AVP 8 108 97 96 101 +m=audio PORT RTP/AVP 8 108 111 96 101 c=IN IP4 203.0.113.1 a=rtpmap:8 PCMA/8000 a=rtpmap:108 AMR/8000 a=fmtp:108 mode-set=7 -a=rtpmap:97 AMR-WB/16000 -a=fmtp:97 mode-set=0,1,2;mode-change-period=2;mode-change-capability=2 +a=rtpmap:111 AMR-WB/16000 +a=fmtp:111 mode-set=0,1,2; mode-change-period=2; mode-change-capability=2 a=rtpmap:96 telephone-event/16000 a=fmtp:96 0-15 a=rtpmap:101 telephone-event/8000 @@ -16164,10 +16163,10 @@ v=0 o=- 1545997027 1 IN IP4 198.51.100.10 s=tester t=0 0 -m=audio 3064 RTP/AVP 97 96 +m=audio 3064 RTP/AVP 111 96 c=IN IP4 198.51.100.10 -a=rtpmap:97 AMR-WB/16000 -a=fmtp:97 octet-align=0; mode-set=0,1,2; max-red=0; mode-change-capability=2 +a=rtpmap:111 AMR-WB/16000 +a=fmtp:111 octet-align=0; mode-set=0,1,2; max-red=0; mode-change-capability=2 a=rtpmap:96 telephone-event/16000 a=fmtp:96 0-16 a=ptime:20 @@ -16179,7 +16178,7 @@ t=0 0 m=audio PORT RTP/AVP 111 96 c=IN IP4 203.0.113.1 a=rtpmap:111 AMR-WB/16000 -a=fmtp:111 mode-set=0,1,2; mode-change-period=2; mode-change-capability=2 +a=fmtp:111 octet-align=0; mode-set=0,1,2; max-red=0; mode-change-capability=2 a=rtpmap:96 telephone-event/16000 a=fmtp:96 0-15 a=sendrecv @@ -16224,13 +16223,13 @@ v=0 o=- 1545997027 1 IN IP4 203.0.113.1 s=tester t=0 0 -m=audio PORT RTP/AVP 8 108 97 96 101 +m=audio PORT RTP/AVP 8 108 111 96 101 c=IN IP4 203.0.113.1 a=rtpmap:8 PCMA/8000 a=rtpmap:108 AMR/8000 a=fmtp:108 mode-set=7 -a=rtpmap:97 AMR-WB/16000 -a=fmtp:97 mode-set=0,1,2;mode-change-period=2;mode-change-capability=2 +a=rtpmap:111 AMR-WB/16000 +a=fmtp:111 mode-set=0,1,2; mode-change-period=2; mode-change-capability=2 a=rtpmap:96 telephone-event/16000 a=fmtp:96 0-15 a=rtpmap:101 telephone-event/8000 @@ -16246,10 +16245,10 @@ v=0 o=- 1545997027 1 IN IP4 198.51.100.10 s=tester t=0 0 -m=audio 3068 RTP/AVP 97 96 +m=audio 3068 RTP/AVP 111 96 c=IN IP4 198.51.100.10 -a=rtpmap:97 AMR-WB/16000 -a=fmtp:97 octet-align=0; mode-set=0,1,2; max-red=0; mode-change-capability=2 +a=rtpmap:111 AMR-WB/16000 +a=fmtp:111 octet-align=0; mode-set=0,1,2; max-red=0; mode-change-capability=2 a=rtpmap:96 telephone-event/16000 a=fmtp:96 0-16 a=ptime:20 @@ -16261,7 +16260,7 @@ t=0 0 m=audio PORT RTP/AVP 111 96 c=IN IP4 203.0.113.1 a=rtpmap:111 AMR-WB/16000 -a=fmtp:111 mode-set=0,1,2; mode-change-period=2; mode-change-capability=2 +a=fmtp:111 octet-align=0; mode-set=0,1,2; max-red=0; mode-change-capability=2 a=rtpmap:96 telephone-event/16000 a=fmtp:96 0-15 a=sendrecv @@ -16303,11 +16302,11 @@ v=0 o=- 3812713289 3812713289 IN IP4 foo.bar.com s=- t=0 0 -m=audio PORT RTP/AVP 9 97 108 8 96 101 +m=audio PORT RTP/AVP 9 111 108 8 96 101 c=IN IP4 203.0.113.1 a=rtpmap:9 G722/8000 -a=rtpmap:97 AMR-WB/16000 -a=fmtp:97 mode-set=0,1,2;mode-change-period=2;mode-change-capability=2 +a=rtpmap:111 AMR-WB/16000 +a=fmtp:111 mode-set=0,1,2; mode-change-period=2; mode-change-capability=2 a=rtpmap:108 AMR/8000 a=fmtp:108 mode-set=7 a=rtpmap:8 PCMA/8000 @@ -16383,11 +16382,11 @@ v=0 o=- 3812713289 3812713289 IN IP4 foo.bar.com s=- t=0 0 -m=audio PORT RTP/AVP 9 97 108 8 96 101 +m=audio PORT RTP/AVP 9 111 108 8 96 101 c=IN IP4 203.0.113.1 a=rtpmap:9 G722/8000 -a=rtpmap:97 AMR-WB/16000 -a=fmtp:97 mode-set=0,1,2;mode-change-period=2;mode-change-capability=2 +a=rtpmap:111 AMR-WB/16000 +a=fmtp:111 mode-set=0,1,2; mode-change-period=2; mode-change-capability=2 a=rtpmap:108 AMR/8000 a=fmtp:108 mode-set=7 a=rtpmap:8 PCMA/8000 @@ -16463,11 +16462,11 @@ v=0 o=- 3812713289 3812713289 IN IP4 foo.bar.com s=- t=0 0 -m=audio PORT RTP/AVP 9 97 108 8 96 101 +m=audio PORT RTP/AVP 9 111 108 8 96 101 c=IN IP4 203.0.113.1 a=rtpmap:9 G722/8000 -a=rtpmap:97 AMR-WB/16000 -a=fmtp:97 mode-set=0,1,2;mode-change-period=2;mode-change-capability=2 +a=rtpmap:111 AMR-WB/16000 +a=fmtp:111 mode-set=0,1,2; mode-change-period=2; mode-change-capability=2 a=rtpmap:108 AMR/8000 a=fmtp:108 mode-set=7 a=rtpmap:8 PCMA/8000