diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-07 11:37:50 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-08-07 11:37:50 +0200 |
commit | 02d96cb7b6a73595e5c517a3e352f578aa5497a0 (patch) | |
tree | 71011ded47e63c4d9854c8c37b511202976e8446 /src/fig | |
parent | 477345c3411cbf25ac6a1011845eca067f6e75bf (diff) | |
download | dabmux-02d96cb7b6a73595e5c517a3e352f578aa5497a0.tar.gz dabmux-02d96cb7b6a73595e5c517a3e352f578aa5497a0.tar.bz2 dabmux-02d96cb7b6a73595e5c517a3e352f578aa5497a0.zip |
Start FIB1, add FIG0/8
Diffstat (limited to 'src/fig')
-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 |
4 files changed, 167 insertions, 7 deletions
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; |