summaryrefslogtreecommitdiffstats
path: root/src/dabOutput/edi
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-01-26 22:10:29 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-01-26 22:10:29 +0100
commitd4797ace7fcee41d9c9cdf35a3cac54e4c0235db (patch)
treeafa17bd8b9c7cdd2a54d751c84dd947048e8cb3d /src/dabOutput/edi
parenta8dcf5fcb160e94d0fcdb12ac71961c85e1e4599 (diff)
downloaddabmux-d4797ace7fcee41d9c9cdf35a3cac54e4c0235db.tar.gz
dabmux-d4797ace7fcee41d9c9cdf35a3cac54e4c0235db.tar.bz2
dabmux-d4797ace7fcee41d9c9cdf35a3cac54e4c0235db.zip
EDI: write transport header in PFT
Diffstat (limited to 'src/dabOutput/edi')
-rw-r--r--src/dabOutput/edi/PFT.cpp35
-rw-r--r--src/dabOutput/edi/PFT.h10
2 files changed, 38 insertions, 7 deletions
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<uint8_t> > fragments = ProtectAndFragment(af_packet);
vector< vector<uint8_t> > 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<uint8_t>& fragment = fragments[i];
- std::string psync("PF"); // SYNC
+ // Psync
+ std::string psync("PF");
std::vector<uint8_t> 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<uint8_t> RSBlock;
typedef std::vector<uint8_t> 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;