From 8222356f6c3dff6f66283c32354be033898749fc Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 7 Aug 2015 15:38:43 +0200 Subject: Add FIG1/4 --- src/fig/FIG1.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ src/fig/FIG1.h | 18 +++++++++++ src/fig/FIGCarousel.cpp | 2 ++ src/fig/FIGCarousel.h | 1 + 4 files changed, 107 insertions(+) (limited to 'src') diff --git a/src/fig/FIG1.cpp b/src/fig/FIG1.cpp index fa8e380..2da9130 100644 --- a/src/fig/FIG1.cpp +++ b/src/fig/FIG1.cpp @@ -123,6 +123,92 @@ FillStatus FIG1_1::fill(uint8_t *buf, size_t max_size) return fs; } +//=========== FIG 1/4 =========== + +FillStatus FIG1_4::fill(uint8_t *buf, size_t max_size) +{ + FillStatus fs; + + ssize_t remaining = max_size; + + if (not m_initialised) { + component = m_rti->ensemble->components.end(); + } + + auto ensemble = m_rti->ensemble; + + // Rotate through the subchannels until there is no more + // space + if (component == ensemble->components.end()) { + component = ensemble->components.begin(); + fs.complete_fig_transmitted = true; + } + + for (; component != ensemble->components.end(); + ++component) { + + auto service = getService(*component, ensemble->services); + + if (not (*component)->label.long_label().empty() ) { + if ((*service)->getType(ensemble) == subchannel_type_t::Audio) { + + if (remaining < 5 + 16 + 2) { + break; + } + + // Programme + FIGtype1_4_programme *fig1_4; + fig1_4 = (FIGtype1_4_programme*)buf; + + fig1_4->FIGtypeNumber = 1; + fig1_4->Length = 22; + fig1_4->Charset = 0; + fig1_4->OE = 0; + fig1_4->Extension = 4; + fig1_4->PD = 0; + fig1_4->rfa = 0; + fig1_4->SCIdS = (*component)->SCIdS; + + fig1_4->SId = htons((*service)->id); + buf += 5; + remaining -= 5; + } + else { // Data + + if (remaining < 7 + 16 + 2) { + break; + } + + FIGtype1_4_data *fig1_4; + fig1_4 = (FIGtype1_4_data *)buf; + fig1_4->FIGtypeNumber = 1; + fig1_4->Length = 24; + fig1_4->Charset = 0; + fig1_4->OE = 0; + fig1_4->Extension = 4; + fig1_4->PD = 1; + fig1_4->rfa = 0; + fig1_4->SCIdS = (*component)->SCIdS; + + fig1_4->SId = htonl((*service)->id); + buf += 7; + remaining -= 7; + } + (*component)->label.writeLabel(buf); + buf += 16; + remaining -= 16; + + buf[0] = (*component)->label.flag() >> 8; + buf[1] = (*component)->label.flag() & 0xFF; + buf += 2; + remaining -= 2; + } + } + + fs.num_bytes_written = max_size - remaining; + return fs; +} + //=========== FIG 1/5 =========== FillStatus FIG1_5::fill(uint8_t *buf, size_t max_size) diff --git a/src/fig/FIG1.h b/src/fig/FIG1.h index b322eab..786dae9 100644 --- a/src/fig/FIG1.h +++ b/src/fig/FIG1.h @@ -67,6 +67,24 @@ class FIG1_1 : public IFIG std::vector >::iterator service; }; +// FIG type 1/4, service component label +class FIG1_4 : public IFIG +{ + public: + FIG1_4(FIGRuntimeInformation* rti) : + m_rti(rti), m_initialised(false) {} + 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 1; } + virtual const int figextension(void) const { return 4; } + + private: + FIGRuntimeInformation *m_rti; + bool m_initialised; + std::vector::iterator component; +}; + // FIG type 1/5, data service label class FIG1_5 : public IFIG { diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp index 932945a..0b25233 100644 --- a/src/fig/FIGCarousel.cpp +++ b/src/fig/FIGCarousel.cpp @@ -66,6 +66,7 @@ FIGCarousel::FIGCarousel(boost::shared_ptr ensemble) : m_fig0_10(&m_rti), m_fig0_9(&m_rti), m_fig1_1(&m_rti), + m_fig1_4(&m_rti), m_fig1_5(&m_rti) { load_and_allocate(m_fig0_0, 0); @@ -82,6 +83,7 @@ FIGCarousel::FIGCarousel(boost::shared_ptr ensemble) : load_and_allocate(m_fig1_1, 2); load_and_allocate(m_fig1_5, 2); + load_and_allocate(m_fig1_4, 2); } void FIGCarousel::load_and_allocate(IFIG& fig, int fib) diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h index 0e70f40..2fa0335 100644 --- a/src/fig/FIGCarousel.h +++ b/src/fig/FIGCarousel.h @@ -83,6 +83,7 @@ class FIGCarousel { // FIB 2 figs FIG1_1 m_fig1_1; + FIG1_4 m_fig1_4; FIG1_5 m_fig1_5; }; -- cgit v1.2.3