shithub: opus-tools

Download patch

ref: 091271a5a3a9e6ba2491d7b4695ea3f02e887c76
parent: f7455e66cab87a238b6c3ebe79c40c22f0ff384a
author: Ralph Giles <giles@mozilla.com>
date: Wed Oct 3 20:10:30 EDT 2012

Accept filenames to send over rtp on the command line.

Also update the usage and manpage for the send functionality.

--- a/man/opusrtp.1
+++ b/man/opusrtp.1
@@ -14,6 +14,10 @@
 [
 .B --sniff
 ]
+.B file.opus
+[
+.B file2.opus ...
+]
 
 .SH DESCRIPTION
 
@@ -21,9 +25,7 @@
 Demonstration tool for sending and receiving Opus audio data in RTP,
 used for interactive applications on the internet.
 
-Currently the
-.B --sniff
-mode is all that's implemented.
+By default, Opus audio from each given file is sent as an RTP stream.
 
 .SH "OPTIONS"
 .IP "-h, --help"
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -506,7 +506,7 @@
   return ret;
 }
 
-int rtp_test(void)
+int rtp_send_file(const char *filename)
 {
   rtp_header rtp;
   int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -540,7 +540,6 @@
   rtp.header_size = 0;
   rtp.payload_size = 0;
 
-  const char *filename = "rtpdump.opus";
   fprintf(stderr, "Sending %s...\n", filename);
   FILE *in = fopen(filename, "rb");
   ogg_sync_state oy;
@@ -835,14 +834,16 @@
 
 void usage(char *exe)
 {
-  printf("Usage: %s [--sniff]\n", exe);
+  printf("Usage: %s [--sniff] <file.opus> [<file2.opus>]\n", exe);
   printf("\n");
-  printf("Receives Opus audio RTP streams.\n");
+  printf("Sends and receives Opus audio RTP streams.\n");
   printf("\nGeneral Options:\n");
   printf(" -h, --help           This help\n");
   printf(" -V, --version        Version information\n");
   printf(" -q, --quiet          Suppress status output\n");
   printf(" --sniff              Sniff and record Opus RTP streams\n");
+  printf("\n");
+  printf("By default, the given file(s) will be sent over RTP.\n");
 }
 
 int main(int argc, char *argv[])
@@ -887,8 +888,12 @@
         return 1;
     }
   }
+  argc -= i;
+  argv += i;
 
-  rtp_test();
+  for (i = 1; i < argc; i++) {
+    rtp_send_file(argv[i]);
+  }
 
   return 0;
 }