diff pcap/rtp-cont-check.c @ 172:693a0958a303

yet another refactoring of RTP tools: the program that prints each time delta is now rtp-jitter-view, whereas rtp-cont-check now reports min and max instead.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Dec 2022 22:42:41 +0000
parents 75607bc26f57
children 10f11a2d4042
line wrap: on
line diff
--- a/pcap/rtp-cont-check.c	Mon Dec 26 21:35:09 2022 +0000
+++ b/pcap/rtp-cont-check.c	Mon Dec 26 22:42:41 2022 +0000
@@ -4,9 +4,8 @@
  * IP:port, and checks its continuity: verifies that the sequence
  * number always increments by 1 and that the timestamp always
  * increments by 160 units.  Finally, this program prints out
- * the Rx time delta of each stream packet (the capture time of
- * the current packet minus the capture time of the previous packet)
- * on stdout, allowing visual timing analysis.
+ * the minimum and maximum observed capture time deltas between
+ * successive packets of the stream.
  *
  * The codec can be anything, and this program can also be used to
  * check continuity of RTP streams coming from PSTN/SIP, but the
@@ -30,9 +29,10 @@
 static u_short match_udp_port;
 static unsigned iphdr_addr_offset, udphdr_port_offset;
 static unsigned link_hdr_len, ethertype_offset;
-static int stream_init_flag;
+static int stream_init_flag, deltat_init_flag;
 static unsigned last_seq, last_tstamp, stream_ssrc;
 static struct timeval last_pkt_time;
+static unsigned deltat_min, deltat_max;
 
 static void
 check_dl_type()
@@ -105,8 +105,16 @@
 				pkt_idx);
 			exit(1);
 		}
-		printf("Packet #%u: time delta %u us\n", pkt_idx,
-			(unsigned) deltat.tv_usec);
+		if (deltat_init_flag) {
+			if (deltat.tv_usec < deltat_min)
+				deltat_min = deltat.tv_usec;
+			if (deltat.tv_usec > deltat_max)
+				deltat_max = deltat.tv_usec;
+		} else {
+			deltat_min = deltat.tv_usec;
+			deltat_max = deltat.tv_usec;
+			deltat_init_flag = 1;
+		}
 	} else {
 		stream_init_flag = 1;
 		stream_ssrc = cur_ssrc;
@@ -215,5 +223,11 @@
 		fprintf(stderr, "error: specified RTP stream not found\n");
 		exit(1);
 	}
+	if (!deltat_init_flag) {
+		fprintf(stderr, "error: found only one matching packet\n");
+		exit(1);
+	}
+	printf("Minimum time delta: %u us\n", deltat_min);
+	printf("Maximum time delta: %u us\n", deltat_max);
 	exit(0);
 }