aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-07-18 23:36:16 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-07-18 23:36:16 +0200
commit9d109d386e465dc4ea46159b0a7191ac30454a6d (patch)
tree20ebf9c3283a237d4e6c1536846bdca0c5f4d236
parent9d2beec11b78e44742d8242e0c8da2633a9162cf (diff)
downloaddabmux-9d109d386e465dc4ea46159b0a7191ac30454a6d.tar.gz
dabmux-9d109d386e465dc4ea46159b0a7191ac30454a6d.tar.bz2
dabmux-9d109d386e465dc4ea46159b0a7191ac30454a6d.zip
Use new FIG carousel for FIB0 in DabMultiplexer
-rw-r--r--src/DabMultiplexer.cpp14
-rw-r--r--src/DabMultiplexer.h4
-rw-r--r--src/fig/FIG.h15
-rw-r--r--src/fig/FIGCarousel.cpp35
-rw-r--r--src/fig/FIGCarousel.h2
5 files changed, 46 insertions, 24 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp
index 89c32c2..a44f8b2 100644
--- a/src/DabMultiplexer.cpp
+++ b/src/DabMultiplexer.cpp
@@ -86,11 +86,11 @@ DabMultiplexer::DabMultiplexer(
sync(0x49C5F8),
currentFrame(0),
insertFIG(0),
- rotateFIB(0)
+ rotateFIB(0),
+ ensemble(boost::make_shared<dabEnsemble>()),
+ fig_carousel(ensemble)
{
prepare_watermark();
-
- ensemble = boost::make_shared<dabEnsemble>();
}
void DabMultiplexer::prepare_watermark()
@@ -631,7 +631,13 @@ void DabMultiplexer::mux_frame(std::vector<boost::shared_ptr<DabOutput> >& outpu
unsigned char figSize = 0;
// FIB 0 Insertion
- switch (insertFIG) {
+ bool new_fib0_carousel = m_pt.get("general.new_fib0_carousel", false);
+ if (new_fib0_carousel) {
+ fig_carousel.fib0(&etiFrame[index], 30, currentFrame % 4);
+ }
+ // Skip creating a block for the else because
+ // I don't want to reindent the whole switch block
+ else switch (insertFIG) {
case 0:
case 4:
diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h
index 27cc063..44e9bdb 100644
--- a/src/DabMultiplexer.h
+++ b/src/DabMultiplexer.h
@@ -35,6 +35,7 @@
#include "dabOutput/edi/TagPacket.h"
#include "dabOutput/edi/AFPacket.h"
#include "dabOutput/edi/PFT.h"
+#include "fig/FIGCarousel.h"
#include "crc.h"
#include "utils.h"
#include "UdpSocket.h"
@@ -136,6 +137,9 @@ class DabMultiplexer {
// The AF Packet will be protected with reed-solomon and split in fragments
PFT edi_pft;
#endif // HAVE_OUTPUT_EDI
+
+ /* New FIG Carousel */
+ FIGCarousel fig_carousel;
};
// DAB Mode
diff --git a/src/fig/FIG.h b/src/fig/FIG.h
index 915e5f3..318b788 100644
--- a/src/fig/FIG.h
+++ b/src/fig/FIG.h
@@ -30,11 +30,16 @@
#include <boost/shared_ptr.hpp>
#include "MuxElements.h"
-struct FIGRuntimeInformation {
- unsigned long currentFrame;
- boost::shared_ptr<dabEnsemble> ensemble;
- bool factumAnalyzer;
-
+class FIGRuntimeInformation {
+ public:
+ FIGRuntimeInformation(boost::shared_ptr<dabEnsemble> e) :
+ currentFrame(0),
+ ensemble(e),
+ factumAnalyzer(false) {}
+
+ unsigned long currentFrame;
+ boost::shared_ptr<dabEnsemble> ensemble;
+ bool factumAnalyzer;
};
// Recommended FIG rates according to ETSI TR 101 496-2 Table 3.6.1
diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp
index 2634a32..0e3742c 100644
--- a/src/fig/FIGCarousel.cpp
+++ b/src/fig/FIGCarousel.cpp
@@ -32,11 +32,15 @@
/**************** FIGCarouselElement ****************/
void FIGCarouselElement::reduce_deadline()
{
+#error "Wrong: deadline should decrement identically for all FIGs"
deadline -= rate_increment_ms(fig->repetition_rate());
+ std::cerr << "FIG " << fig->name() <<
+ " deadline: " << deadline << std::endl;
+
if (deadline < 0) {
std::cerr << "FIG " << fig->name() <<
- "has negative scheduling deadline" << std::endl;
+ " has negative scheduling deadline" << std::endl;
}
}
@@ -44,16 +48,13 @@ void FIGCarouselElement::reduce_deadline()
/**************** FIGCarousel *****************/
FIGCarousel::FIGCarousel(boost::shared_ptr<dabEnsemble> ensemble) :
+ m_rti(ensemble),
m_fig0_0(&m_rti),
m_fig0_1(&m_rti),
m_fig0_2(&m_rti),
m_fig0_3(&m_rti),
m_fig0_17(&m_rti)
{
- m_rti.ensemble = ensemble;
- m_rti.currentFrame = 0;
- m_rti.factumAnalyzer = false;
-
m_figs_available[std::make_pair(0, 0)] = &m_fig0_0;
m_figs_available[std::make_pair(0, 1)] = &m_fig0_1;
m_figs_available[std::make_pair(0, 2)] = &m_fig0_2;
@@ -94,9 +95,11 @@ void FIGCarousel::allocate_fig_to_fib(int figtype, int extension, int fib)
}
}
-void FIGCarousel::fib0(int framephase) {
+size_t FIGCarousel::fib0(uint8_t *buf, size_t bufsize, int framephase) {
std::list<FIGCarouselElement> figs = m_fibs[0];
+ std::cerr << "fib0(framephase=" << framephase << ")" << std::endl;
+
std::vector<FIGCarouselElement> sorted_figs;
/* Decrement all deadlines according to the desired repetition rate */
@@ -114,10 +117,7 @@ void FIGCarousel::fib0(int framephase) {
});
/* Data structure to carry FIB */
- const size_t fib_size = 30;
- uint8_t fib_data[fib_size];
- uint8_t *fib_data_current = fib_data;
- size_t available_size = fib_size;
+ size_t available_size = bufsize;
/* Take special care for FIG0/0 */
auto fig0_0 = find_if(sorted_figs.begin(), sorted_figs.end(),
@@ -126,14 +126,15 @@ void FIGCarousel::fib0(int framephase) {
});
if (fig0_0 != sorted_figs.end()) {
+ std::cerr << "Special FIG 0/0" << std::endl;
sorted_figs.erase(fig0_0);
if (framephase == 0) { // TODO check for all TM
- size_t written = fig0_0->fig->fill(fib_data_current, available_size);
+ size_t written = fig0_0->fig->fill(buf, available_size);
if (written > 0) {
available_size -= written;
- fib_data_current += written;
+ buf += written;
}
else {
throw std::runtime_error("Failed to write FIG0/0");
@@ -141,17 +142,23 @@ void FIGCarousel::fib0(int framephase) {
}
}
+ for (auto& fig : sorted_figs) {
+ std::cerr << " FIG:" << fig.fig->name() << std::endl;
+ }
+
/* 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.begin();
- size_t written = fig_el->fig->fill(fib_data_current, available_size);
+ size_t written = fig_el->fig->fill(buf, available_size);
if (written > 0) {
available_size -= written;
- fib_data_current += written;
+ buf += written;
}
sorted_figs.erase(fig_el);
}
+
+ return bufsize - available_size;
}
diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h
index c8a250e..e823bef 100644
--- a/src/fig/FIGCarousel.h
+++ b/src/fig/FIGCarousel.h
@@ -51,7 +51,7 @@ class FIGCarousel {
void allocate_fig_to_fib(int figtype, int extension, int fib);
- void fib0(int framephase);
+ size_t fib0(uint8_t *buf, size_t bufsize, int framephase);
private:
FIGRuntimeInformation m_rti;