diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-04-15 10:32:50 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-04-15 10:32:50 +0200 |
commit | d4ab701073e4876aa3d2e5f6c883cebf08783ac4 (patch) | |
tree | b4b442e8def873cc4cbb6b3b2a217469c34b1498 /src/fig/FIG0.cpp | |
parent | 1c311e48b7691eed7f912579e9aad1f90a5bb5f5 (diff) | |
download | dabmux-d4ab701073e4876aa3d2e5f6c883cebf08783ac4.tar.gz dabmux-d4ab701073e4876aa3d2e5f6c883cebf08783ac4.tar.bz2 dabmux-d4ab701073e4876aa3d2e5f6c883cebf08783ac4.zip |
Fix FIG0/8 insertion with data & audio services
Diffstat (limited to 'src/fig/FIG0.cpp')
-rw-r--r-- | src/fig/FIG0.cpp | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index b5dbf79..5c85ee8 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -584,7 +584,8 @@ FillStatus FIG0_3::fill(uint8_t *buf, size_t max_size) FIG0_8::FIG0_8(FIGRuntimeInformation *rti) : m_rti(rti), - m_initialised(false) + m_initialised(false), + m_transmit_programme(false) { } @@ -603,10 +604,12 @@ FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size) 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 " @@ -616,29 +619,28 @@ FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size) throw MuxInitException(); } - const int required_size = (*service)->program ? - ((*subchannel)->type == subchannel_type_t::Packet ? 5 : 4) : - ((*subchannel)->type == subchannel_type_t::Packet ? 7 : 6); + if (m_transmit_programme and (*service)->program) { + const int required_size = + ((*subchannel)->type == subchannel_type_t::Packet ? 5 : 4); - if (fig0 == NULL) { - if (remaining < 2 + required_size) { + if (fig0 == NULL) { + if (remaining < 2 + required_size) { + break; + } + 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; + } + else if (remaining < required_size) { break; } - 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; - } - else if (remaining < required_size) { - break; - } - if ((*service)->program) { if ((*subchannel)->type == subchannel_type_t::Packet) { // Data packet buf[0] = ((*componentFIG0_8)->serviceId >> 8) & 0xFF; buf[1] = ((*componentFIG0_8)->serviceId) & 0xFF; @@ -676,7 +678,28 @@ FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size) remaining -= 2; } } - else { // Data + else if (!m_transmit_programme and !(*service)->program) { // Data + const int required_size = + ((*subchannel)->type == subchannel_type_t::Packet ? 7 : 6); + + if (fig0 == NULL) { + if (remaining < 2 + required_size) { + break; + } + fig0 = (FIGtype0*)buf; + fig0->FIGtypeNumber = 0; + fig0->Length = 1; + fig0->CN = 0; + fig0->OE = 0; + fig0->PD = 1; + fig0->Extension = 8; + buf += 2; + remaining -= 2; + } + else if (remaining < required_size) { + break; + } + if ((*subchannel)->type == subchannel_type_t::Packet) { // Data packet buf[0] = ((*componentFIG0_8)->serviceId >> 8) & 0xFF; buf[1] = ((*componentFIG0_8)->serviceId) & 0xFF; @@ -717,7 +740,14 @@ FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size) if (componentFIG0_8 == ensemble->components.end()) { componentFIG0_8 = ensemble->components.begin(); - fs.complete_fig_transmitted = true; + + // The full database is sent every second full loop + fs.complete_fig_transmitted = m_transmit_programme; + + m_transmit_programme = not m_transmit_programme; + // Alternate between data and and programme FIG0/13, + // do not mix fig0 with PD=0 with extension 13 stuff + // that actually needs PD=1, and vice versa } fs.num_bytes_written = max_size - remaining; |