From a73cde83822ad7e31be5ccd0f9d9d2e4f3145775 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 29 Jun 2022 13:59:35 -0400 Subject: [PATCH] TT#14008 DTX buffer PT change: take supp PTs into account The PT tracker doesn't distinguish between audio/media types and supplemental types, so in order not to break DTMF handling we must take all combinations of primary (audio/media) types and supplemental types as both input types and handler types into account. Fix-up for 74075f6396d084762768429f1b92eabf48b30b94 Fix-up for I57e1278e4fad157083d9526d4829f2940581687f closes #1508 possibly also #1504 Change-Id: If7b242def2d35fbed14b11d204ea328b8bfe5d79 --- daemon/codec.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 3cd06026c..efd5f0224 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -2983,10 +2983,33 @@ static void __dtx_send_later(struct codec_timer *ct) { shutdown = true; else if (dtxb->ct.next.tv_sec == 0) shutdown = true; - else if (ps->ssrc_in[0]->tracker.most_len < 1) - shutdown = true; - else if (ps->ssrc_in[0]->tracker.most[0] != ch->handler->source_pt.payload_type) - shutdown = true; + else { + shutdown = true; // default if no most used PTs are known + + for (int i = 0; i < ps->ssrc_in[0]->tracker.most_len; i++) { + unsigned char most_pt = ps->ssrc_in[0]->tracker.most[i]; + shutdown = false; + // we are good if the most used PT is + // either us + if (ch->handler->source_pt.payload_type == most_pt) + break; + // or our input PT (which is the audio PT if we are supplemental) + if (ch->handler->input_handler && ch->handler->input_handler->source_pt.payload_type == most_pt) + break; + + // looks like codec change, but... + shutdown = true; + + // another possibility is that the most used PT is actually a supplemental type. check this, + // and if true move on to the next most used PT. + struct rtp_payload_type *pt = g_hash_table_lookup(ps->media->codecs.codecs, GUINT_TO_POINTER(most_pt)); + if (pt && pt->codec_def && pt->codec_def->supplemental) + continue; + + // all other cases: codec change + break; + } + } if (shutdown) { ilogs(dtx, LOG_DEBUG, "DTX buffer for %lx has been shut down", (unsigned long) dtxb->ssrc);