changeset 7:9b0613775cf6

rtp-g711-extr: add ability to skip some number of packets, effectively starting the process at packet N rather than packet 0
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 08 Jul 2023 20:47:29 +0000
parents 709aa9ad72d1
children d180987db615
files rtp-g711-extr.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rtp-g711-extr.c	Sat Jul 08 20:30:33 2023 +0000
+++ b/rtp-g711-extr.c	Sat Jul 08 20:47:29 2023 +0000
@@ -155,11 +155,11 @@
 	char errbuf[PCAP_ERRBUF_SIZE];
 	u_char *pkt;
 	struct pcap_pkthdr pkthdr;
-	unsigned pkt_idx;
+	unsigned pkt_idx, skip_num;
 
-	if (argc != 6) {
+	if (argc < 6 || argc > 7) {
 		fprintf(stderr,
-		"usage: %s pcap-file src|dest ip-addr udp-port outfile\n",
+	"usage: %s pcap-file src|dest ip-addr udp-port outfile [skip-count]\n",
 			argv[0]);
 		exit(1);
 	}
@@ -191,10 +191,16 @@
 		perror(argv[5]);
 		exit(1);
 	}
+	if (argv[6])
+		skip_num = strtoul(argv[6], 0, 0);
+	else
+		skip_num = 0;
 	for (pkt_idx = 0; ; pkt_idx++) {
 		pkt = pcap_next(pcap, &pkthdr);
 		if (!pkt)
 			break;
+		if (pkt_idx < skip_num)
+			continue;
 		process_packet(pkt, (unsigned) pkthdr.caplen, pkt_idx);
 	}
 	if (!stream_init_flag) {