diff options
-rw-r--r-- | src/ensembledatabase.cpp | 32 | ||||
-rw-r--r-- | src/ensembledatabase.hpp | 9 | ||||
-rw-r--r-- | src/fig0_8.cpp | 12 | ||||
-rw-r--r-- | src/fig2.cpp | 8 |
4 files changed, 51 insertions, 10 deletions
diff --git a/src/ensembledatabase.cpp b/src/ensembledatabase.cpp index e5066a6..735aca3 100644 --- a/src/ensembledatabase.cpp +++ b/src/ensembledatabase.cpp @@ -29,9 +29,11 @@ #include <locale> #include <codecvt> +#include <iomanip> #include <sstream> #include "ensembledatabase.hpp" #include "charset.hpp" +#include "utils.hpp" namespace ensemble_database { @@ -118,9 +120,17 @@ string label_t::assemble() const string label_t::assembly_state() const { stringstream ss; - ss << "["; + ss << "("; for (const auto& s : segments) { - ss << s.first << ","; + ss << s.first; + if (get_verbosity() > 1) { + ss << "["; + for (const auto& c : s.second) { + ss << hex << setw(2) << (int)c << " "; + } + ss << "]" << dec; + } + ss << ","; } ss << "count=" << segment_count << ","; @@ -138,12 +148,12 @@ string label_t::assembly_state() const ss << "UNDEFINED"; break; } - ss << "]"; + ss << ")"; return ss.str(); } -component_t& service_t::get_component(uint32_t subchannel_id) +component_t& service_t::get_component_by_subchannel(uint32_t subchannel_id) { for (auto& component : components) { if (component.subchId == subchannel_id) { @@ -151,10 +161,22 @@ component_t& service_t::get_component(uint32_t subchannel_id) } } - throw not_found("component referring to subchannel " + + throw not_found("component with subchannel id " + to_string(subchannel_id) + " not found"); } +component_t& service_t::get_component_by_scids(uint8_t scids) +{ + for (auto& component : components) { + if (component.scids == scids) { + return component; + } + } + + throw not_found("component with SCIdS " + + to_string(scids) + " not found"); +} + component_t& service_t::get_or_create_component(uint32_t subchannel_id) { for (auto& component : components) { diff --git a/src/ensembledatabase.hpp b/src/ensembledatabase.hpp index dee434d..fff989f 100644 --- a/src/ensembledatabase.hpp +++ b/src/ensembledatabase.hpp @@ -94,11 +94,15 @@ struct subchannel_t { }; struct component_t { - uint32_t service_id; + uint32_t service_id = 0; uint8_t subchId; + uint8_t scids = 255; // 255 is invalid, as scids is only 4 bits wide + bool primary; + label_t label; + /* TODO uint8_t type; @@ -114,7 +118,8 @@ struct service_t { std::list<component_t> components; - component_t& get_component(uint32_t subchannel_id); + component_t& get_component_by_subchannel(uint32_t subchannel_id); + component_t& get_component_by_scids(uint8_t scids); component_t& get_or_create_component(uint32_t subchannel_id); // TODO PTy language announcement diff --git a/src/fig0_8.cpp b/src/fig0_8.cpp index 5060202..8a651ad 100644 --- a/src/fig0_8.cpp +++ b/src/fig0_8.cpp @@ -83,6 +83,7 @@ fig_result_t fig0_8(fig0_common_t& fig0, const display_settings_t &disp) Rfa = (f[i] >> 4) & 0x7; SCIdS = f[i] & 0x0F; r.complete |= fig0_8_is_complete(SId, SCIdS); + r.msgs.emplace_back("-"); r.msgs.emplace_back(1, strprintf("SId=0x%X", SId)); r.msgs.emplace_back(1, strprintf("Ext flag=%d 8-bit Rfa %s", @@ -103,6 +104,17 @@ fig_result_t fig0_8(fig0_common_t& fig0, const display_settings_t &disp) if (MSC_FIC_flag == 0) { // MSC in stream mode and SubChId identifies the sub-channel SubChId = f[i] & 0x3F; + + try { + auto& srv = fig0.ensemble.get_service(SId); + auto& component = srv.get_component_by_subchannel(SubChId); + component.scids = SCIdS; + } + catch (ensemble_database::not_found &e) { + r.errors.push_back("Not yet in DB"); + } + + r.msgs.emplace_back(1, strprintf("MSC/FIC flag=%d MSC, SubChId=0x%X", MSC_FIC_flag, SubChId)); } else { diff --git a/src/fig2.cpp b/src/fig2.cpp index 74243ce..97622c8 100644 --- a/src/fig2.cpp +++ b/src/fig2.cpp @@ -185,10 +185,12 @@ fig_result_t fig2_select(fig2_common_t& fig2, const display_settings_t &disp) try { auto& service = fig2.ensemble.get_service(sid); - handle_ext_label_data_field(fig2, service.label, disp, r); + auto& comp = service.get_component_by_scids(SCIdS); - const auto complete_label = service.label.assemble(); - r.msgs.push_back(strprintf("Label segments=\"%s\"", service.label.assembly_state().c_str())); + handle_ext_label_data_field(fig2, comp.label, disp, r); + + const auto complete_label = comp.label.assemble(); + r.msgs.push_back(strprintf("Label segments=\"%s\"", comp.label.assembly_state().c_str())); if (not complete_label.empty()) { r.msgs.push_back(strprintf("Label=\"%s\"", complete_label.c_str())); } |