aboutsummaryrefslogtreecommitdiffstats
path: root/src/fig
diff options
context:
space:
mode:
Diffstat (limited to 'src/fig')
-rw-r--r--src/fig/FIG0.cpp74
-rw-r--r--src/fig/FIG0.h1
2 files changed, 53 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;
diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h
index 2655aa0..9e491e9 100644
--- a/src/fig/FIG0.h
+++ b/src/fig/FIG0.h
@@ -131,6 +131,7 @@ class FIG0_8 : public IFIG
private:
FIGRuntimeInformation *m_rti;
bool m_initialised;
+ bool m_transmit_programme;
std::vector<DabComponent*>::iterator componentFIG0_8;
};