diff options
Diffstat (limited to 'src/dabOutput')
-rw-r--r-- | src/dabOutput/dabOutput.h | 1 | ||||
-rw-r--r-- | src/dabOutput/edi/TagItems.cpp | 20 | ||||
-rw-r--r-- | src/dabOutput/edi/TagItems.h | 13 | ||||
-rw-r--r-- | src/dabOutput/edi/TagPacket.cpp | 21 | ||||
-rw-r--r-- | src/dabOutput/edi/TagPacket.h | 4 |
5 files changed, 55 insertions, 4 deletions
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<uint8_t> TagESTn::Assemble() */ return packet; } + +std::vector<uint8_t> TagStarDMY::Assemble() +{ + std::string pack_data("*dmy"); + std::vector<uint8_t> 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<uint8_t> 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 <stdint.h> #include <cassert> +TagPacket::TagPacket(unsigned int alignment) : m_alignment(alignment) +{ } std::vector<uint8_t> TagPacket::Assemble() { @@ -49,10 +51,21 @@ std::vector<uint8_t> 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<uint8_t> Assemble(); std::list<TagItem*> tag_items; + + private: + unsigned int m_alignment; }; #endif |