diff options
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | toolame.c | 2 | ||||
-rw-r--r-- | zmqoutput.c | 28 | ||||
-rw-r--r-- | zmqoutput.h | 5 |
4 files changed, 34 insertions, 8 deletions
@@ -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] @@ -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); |