From ea5594186bafa5489d6086a26d71b8f3d1ccf9cd Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 13 Jan 2017 11:53:15 +0100 Subject: Add threaded UDP input for EDI --- src/EtiReader.h | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src/EtiReader.h') diff --git a/src/EtiReader.h b/src/EtiReader.h index cd04a16..1b75025 100644 --- a/src/EtiReader.h +++ b/src/EtiReader.h @@ -2,7 +2,7 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2017 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -38,29 +38,40 @@ #include "TimestampDecoder.h" #include "lib/edi/ETIDecoder.hpp" #include "lib/UdpSocket.h" +#include "ThreadsafeQueue.h" #include #include #include #include - +/* The modulator uses this interface to get the necessary multiplex data, + * either from an ETI or an EDI source. + */ class EtiSource { public: + /* Get the DAB Transmission Mode. Valid values: 1, 2, 3 or 4 */ virtual unsigned getMode() = 0; + + /* Get the current Frame Phase */ virtual unsigned getFp() = 0; + /* Returns true if we have valid time stamps in the ETI*/ virtual bool sourceContainsTimestamp() = 0; virtual void calculateTimestamp(struct frame_timestamp& ts) = 0; + /* Return the FIC source to be used for modulation */ virtual std::shared_ptr& getFic(void); + + /* Return all subchannel sources containing MST data */ virtual const std::vector > getSubchannels() const = 0; protected: std::shared_ptr myFicSource; }; +/* The EtiReader extracts the necessary data for modulation from an ETI(NI) byte stream. */ class EtiReader : public EtiSource { public: @@ -72,25 +83,22 @@ public: virtual unsigned getFp(); /* Read ETI data from dataIn. Returns the number of bytes - * read from the buffer + * read from the buffer. */ int loadEtiData(const Buffer& dataIn); + virtual bool sourceContainsTimestamp(); virtual void calculateTimestamp(struct frame_timestamp& ts) { myTimestampDecoder.calculateTimestamp(ts); } - /* Returns true if we have valid time stamps in the ETI*/ - virtual bool sourceContainsTimestamp(); - virtual const std::vector > getSubchannels() const; private: /* Transform the ETI TIST to a PPS offset in units of 1/16384000 s */ uint32_t getPPSOffset(); - void sync(); int state; uint32_t nb_frames; uint16_t framesize; @@ -108,6 +116,9 @@ private: std::vector > mySources; }; +/* The EdiReader extracts the necessary data using the EDI input library in + * lib/edi + */ class EdiReader : public EtiSource, public EdiDecoder::DataCollector { public: @@ -147,7 +158,7 @@ public: virtual void add_subchannel(const EdiDecoder::eti_stc_data& stc); - // Tell the ETIWriter that the AFPacket is complete + // Gets called by the EDI library to tell us that all data for a frame was given to us virtual void assemble(void); private: bool m_proto_valid = false; @@ -172,11 +183,15 @@ private: std::map > m_sources; }; +/* The EDI input does not use the inputs defined in InputReader.h, as they were designed + * for ETI. It uses the EdiUdpInput which in turn uses a threaded receiver. + */ + class EdiUdpInput { public: EdiUdpInput(EdiDecoder::ETIDecoder& decoder); - int Open(const std::string& uri); + void Open(const std::string& uri); bool isEnabled(void) const { return m_enabled; } @@ -190,7 +205,7 @@ class EdiUdpInput { bool m_enabled; int m_port; - UdpSocket m_sock; + UdpReceiver m_udp_rx; EdiDecoder::ETIDecoder& m_decoder; }; -- cgit v1.2.3