diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-15 00:03:04 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-15 00:03:04 +0200 |
commit | 3dab3da3f669e1f2c70fd81c13f67c9c5c77278a (patch) | |
tree | 17ad5b8949654a03cc741d7e910fecf3eb35a71a /src/fig | |
parent | ebe8447f4cee32e2a096438ca0b458036f646b28 (diff) | |
download | dabmux-3dab3da3f669e1f2c70fd81c13f67c9c5c77278a.tar.gz dabmux-3dab3da3f669e1f2c70fd81c13f67c9c5c77278a.tar.bz2 dabmux-3dab3da3f669e1f2c70fd81c13f67c9c5c77278a.zip |
Implement FIG0/18 for announcements
Diffstat (limited to 'src/fig')
-rw-r--r-- | src/fig/FIG0.cpp | 74 | ||||
-rw-r--r-- | src/fig/FIG0.h | 18 | ||||
-rw-r--r-- | src/fig/FIGCarousel.cpp | 5 | ||||
-rw-r--r-- | src/fig/FIGCarousel.h | 1 |
4 files changed, 95 insertions, 3 deletions
diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index b424fe3..7cb3dde 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -919,5 +919,79 @@ FillStatus FIG0_17::fill(uint8_t *buf, size_t max_size) return fs; } +//=========== FIG 0/18 =========== + +FIG0_18::FIG0_18(FIGRuntimeInformation *rti) : + m_rti(rti), + m_initialised(false) +{ +} + +FillStatus FIG0_18::fill(uint8_t *buf, size_t max_size) +{ + FillStatus fs; + ssize_t remaining = max_size; + + if (not m_initialised) { + service = m_rti->ensemble->services.end(); + m_initialised = true; + } + + auto ensemble = m_rti->ensemble; + + FIGtype0* fig0 = NULL; + + if (service == ensemble->services.end()) { + service = ensemble->services.begin(); + fs.complete_fig_transmitted = true; + } + + for (; service != ensemble->services.end(); + ++service) { + + if ( (*service)->ASu == 0 ) { + continue; + } + + // TODO support more than one cluster + const int numclusters = 1; + + if (remaining < (int)sizeof(FIGtype0_18) + numclusters) { + break; + } + + if (fig0 == NULL) { + if (remaining < 2 + (int)sizeof(FIGtype0_18) + numclusters) { + break; + } + + fig0 = (FIGtype0*)buf; + fig0->FIGtypeNumber = 0; + fig0->Length = 1; + fig0->CN = 0; + fig0->OE = 0; + fig0->PD = 0; + fig0->Extension = 18; + buf += 2; + remaining -= 2; + } + + auto programme = (FIGtype0_18*)buf; + programme->SId = htons((*service)->id); + programme->ASu = htons((*service)->ASu); + programme->Rfa = 0; + programme->NumClusters = numclusters; + buf += sizeof(FIGtype0_18); + buf[0] = 0x1; // TODO support not only cluster 1 + buf += numclusters; + + fig0->Length += sizeof(FIGtype0_18) + numclusters; + remaining -= sizeof(FIGtype0_18) + numclusters; + } + + fs.num_bytes_written = max_size - remaining; + return fs; +} + } // namespace FIC diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h index 14b658f..0c11ced 100644 --- a/src/fig/FIG0.h +++ b/src/fig/FIG0.h @@ -180,7 +180,6 @@ class FIG0_13 : public IFIG std::vector<DabComponent*>::iterator componentFIG0_13; }; - // FIG type 0/17 class FIG0_17 : public IFIG { @@ -198,6 +197,23 @@ class FIG0_17 : public IFIG std::vector<std::shared_ptr<DabService> >::iterator serviceFIG0_17; }; +// FIG type 0/18 +class FIG0_18 : public IFIG +{ + public: + FIG0_18(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 18; } + + private: + FIGRuntimeInformation *m_rti; + bool m_initialised; + std::vector<std::shared_ptr<DabService> >::iterator service; +}; + } // namespace FIC #endif // __FIG0_H_ diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp index cfe5c38..8eedd6e 100644 --- a/src/fig/FIGCarousel.cpp +++ b/src/fig/FIGCarousel.cpp @@ -67,7 +67,8 @@ FIGCarousel::FIGCarousel(boost::shared_ptr<dabEnsemble> ensemble) : m_fig0_9(&m_rti), m_fig1_1(&m_rti), m_fig1_4(&m_rti), - m_fig1_5(&m_rti) + m_fig1_5(&m_rti), + m_fig0_18(&m_rti) { load_and_allocate(m_fig0_0, 0); load_and_allocate(m_fig0_1, 0); @@ -83,7 +84,7 @@ FIGCarousel::FIGCarousel(boost::shared_ptr<dabEnsemble> ensemble) : load_and_allocate(m_fig1_1, 2); load_and_allocate(m_fig1_5, 2); - load_and_allocate(m_fig1_4, 2); + load_and_allocate(m_fig0_18, 2); } void FIGCarousel::load_and_allocate(IFIG& fig, int fib) diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h index 2fa0335..170ffdd 100644 --- a/src/fig/FIGCarousel.h +++ b/src/fig/FIGCarousel.h @@ -85,6 +85,7 @@ class FIGCarousel { FIG1_1 m_fig1_1; FIG1_4 m_fig1_4; FIG1_5 m_fig1_5; + FIG0_18 m_fig0_18; }; } // namespace FIC |