Browse Source

TT#101653 detect and adjust for output clock skew

Change-Id: I3844a49bf2a8cd416f9cb1ceab6b3ed69732d0e6
pull/1163/head
Richard Fuchs 5 years ago
parent
commit
8517c99af2
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      daemon/codec.c

+ 11
- 0
daemon/codec.c View File

@ -103,6 +103,7 @@ struct codec_ssrc_handler {
unsigned long ts_in; // for DTMF dupe detection
struct timeval first_send;
unsigned long first_send_ts;
unsigned long output_skew;
GString *sample_buffer;
struct dtx_buffer *dtx_buffer;
@ -1805,6 +1806,16 @@ static void __output_rtp(struct media_packet *mp, struct codec_ssrc_handler *ch,
unsigned long long ts_diff_us
= timeval_diff(&p->ttq_entry.when, &rtpe_now);
ch->output_skew = ch->output_skew * 15 / 16 + ts_diff_us / 16;
if (ch->output_skew > 40000 && ts_diff_us > 10000) { // arbitrary value, 40 ms, 10 ms shift
ilog(LOG_DEBUG, "Steady clock skew of %lu.%01lu ms detected, shifting send timer back by 10 ms",
ch->output_skew / 1000,
(ch->output_skew % 1000) / 100);
timeval_add_usec(&p->ttq_entry.when, -10000);
ch->output_skew -= 10000;
ch->first_send_ts += ch->encoder_format.clockrate / 100;
}
ilog(LOG_DEBUG, "Scheduling to send RTP packet (seq %u TS %lu) in %llu.%01llu ms (at %lu.%06lu)",
ntohs(rh->seq_num),
ts,


Loading…
Cancel
Save