ref: 1e4fa4bc007448fee6b2b74677817f51f97b5ee7
parent: 69f47e2d4f4f59af4203930e1b3f1dbd74968460
author: Martin Meszaros <meszaros@hft-leipzig.de>
date: Fri Nov 17 10:11:35 EST 2017
opusrtp: Allow an output filename for extraction Closes https://github.com/xiph/opus-tools/pull/18 Signed-off-by: Mark Harris <mark.hsj@gmail.com>
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -796,7 +796,7 @@
}
}
-int extract(const char* input_file)
+int extract(const char* input_file, const char* output_file)
{
state *params;
pcap_t *pcap;
@@ -830,7 +830,7 @@
pcap_close(pcap);
return -1;
}
- params->out = fopen("rtpdump.opus", "wb");
+ params->out = fopen(output_file, "wb");
if (!params->out) {
fprintf(stderr, "Couldn't open output file.\n");
free(params->stream);
@@ -974,6 +974,7 @@
const char *dest = "127.0.0.1";
#ifdef HAVE_PCAP
const char *input_pcap = NULL;
+ const char *output_file = "rtpdump.opus";
#endif
int port = 1234;
struct option long_options[] = {
@@ -1051,8 +1052,16 @@
}
}
#ifdef HAVE_PCAP
- if(input_pcap) {
- extract(input_pcap);
+ if (input_pcap) {
+ if (optind + 1 == argc) {
+ output_file = argv[optind];
+ }
+ else if (argc > optind + 1) {
+ fprintf(stderr,
+ "Please specify exactly one input PCAP file and one output file.\n");
+ return 1;
+ }
+ extract(input_pcap, output_file);
return 0;
}
#endif