summaryrefslogtreecommitdiffstats
path: root/src/dabOutput/dabOutputZMQ.cpp
diff options
context:
space:
mode:
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