From 47033e0ba1377cee310490587b87490249d9b510 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 1 Aug 2015 11:03:38 +0200 Subject: Add option to pad TAGPacket in different ways --- doc/example.mux | 6 ++++++ src/DabMultiplexer.cpp | 2 +- src/DabMux.cpp | 20 +++++++++++--------- src/dabOutput/dabOutput.h | 1 + src/dabOutput/edi/TagItems.cpp | 20 ++++++++++++++++++++ src/dabOutput/edi/TagItems.h | 13 +++++++++++++ src/dabOutput/edi/TagPacket.cpp | 21 +++++++++++++++++---- src/dabOutput/edi/TagPacket.h | 4 ++++ 8 files changed, 73 insertions(+), 14 deletions(-) diff --git a/doc/example.mux b/doc/example.mux index 1e6495b..3dd8f17 100644 --- a/doc/example.mux +++ b/doc/example.mux @@ -308,6 +308,12 @@ outputs { ; show more debugging info verbose true + + ; (optional) set the kind of alignment to use in TAG Packets + ; 0: no padding + ; 8: pad to eight bytes (default) + ; above 8: insert *dmy TAG Item to pad to given size in bytes + ;tagpacket_alignment 8 } ; Other outputs: diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index e79d3fa..ccf3594 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -418,7 +418,7 @@ void DabMultiplexer::mux_frame(std::vector >& outpu map edi_subchannelToTag; // The above Tag Items will be assembled into a TAG Packet - TagPacket edi_tagpacket; + TagPacket edi_tagpacket(edi_conf.tagpacket_alignment); edi_tagDETI.atstf = 1; edi_tagDETI.utco = 0; diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 854c311..04aed2b 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -321,18 +321,20 @@ int main(int argc, char *argv[]) #if HAVE_OUTPUT_EDI ptree pt_edi = pt_outputs.get_child("edi"); - edi_conf.enabled = true; + edi_conf.enabled = true; - edi_conf.dest_addr = pt_edi.get("destination"); - edi_conf.dest_port = pt_edi.get("port"); - edi_conf.source_port = pt_edi.get("sourceport"); + edi_conf.dest_addr = pt_edi.get("destination"); + edi_conf.dest_port = pt_edi.get("port"); + edi_conf.source_port = pt_edi.get("sourceport"); - edi_conf.dump = pt_edi.get("dump"); - edi_conf.enable_pft = pt_edi.get("enable_pft"); - edi_conf.verbose = pt_edi.get("verbose"); + edi_conf.dump = pt_edi.get("dump"); + edi_conf.enable_pft = pt_edi.get("enable_pft"); + edi_conf.verbose = pt_edi.get("verbose"); - edi_conf.fec = pt_edi.get("fec"); - edi_conf.chunk_len = pt_edi.get("chunk_len", 207); + edi_conf.fec = pt_edi.get("fec", 3); + edi_conf.chunk_len = pt_edi.get("chunk_len", 207); + + edi_conf.tagpacket_alignment = pt_edi.get("tagpacket_alignment", 8); mux.set_edi_config(edi_conf); #else diff --git a/src/dabOutput/dabOutput.h b/src/dabOutput/dabOutput.h index c8ce9f2..cd48790 100644 --- a/src/dabOutput/dabOutput.h +++ b/src/dabOutput/dabOutput.h @@ -64,6 +64,7 @@ struct edi_configuration_t { bool enable_pft; std::string dest_addr; unsigned int dest_port; + unsigned int tagpacket_alignment; }; diff --git a/src/dabOutput/edi/TagItems.cpp b/src/dabOutput/edi/TagItems.cpp index 2cae7d1..b97721a 100644 --- a/src/dabOutput/edi/TagItems.cpp +++ b/src/dabOutput/edi/TagItems.cpp @@ -171,5 +171,25 @@ std::vector TagESTn::Assemble() */ return packet; } + +std::vector TagStarDMY::Assemble() +{ + std::string pack_data("*dmy"); + std::vector packet(pack_data.begin(), pack_data.end()); + + packet.resize(4 + 4 + length_); + + const uint32_t length_bits = length_ * 8; + + packet[4] = (length_bits >> 24) & 0xFF; + packet[5] = (length_bits >> 16) & 0xFF; + packet[6] = (length_bits >> 8) & 0xFF; + packet[7] = length_bits & 0xFF; + + // The remaining bytes in the packet are "undefined data" + + return packet; +} + #endif diff --git a/src/dabOutput/edi/TagItems.h b/src/dabOutput/edi/TagItems.h index fccea2d..e75d241 100644 --- a/src/dabOutput/edi/TagItems.h +++ b/src/dabOutput/edi/TagItems.h @@ -111,5 +111,18 @@ class TagESTn : public TagItem private: uint8_t id_; }; + +// ETSI TS 102 821, 5.2.2.2 Dummy padding +class TagStarDMY : public TagItem +{ + public: + /* length is the TAG value length in bytes */ + TagStarDMY(uint32_t length) : length_(length) {} + std::vector Assemble(); + + private: + uint32_t length_; +}; + #endif diff --git a/src/dabOutput/edi/TagPacket.cpp b/src/dabOutput/edi/TagPacket.cpp index aa4f23b..435c071 100644 --- a/src/dabOutput/edi/TagPacket.cpp +++ b/src/dabOutput/edi/TagPacket.cpp @@ -33,6 +33,8 @@ #include #include +TagPacket::TagPacket(unsigned int alignment) : m_alignment(alignment) +{ } std::vector TagPacket::Assemble() { @@ -49,10 +51,21 @@ std::vector TagPacket::Assemble() //std::cerr << " Add TAGItem of length " << tag_data.size() << std::endl; } - // Add padding - while (packet.size() % 8 > 0) - { - packet.push_back(0); // TS 102 821, 5.1, "padding shall be undefined" + if (m_alignment == 0) { /* no padding */ } + else if (m_alignment == 8) { + // Add padding inside TAG packet + while (packet.size() % 8 > 0) { + packet.push_back(0); // TS 102 821, 5.1, "padding shall be undefined" + } + } + else if (m_alignment > 8) { + TagStarDMY dmy(m_alignment - 8); + auto dmy_data = dmy.Assemble(); + packet.insert(packet.end(), dmy_data.begin(), dmy_data.end()); + } + else { + std::cerr << "Invalid alignment requirement " << m_alignment << + " defined in TagPacket" << std::endl; } return packet; diff --git a/src/dabOutput/edi/TagPacket.h b/src/dabOutput/edi/TagPacket.h index 9d69226..5ad1904 100644 --- a/src/dabOutput/edi/TagPacket.h +++ b/src/dabOutput/edi/TagPacket.h @@ -42,9 +42,13 @@ class TagPacket { public: + TagPacket(unsigned int alignment); std::vector Assemble(); std::list tag_items; + + private: + unsigned int m_alignment; }; #endif -- cgit v1.2.3