diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-08-15 21:44:53 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-08-15 21:45:05 +0200 |
commit | 945a9bb7460dbe84f3ed657bdd718ea91d57b31a (patch) | |
tree | 39e3541c0117247d6a7d1b1ff8db3330ae25be22 /zmqoutput.c | |
parent | 10c98b106dbb7ee90aca745c7c100a43f80fa01e (diff) | |
download | toolame-dab-945a9bb7460dbe84f3ed657bdd718ea91d57b31a.tar.gz toolame-dab-945a9bb7460dbe84f3ed657bdd718ea91d57b31a.tar.bz2 toolame-dab-945a9bb7460dbe84f3ed657bdd718ea91d57b31a.zip |
Switch to new ZMQ frame format
Diffstat (limited to 'zmqoutput.c')
-rw-r--r-- | zmqoutput.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/zmqoutput.c b/zmqoutput.c index cc8937e..6d9db68 100644 --- a/zmqoutput.c +++ b/zmqoutput.c @@ -1,6 +1,7 @@ #include "zmqoutput.h" #include <zmq.h> #include <stdlib.h> +#include <string.h> #include "common.h" static void *zmq_context; @@ -43,7 +44,22 @@ int zmqoutput_write_byte(Bit_stream_struc *bs, unsigned char data) if (zmqbuf_len == bs->zmq_framesize) { - int send_error = zmq_send(bs->zmq_sock, zmqbuf, bs->zmq_framesize, + int frame_length = sizeof(struct zmq_frame_header) + zmqbuf_len; + + struct zmq_frame_header* header = + malloc(frame_length); + + uint8_t* txframe = ((uint8_t*)header) + sizeof(struct zmq_frame_header); + + header->version = 1; + header->encoder = ZMQ_ENCODER_TOOLAME; + header->datasize = zmqbuf_len; + header->audiolevel_left = 0; + header->audiolevel_right = 0; + + memcpy(txframe, zmqbuf, zmqbuf_len); + + int send_error = zmq_send(bs->zmq_sock, txframe, frame_length, ZMQ_DONTWAIT); if (send_error < 0) { |