summaryrefslogtreecommitdiffstats
path: root/src/fig
diff options
context:
space:
mode:
Diffstat (limited to 'src/fig')
-rw-r--r--src/fig/FIG0.cpp43
-rw-r--r--src/fig/FIG0.h2
2 files changed, 29 insertions, 16 deletions
diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp
index 57321ed..1e29ca5 100644
--- a/src/fig/FIG0.cpp
+++ b/src/fig/FIG0.cpp
@@ -342,7 +342,8 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size)
//=========== FIG 0/3 ===========
FIG0_3::FIG0_3(FIGRuntimeInformation *rti) :
- m_rti(rti)
+ m_rti(rti),
+ m_initialised(false)
{
}
@@ -352,26 +353,36 @@ FillStatus FIG0_3::fill(uint8_t *buf, size_t max_size)
ssize_t remaining = max_size;
auto ensemble = m_rti->ensemble;
+ if (not m_initialised) {
+ componentFIG0_3 = m_rti->ensemble->components.end();
+ m_initialised = true;
+ }
+
FIGtype0_3_header *fig0_3_header = NULL;
FIGtype0_3_data *fig0_3_data = NULL;
- // TODO: implement component carousel
- for (auto& component : ensemble->components) {
+ for (; componentFIG0_3 != ensemble->components.end();
+ ++componentFIG0_3) {
auto subchannel = getSubchannel(ensemble->subchannels,
- component->subchId);
+ (*componentFIG0_3)->subchId);
if (subchannel == ensemble->subchannels.end()) {
etiLog.log(error,
"Subchannel %i does not exist for component "
"of service %i\n",
- component->subchId, component->serviceId);
+ (*componentFIG0_3)->subchId, (*componentFIG0_3)->serviceId);
throw MuxInitException();
}
if ((*subchannel)->type != subchannel_type_t::Packet)
continue;
+ const int required_size = 5 + (m_rti->factumAnalyzer ? 2 : 0);
+
if (fig0_3_header == NULL) {
+ if (remaining < 2 + required_size) {
+ break;
+ }
fig0_3_header = (FIGtype0_3_header*)buf;
fig0_3_header->FIGtypeNumber = 0;
fig0_3_header->Length = 1;
@@ -383,21 +394,24 @@ FillStatus FIG0_3::fill(uint8_t *buf, size_t max_size)
buf += 2;
remaining -= 2;
}
+ else if (remaining < required_size) {
+ break;
+ }
/* Warning: When bit SCCA_flag is unset(0), the multiplexer
* R&S does not send the SCCA field. But, in the Factum ETI
* analyzer, if this field is not there, it is an error.
*/
fig0_3_data = (FIGtype0_3_data*)buf;
- fig0_3_data->setSCId(component->packet.id);
+ fig0_3_data->setSCId((*componentFIG0_3)->packet.id);
fig0_3_data->rfa = 0;
fig0_3_data->SCCA_flag = 0;
// if 0, datagroups are used
- fig0_3_data->DG_flag = !component->packet.datagroup;
+ fig0_3_data->DG_flag = !(*componentFIG0_3)->packet.datagroup;
fig0_3_data->rfu = 0;
- fig0_3_data->DSCTy = component->type;
+ fig0_3_data->DSCTy = (*componentFIG0_3)->type;
fig0_3_data->SubChId = (*subchannel)->id;
- fig0_3_data->setPacketAddress(component->packet.address);
+ fig0_3_data->setPacketAddress((*componentFIG0_3)->packet.address);
if (m_rti->factumAnalyzer) {
fig0_3_data->SCCA = 0;
}
@@ -410,17 +424,14 @@ FillStatus FIG0_3::fill(uint8_t *buf, size_t max_size)
buf += 2;
remaining -= 2;
}
+ }
- if (remaining < 0) {
- etiLog.level(error) <<
- "can't add FIG 0/3 to FIB, "
- "too many packet services";
- throw MuxInitException();
- }
+ if (componentFIG0_3 == ensemble->components.end()) {
+ componentFIG0_3 = ensemble->components.begin();
+ fs.complete_fig_transmitted = true;
}
fs.num_bytes_written = max_size - remaining;
- fs.complete_fig_transmitted = true;
return fs;
}
diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h
index 2dc6483..87872eb 100644
--- a/src/fig/FIG0.h
+++ b/src/fig/FIG0.h
@@ -102,6 +102,8 @@ class FIG0_3 : public IFIG
private:
FIGRuntimeInformation *m_rti;
+ bool m_initialised;
+ std::vector<DabComponent*>::iterator componentFIG0_3;
};
// FIG type 0/8