changeset 11:4f82b9c07ddb

twjit: update to stats
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Jul 2024 01:57:52 +0000
parents e60df79cbe9f
children 323957bebd53
files include/twjit.h src/twjit_in.c src/twjit_out.c
diffstat 3 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/include/twjit.h	Sat Jul 06 00:29:24 2024 +0000
+++ b/include/twjit.h	Sat Jul 06 01:57:52 2024 +0000
@@ -32,9 +32,10 @@
  */
 struct twrtp_jibuf_stats {
 	/* normal operation */
+	uint32_t rx_packets;
 	uint32_t delivered_pkt;
-	uint32_t delivered_bytes;
-	uint32_t handovers;
+	uint32_t handovers_in;
+	uint32_t handovers_out;
 	/* undesirable, but not totally unexpected */
 	uint32_t too_old;
 	uint32_t underruns;
@@ -50,6 +51,7 @@
 	uint32_t seq_repeats;
 	uint32_t intentional_gaps;
 	uint32_t ts_resets;
+	uint32_t jitter_max;
 };
 
 /*
--- a/src/twjit_in.c	Sat Jul 06 00:29:24 2024 +0000
+++ b/src/twjit_in.c	Sat Jul 06 01:57:52 2024 +0000
@@ -99,6 +99,8 @@
 	if (jitter_new < 0)
 		jitter_new = -jitter_new;
 	rri->jitter_accum += jitter_new - ((rri->jitter_accum + 8) >> 4);
+	if (jitter_new > twjit->stats.jitter_max)
+		twjit->stats.jitter_max = jitter_new;
 }
 
 /* actual twjit input logic */
@@ -246,6 +248,7 @@
 	twjit->last_seq = rx_seq;
 	twjit->last_ts = rx_ts;
 	memcpy(&twjit->last_arrival, &now, sizeof(struct timespec));
+	twjit->stats.rx_packets++;
 	msg->cb[0] = rx_ts;
 
 	switch (twjit->state) {
@@ -281,7 +284,7 @@
 			twjit->state = TWJIT_STATE_HANDOVER;
 			twjit->write_sb = !twjit->write_sb;
 			init_subbuf_first_packet(twjit, msg, rx_ssrc, rx_ts);
-			twjit->stats.handovers++;
+			twjit->stats.handovers_in++;
 			return;
 		}
 		insert_pkt_write_sb(twjit, msg, rx_ts);
--- a/src/twjit_out.c	Sat Jul 06 00:29:24 2024 +0000
+++ b/src/twjit_out.c	Sat Jul 06 01:57:52 2024 +0000
@@ -42,7 +42,6 @@
 	if (msg->cb[0] == sb->head_ts) {
 		llist_del(&msg->list);
 		twjit->stats.delivered_pkt++;
-		twjit->stats.delivered_bytes += msg->len;
 	} else {
 		msg = NULL;
 		twjit->stats.output_gaps++;
@@ -100,6 +99,7 @@
 	case TWJIT_STATE_HANDOVER:
 		if (starting_sb_is_ready(twjit)) {
 			toss_read_queue(twjit);
+			twjit->stats.handovers_out++;
 			twjit->state = TWJIT_STATE_FLOWING;
 			twjit->read_sb = twjit->write_sb;
 			return pull_from_read_sb(twjit);