aboutsummaryrefslogtreecommitdiffstats
path: root/src/fig
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-08-07 10:05:33 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-08-07 10:05:33 +0200
commit8f347e6eeb809cd51a561768619e0a64c86a469e (patch)
tree0e20aeccbb33aafc07d50abfe9f129de33c108f9 /src/fig
parent43c436d9150057019cfb2638f076ab1fe09266b8 (diff)
downloaddabmux-8f347e6eeb809cd51a561768619e0a64c86a469e.tar.gz
dabmux-8f347e6eeb809cd51a561768619e0a64c86a469e.tar.bz2
dabmux-8f347e6eeb809cd51a561768619e0a64c86a469e.zip
Add FIG FillStatus
Diffstat (limited to 'src/fig')
-rw-r--r--src/fig/FIG.h15
-rw-r--r--src/fig/FIG0.cpp42
-rw-r--r--src/fig/FIG0.h10
-rw-r--r--src/fig/FIGCarousel.cpp38
-rw-r--r--src/fig/FIGCarousel.h2
5 files changed, 77 insertions, 30 deletions
diff --git a/src/fig/FIG.h b/src/fig/FIG.h
index 4e6c20f..7f6e499 100644
--- a/src/fig/FIG.h
+++ b/src/fig/FIG.h
@@ -73,10 +73,23 @@ inline int rate_increment_ms(FIG_rate rate)
return 1000; //some default value, shouldn't be used
}
+/* The fill function of each FIG shall return a status telling
+ * the carousel how many bytes have been written, and if the complete
+ * set of information from that FIG was transmitted.
+ */
+struct FillStatus
+{
+ FillStatus() :
+ num_bytes_written(0),
+ complete_fig_transmitted(false) {}
+ size_t num_bytes_written;
+ bool complete_fig_transmitted;
+};
+
class IFIG
{
public:
- virtual size_t fill(uint8_t *buf, size_t max_size) = 0;
+ virtual FillStatus fill(uint8_t *buf, size_t max_size) = 0;
virtual FIG_rate repetition_rate(void) = 0;
diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp
index 458116e..f738a46 100644
--- a/src/fig/FIG0.cpp
+++ b/src/fig/FIG0.cpp
@@ -32,10 +32,13 @@
//=========== FIG 0/0 ===========
-size_t FIG0_0::fill(uint8_t *buf, size_t max_size)
+FillStatus FIG0_0::fill(uint8_t *buf, size_t max_size)
{
+ FillStatus fs;
+
if (max_size < 6) {
- return 0;
+ fs.num_bytes_written = 0;
+ return fs;
}
FIGtype0_0 *fig0_0;
@@ -54,7 +57,9 @@ size_t FIG0_0::fill(uint8_t *buf, size_t max_size)
fig0_0->CIFcnt_hight = (m_rti->currentFrame / 250) % 20;
fig0_0->CIFcnt_low = (m_rti->currentFrame % 250);
- return 6;
+ fs.complete_fig_transmitted = true;
+ fs.num_bytes_written = 6;
+ return fs;
}
@@ -66,8 +71,9 @@ FIG0_1::FIG0_1(FIGRuntimeInformation *rti) :
{
}
-size_t FIG0_1::fill(uint8_t *buf, size_t max_size)
+FillStatus FIG0_1::fill(uint8_t *buf, size_t max_size)
{
+ FillStatus fs;
size_t remaining = max_size;
if (not m_initialised) {
@@ -75,7 +81,7 @@ size_t FIG0_1::fill(uint8_t *buf, size_t max_size)
}
if (max_size < 6) {
- return 0;
+ return fs;
}
auto ensemble = m_rti->ensemble;
@@ -96,6 +102,7 @@ size_t FIG0_1::fill(uint8_t *buf, size_t max_size)
// space in the FIG0/1
if (subchannelFIG0_1 == ensemble->subchannels.end()) {
subchannelFIG0_1 = ensemble->subchannels.begin();
+ fs.complete_fig_transmitted = true;
}
for (; subchannelFIG0_1 != ensemble->subchannels.end();
@@ -152,7 +159,8 @@ size_t FIG0_1::fill(uint8_t *buf, size_t max_size)
}
}
- return max_size - remaining;
+ fs.num_bytes_written = max_size - remaining;
+ return fs;
}
@@ -164,8 +172,9 @@ FIG0_2::FIG0_2(FIGRuntimeInformation *rti) :
{
}
-size_t FIG0_2::fill(uint8_t *buf, size_t max_size)
+FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size)
{
+ FillStatus fs;
FIGtype0_2 *fig0_2 = NULL;
int cur = 0;
ssize_t remaining = max_size;
@@ -180,6 +189,7 @@ size_t FIG0_2::fill(uint8_t *buf, size_t max_size)
// space
if (serviceFIG0_2 == ensemble->services.end()) {
serviceFIG0_2 = ensemble->services.begin();
+ fs.complete_fig_transmitted = true;
}
for (; serviceFIG0_2 != ensemble->services.end();
@@ -316,7 +326,8 @@ size_t FIG0_2::fill(uint8_t *buf, size_t max_size)
++curCpnt;
}
}
- return max_size - remaining;
+ fs.num_bytes_written = max_size - remaining;
+ return fs;
}
@@ -327,8 +338,9 @@ FIG0_3::FIG0_3(FIGRuntimeInformation *rti) :
{
}
-size_t FIG0_3::fill(uint8_t *buf, size_t max_size)
+FillStatus FIG0_3::fill(uint8_t *buf, size_t max_size)
{
+ FillStatus fs;
ssize_t remaining = max_size;
auto ensemble = m_rti->ensemble;
@@ -398,7 +410,9 @@ size_t FIG0_3::fill(uint8_t *buf, size_t max_size)
}
}
- return max_size - remaining;
+ fs.num_bytes_written = max_size - remaining;
+ fs.complete_fig_transmitted = true;
+ return fs;
}
//=========== FIG 0/17 ===========
@@ -409,8 +423,9 @@ FIG0_17::FIG0_17(FIGRuntimeInformation *rti) :
{
}
-size_t FIG0_17::fill(uint8_t *buf, size_t max_size)
+FillStatus FIG0_17::fill(uint8_t *buf, size_t max_size)
{
+ FillStatus fs;
ssize_t remaining = max_size;
if (not m_initialised) {
@@ -423,7 +438,9 @@ size_t FIG0_17::fill(uint8_t *buf, size_t max_size)
if (serviceFIG0_17 == ensemble->services.end()) {
serviceFIG0_17 = ensemble->services.begin();
+ fs.complete_fig_transmitted = true;
}
+
for (; serviceFIG0_17 != ensemble->services.end();
++serviceFIG0_17) {
@@ -478,6 +495,7 @@ size_t FIG0_17::fill(uint8_t *buf, size_t max_size)
}
}
- return max_size - remaining;
+ fs.num_bytes_written = max_size - remaining;
+ return fs;
}
diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h
index 3f02890..d253555 100644
--- a/src/fig/FIG0.h
+++ b/src/fig/FIG0.h
@@ -37,7 +37,7 @@ class FIG0_0 : public IFIG
public:
FIG0_0(FIGRuntimeInformation* rti) :
m_rti(rti) {}
- virtual size_t fill(uint8_t *buf, size_t max_size);
+ virtual FillStatus fill(uint8_t *buf, size_t max_size);
virtual FIG_rate repetition_rate(void) { return FIG_rate::FIG0_0; }
virtual const int figtype(void) const { return 0; }
@@ -53,7 +53,7 @@ class FIG0_1 : public IFIG
{
public:
FIG0_1(FIGRuntimeInformation* rti);
- virtual size_t fill(uint8_t *buf, size_t max_size);
+ virtual FillStatus fill(uint8_t *buf, size_t max_size);
virtual FIG_rate repetition_rate(void) { return FIG_rate::A; }
virtual const int figtype(void) const { return 0; }
@@ -71,7 +71,7 @@ class FIG0_2 : public IFIG
{
public:
FIG0_2(FIGRuntimeInformation* rti);
- virtual size_t fill(uint8_t *buf, size_t max_size);
+ virtual FillStatus fill(uint8_t *buf, size_t max_size);
virtual FIG_rate repetition_rate(void) { return FIG_rate::A; }
virtual const int figtype(void) const { return 0; }
@@ -90,7 +90,7 @@ class FIG0_3 : public IFIG
{
public:
FIG0_3(FIGRuntimeInformation* rti);
- virtual size_t fill(uint8_t *buf, size_t max_size);
+ virtual FillStatus fill(uint8_t *buf, size_t max_size);
virtual FIG_rate repetition_rate(void) { return FIG_rate::A; }
virtual const int figtype(void) const { return 0; }
@@ -105,7 +105,7 @@ class FIG0_17 : public IFIG
{
public:
FIG0_17(FIGRuntimeInformation* rti);
- virtual size_t fill(uint8_t *buf, size_t max_size);
+ virtual FillStatus fill(uint8_t *buf, size_t max_size);
virtual FIG_rate repetition_rate(void) { return FIG_rate::A; }
virtual const int figtype(void) const { return 0; }
diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp
index 021dd80..e3c49d6 100644
--- a/src/fig/FIGCarousel.cpp
+++ b/src/fig/FIGCarousel.cpp
@@ -105,7 +105,7 @@ void FIGCarousel::allocate_fig_to_fib(int figtype, int extension, int fib)
}
}
-void dumpfib(uint8_t *buf, size_t bufsize) {
+void dumpfib(const uint8_t *buf, size_t bufsize) {
std::cerr << "FIB ";
for (size_t i = 0; i < bufsize; i++) {
std::cerr << boost::format("%02x ") % (unsigned int)buf[i];
@@ -113,13 +113,21 @@ void dumpfib(uint8_t *buf, size_t bufsize) {
std::cerr << std::endl;
}
-size_t FIGCarousel::fib0(uint8_t *fib, const size_t bufsize, int framephase) {
+size_t FIGCarousel::fib0(uint8_t *buf, const size_t bufsize, int framephase) {
+ return carousel(0, buf, bufsize, framephase);
+}
- uint8_t *buf = fib;
+size_t FIGCarousel::carousel(
+ size_t fib,
+ uint8_t *buf,
+ const size_t bufsize,
+ int framephase)
+{
+ uint8_t *pbuf = buf;
- std::list<FIGCarouselElement>& figs = m_fibs[0];
+ std::list<FIGCarouselElement>& figs = m_fibs[fib];
- std::cerr << "fib0(framephase=" << framephase << ")" << std::endl;
+ std::cerr << "fib" << fib << "(framephase=" << framephase << ")" << std::endl;
std::deque<FIGCarouselElement*> sorted_figs;
@@ -158,14 +166,17 @@ size_t FIGCarousel::fib0(uint8_t *fib, const size_t bufsize, int framephase) {
sorted_figs.erase(fig0_0);
if (framephase == 0) { // TODO check for all TM
- size_t written = (*fig0_0)->fig->fill(buf, available_size);
+ FillStatus status = (*fig0_0)->fig->fill(pbuf, available_size);
+ size_t written = status.num_bytes_written;
std::cerr << "Special FIG 0/0 wrote " <<
written << " bytes" << std::endl;
if (written > 0) {
available_size -= written;
- buf += written;
- (*fig0_0)->increase_deadline();
+ pbuf += written;
+ if (status.complete_fig_transmitted) {
+ (*fig0_0)->increase_deadline();
+ }
}
else {
throw std::runtime_error("Failed to write FIG0/0");
@@ -177,22 +188,25 @@ size_t FIGCarousel::fib0(uint8_t *fib, const size_t bufsize, int framephase) {
/* Fill the FIB with the FIGs, taking the earliest deadline first */
while (available_size > 0 and not sorted_figs.empty()) {
auto fig_el = sorted_figs[0];
- size_t written = fig_el->fig->fill(buf, available_size);
+ FillStatus status = fig_el->fig->fill(pbuf, available_size);
+ size_t written = status.num_bytes_written;
std::cerr << " FIG " << fig_el->fig->name() <<
" wrote " << written << " bytes" << std::endl;
if (written > 0) {
available_size -= written;
- buf += written;
+ pbuf += written;
- fig_el->increase_deadline();
+ if (status.complete_fig_transmitted) {
+ fig_el->increase_deadline();
+ }
}
sorted_figs.pop_front();
}
- dumpfib(fib, bufsize);
+ dumpfib(buf, bufsize);
return bufsize - available_size;
}
diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h
index f65bd81..4e91009 100644
--- a/src/fig/FIGCarousel.h
+++ b/src/fig/FIGCarousel.h
@@ -56,6 +56,8 @@ class FIGCarousel {
size_t fib0(uint8_t *buf, size_t bufsize, int framephase);
private:
+ size_t carousel(size_t fib, uint8_t *buf, size_t bufsize, int framephase);
+
FIGRuntimeInformation m_rti;
std::map<std::pair<int, int>, IFIG*> m_figs_available;