summaryrefslogtreecommitdiffstats
path: root/src/dabOutput/dabOutputZMQ.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-03-26 18:22:56 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-03-26 18:22:56 +0100
commit77b7ee920e74d73178254a8f6d0954df6bd57ee9 (patch)
tree46872cefa78bc0ec21152e8fe6df0ecc6325c3d5 /src/dabOutput/dabOutputZMQ.cpp
parent12f130a487a0119fa9f9fa2da33e0ab19b54cdda (diff)
downloaddabmux-77b7ee920e74d73178254a8f6d0954df6bd57ee9.tar.gz
dabmux-77b7ee920e74d73178254a8f6d0954df6bd57ee9.tar.bz2
dabmux-77b7ee920e74d73178254a8f6d0954df6bd57ee9.zip
Change ZMQ output message format
Diffstat (limited to 'src/dabOutput/dabOutputZMQ.cpp')
-rw-r--r--src/dabOutput/dabOutputZMQ.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/dabOutput/dabOutputZMQ.cpp b/src/dabOutput/dabOutputZMQ.cpp
index cbb3445..ac26403 100644
--- a/src/dabOutput/dabOutputZMQ.cpp
+++ b/src/dabOutput/dabOutputZMQ.cpp
@@ -2,9 +2,11 @@
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2013 Matthias P. Braendli
+ Copyright (C) 2013, 2014 Matthias P. Braendli
http://mpb.li
+ http://opendigitalradio.org
+
ZeroMQ output. see www.zeromq.org for more info
From the ZeroMQ manpage 'zmq':
@@ -66,9 +68,40 @@ int DabOutputZMQ::Open(const char* endpoint)
int DabOutputZMQ::Write(void* buffer, int size)
{
- int flags = 0;
+ int offset = 0;
+
+ for (int i = 0; i < zmq_message_ix; i++) {
+ offset += zmq_message.buflen[i];
+ }
+
+ if (offset + size > NUM_FRAMES_PER_ZMQ_MESSAGE*6144) {
+ throw std::runtime_error("FAULT: invalid ETI frame size!");
+ }
+ memcpy(zmq_message.buf + offset, buffer, size);
+ zmq_message.buflen[zmq_message_ix] = size;
+ zmq_message_ix++;
+
+ if (zmq_message_ix == NUM_FRAMES_PER_ZMQ_MESSAGE) {
+ int full_length = 0;
+
+ for (int i = 0; i < NUM_FRAMES_PER_ZMQ_MESSAGE; i++) {
+ full_length += zmq_message.buflen[i];
+ }
- return zmq_send(zmq_pub_sock_, buffer, size, flags);
+ zmq_message_ix = 0;
+
+ const int flags = 0;
+ zmq_send(zmq_pub_sock_,
+ (uint8_t*)&zmq_message,
+ NUM_FRAMES_PER_ZMQ_MESSAGE * sizeof(*zmq_message.buflen) +
+ full_length, flags);
+
+ for (int i = 0; i < NUM_FRAMES_PER_ZMQ_MESSAGE; i++) {
+ zmq_message.buflen[i] = -1;
+ }
+ }
+
+ return size;
}
@@ -78,3 +111,4 @@ int DabOutputZMQ::Close()
}
#endif
+