aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-08-01 11:03:38 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-08-01 11:03:38 +0200
commit47033e0ba1377cee310490587b87490249d9b510 (patch)
tree281fbe2215b4479a551b40b6b150c768821e0736
parentaa84bda648f5b74625e3a54ea98788f49481beba (diff)
downloaddabmux-47033e0ba1377cee310490587b87490249d9b510.tar.gz
dabmux-47033e0ba1377cee310490587b87490249d9b510.tar.bz2
dabmux-47033e0ba1377cee310490587b87490249d9b510.zip
Add option to pad TAGPacket in different ways
-rw-r--r--doc/example.mux6
-rw-r--r--src/DabMultiplexer.cpp2
-rw-r--r--src/DabMux.cpp20
-rw-r--r--src/dabOutput/dabOutput.h1
-rw-r--r--src/dabOutput/edi/TagItems.cpp20
-rw-r--r--src/dabOutput/edi/TagItems.h13
-rw-r--r--src/dabOutput/edi/TagPacket.cpp21
-rw-r--r--src/dabOutput/edi/TagPacket.h4
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<boost::shared_ptr<DabOutput> >& outpu
map<dabSubchannel*, TagESTn*> 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<string>("destination");
- edi_conf.dest_port = pt_edi.get<unsigned int>("port");
- edi_conf.source_port = pt_edi.get<unsigned int>("sourceport");
+ edi_conf.dest_addr = pt_edi.get<string>("destination");
+ edi_conf.dest_port = pt_edi.get<unsigned int>("port");
+ edi_conf.source_port = pt_edi.get<unsigned int>("sourceport");
- edi_conf.dump = pt_edi.get<bool>("dump");
- edi_conf.enable_pft = pt_edi.get<bool>("enable_pft");
- edi_conf.verbose = pt_edi.get<bool>("verbose");
+ edi_conf.dump = pt_edi.get<bool>("dump");
+ edi_conf.enable_pft = pt_edi.get<bool>("enable_pft");
+ edi_conf.verbose = pt_edi.get<bool>("verbose");
- edi_conf.fec = pt_edi.get<unsigned int>("fec");
- edi_conf.chunk_len = pt_edi.get<unsigned int>("chunk_len", 207);
+ edi_conf.fec = pt_edi.get<unsigned int>("fec", 3);
+ edi_conf.chunk_len = pt_edi.get<unsigned int>("chunk_len", 207);
+
+ edi_conf.tagpacket_alignment = pt_edi.get<unsigned int>("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<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