aboutsummaryrefslogtreecommitdiffstats
path: root/src/dabOutput/dabOutputZMQ.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-07-28 11:17:24 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-07-28 11:17:24 +0200
commit9aee86aace7d6c504b410c972d0ab5065f7f7b94 (patch)
tree41390a781e3899f4f0827012891e2ad3d208366b /src/dabOutput/dabOutputZMQ.cpp
parentc49acf830b68d25dbb18ed3e74683cba89187626 (diff)
downloaddabmux-9aee86aace7d6c504b410c972d0ab5065f7f7b94.tar.gz
dabmux-9aee86aace7d6c504b410c972d0ab5065f7f7b94.tar.bz2
dabmux-9aee86aace7d6c504b410c972d0ab5065f7f7b94.zip
Add edi time and utco as ZMQ metadata
Since ODR-DabMod doesn't check the zmq message length, it will accept additional metadata at the end of the ETI data
Diffstat (limited to 'src/dabOutput/dabOutputZMQ.cpp')
-rw-r--r--src/dabOutput/dabOutputZMQ.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/dabOutput/dabOutputZMQ.cpp b/src/dabOutput/dabOutputZMQ.cpp
index 6a9d669..582af80 100644
--- a/src/dabOutput/dabOutputZMQ.cpp
+++ b/src/dabOutput/dabOutputZMQ.cpp
@@ -88,19 +88,28 @@ int DabOutputZMQ::Write(void* buffer, int size)
if (zmq_message_ix == NUM_FRAMES_PER_ZMQ_MESSAGE) {
// Size of the header:
- int full_length = ZMQ_DAB_MESSAGE_HEAD_LENGTH;
+ size_t full_length = ZMQ_DAB_MESSAGE_HEAD_LENGTH;
for (int i = 0; i < NUM_FRAMES_PER_ZMQ_MESSAGE; i++) {
full_length += zmq_message.buflen[i];
}
- zmq_message_ix = 0;
+ vector<uint8_t> msg(full_length);
+ memcpy(msg.data(), (uint8_t*)&zmq_message, full_length);
+
+ // metadata gets appended at the end
+ for (const auto& md : meta_) {
+ vector<uint8_t> md_data(md->getLength());
+ md->write(md_data.data());
+
+ copy(md_data.begin(), md_data.end(), back_inserter(msg));
+ }
const int flags = 0;
- zmq_send(zmq_pub_sock_,
- (uint8_t*)&zmq_message,
- full_length, flags);
+ zmq_send(zmq_pub_sock_, msg.data(), msg.size(), flags);
+ meta_.clear();
+ zmq_message_ix = 0;
for (int i = 0; i < NUM_FRAMES_PER_ZMQ_MESSAGE; i++) {
zmq_message.buflen[i] = -1;
}
@@ -115,5 +124,10 @@ int DabOutputZMQ::Close()
return zmq_close(zmq_pub_sock_);
}
+void DabOutputZMQ::setMetadata(std::shared_ptr<OutputMetadata> &md)
+{
+ meta_.push_back(md);
+}
+
#endif