diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-05-06 15:04:51 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-05-06 15:04:51 +0200 |
commit | 956814cc526bdd245e52c5004bf5661a57d848cc (patch) | |
tree | 10a4e368432740fc0514ae9d1de572bb1c844768 /src/dabOutput/edi/PFT.cpp | |
parent | 8cb5b3eac1bb669b8828777489d54e9d9057fe6f (diff) | |
download | dabmux-956814cc526bdd245e52c5004bf5661a57d848cc.tar.gz dabmux-956814cc526bdd245e52c5004bf5661a57d848cc.tar.bz2 dabmux-956814cc526bdd245e52c5004bf5661a57d848cc.zip |
EDI: put more code in common between DabMux and ZMQ2EDI
Diffstat (limited to 'src/dabOutput/edi/PFT.cpp')
-rw-r--r-- | src/dabOutput/edi/PFT.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/dabOutput/edi/PFT.cpp b/src/dabOutput/edi/PFT.cpp index 1c885f9..5b93016 100644 --- a/src/dabOutput/edi/PFT.cpp +++ b/src/dabOutput/edi/PFT.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 + Copyright (C) 2019 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -50,6 +50,30 @@ using namespace std; // An integer division that rounds up, i.e. ceil(a/b) #define CEIL_DIV(a, b) (a % b == 0 ? a / b : a / b + 1) +PFT::PFT() { } + +PFT::PFT(const configuration_t &conf) : + m_k(conf.chunk_len), + m_m(conf.fec), + m_dest_port(conf.dest_port), + m_pseq(0), + m_num_chunks(0), + m_verbose(conf.verbose) + { + if (m_k > 207) { + etiLog.level(warn) << + "EDI PFT: maximum chunk size is 207."; + throw std::out_of_range("EDI PFT Chunk size too large."); + } + + if (m_m > 5) { + etiLog.level(warn) << + "EDI PFT: high number of recoverable fragments" + " may lead to large overhead"; + // See TS 102 821, 7.2.1 Known values, list entry for 'm' + } + } + RSBlock PFT::Protect(AFPacket af_packet) { RSBlock rs_block; @@ -98,7 +122,7 @@ RSBlock PFT::Protect(AFPacket af_packet) // Calculate RS for each chunk and assemble RS block for (size_t i = 0; i < af_packet.size(); i+= chunk_len) { vector<uint8_t> chunk(207); - vector<uint8_t> protection(ParityBytes); + vector<uint8_t> protection(PARITYBYTES); // copy chunk_len bytes into new chunk memcpy(&chunk.front(), &af_packet[i], chunk_len); @@ -139,7 +163,7 @@ vector< vector<uint8_t> > PFT::ProtectAndFragment(AFPacket af_packet) #endif // TS 102 821 7.2.2: s_max = MIN(floor(c*p/(m+1)), MTU - h)) - const size_t max_payload_size = ( m_num_chunks * ParityBytes ) / (m_m + 1); + const size_t max_payload_size = ( m_num_chunks * PARITYBYTES ) / (m_m + 1); // Calculate fragment count and size // TS 102 821 7.2.2: ceil((l + c*p + z) / s_max) |