TT#99621 support jitter tracking for RTCP

Change-Id: I181e06e904702f37e155990dc597391c17ae4ad0
pull/1134/head
Richard Fuchs 5 years ago
parent ba66e5fa3a
commit c12ec6600d

@ -2502,6 +2502,27 @@ static int packet_decode(struct codec_ssrc_handler *ch, struct transcode_packet
return ret;
}
static void codec_calc_jitter(struct media_packet *mp, unsigned int clockrate) {
if (!mp->ssrc_in)
return;
struct ssrc_entry_call *sec = mp->ssrc_in->parent;
// RFC 3550 A.8
uint32_t transit = (((timeval_us(&mp->tv) / 1000) * clockrate) / 1000)
- ntohl(mp->rtp->timestamp);
mutex_lock(&sec->h.lock);
int32_t d = 0;
if (sec->transit)
d = transit - sec->transit;
sec->transit = transit;
if (d < 0)
d = -d;
sec->jitter += d - ((sec->jitter + 8) >> 4);
mutex_unlock(&sec->h.lock);
}
static int handler_func_transcode(struct codec_handler *h, struct media_packet *mp) {
if (G_UNLIKELY(!mp->rtp))
return handler_func_passthrough(h, mp);
@ -2514,6 +2535,8 @@ static int handler_func_transcode(struct codec_handler *h, struct media_packet *
ntohl(mp->rtp->ssrc), mp->rtp->m_pt, ntohs(mp->rtp->seq_num),
ntohl(mp->rtp->timestamp), mp->payload.len);
codec_calc_jitter(mp, h->source_pt.clock_rate);
if (h->stats_entry) {
unsigned int idx = rtpe_now.tv_sec & 1;
int last_tv_sec = g_atomic_int_get(&h->stats_entry->last_tv_sec[idx]);

@ -1431,6 +1431,7 @@ GString *rtcp_sender_report(uint32_t ssrc, uint32_t ts, uint32_t packets, uint32
tv_diff = timeval_diff(&rtpe_now, &si->received);
ntp_middle_bits = si->ntp_middle_bits;
}
uint32_t jitter = se->jitter;
mutex_unlock(&se->h.lock);
uint64_t lost = atomic64_get(&s->packets_lost);
@ -1445,8 +1446,8 @@ GString *rtcp_sender_report(uint32_t ssrc, uint32_t ts, uint32_t packets, uint32
.high_seq_received = htonl(atomic64_get(&s->last_seq)),
.lsr = htonl(ntp_middle_bits),
.dlsr = htonl(tv_diff * 65536 / 1000000),
.jitter = htonl(jitter >> 4),
};
// XXX jitter
n++;
}
ssrc_ctx_put(&s);

@ -98,6 +98,7 @@ struct ssrc_entry_call {
// for transcoding
// input only
packet_sequencer_t sequencer;
uint32_t jitter, transit;
// output only
uint16_t seq_diff;
};

Loading…
Cancel
Save