summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-02-28 11:06:56 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-02-28 17:49:36 +0100
commit8d01f90791b1dfd152f91a021422d4d2c2f1be46 (patch)
tree8ed373848955925771b60d65e36ebf0be8932008
parentaa5ad55fdb730c96919cc3ff265d1f72af29c16f (diff)
downloaddabmux-8d01f90791b1dfd152f91a021422d4d2c2f1be46.tar.gz
dabmux-8d01f90791b1dfd152f91a021422d4d2c2f1be46.tar.bz2
dabmux-8d01f90791b1dfd152f91a021422d4d2c2f1be46.zip
Move watermark to FIG0/1 in new carousel
-rw-r--r--src/fig/FIG0.cpp113
-rw-r--r--src/fig/FIG0.h11
2 files changed, 75 insertions, 49 deletions
diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp
index 1e29ca5..fbe231e 100644
--- a/src/fig/FIG0.cpp
+++ b/src/fig/FIG0.cpp
@@ -3,7 +3,7 @@
2011, 2012 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2015
+ Copyright (C) 2015, 2016
Matthias P. Braendli, matthias.braendli@mpb.li
Implementation of FIG0
@@ -67,8 +67,37 @@ FillStatus FIG0_0::fill(uint8_t *buf, size_t max_size)
FIG0_1::FIG0_1(FIGRuntimeInformation *rti) :
m_rti(rti),
- m_initialised(false)
+ m_initialised(false),
+ m_watermarkSize(0),
+ m_watermarkPos(0)
{
+ uint8_t buffer[sizeof(m_watermarkData) / 2];
+ snprintf((char*)buffer, sizeof(buffer),
+ "%s %s, %s %s",
+ PACKAGE_NAME,
+#if defined(GITVERSION)
+ GITVERSION,
+#else
+ PACKAGE_VERSION,
+#endif
+ __DATE__, __TIME__);
+
+ memset(m_watermarkData, 0, sizeof(m_watermarkData));
+ m_watermarkData[0] = 0x55; // Sync
+ m_watermarkData[1] = 0x55;
+ m_watermarkSize = 16;
+ for (unsigned i = 0; i < strlen((char*)buffer); ++i) {
+ for (int j = 0; j < 8; ++j) {
+ uint8_t bit = (buffer[m_watermarkPos >> 3] >> (7 - (m_watermarkPos & 0x07))) & 1;
+ m_watermarkData[m_watermarkSize >> 3] |= bit << (7 - (m_watermarkSize & 0x07));
+ ++m_watermarkSize;
+ bit = 1;
+ m_watermarkData[m_watermarkSize >> 3] |= bit << (7 - (m_watermarkSize & 0x07));
+ ++m_watermarkSize;
+ ++m_watermarkPos;
+ }
+ }
+ m_watermarkPos = 0;
}
FillStatus FIG0_1::fill(uint8_t *buf, size_t max_size)
@@ -76,23 +105,43 @@ FillStatus FIG0_1::fill(uint8_t *buf, size_t max_size)
FillStatus fs;
size_t remaining = max_size;
+ const int watermark_bit = (m_watermarkData[m_watermarkPos >> 3] >>
+ (7 - (m_watermarkPos & 0x07))) & 1;
+
+ const bool iterate_forward = (watermark_bit == 1);
+
+ etiLog.level(debug) << "FIG0/1 forward " << iterate_forward;
+
if (not m_initialised) {
- subchannelFIG0_1 = m_rti->ensemble->subchannels.end();
m_initialised = true;
+ etiLog.level(debug) << "FIG0/1 init";
+
+ subchannels = m_rti->ensemble->subchannels;
+
+ if (not iterate_forward) {
+ std::reverse(subchannels.begin(), subchannels.end());
+ }
+ subchannelFIG0_1 = subchannels.begin();
}
if (max_size < 6) {
return fs;
}
- auto ensemble = m_rti->ensemble;
-
FIGtype0_1 *figtype0_1 = NULL;
+ etiLog.level(debug) << "FIG0/1 start at " <<
+ std::distance(subchannels.begin(), subchannelFIG0_1) <<
+ " uid " << (*subchannelFIG0_1)->uid;
+
// Rotate through the subchannels until there is no more
// space in the FIG0/1
- for (; subchannelFIG0_1 != ensemble->subchannels.end();
- ++subchannelFIG0_1) {
+ for (; subchannelFIG0_1 != subchannels.end(); ++subchannelFIG0_1 ) {
+
+ etiLog.level(debug) << "FIG0/1 insert " <<
+ std::distance(subchannels.begin(), subchannelFIG0_1) <<
+ " uid " << (*subchannelFIG0_1)->uid;
+
dabProtection* protection = &(*subchannelFIG0_1)->protection;
if (figtype0_1 == NULL) {
@@ -162,11 +211,20 @@ FillStatus FIG0_1::fill(uint8_t *buf, size_t max_size)
}
}
- if (subchannelFIG0_1 == ensemble->subchannels.end()) {
- subchannelFIG0_1 = ensemble->subchannels.begin();
+ if (subchannelFIG0_1 == subchannels.end()) {
+ m_initialised = false;
fs.complete_fig_transmitted = true;
+
+ m_watermarkPos++;
+ if (m_watermarkPos == m_watermarkSize) {
+ m_watermarkPos = 0;
+ }
+
+ etiLog.level(debug) << "FIG0/1 done, new watermark pos " << m_watermarkPos;
}
+ etiLog.level(debug) << "FIG0/1 quit, wrote " << max_size - remaining;
+
fs.num_bytes_written = max_size - remaining;
return fs;
}
@@ -633,37 +691,8 @@ FillStatus FIG0_9::fill(uint8_t *buf, size_t max_size)
//=========== FIG 0/10 ===========
FIG0_10::FIG0_10(FIGRuntimeInformation *rti) :
- m_rti(rti),
- m_watermarkSize(0),
- m_watermarkPos(0)
+ m_rti(rti)
{
- uint8_t buffer[sizeof(m_watermarkData) / 2];
- snprintf((char*)buffer, sizeof(buffer),
- "%s %s, compiled at %s, %s",
- PACKAGE_NAME,
-#if defined(GITVERSION)
- GITVERSION,
-#else
- PACKAGE_VERSION,
-#endif
- __DATE__, __TIME__);
-
- memset(m_watermarkData, 0, sizeof(m_watermarkData));
- m_watermarkData[0] = 0x55; // Sync
- m_watermarkData[1] = 0x55;
- m_watermarkSize = 16;
- for (unsigned i = 0; i < strlen((char*)buffer); ++i) {
- for (int j = 0; j < 8; ++j) {
- uint8_t bit = (buffer[m_watermarkPos >> 3] >> (7 - (m_watermarkPos & 0x07))) & 1;
- m_watermarkData[m_watermarkSize >> 3] |= bit << (7 - (m_watermarkSize & 0x07));
- ++m_watermarkSize;
- bit = 1;
- m_watermarkData[m_watermarkSize >> 3] |= bit << (7 - (m_watermarkSize & 0x07));
- ++m_watermarkSize;
- ++m_watermarkPos;
- }
- }
- m_watermarkPos = 0;
}
FillStatus FIG0_10::fill(uint8_t *buf, size_t max_size)
@@ -697,11 +726,7 @@ FillStatus FIG0_10::fill(uint8_t *buf, size_t max_size)
timeData->tm_mon + 1,
timeData->tm_mday));
fig0_10->LSI = 0;
- fig0_10->ConfInd = (m_watermarkData[m_watermarkPos >> 3] >>
- (7 - (m_watermarkPos & 0x07))) & 1;
- if (++m_watermarkPos == m_watermarkSize) {
- m_watermarkPos = 0;
- }
+ fig0_10->ConfInd = 1;
fig0_10->UTC = 0;
fig0_10->setHours(timeData->tm_hour);
fig0_10->Minutes = timeData->tm_min;
diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h
index 87872eb..927a7f5 100644
--- a/src/fig/FIG0.h
+++ b/src/fig/FIG0.h
@@ -3,7 +3,7 @@
2011, 2012 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2015
+ Copyright (C) 2015, 2016
Matthias P. Braendli, matthias.braendli@mpb.li
*/
/*
@@ -66,7 +66,12 @@ class FIG0_1 : public IFIG
private:
FIGRuntimeInformation *m_rti;
bool m_initialised;
+ std::vector<dabSubchannel*> subchannels;
std::vector<dabSubchannel*>::iterator subchannelFIG0_1;
+
+ uint8_t m_watermarkData[128];
+ size_t m_watermarkSize;
+ size_t m_watermarkPos;
};
// FIG type 0/2, MCI, Service Organization, one instance of
@@ -159,10 +164,6 @@ class FIG0_10 : public IFIG
private:
FIGRuntimeInformation *m_rti;
-
- uint8_t m_watermarkData[128];
- size_t m_watermarkSize;
- size_t m_watermarkPos;
};
// FIG type 0/13