diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DabMultiplexer.cpp | 13 | ||||
-rw-r--r-- | src/fig/FIG0.cpp | 148 | ||||
-rw-r--r-- | src/fig/FIG0.h | 18 | ||||
-rw-r--r-- | src/fig/FIGCarousel.cpp | 4 | ||||
-rw-r--r-- | src/fig/FIGCarousel.h | 4 |
5 files changed, 175 insertions, 12 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index ccf3594..3dbe325 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -631,10 +631,10 @@ void DabMultiplexer::mux_frame(std::vector<boost::shared_ptr<DabOutput> >& outpu unsigned char figSize = 0; // FIB 0 Insertion - bool new_fib0_carousel = m_pt.get("general.new_fib0_carousel", false); - if (new_fib0_carousel) { - // TODO update currentframe in rti - figSize += fig_carousel.fib0(&etiFrame[index], 30, currentFrame % 4); + bool new_fig_carousel = m_pt.get("general.new_fig_carousel", false); + if (new_fig_carousel) { + fig_carousel.set_currentFrame(currentFrame); + figSize += fig_carousel.carousel(0, &etiFrame[index], 30, currentFrame % 4); index += figSize; } // Skip creating a block for the else because @@ -1129,7 +1129,10 @@ void DabMultiplexer::mux_frame(std::vector<boost::shared_ptr<DabOutput> >& outpu figSize = 0; // FIB 1 insertion - switch (rotateFIB) { + if (new_fig_carousel) { + figSize += fig_carousel.carousel(1, &etiFrame[index], 30, currentFrame % 4); + index += figSize; + } else switch (rotateFIB) { case 0: // FIG 0/8 program fig0 = NULL; diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index 36e993a..2beaea0 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -417,6 +417,154 @@ FillStatus FIG0_3::fill(uint8_t *buf, size_t max_size) return fs; } +//=========== FIG 0/8 =========== + +FIG0_8::FIG0_8(FIGRuntimeInformation *rti) : + m_rti(rti), + m_initialised(false) +{ +} + +FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size) +{ + FillStatus fs; + auto ensemble = m_rti->ensemble; + ssize_t remaining = max_size; + + if (not m_initialised) { + componentFIG0_8 = m_rti->ensemble->components.end(); + } + + FIGtype0* fig0 = NULL; + + if (componentFIG0_8 == ensemble->components.end()) { + componentFIG0_8 = ensemble->components.begin(); + fs.complete_fig_transmitted = true; + } + + for (; componentFIG0_8 != ensemble->components.end(); + ++componentFIG0_8) { + auto service = getService(*componentFIG0_8, + ensemble->services); + auto subchannel = getSubchannel(ensemble->subchannels, + (*componentFIG0_8)->subchId); + if (subchannel == ensemble->subchannels.end()) { + etiLog.log(error, + "Subchannel %i does not exist for component " + "of service %i\n", + (*componentFIG0_8)->subchId, + (*componentFIG0_8)->serviceId); + throw MuxInitException(); + } + + if (!(*service)->program) + continue; + + if (fig0 == NULL) { + fig0 = (FIGtype0*)buf; + fig0->FIGtypeNumber = 0; + fig0->Length = 1; + fig0->CN = 0; + fig0->OE = 0; + fig0->PD = 0; + fig0->Extension = 8; + buf += 2; + remaining -= 2; + } + + if ((*service)->program) { + if ((*subchannel)->type == Packet) { // Data packet + if (remaining < 5) { + break; + } + buf[0] = ((*componentFIG0_8)->serviceId >> 8) & 0xFF; + buf[1] = ((*componentFIG0_8)->serviceId) & 0xFF; + fig0->Length += 2; + buf += 2; + remaining -= 2; + + FIGtype0_8_long* definition = (FIGtype0_8_long*)buf; + memset(definition, 0, 3); + definition->ext = 0; // no rfa + definition->SCIdS = (*componentFIG0_8)->SCIdS; + definition->LS = 1; + definition->setSCId((*componentFIG0_8)->packet.id); + fig0->Length += 3; + buf += 3; // 8 minus rfa + remaining -= 3; + } + else { // Audio, data stream or FIDC + if (remaining < 4) { + break; + } + buf[0] = ((*componentFIG0_8)->serviceId >> 8) & 0xFF; + buf[1] = ((*componentFIG0_8)->serviceId) & 0xFF; + + fig0->Length += 2; + buf += 2; + remaining -= 2; + + FIGtype0_8_short* definition = (FIGtype0_8_short*)buf; + memset(definition, 0, 2); + definition->ext = 0; // no rfa + definition->SCIdS = (*componentFIG0_8)->SCIdS; + definition->LS = 0; + definition->MscFic = 0; + definition->Id = (*componentFIG0_8)->subchId; + fig0->Length += 2; + buf += 2; // 4 minus rfa + remaining -= 2; + } + } + else { // Data + if ((*subchannel)->type == Packet) { // Data packet + if (remaining < 7) { + break; + } + buf[0] = ((*componentFIG0_8)->serviceId >> 8) & 0xFF; + buf[1] = ((*componentFIG0_8)->serviceId) & 0xFF; + fig0->Length += 4; + buf += 4; + remaining -= 4; + + FIGtype0_8_long* definition = (FIGtype0_8_long*)buf; + memset(definition, 0, 3); + definition->ext = 0; // no rfa + definition->SCIdS = (*componentFIG0_8)->SCIdS; + definition->LS = 1; + definition->setSCId((*componentFIG0_8)->packet.id); + fig0->Length += 3; + buf += 3; // 8 minus rfa + remaining -= 3; + } + else { // Audio, data stream or FIDC + if (remaining < 6 ) { + break; + } + buf[0] = ((*componentFIG0_8)->serviceId >> 8) & 0xFF; + buf[1] = ((*componentFIG0_8)->serviceId) & 0xFF; + fig0->Length += 4; + buf += 4; + remaining -= 4; + + FIGtype0_8_short* definition = (FIGtype0_8_short*)buf; + memset(definition, 0, 2); + definition->ext = 0; // no rfa + definition->SCIdS = (*componentFIG0_8)->SCIdS; + definition->LS = 0; + definition->MscFic = 0; + definition->Id = (*componentFIG0_8)->subchId; + fig0->Length += 2; + buf += 2; // 4 minus rfa + remaining -= 2; + } + } + } + + fs.num_bytes_written = max_size - remaining; + return fs; +} + //=========== FIG 0/17 =========== FIG0_17::FIG0_17(FIGRuntimeInformation *rti) : diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h index 8797931..57ca317 100644 --- a/src/fig/FIG0.h +++ b/src/fig/FIG0.h @@ -102,6 +102,24 @@ class FIG0_3 : public IFIG FIGRuntimeInformation *m_rti; }; +// FIG type 0/8, MCI, Service Organization, one instance of +// FIGtype0_8_Service for each subchannel +class FIG0_8 : public IFIG +{ + public: + FIG0_8(FIGRuntimeInformation* rti); + virtual FillStatus fill(uint8_t *buf, size_t max_size); + virtual FIG_rate repetition_rate(void) { return FIG_rate::B; } + + virtual const int figtype(void) const { return 0; } + virtual const int figextension(void) const { return 8; } + + private: + FIGRuntimeInformation *m_rti; + bool m_initialised; + std::vector<DabComponent*>::iterator componentFIG0_8; +}; + // FIG type 0/17 class FIG0_17 : public IFIG { diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp index 6a463c7..ce5e7bb 100644 --- a/src/fig/FIGCarousel.cpp +++ b/src/fig/FIGCarousel.cpp @@ -115,10 +115,6 @@ void dumpfib(const uint8_t *buf, size_t bufsize) { std::cerr << std::endl; } -size_t FIGCarousel::fib0(uint8_t *buf, const size_t bufsize, int framephase) { - return carousel(0, buf, bufsize, framephase); -} - size_t FIGCarousel::carousel( size_t fib, uint8_t *buf, diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h index acf53c1..e8f3b81 100644 --- a/src/fig/FIGCarousel.h +++ b/src/fig/FIGCarousel.h @@ -55,10 +55,8 @@ class FIGCarousel { void allocate_fig_to_fib(int figtype, int extension, int fib); - 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); + private: FIGRuntimeInformation m_rti; std::map<std::pair<int, int>, IFIG*> m_figs_available; |