aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 12:37:39 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 12:37:39 +0200
commit1e2a3730e9833f4bac850f89e552f023b7eec3f1 (patch)
tree719fb8330640072a31762af6b7a0391c08fd0af2
parent86659b51355c4eade8124a90afc5995f2765fc41 (diff)
downloadtoolame-dab-1e2a3730e9833f4bac850f89e552f023b7eec3f1.tar.gz
toolame-dab-1e2a3730e9833f4bac850f89e552f023b7eec3f1.tar.bz2
toolame-dab-1e2a3730e9833f4bac850f89e552f023b7eec3f1.zip
accept a list of ZMQ endpoints, separated by semicolons
-rw-r--r--README7
-rw-r--r--toolame.c2
-rw-r--r--zmqoutput.c28
-rw-r--r--zmqoutput.h5
4 files changed, 34 insertions, 8 deletions
diff --git a/README b/README
index 4acc34d..86ffe85 100644
--- a/README
+++ b/README
@@ -42,7 +42,7 @@ See http://opendigitalradio.org
INSTALLATION
*********************
-0. install zeromq 4.0.3 and JACK
+0. install zeromq 4.0.3 or newer and JACK
1. edit Makefile
maybe change the architecture type (ARCH) to suit your machine.
2. 'make'
@@ -66,7 +66,10 @@ Output
file is automatically renamed from *.* to *.mp2
for stdout use a -
for zeromq use tcp://<hostname>:<port> pointing to
- a ODR-DabMux
+ a ODR-DabMux. You can put more than one endpoint,
+ separated by a semicolon. Mind that the shell might
+ interpret the semicolon: use quotes around the list
+ of endpoints to avoid this.
Input Options
-s [int]
diff --git a/toolame.c b/toolame.c
index 41c5dc7..68440d8 100644
--- a/toolame.c
+++ b/toolame.c
@@ -693,6 +693,8 @@ void usage (void)
"\tinput input sound file. (WAV,AIFF,PCM or use '/dev/stdin')\n");
fprintf (stdout, "\toutput output bit stream of encoded audio\n");
fprintf (stdout, "\t prefix with tcp:// to use a ZMQ output\n");
+ fprintf (stdout, "\t Several ZMQ destinations can be given,\n");
+ fprintf (stdout, "\t separated by semicolons.\n");
fprintf (stdout,
"\n\tAllowable bitrates for 16, 22.05 and 24kHz sample input\n");
fprintf (stdout,
diff --git a/zmqoutput.c b/zmqoutput.c
index 1345bfd..03007cc 100644
--- a/zmqoutput.c
+++ b/zmqoutput.c
@@ -22,7 +22,7 @@ void zmqoutput_set_peaks(int left, int right)
zmq_peak_right = right;
}
-int zmqoutput_open(Bit_stream_struc *bs, char* uri)
+int zmqoutput_open(Bit_stream_struc *bs, const char* uri_list)
{
zmq_context = zmq_ctx_new();
bs->zmq_sock = zmq_socket(zmq_context, ZMQ_PUB);
@@ -31,12 +31,30 @@ int zmqoutput_open(Bit_stream_struc *bs, char* uri)
zmq_strerror(errno));
return -1;
}
- if (zmq_connect(bs->zmq_sock, uri) != 0) {
- fprintf(stderr, "Error occurred during zmq_connect: %s\n",
- zmq_strerror(errno));
- return -1;
+
+ char* uris = strdup(uri_list);
+ char* saveptr = NULL;
+
+ for (; ; uris = NULL) {
+ char* uri = strtok_r(uris, ";", &saveptr);
+
+
+ if (uri) {
+ fprintf(stderr, "Connecting ZMQ to %s\n", uri);
+ if (zmq_connect(bs->zmq_sock, uri) != 0) {
+ fprintf(stderr, "Error occurred during zmq_connect: %s\n",
+ zmq_strerror(errno));
+ free(uris);
+ return -1;
+ }
+ }
+ else {
+ break;
+ }
}
+ free(uris);
+
zmqbuf = (unsigned char*)malloc(bs->zmq_framesize);
if (zmqbuf == NULL) {
fprintf(stderr, "Unable to allocate ZMQ buffer\n");
diff --git a/zmqoutput.h b/zmqoutput.h
index 36b8e9b..7f4eb59 100644
--- a/zmqoutput.h
+++ b/zmqoutput.h
@@ -22,7 +22,10 @@ struct zmq_frame_header
} __attribute__ ((packed));
-int zmqoutput_open(Bit_stream_struc * bs, char* uri);
+/* Open the zmq socket and connect it to all URIs in the list.
+ * The URIs are semicolon delimited
+ */
+int zmqoutput_open(Bit_stream_struc * bs, const char* uri_list);
int zmqoutput_write_byte(Bit_stream_struc *bs, unsigned char data);