From 9d70c057db2bc04832c5aa3017110bd91db73c62 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 30 Nov 2023 14:01:36 -0500 Subject: [PATCH] MT#58636 add new option 'static codecs' Change-Id: Ife8ef86ff0c6dd8733fd063d8ce19f6baaa30e58 (cherry picked from commit 76203fdce9460dbbf05b80ad0ac20f12eb697e76) --- daemon/call.c | 4 +- daemon/call_interfaces.c | 4 + daemon/codec.c | 1 - docs/ng_control_protocol.md | 6 + include/call_interfaces.h | 1 + t/auto-daemon-tests.pl | 334 ++++++++++++++++++++++++++++++++++++ 6 files changed, 348 insertions(+), 2 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index c423e6a87..3c5d82691 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2687,7 +2687,9 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi ilogs(codec, LOG_DEBUG, "Updating codecs for answerer " STR_FORMAT " #%u", STR_FMT(&media->monologue->tag), media->index); - if (flags && flags->reuse_codec) + if (flags->static_codecs && media->codecs.codec_prefs.length) + ilogs(codec, LOG_DEBUG, "Leaving answerer codecs alone"); + else if (flags && flags->reuse_codec) codec_store_populate_reuse(&media->codecs, &sp->codecs, NULL, false); else codec_store_populate(&media->codecs, &sp->codecs, NULL, false); diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 14cbae942..46c00b859 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1108,6 +1108,10 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) { case CSH_LOOKUP("no-codec-renegotiation"): out->reuse_codec = 1; break; + case CSH_LOOKUP("static-codec"): + case CSH_LOOKUP("static-codecs"): + out->static_codecs = 1; + break; case CSH_LOOKUP("single-codec"): out->single_codec = 1; break; diff --git a/daemon/codec.c b/daemon/codec.c index c127bd69d..753f10470 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -4660,7 +4660,6 @@ static void codec_store_add_end(struct codec_store *cs, struct rtp_payload_type void codec_store_populate_reuse(struct codec_store *dst, struct codec_store *src, GHashTable *codec_set, bool answer_only) { - // start fresh struct call_media *media = dst->media; struct call *call = media ? media->call : NULL; diff --git a/docs/ng_control_protocol.md b/docs/ng_control_protocol.md index 628f7b864..19082e551 100644 --- a/docs/ng_control_protocol.md +++ b/docs/ng_control_protocol.md @@ -950,6 +950,12 @@ Spaces in each string may be replaced by hyphens. and will remove all others from the list. Useful for RTP clients which get confused if more than one codec is listed in an answer. +* `static codecs` + + Useful in an `offer` message to suppress any change in codecs towards the + answer side, instead of passing along the list of offered codecs from the + offer side as it normally would. + * `SIP source address` Ignore any IP addresses given in the SDP body and use the source address of the received diff --git a/include/call_interfaces.h b/include/call_interfaces.h index ac2ead366..2f2ec7df4 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -164,6 +164,7 @@ struct sdp_ng_flags { original_sendrecv:1, single_codec:1, reuse_codec:1, + static_codecs:1, allow_transcoding:1, early_media:1, accept_any:1, diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 83cf50aa6..323fc7c08 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -80,6 +80,340 @@ sub stun_succ { + + +new_call; + +offer('static codecs control', { codec => { transcode => + ['opus/48000/2///useinbandfec--1;stereo--0;sprop-stereo--0'], + }}, < { transcode => + ['opus/48000/2///useinbandfec--1;stereo--0;sprop-stereo--0'], + }}, < { transcode => + ['opus/48000/2///useinbandfec--1;stereo--0;sprop-stereo--0'], + }, flags => ['no codec renegotiation'] }, < ['no codec renegotiation'] }, < { transcode => + ['opus/48000/2///useinbandfec--1;stereo--0;sprop-stereo--0'], + }, flags => ['no codec renegotiation'] }, < { transcode => + ['opus/48000/2///useinbandfec--1;stereo--0;sprop-stereo--0'], + }, flags => ['static codecs'] }, < ['static codecs'] }, < { transcode => + ['opus/48000/2///useinbandfec--1;stereo--0;sprop-stereo--0'], + }, flags => ['static codecs'] }, <