--- a/mpd2src/mpd2sc.cpp
+++ b/mpd2src/mpd2sc.cpp
@@ -43,6 +43,8 @@
#include <OpenHome/Private/Env.h>
#include <cstring>
+#include <fstream>
+#include <iostream>
#include <vector>
#include <stdio.h>
#include <unistd.h>
@@ -479,6 +481,7 @@
" -f, --file, [file] file name to read and send.\n"
" Use xx.wav for an actual wav,\n"
" xx or xx.fifo for a fifo, stdin for stdin.\n"
+" -o, --output, [output] file name to write uri and metadata.\n"
" -l, --latency, [latency] latency in ms.\n"
" -m, --multicast, [multicast] use multicast instead of unicast.\n"
" -p, --pace, Use internal timer to pace source. Implicit for regular files.\n"
@@ -513,6 +516,7 @@
{"channel", required_argument, 0, 'c'},
{"disabled", 0, 0, 'd'},
{"file", required_argument, 0, 'f'},
+ {"output", required_argument, 0, 'o'},
{"latency", required_argument, 0, 'l'},
{"multicast", 0, 0, 'm'},
{"name", required_argument, 0, 'n'},
@@ -528,8 +532,9 @@
int ret;
(void)op_flags;
string audioparams, sfile, sname("Openhome WavSender"), sudn("12345678");
+ string ofile;
unsigned int adaptidx(0), channel(0), ttl(1), latency(100);
- while ((ret = getopt_long(argc, argv, "A:a:c:df:l:mn:pt:u:",
+ while ((ret = getopt_long(argc, argv, "A:a:c:df:o:l:mn:pt:u:",
long_options, NULL)) != -1) {
switch (ret) {
case 'A': audioparams = optarg;op_flags |= OPT_A; break;
@@ -537,6 +542,7 @@
case 'c': channel = atoi(optarg);op_flags |= OPT_c; break;
case 'd': op_flags |= OPT_d; break;
case 'f': sfile = optarg;op_flags |= OPT_f; break;
+ case 'o': ofile = optarg; break;
case 'h': Usage(stdout);break;
case 'l': latency = atoi(optarg); op_flags |= OPT_l; break;
case 'm': op_flags |= OPT_m; break;
@@ -630,10 +636,15 @@
string uri((const char*)suri.Ptr(), suri.Bytes());
const Brx& smeta(sender->SenderMetadata());
string meta((const char*)smeta.Ptr(), smeta.Bytes());
- cout << "URI " << UPnPP::base64_encode(uri) <<
- " METADATA " << UPnPP::base64_encode(meta) << endl;
-// cout << "URI " << uri << " METADATA " << meta << endl;
- cout.flush();
+
+ ostream* fp = &cout;
+ ofstream fout;
+ if (!ofile.empty()) {
+ fout.open(ofile);
+ fp = &fout;
+ }
+ *fp << "URI " << UPnPP::base64_encode(uri) <<
+ " METADATA " << UPnPP::base64_encode(meta) << endl << flush;
signal(SIGUSR1, sigcatcher);
signal(SIGINT, sigcatcher);