diff --git a/daemon/codec.c b/daemon/codec.c index ac2151409..1d5bc503d 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -6095,7 +6095,8 @@ int codec_store_accept_one(struct codec_store *cs, const str_q *accept, bool acc return -1; } - // delete all codecs except the accepted one + // delete all codecs except the accepted one, preserving supplemental codecs + // that match the accepted codec's clock rate __auto_type link = cs->codec_prefs.head; while (link) { rtp_payload_type *pt = link->data; @@ -6103,6 +6104,13 @@ int codec_store_accept_one(struct codec_store *cs, const str_q *accept, bool acc link = link->next; continue; } + ensure_codec_def(pt, cs->media); + if (pt->codec_def && pt->codec_def->supplemental + && pt->clock_rate == accept_pt->clock_rate) + { + link = link->next; + continue; + } link = __codec_store_delete_link(link, cs); } @@ -6445,6 +6453,8 @@ void codec_store_synthesise(struct codec_store *dst, struct codec_store *opposit bool codec_store_is_full_answer(const struct codec_store *src, const struct codec_store *dst) { for (auto_iter(l, src->codec_prefs.head); l; l = l->next) { const rtp_payload_type *src_pt = l->data; + if (src_pt->codec_def && src_pt->codec_def->supplemental) + continue; const rtp_payload_type *dst_pt = t_hash_table_lookup(dst->codecs, GINT_TO_POINTER(src_pt->payload_type)); if (!dst_pt || !rtp_payload_type_eq_compat(src_pt, dst_pt)) { diff --git a/lib/codeclib.c b/lib/codeclib.c index 0aef8488d..6a1873323 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -784,6 +784,18 @@ static struct codec_def_s __codec_defs[] = { .format_cmp = format_cmp_ignore, .codec_type = &codec_type_cn, }, + { + .rtpname = "red", + .avcodec_id = -1, + .packetizer = packetizer_passthrough, + .media_type = MT_AUDIO, + .supplemental = 1, + .default_clockrate = 8000, + .default_channels = 1, + .format_cmp = format_cmp_ignore, + .support_encoding = 1, + .support_decoding = 1, + }, { .rtpname = "G726-16", .avcodec_id = AV_CODEC_ID_ADPCM_G726, diff --git a/t/auto-daemon-tests-pubsub.pl b/t/auto-daemon-tests-pubsub.pl index eb77c383e..066220d53 100755 --- a/t/auto-daemon-tests-pubsub.pl +++ b/t/auto-daemon-tests-pubsub.pl @@ -4716,5 +4716,137 @@ a=sendrecv a=rtcp:PORT SDP + +# publish with RED supplemental codec preserved alongside primary codec + +($sock_a, $sock_b) = + new_call([qw(198.51.100.14 6160)], [qw(198.51.100.14 6162)]); + +($port_a) = publish('publish w RED supplemental', + { codec => { accept => ['any'] } }, < ft() }, < $ttr }, < { accept => ['any'] } }, < ft() }, < $ttr }, <