comparison rtp-g711-extr.c @ 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 05ff0f7ac977
children
comparison
equal deleted inserted replaced
6:709aa9ad72d1 7:9b0613775cf6
153 char **argv; 153 char **argv;
154 { 154 {
155 char errbuf[PCAP_ERRBUF_SIZE]; 155 char errbuf[PCAP_ERRBUF_SIZE];
156 u_char *pkt; 156 u_char *pkt;
157 struct pcap_pkthdr pkthdr; 157 struct pcap_pkthdr pkthdr;
158 unsigned pkt_idx; 158 unsigned pkt_idx, skip_num;
159 159
160 if (argc != 6) { 160 if (argc < 6 || argc > 7) {
161 fprintf(stderr, 161 fprintf(stderr,
162 "usage: %s pcap-file src|dest ip-addr udp-port outfile\n", 162 "usage: %s pcap-file src|dest ip-addr udp-port outfile [skip-count]\n",
163 argv[0]); 163 argv[0]);
164 exit(1); 164 exit(1);
165 } 165 }
166 pcap = pcap_open_offline(argv[1], errbuf); 166 pcap = pcap_open_offline(argv[1], errbuf);
167 if (!pcap) { 167 if (!pcap) {
189 outfile = fopen(argv[5], "w"); 189 outfile = fopen(argv[5], "w");
190 if (!outfile) { 190 if (!outfile) {
191 perror(argv[5]); 191 perror(argv[5]);
192 exit(1); 192 exit(1);
193 } 193 }
194 if (argv[6])
195 skip_num = strtoul(argv[6], 0, 0);
196 else
197 skip_num = 0;
194 for (pkt_idx = 0; ; pkt_idx++) { 198 for (pkt_idx = 0; ; pkt_idx++) {
195 pkt = pcap_next(pcap, &pkthdr); 199 pkt = pcap_next(pcap, &pkthdr);
196 if (!pkt) 200 if (!pkt)
197 break; 201 break;
202 if (pkt_idx < skip_num)
203 continue;
198 process_packet(pkt, (unsigned) pkthdr.caplen, pkt_idx); 204 process_packet(pkt, (unsigned) pkthdr.caplen, pkt_idx);
199 } 205 }
200 if (!stream_init_flag) { 206 if (!stream_init_flag) {
201 fprintf(stderr, "error: specified RTP stream not found\n"); 207 fprintf(stderr, "error: specified RTP stream not found\n");
202 exit(1); 208 exit(1);