From c3e86a6e1770e24ad5d88343add13fe3cf4c9859 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 2 May 2023 15:47:38 -0400 Subject: [PATCH] MT#55283 fix DTMF send scheduling Don't try to interpret or schedule DTMF packets if we're just doing RTP passthrough. Without tracking the seqencing and timestamping of the primary media stream, we cannot actually schedule DTMF packets properly. Use the presence of a defined output sequence number to make this determination. The other case that uses a predefined output sequence number is when media is coming from a pre-coded media player stream. The same thing applies: These packets are already scheduled, so we can skip trying to schedule them again. closes #1638 Change-Id: I2d2c20e731f20a3136ca3eee37f0b521062cdb11 (cherry picked from commit 6f57d381e6cd68da85b2b33f6525547f61d6cdb3) --- daemon/codec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 67c388461..d6b5f1023 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1939,6 +1939,16 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *csch, ssrc_ctx_hold(ssrc_out); p->ssrc_out = ssrc_out; + long long ts_diff_us = 0; + + // ignore scheduling if a sequence number was supplied. in that case we're just doing + // passthrough forwarding (or are handling some other prepared RTP stream) and want + // to send the packet out immediately. + if (seq != -1) { + p->ttq_entry.when = rtpe_now; + goto send; + } + // this packet is dynamically allocated, so we're able to schedule it. // determine scheduled time to send if (csch->first_send.tv_sec && handler->dest_pt.clock_rate) { @@ -1960,8 +1970,7 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *csch, csch->first_send_ts = ts; } - long long ts_diff_us - = timeval_diff(&p->ttq_entry.when, &rtpe_now); + ts_diff_us = timeval_diff(&p->ttq_entry.when, &rtpe_now); csch->output_skew = csch->output_skew * 15 / 16 + ts_diff_us / 16; if (csch->output_skew > 50000 && ts_diff_us > 10000) { // arbitrary value, 50 ms, 10 ms shift @@ -1984,6 +1993,7 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *csch, ts_diff_us = timeval_diff(&p->ttq_entry.when, &rtpe_now); // should be 0 now } +send: ilogs(transcoding, LOG_DEBUG, "Scheduling to send RTP packet (seq %u TS %lu) in %s%lli.%01lli ms (at %lu.%06lu)", ntohs(rh->seq_num), ts,