diff --git a/daemon/codec.c b/daemon/codec.c index 35f35dbb5..5a83f4a33 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -6050,6 +6050,7 @@ int codec_store_accept_one(struct codec_store *cs, const str_q *accept, bool acc // local codec-accept routine: accept first supported codec, or first from "accept" list // if given + bool accept_all = false; rtp_payload_type *accept_pt = NULL; for (auto_iter(l, accept->head); l; l = l->next) { @@ -6059,6 +6060,10 @@ int codec_store_accept_one(struct codec_store *cs, const str_q *accept, bool acc accept_any = true; continue; } + if (!str_cmp(codec, "all")) { + accept_all = true; + continue; + } GQueue *pts = t_hash_table_lookup(cs->codec_names, codec); if (!pts) continue; @@ -6077,6 +6082,9 @@ int codec_store_accept_one(struct codec_store *cs, const str_q *accept, bool acc break; } + if (accept_all && accept_any) + return 0; + if (!accept_pt) { // none found yet - pick the first one for (__auto_type l = cs->codec_prefs.head; l; l = l->next) { @@ -6106,7 +6114,15 @@ int codec_store_accept_one(struct codec_store *cs, const str_q *accept, bool acc continue; } ensure_codec_def(pt, cs->media); - if (pt->codec_def && pt->codec_def->supplemental + if (accept_all) { + if (codec_def_supported(pt->codec_def) + || (pt->codec_def && pt->codec_def->supplemental)) + { + link = link->next; + continue; + } + } + else if (pt->codec_def && pt->codec_def->supplemental && pt->clock_rate == accept_pt->clock_rate) { link = link->next; diff --git a/docs/ng_control_protocol.md b/docs/ng_control_protocol.md index ec0f0cfce..1b39fbd7a 100644 --- a/docs/ng_control_protocol.md +++ b/docs/ng_control_protocol.md @@ -2605,7 +2605,10 @@ the first codec that is supported for transcoding is selected. If no such codec is present, then the offer is rejected. The special string `any` can be given in the `accept` list to influence this behaviour: If `any` is listed, then the first codec from the offer is accepted even if it's not supported for -transcoding. +transcoding. The special string `all` can be given in the `accept` list to +keep all codecs that are supported for transcoding (and their supplemental +codecs), removing only unsupported codecs. If both `all` and `any` are given, +all codecs from the offer are kept without removing any. ## `subscribe request` Message diff --git a/t/auto-daemon-tests-pubsub.pl b/t/auto-daemon-tests-pubsub.pl index 066220d53..0f506f48b 100755 --- a/t/auto-daemon-tests-pubsub.pl +++ b/t/auto-daemon-tests-pubsub.pl @@ -4848,5 +4848,144 @@ SDP snd($sock_a, $port_a, rtp(8, 2000, 4000, 0x3456, "\x00" x 160)); rcv($sock_b, $port_b, rtpm(8, 2000, 4000, 0x3456, "\x00" x 160)); + + +# publish with accept all: keep all codecs including unsupported ones + +($sock_a, $sock_b) = + new_call([qw(198.51.100.14 6168)], [qw(198.51.100.14 6170)]); + +($port_a) = publish('publish accept all', + { codec => { accept => ['all', 'any'] } }, < ft() }, < $ttr }, < { accept => ['all'] } }, < ft() }, < $ttr }, <