diff src/twjit_in.c @ 12:323957bebd53

twjit: smarter counting of underruns
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Jul 2024 02:47:21 +0000
parents 4f82b9c07ddb
children ec50018cc4ea
line wrap: on
line diff
--- a/src/twjit_in.c	Sat Jul 06 01:57:52 2024 +0000
+++ b/src/twjit_in.c	Sat Jul 06 02:47:21 2024 +0000
@@ -218,6 +218,7 @@
 
 void twrtp_jibuf_input(struct twrtp_jibuf_inst *twjit, struct msgb *msg)
 {
+	bool got_previous_input = twjit->got_first_packet;
 	struct rtp_basic_hdr *rtph;
 	uint32_t rx_ssrc, rx_ts;
 	uint16_t rx_seq;
@@ -236,7 +237,7 @@
 	rx_ts = ntohl(rtph->tstamp);
 	rx_seq = ntohs(rtph->seq);
 	osmo_clock_gettime(CLOCK_MONOTONIC, &now);
-	if (!twjit->got_first_packet) {
+	if (!got_previous_input) {
 		analytics_init(twjit, rx_seq);
 		twjit->got_first_packet = true;
 	} else if (rx_ssrc != twjit->last_ssrc) {
@@ -254,6 +255,8 @@
 	switch (twjit->state) {
 	case TWJIT_STATE_EMPTY:
 		/* first packet into totally empty buffer */
+		if (got_previous_input)
+			twjit->stats.underruns++;
 		twjit->state = TWJIT_STATE_HUNT;
 		twjit->write_sb = 0;
 		init_subbuf_first_packet(twjit, msg, rx_ssrc, rx_ts);