aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-21 16:40:08 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-21 16:40:08 +0100
commitde472d4b7f674cd24c4dafa30ca42bd73665e4f8 (patch)
tree794f35bddbd6c49984c2885a10f76a311ded75ff /src
parent9b5dad36648022a1d78f4060a30edc0fb8e32001 (diff)
downloaddabmux-de472d4b7f674cd24c4dafa30ca42bd73665e4f8.tar.gz
dabmux-de472d4b7f674cd24c4dafa30ca42bd73665e4f8.tar.bz2
dabmux-de472d4b7f674cd24c4dafa30ca42bd73665e4f8.zip
Let FIGs fail more gently in case of errors
Diffstat (limited to 'src')
-rw-r--r--src/MuxElements.cpp9
-rw-r--r--src/fig/FIG0_13.cpp4
-rw-r--r--src/fig/FIG0_2.cpp13
-rw-r--r--src/fig/FIG0_3.cpp9
-rw-r--r--src/fig/FIG0_5.cpp6
-rw-r--r--src/fig/FIG0_6.cpp21
-rw-r--r--src/fig/FIG0_8.cpp4
7 files changed, 39 insertions, 27 deletions
diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp
index ef04507..e07a49d 100644
--- a/src/MuxElements.cpp
+++ b/src/MuxElements.cpp
@@ -666,6 +666,15 @@ bool dabEnsemble::validate_linkage_sets()
keyserviceuid.c_str(), ls->lsn);
return false;
}
+
+ // need to add key service to num_ids
+ const size_t num_ids = 1 + ls->id_list.size();
+ if (num_ids > 0x0F) {
+ etiLog.log(error,
+ "Too many links for linkage set 0x%04x",
+ ls->lsn);
+ return false;
+ }
}
return true;
diff --git a/src/fig/FIG0_13.cpp b/src/fig/FIG0_13.cpp
index 40a0be8..0bb7fd7 100644
--- a/src/fig/FIG0_13.cpp
+++ b/src/fig/FIG0_13.cpp
@@ -83,10 +83,10 @@ FillStatus FIG0_13::fill(uint8_t *buf, size_t max_size)
if (subchannel == ensemble->subchannels.end()) {
etiLog.log(error,
"Subchannel %i does not exist for component "
- "of service %i\n",
+ "of service %i",
(*componentFIG0_13)->subchId,
(*componentFIG0_13)->serviceId);
- throw MuxInitException();
+ continue;
}
if ( m_transmit_programme &&
diff --git a/src/fig/FIG0_2.cpp b/src/fig/FIG0_2.cpp
index 0e5c13c..e587c2b 100644
--- a/src/fig/FIG0_2.cpp
+++ b/src/fig/FIG0_2.cpp
@@ -111,7 +111,8 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size)
// Exclude Fidc type services, TODO unsupported
auto type = s->getType(ensemble);
if (type == subchannel_type_t::Fidc) {
- throw invalid_argument("FIG0/2 does not support FIDC");
+ etiLog.log(warn, "FIG0/2 does not support FIDC");
+ continue;
}
}
@@ -250,9 +251,9 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size)
if (subchannel == ensemble->subchannels.end()) {
etiLog.log(error,
"Subchannel %i does not exist for component "
- "of service %i\n",
+ "of service %i",
(*component)->subchId, (*component)->serviceId);
- throw MuxInitException();
+ continue;
}
switch ((*subchannel)->type) {
@@ -286,9 +287,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size)
}
break;
default:
- etiLog.log(error,
- "Component type not supported\n");
- throw MuxInitException();
+ throw logic_error("Component type not supported");
}
buf += 2;
fig0_2->Length += 2;
@@ -296,7 +295,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size)
if (remaining < 0) {
etiLog.log(error,
"Sorry, no space left in FIG 0/2 to insert "
- "component %i of program service %i.\n",
+ "component %i of program service %i.",
curCpnt, cur);
throw MuxInitException();
}
diff --git a/src/fig/FIG0_3.cpp b/src/fig/FIG0_3.cpp
index 9362a78..5698236 100644
--- a/src/fig/FIG0_3.cpp
+++ b/src/fig/FIG0_3.cpp
@@ -85,10 +85,11 @@ FillStatus FIG0_3::fill(uint8_t *buf, size_t max_size)
if (subchannel == ensemble->subchannels.end()) {
etiLog.log(error,
- "Subchannel %i does not exist for component "
- "of service %i\n",
- (*componentFIG0_3)->subchId, (*componentFIG0_3)->serviceId);
- throw MuxInitException();
+ "FIG0/3: Subchannel %i does not exist "
+ "for component of service %i",
+ (*componentFIG0_3)->subchId,
+ (*componentFIG0_3)->serviceId);
+ continue;
}
if ((*subchannel)->type != subchannel_type_t::Packet)
diff --git a/src/fig/FIG0_5.cpp b/src/fig/FIG0_5.cpp
index 8691a6b..1a6a534 100644
--- a/src/fig/FIG0_5.cpp
+++ b/src/fig/FIG0_5.cpp
@@ -66,11 +66,11 @@ FillStatus FIG0_5::fill(uint8_t *buf, size_t max_size)
if (subchannel == ensemble->subchannels.end()) {
etiLog.log(error,
- "Subchannel %i does not exist for component "
- "of service %i\n",
+ "FIG0/5: Subchannel %i does not exist "
+ "for component of service %i",
(*componentFIG0_5)->subchId,
(*componentFIG0_5)->serviceId);
- throw MuxInitException();
+ continue;
}
if ( (*service)->language == 0) {
diff --git a/src/fig/FIG0_6.cpp b/src/fig/FIG0_6.cpp
index 51df05b..e540ebc 100644
--- a/src/fig/FIG0_6.cpp
+++ b/src/fig/FIG0_6.cpp
@@ -83,6 +83,13 @@ FillStatus FIG0_6::fill(uint8_t *buf, size_t max_size)
// need to add key service to num_ids
const size_t num_ids = 1 + linkageSetFIG0_6->id_list.size();
+ if (num_ids > 0x0F) {
+ etiLog.log(error,
+ "Too many links for linkage set 0x%04x",
+ linkageSetFIG0_6->lsn);
+ continue;
+ }
+
const size_t headersize = sizeof(struct FIGtype0_6_header);
const int required_size = sizeof(struct FIGtype0_6) + headersize +
(num_ids > 0 ?
@@ -123,11 +130,6 @@ FillStatus FIG0_6::fill(uint8_t *buf, size_t max_size)
if (num_ids > 0) {
FIGtype0_6_header *header = (FIGtype0_6_header*)buf;
header->rfu = 0;
- if (num_ids > 0x0F) {
- etiLog.log(error, "Too large number of links for linkage set 0x%04x",
- linkageSetFIG0_6->lsn);
- throw MuxInitException();
- }
// update() guarantees us that all entries in a linkage set
// have the same type
@@ -135,7 +137,7 @@ FillStatus FIG0_6::fill(uint8_t *buf, size_t max_size)
if (l.type != linkageSetFIG0_6->id_list.front().type) {
etiLog.log(error, "INTERNAL ERROR: invalid linkage subset 0x%04x",
linkageSetFIG0_6->lsn);
- throw std::runtime_error("INTERNAL ERROR");
+ throw std::logic_error("FIG0_6 INTERNAL ERROR");
}
}
@@ -161,9 +163,10 @@ FillStatus FIG0_6::fill(uint8_t *buf, size_t max_size)
});
if (keyservice == ensemble->services.end()) {
- etiLog.log(error, "Invalid key service %s in linkage set 0x%04x",
- keyserviceuid.c_str(), linkageSetFIG0_6->lsn);
- throw MuxInitException();
+ std::stringstream ss;
+ ss << "Invalid key service " << keyserviceuid <<
+ " in linkage set 0x" << std::hex << linkageSetFIG0_6->lsn;
+ throw MuxInitException(ss.str());
}
if (not PD and not ILS) {
diff --git a/src/fig/FIG0_8.cpp b/src/fig/FIG0_8.cpp
index 0144b4f..fdb3623 100644
--- a/src/fig/FIG0_8.cpp
+++ b/src/fig/FIG0_8.cpp
@@ -88,10 +88,10 @@ FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size)
if (subchannel == ensemble->subchannels.end()) {
etiLog.log(error,
"Subchannel %i does not exist for component "
- "of service %i\n",
+ "of service %i",
(*componentFIG0_8)->subchId,
(*componentFIG0_8)->serviceId);
- throw MuxInitException();
+ continue;
}
if (m_transmit_programme and (*service)->isProgramme(ensemble)) {