Skip to content

Commit

Permalink
MT#60347 extend allow-asymmetric-codecs
Browse files Browse the repository at this point in the history
... to be operational and useful on supplemental codecs (DTMF etc)

Change-Id: Ifedefb143b984e6bac49dbbd744fe4647891bc7a
  • Loading branch information
rfuchs committed Jul 25, 2024
1 parent 6eecfc0 commit abbc022
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ For quick access, documentation for development:
* [Troubleshooting Overview](https://rtpengine.readthedocs.io/en/latest/troubleshooting.html)
* [Glossary](https://rtpengine.readthedocs.io/en/latest/glossary.html)

# Sponsors

* [Dataport AöR](https://www.dataport.de/)

# Contribution

Every bit matters. Join us. Make the rtpengine community stronger.
3 changes: 2 additions & 1 deletion daemon/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,8 @@ static void codecs_answer(struct call_media *media, struct call_media *other_med
ilogs(codec, LOG_DEBUG, "Codec answer for " STR_FORMAT " #%u",
STR_FMT(&other_media->monologue->tag),
other_media->index);
codec_store_answer(&media->codecs, &other_media->codecs, flags);
codec_store_answer(&media->codecs, &other_media->codecs, flags,
.allow_asymmetric = !!flags->allow_asymmetric_codecs);

// set up handlers
codec_handlers_update(media, other_media, .flags = flags, .sp = sp,
Expand Down
31 changes: 25 additions & 6 deletions daemon/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,10 @@ void __codec_handlers_update(struct call_media *receiver, struct call_media *sin
if (!sink_pt) {
// no matching/identical output codec. maybe we have the same output codec,
// but with a different payload type or a different format?
sink_pt = codec_store_find_compatible(&sink->codecs, pt);
if (!a.allow_asymmetric)
sink_pt = codec_store_find_compatible(&sink->codecs, pt);
else
sink_pt = pt;
}

if (sink_pt && !pt->codec_def->supplemental) {
Expand Down Expand Up @@ -1254,10 +1257,18 @@ void __codec_handlers_update(struct call_media *receiver, struct call_media *sin

sink_pt_fixed:;
// we have found a usable output codec. gather matching output supp codecs
rtp_payload_type *sink_dtmf_pt = __supp_payload_type(supplemental_sinks,
sink_pt->clock_rate, "telephone-event");
rtp_payload_type *sink_cn_pt = __supp_payload_type(supplemental_sinks,
sink_pt->clock_rate, "CN");
rtp_payload_type *sink_dtmf_pt = NULL;
rtp_payload_type *sink_cn_pt = NULL;
if (!a.allow_asymmetric) {
sink_dtmf_pt = __supp_payload_type(supplemental_sinks,
sink_pt->clock_rate, "telephone-event");
sink_cn_pt = __supp_payload_type(supplemental_sinks,
sink_pt->clock_rate, "CN");
}
else {
sink_dtmf_pt = recv_dtmf_pt;
sink_cn_pt = recv_cn_pt;
}
rtp_payload_type *real_sink_dtmf_pt = NULL; // for DTMF delay

// XXX synthesise missing supp codecs according to codec tracker XXX needed?
Expand Down Expand Up @@ -5201,6 +5212,8 @@ void __codec_store_populate(struct codec_store *dst, struct codec_store *src, st
pt->payload_type);
continue;
}
if (orig_pt->codec_def && orig_pt->codec_def->supplemental)
orig_pt = NULL;
}
ilogs(codec, LOG_DEBUG, "Adding codec " STR_FORMAT "/" STR_FORMAT " (%i)",
STR_FMT(&pt->encoding_with_params),
Expand Down Expand Up @@ -5558,7 +5571,9 @@ void codec_store_transcode(struct codec_store *cs, str_q *offer, struct codec_st
#endif
}

void codec_store_answer(struct codec_store *dst, struct codec_store *src, sdp_ng_flags *flags) {
void __codec_store_answer(struct codec_store *dst, struct codec_store *src, sdp_ng_flags *flags,
struct codec_store_args a)
{
// retain existing setup for supplemental codecs, but start fresh otherwise
struct codec_store orig_dst;
codec_store_move(&orig_dst, dst);
Expand Down Expand Up @@ -5672,6 +5687,8 @@ void codec_store_answer(struct codec_store *dst, struct codec_store *src, sdp_ng
// handle associated supplemental codecs
if (h->cn_payload_type != -1) {
pt = t_hash_table_lookup(orig_dst.codecs, GINT_TO_POINTER(h->cn_payload_type));
if (!pt && a.allow_asymmetric)
pt = t_hash_table_lookup(src->codecs, GINT_TO_POINTER(h->cn_payload_type));
if (!pt)
ilogs(codec, LOG_DEBUG, "CN payload type %i is missing", h->cn_payload_type);
else
Expand All @@ -5682,6 +5699,8 @@ void codec_store_answer(struct codec_store *dst, struct codec_store *src, sdp_ng
dtmf_payload_type = h->real_dtmf_payload_type;
if (dtmf_payload_type != -1) {
pt = t_hash_table_lookup(orig_dst.codecs, GINT_TO_POINTER(dtmf_payload_type));
if (!pt && a.allow_asymmetric)
pt = t_hash_table_lookup(src->codecs, GINT_TO_POINTER(dtmf_payload_type));
if (!pt)
ilogs(codec, LOG_DEBUG, "DTMF payload type %i is missing", dtmf_payload_type);
else
Expand Down
5 changes: 4 additions & 1 deletion include/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ void codec_store_track(struct codec_store *, str_q *);
__attribute__((nonnull(1, 2, 3)))
void codec_store_transcode(struct codec_store *, str_q *, struct codec_store *);
__attribute__((nonnull(1, 2, 3)))
void codec_store_answer(struct codec_store *dst, struct codec_store *src, sdp_ng_flags *flags);
void __codec_store_answer(struct codec_store *dst, struct codec_store *src, sdp_ng_flags *flags,
struct codec_store_args);
#define codec_store_answer(dst, src, flags, ...) \
__codec_store_answer(dst, src, flags, (struct codec_store_args) {__VA_ARGS__})
__attribute__((nonnull(1, 2)))
void codec_store_synthesise(struct codec_store *dst, struct codec_store *opposite);
__attribute__((nonnull(1, 2)))
Expand Down

0 comments on commit abbc022

Please sign in to comment.