aboutsummaryrefslogtreecommitdiffstats
path: root/src/EDISender.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-05-06 15:24:49 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-05-06 15:24:49 +0200
commit44e414f0aad8e98e5187baf190412e164ff9942e (patch)
tree08e37375436daff36d4462fd85f14f869dcf4cec /src/EDISender.h
parentd633c266b24f4eada1ed0cf8821b572980ae1b2f (diff)
downloadODR-EDI2EDI-44e414f0aad8e98e5187baf190412e164ff9942e.tar.gz
ODR-EDI2EDI-44e414f0aad8e98e5187baf190412e164ff9942e.tar.bz2
ODR-EDI2EDI-44e414f0aad8e98e5187baf190412e164ff9942e.zip
Add and integrate EDISender from zmq2edi
Diffstat (limited to 'src/EDISender.h')
-rw-r--r--src/EDISender.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/EDISender.h b/src/EDISender.h
new file mode 100644
index 0000000..5f053ea
--- /dev/null
+++ b/src/EDISender.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications
+ Research Center Canada)
+
+ Copyright (C) 2020
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://www.opendigitalradio.org
+ */
+/*
+ This file is part of the ODR-mmbTools.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+#include <iostream>
+#include <iterator>
+#include <thread>
+#include <vector>
+#include <chrono>
+#include <atomic>
+#include "ThreadsafeQueue.h"
+#include "edioutput/TagItems.h"
+#include "edioutput/TagPacket.h"
+#include "edioutput/Transport.h"
+#include "edi/common.hpp"
+
+
+struct tagpacket_t {
+ std::vector<uint8_t> tagpacket;
+ EdiDecoder::frame_timestamp_t timestamp;
+ std::chrono::steady_clock::time_point received_at;
+};
+
+class EDISender {
+ public:
+ EDISender() = default;
+ EDISender(const EDISender& other) = delete;
+ EDISender& operator=(const EDISender& other) = delete;
+ ~EDISender();
+ void start(const edi::configuration_t& conf,
+ int delay_ms, bool drop_late_packets);
+ void push_tagpacket(tagpacket_t&& tagpacket);
+ void print_configuration(void);
+
+ private:
+ void send_tagpacket(tagpacket_t& frame);
+ void process(void);
+
+ int tist_delay_ms;
+ bool drop_late;
+ std::atomic<bool> running;
+ std::thread process_thread;
+ edi::configuration_t edi_conf;
+ ThreadsafeQueue<tagpacket_t> tagpackets;
+
+ std::shared_ptr<edi::Sender> edi_sender;
+
+ struct buffering_stat_t {
+ // Time between when we received the packets and when we transmit packets, in microseconds
+ double buffering_time_us = 0.0;
+ bool late = false;
+ };
+ std::vector<buffering_stat_t> buffering_stats;
+
+};