diff options
-rw-r--r-- | src/DabMultiplexer.cpp | 17 | ||||
-rw-r--r-- | src/MuxElements.cpp | 30 | ||||
-rw-r--r-- | src/MuxElements.h | 8 | ||||
-rw-r--r-- | src/fig/FIG0.cpp | 17 |
4 files changed, 38 insertions, 34 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index c560c96..d9ba496 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -242,23 +242,6 @@ void DabMultiplexer::prepare_services_components() throw MuxInitException(); } - // Adjust service type from this first component - switch (service->getType(ensemble)) { - case subchannel_type_t::Audio: // Audio - service->program = true; - break; - case subchannel_type_t::DataDmb: - case subchannel_type_t::Fidc: - case subchannel_type_t::Packet: - service->program = false; - break; - default: - etiLog.log(error, - "Error, unknown service type: %u\n", - service->getType(ensemble)); - throw MuxInitException(); - } - service->enrol_at(m_rc); // Adjust components type for DAB+ diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index b47a1ae..a4102b8 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -254,7 +254,7 @@ std::vector<std::shared_ptr<DabService> >::iterator getService( throw std::runtime_error("Service not included in any component"); } -bool DabComponent::isPacketComponent(vector<dabSubchannel*>& subchannels) +bool DabComponent::isPacketComponent(vector<dabSubchannel*>& subchannels) const { if (subchId > 63) { etiLog.log(error, @@ -335,8 +335,7 @@ const string DabComponent::get_parameter(const string& parameter) const } - -subchannel_type_t DabService::getType(std::shared_ptr<dabEnsemble> ensemble) +subchannel_type_t DabService::getType(std::shared_ptr<dabEnsemble> ensemble) const { vector<dabSubchannel*>::iterator subchannel; vector<DabComponent*>::iterator component = @@ -353,7 +352,30 @@ subchannel_type_t DabService::getType(std::shared_ptr<dabEnsemble> ensemble) return (*subchannel)->type; } -unsigned char DabService::nbComponent(vector<DabComponent*>& components) +bool DabService::isProgramme(std::shared_ptr<dabEnsemble> ensemble) const +{ + bool ret = false; + switch (getType(ensemble)) { + case subchannel_type_t::Audio: // Audio + ret = true; + break; + case subchannel_type_t::DataDmb: + case subchannel_type_t::Fidc: + case subchannel_type_t::Packet: + ret = false; + break; + default: + etiLog.log(error, + "Error, unknown service type: %u\n", + getType(ensemble)); + throw std::runtime_error("DabService::isProgramme unknown service type"); + } + + return ret; +} + + +unsigned char DabService::nbComponent(vector<DabComponent*>& components) const { int nb = 0; vector<DabComponent*>::iterator current; diff --git a/src/MuxElements.h b/src/MuxElements.h index 44af574..f8e60b1 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -331,7 +331,7 @@ class DabComponent : public RemoteControllable dabFidcComponent fidc; dabPacketComponent packet; - bool isPacketComponent(std::vector<dabSubchannel*>& subchannels); + bool isPacketComponent(std::vector<dabSubchannel*>& subchannels) const; /* Remote control */ virtual void set_parameter(const std::string& parameter, @@ -365,7 +365,6 @@ class DabService : public RemoteControllable uint32_t id; unsigned char pty; unsigned char language; - bool program; /* ASu (Announcement support) flags: this 16-bit flag field shall * specify the type(s) of announcements by which it is possible to @@ -375,8 +374,9 @@ class DabService : public RemoteControllable uint16_t ASu; std::vector<uint8_t> clusters; - subchannel_type_t getType(std::shared_ptr<dabEnsemble> ensemble); - unsigned char nbComponent(std::vector<DabComponent*>& components); + subchannel_type_t getType(std::shared_ptr<dabEnsemble> ensemble) const; + bool isProgramme(std::shared_ptr<dabEnsemble> ensemble) const; + unsigned char nbComponent(std::vector<DabComponent*>& components) const; DabLabel label; diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index 5c85ee8..ca5a4a6 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -282,8 +282,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size) ensemble->services.end(), back_inserter(m_audio_services), [&](shared_ptr<DabService>& s) { - auto type = s->getType(ensemble); - return type == subchannel_type_t::Audio; + return s->isProgramme(ensemble); } ); m_data_services.clear(); @@ -291,9 +290,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size) ensemble->services.end(), back_inserter(m_data_services), [&](shared_ptr<DabService>& s) { - auto type = s->getType(ensemble); - return type == subchannel_type_t::Packet or - type == subchannel_type_t::DataDmb; + return not s->isProgramme(ensemble); } ); m_initialised = true; @@ -319,6 +316,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size) // space for (; serviceFIG0_2 != last_service; ++serviceFIG0_2) { const auto type = (*serviceFIG0_2)->getType(ensemble); + const auto isProgramme = (*serviceFIG0_2)->isProgramme(ensemble); etiLog.log(FIG0_2_TRACE, "FIG0_2::fill loop SId=%04x %s/%s", (*serviceFIG0_2)->id, @@ -336,7 +334,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size) ++cur; - const int required_size = (type == subchannel_type_t::Audio) ? + const int required_size = isProgramme ? 3 + 2 * (*serviceFIG0_2)->nbComponent(ensemble->components) : 5 + 2 * (*serviceFIG0_2)->nbComponent(ensemble->components); @@ -353,7 +351,7 @@ FillStatus FIG0_2::fill(uint8_t *buf, size_t max_size) fig0_2->Length = 1; fig0_2->CN = 0; fig0_2->OE = 0; - fig0_2->PD = (type == subchannel_type_t::Audio) ? 0 : 1; + fig0_2->PD = isProgramme ? 0 : 1; fig0_2->Extension = 2; buf += 2; remaining -= 2; @@ -619,7 +617,7 @@ FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size) throw MuxInitException(); } - if (m_transmit_programme and (*service)->program) { + if (m_transmit_programme and (*service)->isProgramme(ensemble)) { const int required_size = ((*subchannel)->type == subchannel_type_t::Packet ? 5 : 4); @@ -678,7 +676,8 @@ FillStatus FIG0_8::fill(uint8_t *buf, size_t max_size) remaining -= 2; } } - else if (!m_transmit_programme and !(*service)->program) { // Data + else if (!m_transmit_programme and !(*service)->isProgramme(ensemble)) { + // Data const int required_size = ((*subchannel)->type == subchannel_type_t::Packet ? 7 : 6); |