From 55a66f6408042abfd102f92fd0072a000d8e0235 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 15 Aug 2015 11:53:55 +0200 Subject: Add cluster handling for announcements --- doc/example.mux | 3 +++ src/ConfigParser.cpp | 28 ++++++++++++++++++++++++++++ src/DabMultiplexer.cpp | 1 - src/MuxElements.h | 1 + src/fig/FIG0.cpp | 9 +++++---- src/fig/FIG0.h | 17 +++++++++++++++++ src/utils.cpp | 7 +++++++ src/utils.h | 2 +- 8 files changed, 62 insertions(+), 6 deletions(-) diff --git a/doc/example.mux b/doc/example.mux index 1b0059c..c818dbb 100644 --- a/doc/example.mux +++ b/doc/example.mux @@ -101,6 +101,9 @@ services { ProgrammeInfo false Sports false Finance false + + ; a comma separated list of clusters in which the service belongs to + clusters "1,2" } } srv-lu { diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 5290b0f..7840a60 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -37,6 +37,8 @@ #endif #include +#include +#include #include #include #include @@ -261,6 +263,32 @@ void parse_ptree(boost::property_tree::ptree& pt, } } + auto clusterlist = pt_service.get("announcements.clusters", ""); + vector clusters_s; + boost::split(clusters_s, + clusterlist, + boost::is_any_of(",")); + + for (const auto& cluster_s : clusters_s) { + if (cluster_s == "") { + continue; + } + try { + service->clusters.push_back(std::stoi(cluster_s)); + } + catch (std::logic_error& e) { + etiLog.level(warn) << "Cannot parse '" << clusterlist << + "' announcement clusters for service " << serviceuid << + ": " << e.what(); + } + } + + if (service->ASu != 0 and service->clusters.empty()) { + etiLog.level(warn) << "Cluster list for service " << serviceuid << + "is empty, but announcements are defined"; + } + + int success = -5; string servicelabel = pt_service.get("label"); diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index 195ae2c..c7a5554 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -1853,7 +1853,6 @@ void DabMultiplexer::mux_frame(std::vector >& outpu void DabMultiplexer::print_info(void) { - return; // Print settings before starting etiLog.log(info, "--- Multiplex configuration ---"); printEnsemble(ensemble); diff --git a/src/MuxElements.h b/src/MuxElements.h index 5eeac51..e1cc3a9 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -323,6 +323,7 @@ class DabService : public RemoteControllable * field shall be as defined in TS 101 756, table 14. */ uint16_t ASu; + std::vector clusters; subchannel_type_t getType(boost::shared_ptr ensemble); unsigned char nbComponent(std::vector& components); diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index 7cb3dde..9f89109 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -953,8 +953,7 @@ FillStatus FIG0_18::fill(uint8_t *buf, size_t max_size) continue; } - // TODO support more than one cluster - const int numclusters = 1; + const ssize_t numclusters = (*service)->clusters.size(); if (remaining < (int)sizeof(FIGtype0_18) + numclusters) { break; @@ -982,8 +981,10 @@ FillStatus FIG0_18::fill(uint8_t *buf, size_t max_size) programme->Rfa = 0; programme->NumClusters = numclusters; buf += sizeof(FIGtype0_18); - buf[0] = 0x1; // TODO support not only cluster 1 - buf += numclusters; + + for (uint8_t cluster : (*service)->clusters) { + *(buf++) = cluster; + } fig0->Length += sizeof(FIGtype0_18) + numclusters; remaining -= sizeof(FIGtype0_18) + numclusters; diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h index 0c11ced..9015b00 100644 --- a/src/fig/FIG0.h +++ b/src/fig/FIG0.h @@ -214,6 +214,23 @@ class FIG0_18 : public IFIG std::vector >::iterator service; }; +// FIG type 0/19 +class FIG0_19 : public IFIG +{ + public: + FIG0_19(FIGRuntimeInformation* rti); + virtual FillStatus fill(uint8_t *buf, size_t max_size); + virtual FIG_rate repetition_rate(void) { return FIG_rate::A; } + + virtual const int figtype(void) const { return 0; } + virtual const int figextension(void) const { return 19; } + + private: + FIGRuntimeInformation *m_rti; + bool m_initialised; + std::vector >::iterator service; +}; + } // namespace FIC #endif // __FIG0_H_ diff --git a/src/utils.cpp b/src/utils.cpp index 2559cb0..1f6754d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "DabMux.h" #include "utils.h" @@ -389,6 +390,12 @@ void printServices(const vector >& services) service->language, service->language); etiLog.log(info, " announcements: 0x%x", service->ASu); + + std::vector clusters_s; + for (const auto& cluster : service->clusters) { + clusters_s.push_back(std::to_string(cluster)); + } + etiLog.level(info) << " clusters: " << boost::join(clusters_s, ","); ++index; } } diff --git a/src/utils.h b/src/utils.h index 1756adf..3a5cf1c 100644 --- a/src/utils.h +++ b/src/utils.h @@ -52,7 +52,7 @@ void printUsageConfigfile(char *name, FILE* out = stderr); * resp. subchannels*/ void printOutputs(std::vector >& outputs); -void printServices(std::vector >& services); +void printServices(const std::vector >& services); void printComponents(std::vector& components); -- cgit v1.2.3