@ -132,6 +132,7 @@ struct dtx_buffer {
unsigned long head_ts ;
unsigned long head_ts ;
uint32_t ssrc ;
uint32_t ssrc ;
int64_t start_us ;
int64_t start_us ;
unsigned int discard_old_count ;
} ;
} ;
struct dtx_packet {
struct dtx_packet {
struct transcode_packet * packet ;
struct transcode_packet * packet ;
@ -3791,6 +3792,7 @@ static void __dtx_send_later(struct codec_timer *ct) {
unsigned long ts ;
unsigned long ts ;
int p_left = 0 ;
int p_left = 0 ;
int64_t tv_diff = - 1 , ts_diff = 0 ;
int64_t tv_diff = - 1 , ts_diff = 0 ;
bool discarded_old = false ;
mutex_lock ( & dtxb - > lock ) ;
mutex_lock ( & dtxb - > lock ) ;
@ -3815,8 +3817,16 @@ static void __dtx_send_later(struct codec_timer *ct) {
if ( ! dtxb - > head_ts )
if ( ! dtxb - > head_ts )
; / / first packet
; / / first packet
else if ( ts_diff < 0 )
else if ( ts_diff_us < - 10000 0 | | dtxb - > discard_old_count > 3 )
ilogs ( dtx , LOG_DEBUG , " DTX timestamp reset (from %lu to %lu) " , dtxb - > head_ts , ts ) ;
ilogs ( dtx , LOG_DEBUG , " DTX timestamp reset (from %lu to %lu) " , dtxb - > head_ts , ts ) ;
else if ( ts_diff < 0 | | ( ts_diff = = 0 & & discarded_old ) ) {
ilogs ( dtx , LOG_DEBUG , " Discarding old packet (TS %lu < %lu, % " PRId64 " ms old) " ,
ts , dtxb - > head_ts , - ts_diff_us / 1000 ) ;
t_queue_pop_head ( & dtxb - > packets ) ;
dtx_packet_free ( dtxp ) ;
discarded_old = true ;
continue ; / / try again
}
else if ( ts_diff_us > MAX ( 20 * rtpe_config . dtx_delay_us , 200000 ) )
else if ( ts_diff_us > MAX ( 20 * rtpe_config . dtx_delay_us , 200000 ) )
ilogs ( dtx , LOG_DEBUG , " DTX timestamp reset (from %lu to %lu = % " PRId64 " ms) " ,
ilogs ( dtx , LOG_DEBUG , " DTX timestamp reset (from %lu to %lu = % " PRId64 " ms) " ,
dtxb - > head_ts , ts , ts_diff_us ) ;
dtxb - > head_ts , ts , ts_diff_us ) ;
@ -3979,6 +3989,11 @@ static void __dtx_send_later(struct codec_timer *ct) {
int ptime = dtxb - > ptime ;
int ptime = dtxb - > ptime ;
int64_t dtxb_start_us = dtxb - > start_us ;
int64_t dtxb_start_us = dtxb - > start_us ;
if ( discarded_old )
dtxb - > discard_old_count + + ;
else
dtxb - > discard_old_count = 0 ;
mutex_unlock ( & dtxb - > lock ) ;
mutex_unlock ( & dtxb - > lock ) ;
rwlock_lock_r ( & call - > master_lock ) ;
rwlock_lock_r ( & call - > master_lock ) ;