diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2025-10-06 17:35:24 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2025-10-06 17:35:24 +0200 |
commit | 56fa3ca3db83627dbde9bd3a79da897c5a1cccb1 (patch) | |
tree | 04e6c361b99962683500c9db12a568309c3d3b6f | |
parent | b6b840f6072e950f2ded719ae51badfba7566fa8 (diff) | |
download | dabmux-56fa3ca3db83627dbde9bd3a79da897c5a1cccb1.tar.gz dabmux-56fa3ca3db83627dbde9bd3a79da897c5a1cccb1.tar.bz2 dabmux-56fa3ca3db83627dbde9bd3a79da897c5a1cccb1.zip |
Add services other ensembles to linking hot-reloadnext
-rw-r--r-- | src/ConfigParser.cpp | 15 | ||||
-rw-r--r-- | src/ConfigParser.h | 4 | ||||
-rw-r--r-- | src/DabMultiplexer.cpp | 17 | ||||
-rw-r--r-- | src/MuxElements.cpp | 16 | ||||
-rw-r--r-- | src/MuxElements.h | 7 | ||||
-rw-r--r-- | src/fig/FIG0_24.cpp | 31 | ||||
-rw-r--r-- | src/fig/FIG0_24.h | 3 | ||||
-rw-r--r-- | src/utils.cpp | 5 |
8 files changed, 66 insertions, 32 deletions
diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index efc010f..785a0da 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -329,10 +329,10 @@ void parse_freq_info( } // if FI present } -static void parse_other_service_linking(ptree& pt, - std::shared_ptr<dabEnsemble> ensemble) +void parse_other_service_linking( + const boost::optional<boost::property_tree::ptree&> pt_other_services, + std::vector<ServiceOtherEnsembleInfo>& service_other_ensemble) { - const auto pt_other_services = pt.get_child_optional("other-services"); if (pt_other_services) { for (const auto& it_service : *pt_other_services) { const string srv_uid = it_service.first; @@ -362,7 +362,7 @@ static void parse_other_service_linking(ptree& pt, } } - ensemble->service_other_ensemble.push_back(std::move(info)); + service_other_ensemble.push_back(std::move(info)); } } catch (const std::exception &e) { @@ -917,9 +917,12 @@ void parse_ptree( std::vector<FrequencyInformation> frequency_information; parse_freq_info(pt_frequency_information, frequency_information); - ensemble->set_linking_config(linkagesets, frequency_information); + const auto pt_other_services = pt.get_child_optional("other-services"); + std::vector<ServiceOtherEnsembleInfo> services_other_ensemble; + parse_other_service_linking(pt_other_services, services_other_ensemble); + + ensemble->set_linking_config(linkagesets, frequency_information, services_other_ensemble); - parse_other_service_linking(pt, ensemble); } static Inputs::dab_input_zmq_config_t setup_zmq_input( diff --git a/src/ConfigParser.h b/src/ConfigParser.h index dc7c256..4f4cb9b 100644 --- a/src/ConfigParser.h +++ b/src/ConfigParser.h @@ -45,3 +45,7 @@ void parse_linkage( void parse_freq_info( const boost::optional<boost::property_tree::ptree&> pt_frequency_information, std::vector<FrequencyInformation>& frequency_information); + +void parse_other_service_linking( + const boost::optional<boost::property_tree::ptree&> pt_other_services, + std::vector<ServiceOtherEnsembleInfo>& service_other_ensemble); diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index d107b9a..45d9a66 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -504,8 +504,21 @@ void DabMultiplexer::reload_linking() etiLog.level(warn) << "Failed to validate new frequency info: " << e.what(); } - if (linkage_sets_valid and freq_info_valid) { - ensemble->set_linking_config(linkagesets, frequency_information); + bool services_oe_valid = false; + std::vector<ServiceOtherEnsembleInfo> services_other_ensemble; + + try { + const auto pt_other_services = new_conf.pt.get_child_optional("other-services"); + parse_other_service_linking(pt_other_services, services_other_ensemble); + services_oe_valid = true; + } + catch (const std::runtime_error& e) + { + etiLog.level(warn) << "Failed to validate new services in other onsembles: " << e.what(); + } + + if (linkage_sets_valid and freq_info_valid and services_oe_valid) { + ensemble->set_linking_config(linkagesets, frequency_information, services_other_ensemble); etiLog.level(info) << "Loaded new linkage sets and frequency info."; } } diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index d39c874..d9c5392 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -793,7 +793,7 @@ bool dabEnsemble::validate_linkage_sets( std::vector<FrequencyInformation> dabEnsemble::get_frequency_information() const { unique_lock<mutex> lock(m_mutex); - auto fi = m_frequency_information; + const auto fi = m_frequency_information; lock.unlock(); return fi; } @@ -801,18 +801,28 @@ std::vector<FrequencyInformation> dabEnsemble::get_frequency_information() const std::vector<std::shared_ptr<LinkageSet> > dabEnsemble::get_linkagesets() const { unique_lock<mutex> lock(m_mutex); - auto ls = m_linkagesets; + const auto ls = m_linkagesets; lock.unlock(); return ls; } +std::vector<ServiceOtherEnsembleInfo> dabEnsemble::get_service_other_ensemble() const +{ + unique_lock<mutex> lock(m_mutex); + const auto oe = m_service_other_ensemble; + lock.unlock(); + return oe; +} + void dabEnsemble::set_linking_config( std::vector<std::shared_ptr<LinkageSet> >& new_linkage_sets, - std::vector<FrequencyInformation>& new_frequency_information) + std::vector<FrequencyInformation>& new_frequency_information, + std::vector<ServiceOtherEnsembleInfo>& new_services_other_ensemble) { unique_lock<mutex> lock(m_mutex); m_frequency_information = new_frequency_information; m_linkagesets = new_linkage_sets; + m_service_other_ensemble = new_services_other_ensemble; } unsigned short DabSubchannel::getSizeCu() const diff --git a/src/MuxElements.h b/src/MuxElements.h index 51445a9..989730b 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -351,20 +351,21 @@ class dabEnsemble : public RemoteControllable { std::vector<std::shared_ptr<AnnouncementCluster> > clusters; - std::vector<ServiceOtherEnsembleInfo> service_other_ensemble; - std::vector<FrequencyInformation> get_frequency_information() const; std::vector<std::shared_ptr<LinkageSet> > get_linkagesets() const; + std::vector<ServiceOtherEnsembleInfo> get_service_other_ensemble() const; void set_linking_config( std::vector<std::shared_ptr<LinkageSet> >& new_linkage_sets, - std::vector<FrequencyInformation>& new_frequency_information); + std::vector<FrequencyInformation>& new_frequency_information, + std::vector<ServiceOtherEnsembleInfo>& new_services_other_ensemble); private: // The following can be updated by the RC while being read by the main // thread, and need to be protected std::vector<std::shared_ptr<LinkageSet> > m_linkagesets; std::vector<FrequencyInformation> m_frequency_information; + std::vector<ServiceOtherEnsembleInfo> m_service_other_ensemble; mutable std::mutex m_mutex; }; diff --git a/src/fig/FIG0_24.cpp b/src/fig/FIG0_24.cpp index c48d8de..c254e63 100644 --- a/src/fig/FIG0_24.cpp +++ b/src/fig/FIG0_24.cpp @@ -73,21 +73,22 @@ FillStatus FIG0_24::fill(uint8_t *buf, size_t max_size) " ********************************"; if (not m_initialised) { - serviceFIG0_24 = ensemble->service_other_ensemble.begin(); + m_services = ensemble->get_service_other_ensemble(); + m_services_it = m_services.begin(); m_initialised = true; } - const auto last_service = ensemble->service_other_ensemble.end(); + const auto last_service = m_services.end(); bool last_oe = false; // Rotate through the subchannels until there is no more // space - for (; serviceFIG0_24 != last_service; ++serviceFIG0_24) { + for (; m_services_it != last_service; ++m_services_it) { shared_ptr<DabService> service; for (const auto& local_service : ensemble->services) { - if (local_service->id == serviceFIG0_24->service_id) { + if (local_service->id == m_services_it->service_id) { service = local_service; break; } @@ -105,7 +106,7 @@ FillStatus FIG0_24::fill(uint8_t *buf, size_t max_size) etiLog.log(FIG0_24_TRACE, "FIG0_24::fill loop OE=%d SId=%04x %s/%s", oe, - serviceFIG0_24->service_id, + m_services_it->service_id, m_inserting_audio_not_data ? "AUDIO" : "DATA", type == subchannel_type_t::DABAudio ? "Audio" : type == subchannel_type_t::Packet ? "Packet" : @@ -117,7 +118,7 @@ FillStatus FIG0_24::fill(uint8_t *buf, size_t max_size) const ssize_t required_size = (isProgramme ? 2 : 4) + 1 + - serviceFIG0_24->other_ensembles.size() * 2; + m_services_it->other_ensembles.size() * 2; if (fig0 == nullptr) { @@ -132,7 +133,7 @@ FillStatus FIG0_24::fill(uint8_t *buf, size_t max_size) fig0->FIGtypeNumber = 0; fig0->Length = 1; // CN according to ETSI TS 103 176, Clause 5.3.4.1 - bool isFirst = serviceFIG0_24 == ensemble->service_other_ensemble.begin(); + bool isFirst = m_services_it == m_services.begin(); fig0->CN = (isFirst ? 0 : 1); fig0->OE = oe; fig0->PD = isProgramme ? 0 : 1; @@ -149,33 +150,33 @@ FillStatus FIG0_24::fill(uint8_t *buf, size_t max_size) if (isProgramme) { auto fig0_24_audioservice = (FIGtype0_24_audioservice*)buf; - fig0_24_audioservice->SId = htons(serviceFIG0_24->service_id); + fig0_24_audioservice->SId = htons(m_services_it->service_id); fig0_24_audioservice->rfa = 0; fig0_24_audioservice->CAId = 0; - fig0_24_audioservice->Length = serviceFIG0_24->other_ensembles.size(); + fig0_24_audioservice->Length = m_services_it->other_ensembles.size(); buf += 3; fig0->Length += 3; remaining -= 3; etiLog.log(FIG0_24_TRACE, "FIG0_24::fill audio SId=%04x", - serviceFIG0_24->service_id); + m_services_it->service_id); } else { auto fig0_24_dataservice = (FIGtype0_24_dataservice*)buf; - fig0_24_dataservice->SId = htonl(serviceFIG0_24->service_id); + fig0_24_dataservice->SId = htonl(m_services_it->service_id); fig0_24_dataservice->rfa = 0; fig0_24_dataservice->CAId = 0; - fig0_24_dataservice->Length = serviceFIG0_24->other_ensembles.size(); + fig0_24_dataservice->Length = m_services_it->other_ensembles.size(); buf += 4; fig0->Length += 4; remaining -= 4; etiLog.log(FIG0_24_TRACE, "FIG0_24::fill data SId=%04x", - serviceFIG0_24->service_id); + m_services_it->service_id); } - for (const uint16_t oe : serviceFIG0_24->other_ensembles) { + for (const uint16_t oe : m_services_it->other_ensembles) { buf[0] = oe >> 8; buf[1] = oe & 0xFF; @@ -185,7 +186,7 @@ FillStatus FIG0_24::fill(uint8_t *buf, size_t max_size) } } - if (serviceFIG0_24 == last_service) { + if (m_services_it == last_service) { etiLog.log(FIG0_24_TRACE, "FIG0_24::loop reached last"); fs.complete_fig_transmitted = true; m_initialised = false; diff --git a/src/fig/FIG0_24.h b/src/fig/FIG0_24.h index d1e7604..7677e16 100644 --- a/src/fig/FIG0_24.h +++ b/src/fig/FIG0_24.h @@ -47,7 +47,8 @@ class FIG0_24 : public IFIG FIGRuntimeInformation *m_rti; bool m_initialised; bool m_inserting_audio_not_data; - std::vector<ServiceOtherEnsembleInfo>::iterator serviceFIG0_24; + std::vector<ServiceOtherEnsembleInfo> m_services; + std::vector<ServiceOtherEnsembleInfo>::iterator m_services_it; }; } diff --git a/src/utils.cpp b/src/utils.cpp index fc4c864..63ad32c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -369,11 +369,12 @@ static void printLinking(const shared_ptr<dabEnsemble>& ensemble) } etiLog.log(info, " Services in other ensembles"); - if (ensemble->service_other_ensemble.empty()) { + const auto service_other_ensemble = ensemble->get_service_other_ensemble(); + if (service_other_ensemble.empty()) { etiLog.level(info) << " None "; } - for (const auto& s_oe : ensemble->service_other_ensemble) { + for (const auto& s_oe : service_other_ensemble) { int oe = 1; for (const auto& local_service : ensemble->services) { |