From c81859f2315982fd0b70b8d329046d6a4b60086c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 21 Dec 2022 13:04:48 -0500 Subject: [PATCH] MT#55283 fix SSRC stats tracking Change-Id: I3578fc3a233a83f67818e8cdd3a545fc5069a18b --- daemon/call.c | 3 +-- daemon/media_socket.c | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 603069411..0b75cdf52 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -704,8 +704,7 @@ void call_timer(void *ptr) { ps->ssrc_in, 0); if (!ctx) continue; - atomic64_add(&ctx->octets, diff_bytes_in); - atomic64_add(&ctx->packets, diff_packets_in); + // TODO: add in SSRC stats similar to __stream_update_stats atomic64_set(&ctx->last_seq, ke->target.decrypt.last_index[u]); if (sfd->crypto.params.crypto_suite diff --git a/daemon/media_socket.c b/daemon/media_socket.c index fe061e521..cb785cafb 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1510,8 +1510,8 @@ static void __stream_update_stats(struct packet_stream *ps, int have_in_lock) { // check for the right SSRC association if (!stats_info.ssrc[u]) // end of list break; - struct ssrc_ctx *ssrc_ctx = __hunt_ssrc_ctx(ntohl(stats_info.ssrc[u]), - ps->ssrc_in, u); + uint32_t ssrc = ntohl(stats_info.ssrc[u]); + struct ssrc_ctx *ssrc_ctx = __hunt_ssrc_ctx(ssrc, ps->ssrc_in, u); if (!ssrc_ctx) continue; struct ssrc_entry_call *parent = ssrc_ctx->parent; @@ -1531,17 +1531,25 @@ static void __stream_update_stats(struct packet_stream *ps, int have_in_lock) { uint32_t ssrc_map_out = ssrc_ctx->ssrc_map_out; // update opposite outgoing SSRC - if (mutex_trylock(&ps->out_lock)) - continue; // will have to skip this + for (GList *l = ps->rtp_sinks.head; l; l = l->next) { + struct sink_handler *sh = l->data; + struct packet_stream *sink = sh->sink; + + if (mutex_trylock(&sink->out_lock)) + continue; // will have to skip this - ssrc_ctx = __hunt_ssrc_ctx(ssrc_map_out, ps->ssrc_out, u); + ssrc_ctx = __hunt_ssrc_ctx(ssrc, sink->ssrc_out, u); + if (!ssrc_ctx) + ssrc_ctx = __hunt_ssrc_ctx(ssrc_map_out, sink->ssrc_out, u); - if (ssrc_ctx) { - parent = ssrc_ctx->parent; - atomic64_add(&ssrc_ctx->packets, stats_info.ssrc_stats[u].basic_stats.packets); - atomic64_add(&ssrc_ctx->octets, stats_info.ssrc_stats[u].basic_stats.bytes); + if (ssrc_ctx) { + parent = ssrc_ctx->parent; + atomic64_add(&ssrc_ctx->packets, stats_info.ssrc_stats[u].basic_stats.packets); + atomic64_add(&ssrc_ctx->octets, stats_info.ssrc_stats[u].basic_stats.bytes); + } + + mutex_unlock(&sink->out_lock); } - mutex_unlock(&ps->out_lock); } if (!have_in_lock)