From d4797ace7fcee41d9c9cdf35a3cac54e4c0235db Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 26 Jan 2015 22:10:29 +0100 Subject: EDI: write transport header in PFT --- src/DabMux.cpp | 2 +- src/DabMux.h | 10 ---------- src/dabOutput/dabOutput.h | 12 ++++++++++++ src/dabOutput/edi/PFT.cpp | 35 +++++++++++++++++++++++++++++++---- src/dabOutput/edi/PFT.h | 10 +++++++--- 5 files changed, 51 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 376e33c..1597a9b 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -728,7 +728,7 @@ int main(int argc, char *argv[]) AFPacketiser edi_afPacketiser(edi_conf.verbose); // The AF Packet will be protected with reed-solomon and split in fragments - PFT edi_pft(207, 3, edi_conf.verbose); + PFT edi_pft(207, 3, edi_conf); /* Each iteration of the main loop creates one ETI frame */ for (currentFrame = 0; running; currentFrame++) { diff --git a/src/DabMux.h b/src/DabMux.h index ed1855e..89868ac 100644 --- a/src/DabMux.h +++ b/src/DabMux.h @@ -66,16 +66,6 @@ #define DEFAULT_SERVICE_ID 50 #define DEFAULT_PACKET_ADDRESS 0 -struct edi_configuration_t { - bool enabled; - unsigned int source_port; - bool dump; - bool verbose; - bool enable_pft; - std::string dest_addr; - unsigned int dest_port; -}; - /***************************************************************************** ***************** Definition of FIG structures **************************** *****************************************************************************/ diff --git a/src/dabOutput/dabOutput.h b/src/dabOutput/dabOutput.h index 108fd3d..18f3848 100644 --- a/src/dabOutput/dabOutput.h +++ b/src/dabOutput/dabOutput.h @@ -53,6 +53,18 @@ # include "zmq.hpp" #endif +// Configuration for EDI output +struct edi_configuration_t { + bool enabled; + unsigned int source_port; + bool dump; + bool verbose; + bool enable_pft; + std::string dest_addr; + unsigned int dest_port; +}; + + // Abstract base class for all outputs class DabOutput { diff --git a/src/dabOutput/edi/PFT.cpp b/src/dabOutput/edi/PFT.cpp index 3352136..e1c8249 100644 --- a/src/dabOutput/edi/PFT.cpp +++ b/src/dabOutput/edi/PFT.cpp @@ -168,6 +168,9 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) vector< vector > fragments = ProtectAndFragment(af_packet); vector< vector > pft_fragments; // These contain PF headers + const bool enable_RS = true; + const bool enable_transport = true; + unsigned int findex = 0; unsigned fcount = fragments.size(); @@ -184,29 +187,53 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) for (size_t i = 0; i < fragments.size(); i++) { const vector& fragment = fragments[i]; - std::string psync("PF"); // SYNC + // Psync + std::string psync("PF"); std::vector packet(psync.begin(), psync.end()); + // Pseq packet.push_back(m_pseq >> 8); packet.push_back(m_pseq & 0xFF); + // Findex packet.push_back(findex >> 16); packet.push_back(findex >> 8); packet.push_back(findex & 0xFF); findex++; + // Fcount packet.push_back(fcount >> 16); packet.push_back(fcount >> 8); packet.push_back(fcount & 0xFF); + // RS (1 bit), transport (1 bit) and Plen (14 bits) unsigned int plen = fragment.size(); - plen |= 0x8000; // Set FEC bit + if (enable_RS) { + plen |= 0x8000; // Set FEC bit + } + + if (enable_transport) { + plen |= 0x4000; // Set ADDR bit + } packet.push_back(plen >> 8); packet.push_back(plen & 0xFF); - packet.push_back(chunk_len); // RSk - packet.push_back(zero_pad); // RSz + if (enable_RS) { + packet.push_back(chunk_len); // RSk + packet.push_back(zero_pad); // RSz + } + + if (enable_transport) { + // Source (16 bits) + uint16_t addr_source = 0; + packet.push_back(addr_source >> 8); + packet.push_back(addr_source & 0xFF); + + // Dest (16 bits) + packet.push_back(m_dest_port >> 8); + packet.push_back(m_dest_port & 0xFF); + } // calculate CRC over AF Header and payload uint16_t crc = 0xffff; diff --git a/src/dabOutput/edi/PFT.h b/src/dabOutput/edi/PFT.h index 1d09c0b..4aae817 100644 --- a/src/dabOutput/edi/PFT.h +++ b/src/dabOutput/edi/PFT.h @@ -39,6 +39,7 @@ #include "AFPacket.h" #include "Log.h" #include "ReedSolomon.h" +#include "dabOutput/dabOutput.h" typedef std::vector RSBlock; typedef std::vector PFTFragment; @@ -49,12 +50,13 @@ class PFT static const int ParityBytes = 48; PFT(unsigned int RSDataWordLength, - unsigned int NumRecoverableFragments, - bool verbose) : + unsigned int NumRecoverableFragments, + const edi_configuration_t &conf) : m_k(RSDataWordLength), m_m(NumRecoverableFragments), + m_dest_port(conf.dest_port), m_pseq(0), - m_verbose(verbose) + m_verbose(conf.verbose) { if (m_k > 207) { etiLog.level(warn) << @@ -84,6 +86,8 @@ class PFT unsigned int m_k; // length of RS data word unsigned int m_m; // number of fragments that can be recovered if lost + unsigned int m_dest_port; // Destination port for transport header + uint16_t m_pseq; size_t m_num_chunks; -- cgit v1.2.3