Skip to content

Commit

Permalink
Added some RTT related debugging information to event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero committed Mar 7, 2023
1 parent c6758ec commit cce3f23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -4323,8 +4323,17 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
if(medium->codec)
json_object_set_new(info, "codec", json_string(medium->codec));
json_object_set_new(info, "base", json_integer(medium->rtcp_ctx[vindex]->tb));
if(vindex == 0)
json_object_set_new(info, "rtt", json_integer(janus_rtcp_context_get_rtt(medium->rtcp_ctx[vindex])));
if(vindex == 0) {
uint32_t rtt = janus_rtcp_context_get_rtt(medium->rtcp_ctx[vindex]);
json_object_set_new(info, "rtt", json_integer(rtt));
if(rtt > 0 && medium->rtcp_ctx[vindex]) {
json_t *rtt_vals = json_object();
json_object_set_new(rtt_vals, "ntp", json_integer(medium->rtcp_ctx[vindex]->rtt_ntp));
json_object_set_new(rtt_vals, "lsr", json_integer(medium->rtcp_ctx[vindex]->rtt_lsr));
json_object_set_new(rtt_vals, "dlsr", json_integer(medium->rtcp_ctx[vindex]->rtt_dlsr));
json_object_set_new(info, "rtt-values", rtt_vals);
}
}
json_object_set_new(info, "lost", json_integer(janus_rtcp_context_get_lost_all(medium->rtcp_ctx[vindex], FALSE)));
json_object_set_new(info, "lost-by-remote", json_integer(janus_rtcp_context_get_lost_all(medium->rtcp_ctx[vindex], TRUE)));
json_object_set_new(info, "jitter-local", json_integer(janus_rtcp_context_get_jitter(medium->rtcp_ctx[vindex], FALSE)));
Expand Down
3 changes: 3 additions & 0 deletions src/rtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ static void janus_rtcp_incoming_rr(janus_rtcp_context *ctx, janus_rtcp_rr *rr) {
tv.tv_sec = rtt_msw;
tv.tv_usec = (rtt_lsw * 15625) >> 10;
ctx->rtt = tv.tv_sec*1000 + tv.tv_usec/1000; /* We need milliseconds */
ctx->rtt_ntp = a;
ctx->rtt_lsr = lsr;
ctx->rtt_dlsr = dlsr;
JANUS_LOG(LOG_HUGE, "rtt=%"SCNu32"\n", ctx->rtt);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/rtcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ typedef struct rtcp_context

/* Estimated round-trip time */
uint32_t rtt;
/* Fields that led to RTT calculation (for stats) */
uint32_t rtt_ntp, rtt_lsr, rtt_dlsr;

/* RFC 3550 A.3 */
uint32_t received;
Expand Down

0 comments on commit cce3f23

Please sign in to comment.