From f13118dbf7dc2f3867ca5f4e96920b58f36cedcd Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 4 Apr 2025 09:28:26 -0400 Subject: [PATCH] MT#55283 reset encoder and TS on DTX shutdown Shutting down a DTX buffer means that it may restart at an unknown later time. Reset TS tracking when shutting it down so that if it does restart, it receives a fresh TS state, instead of continuing on the previous timestamps, which may then be wrong. Change-Id: I9c7978e2f335eab32982c4739917ca5ce0c27eb6 --- daemon/codec.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 6653d2220..29d9f474e 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -3843,7 +3843,6 @@ static void __dtx_send_later(struct codec_timer *ct) { ilogs(dtx, LOG_DEBUG, "DTX buffer for %lx has been shut down", (unsigned long) dtxb->ssrc); dtxb->ct.next.tv_sec = 0; - dtxb->head_ts = 0; mutex_unlock(&dtxb->lock); goto out; // shut down } @@ -3960,9 +3959,24 @@ out: media_packet_release(&mp_copy); } static void __dtx_shutdown(struct dtx_buffer *dtxb) { - obj_release(dtxb->csh); + if (dtxb->csh) { + __auto_type ch = dtxb->csh; + ilog(LOG_ERR, "XXXXXXXXXXXXX %s:%d %lu %lu %lu", __FILE__, __LINE__, ch->encoder->next_pts, ch->csch.first_ts, ch->csch.first_send_ts); + ch->csch.first_send = (struct timeval) {0}; + ch->csch.first_ts = 0; + ch->csch.first_ts = 0; + if (ch->encoder) { + ch->encoder->packet_pts = 0; + ch->encoder->fifo_pts = 0; + ch->encoder->next_pts = 0; + ch->encoder->mux_dts = 0; + } + + obj_release(dtxb->csh); + } obj_release(dtxb->call); t_queue_clear_full(&dtxb->packets, dtx_packet_free); + dtxb->head_ts = 0; } static void __delay_buffer_shutdown(struct delay_buffer *dbuf, bool flush) { if (flush) {