From b09c89b9edda0abe2ab69df5c0d0723db43ad945 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 20 Feb 2018 15:09:59 +0100 Subject: Use shared_ptr instead of component and subchannel pointers --- src/ConfigParser.cpp | 78 ++++++++++++++------------------------------------ src/DabMultiplexer.cpp | 66 ++++++++++++++++++------------------------ src/MuxElements.cpp | 50 ++++++++++++++++---------------- src/MuxElements.h | 51 ++++++++++++++------------------- src/fig/FIG0_1.h | 4 +-- src/fig/FIG0_13.h | 2 +- src/fig/FIG0_17.h | 2 +- src/fig/FIG0_18.h | 2 +- src/fig/FIG0_2.h | 6 ++-- src/fig/FIG0_24.h | 2 +- src/fig/FIG0_3.h | 2 +- src/fig/FIG0_5.h | 2 +- src/fig/FIG0_8.h | 2 +- src/fig/FIG1.h | 6 ++-- src/utils.cpp | 35 +++++++++++----------- src/utils.h | 8 +++--- 16 files changed, 131 insertions(+), 187 deletions(-) diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index a04d90d..0ab3d43 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -36,67 +36,32 @@ # include "config.h" #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "dabOutput/dabOutput.h" -#include "input/inputs.h" #include "utils.h" #include "DabMux.h" #include "ManagementServer.h" - #include "input/Prbs.h" #include "input/Zmq.h" #include "input/File.h" #include "input/Udp.h" - - -#ifdef _WIN32 -# pragma warning ( disable : 4103 ) -# include "Eti.h" -# pragma warning ( default : 4103 ) -#else -# include "Eti.h" -#endif - - -#ifdef _WIN32 -# include -# include -# include -# include -# include // For types... -typedef u_char uint8_t; -typedef WORD uint16_t; -typedef DWORD32 uint32_t; - -# ifndef __MINGW32__ -# include "xgetopt.h" -# endif -# define read _read -# define snprintf _snprintf -# define sleep(a) Sleep((a) * 1000) -#else -# include -# include -# include -# include -# include -#endif +#include "Eti.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; using boost::property_tree::ptree; using boost::property_tree::ptree_error; -static void setup_subchannel_from_ptree(DabSubchannel* subchan, +static void setup_subchannel_from_ptree(shared_ptr& subchan, const ptree &pt, std::shared_ptr ensemble, const string& subchanuid); @@ -634,12 +599,12 @@ void parse_ptree( /******************** READ SUBCHAN PARAMETERS **************/ - map allsubchans; + map > allsubchans; ptree pt_subchans = pt.get_child("subchannels"); for (ptree::iterator it = pt_subchans.begin(); it != pt_subchans.end(); ++it) { string subchanuid = it->first; - auto subchan = new DabSubchannel(subchanuid); + auto subchan = make_shared(subchanuid); ensemble->subchannels.push_back(subchan); @@ -666,7 +631,7 @@ void parse_ptree( } /******************** READ COMPONENT PARAMETERS ************/ - map allcomponents; + map > allcomponents; ptree pt_components = pt.get_child("components"); for (ptree::iterator it = pt_components.begin(); it != pt_components.end(); ++it) { string componentuid = it->first; @@ -690,7 +655,7 @@ void parse_ptree( throw runtime_error(ss.str()); } - DabSubchannel* subchannel; + shared_ptr subchannel; try { string subchan_uid = pt_comp.get("subchannel"); if (allsubchans.count(subchan_uid) != 1) { @@ -712,7 +677,7 @@ void parse_ptree( int packet_datagroup = pt_comp.get("datagroup", false); uint8_t component_type = hexparse(pt_comp.get("type", "0")); - auto component = new DabComponent(componentuid); + auto component = make_shared(componentuid); component->serviceId = service->id; component->subchId = subchannel->id; @@ -842,7 +807,7 @@ static Inputs::dab_input_zmq_config_t setup_zmq_input( return zmqconfig; } -static void setup_subchannel_from_ptree(DabSubchannel* subchan, +static void setup_subchannel_from_ptree(shared_ptr& subchan, const ptree &pt, std::shared_ptr ensemble, const string& subchanuid) @@ -885,8 +850,6 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, subchan->inputUri = inputUri; - dabProtection* protection = &subchan->protection; - if (type == "dabplus" or type == "audio") { subchan->type = subchannel_type_t::Audio; subchan->bitrate = 0; @@ -988,6 +951,7 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, subchan->startAddress = 0; + dabProtection* protection = &subchan->protection; if (type == "audio") { protection->form = UEP; protection->level = 2; @@ -1022,7 +986,7 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, } catch (ptree_error &e) { for (int i = 0; i < 64; ++i) { // Find first free subchannel - vector::iterator subchannel = getSubchannel(ensemble->subchannels, i); + auto subchannel = getSubchannel(ensemble->subchannels, i); if (subchannel == ensemble->subchannels.end()) { subchannel = ensemble->subchannels.end() - 1; subchan->id = i; diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index f452685..daa4f3f 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -152,10 +152,9 @@ void DabMultiplexer::prepare(bool require_tai_clock) throw MuxInitException(); } - vector::iterator subchannel = - ensemble->subchannels.end() - 1; + auto last_subchannel = *(ensemble->subchannels.end() - 1); - if ((*subchannel)->startAddress + (*subchannel)->getSizeCu() > 864) { + if (last_subchannel->startAddress + last_subchannel->getSizeCu() > 864) { etiLog.log(error, "Total size in CU exceeds 864\n"); printSubchannels(ensemble->subchannels); throw MuxInitException(); @@ -222,8 +221,8 @@ void DabMultiplexer::prepare_services_components() set ids; dabProtection* protection = nullptr; - vector::iterator component; - vector::iterator subchannel; + vec_sp_component::iterator component; + vec_sp_subchannel::iterator subchannel; for (auto service : ensemble->services) { if (ids.find(service->id) != ids.end()) { @@ -302,7 +301,7 @@ void DabMultiplexer::prepare_services_components() component->packet.id = cur_packetid++; - rcs.enrol(component); + rcs.enrol(component.get()); } } @@ -310,10 +309,9 @@ void DabMultiplexer::prepare_services_components() void DabMultiplexer::prepare_data_inputs() { dabProtection* protection = nullptr; - vector::iterator subchannel; // Prepare and check the data inputs - for (subchannel = ensemble->subchannels.begin(); + for (auto subchannel = ensemble->subchannels.begin(); subchannel != ensemble->subchannels.end(); ++subchannel) { protection = &(*subchannel)->protection; @@ -376,9 +374,8 @@ void DabMultiplexer::mux_frame(std::vector >& outputs unsigned char etiFrame[6144]; unsigned short index = 0; - vector >::iterator service; - vector::iterator component; - vector::iterator subchannel; + vec_sp_service::iterator service; + vec_sp_component::iterator component; // FIC Length, DAB Mode I, II, IV -> FICL = 24, DAB Mode III -> FICL = 32 unsigned FICL = @@ -467,7 +464,7 @@ void DabMultiplexer::mux_frame(std::vector >& outputs */ unsigned short FLtmp = 1 + FICL + (fc->NST); - for (subchannel = ensemble->subchannels.begin(); + for (auto subchannel = ensemble->subchannels.begin(); subchannel != ensemble->subchannels.end(); ++subchannel) { // Add STLsbch @@ -481,15 +478,13 @@ void DabMultiplexer::mux_frame(std::vector >& outputs // Stream Characterization, // number of channels * 4 octets = nb octets total int edi_stream_id = 1; - for (subchannel = ensemble->subchannels.begin(); - subchannel != ensemble->subchannels.end(); - ++subchannel) { - dabProtection* protection = &(*subchannel)->protection; + for (auto subchannel : ensemble->subchannels) { + dabProtection* protection = &subchannel->protection; eti_STC *sstc = (eti_STC *) & etiFrame[index]; - sstc->SCID = (*subchannel)->id; - sstc->startAddress_high = (*subchannel)->startAddress / 256; - sstc->startAddress_low = (*subchannel)->startAddress % 256; + sstc->SCID = subchannel->id; + sstc->startAddress_high = subchannel->startAddress / 256; + sstc->startAddress_low = subchannel->startAddress % 256; // depends on the desired protection form if (protection->form == UEP) { sstc->TPL = 0x10 | @@ -500,20 +495,20 @@ void DabMultiplexer::mux_frame(std::vector >& outputs } // Sub-channel Stream Length, multiple of 64 bits - sstc->STL_high = (*subchannel)->getSizeDWord() / 256; - sstc->STL_low = (*subchannel)->getSizeDWord() % 256; + sstc->STL_high = subchannel->getSizeDWord() / 256; + sstc->STL_low = subchannel->getSizeDWord() % 256; edi::TagESTn tag_ESTn; tag_ESTn.id = edi_stream_id++; - tag_ESTn.scid = (*subchannel)->id; - tag_ESTn.sad = (*subchannel)->startAddress; + tag_ESTn.scid = subchannel->id; + tag_ESTn.sad = subchannel->startAddress; tag_ESTn.tpl = sstc->TPL; tag_ESTn.rfa = 0; // two bits - tag_ESTn.mst_length = (*subchannel)->getSizeByte() / 8; + tag_ESTn.mst_length = subchannel->getSizeByte() / 8; tag_ESTn.mst_data = nullptr; - assert((*subchannel)->getSizeByte() % 8 == 0); + assert(subchannel->getSizeByte() % 8 == 0); - edi_subchannelToTag[*subchannel] = tag_ESTn; + edi_subchannelToTag[subchannel.get()] = tag_ESTn; index += 4; } @@ -591,20 +586,17 @@ void DabMultiplexer::mux_frame(std::vector >& outputs ****** Input Data Reading ******************************************* **********************************************************************/ - for (subchannel = ensemble->subchannels.begin(); - subchannel != ensemble->subchannels.end(); - ++subchannel) { - - edi::TagESTn& tag = edi_subchannelToTag[*subchannel]; + for (auto subchannel : ensemble->subchannels) { + edi::TagESTn& tag = edi_subchannelToTag[subchannel.get()]; - int sizeSubchannel = (*subchannel)->getSizeByte(); - int result = (*subchannel)->input->readFrame( + int sizeSubchannel = subchannel->getSizeByte(); + int result = subchannel->input->readFrame( &etiFrame[index], sizeSubchannel); if (result < 0) { etiLog.log(info, "Subchannel %d read failed at ETI frame number: %d\n", - (*subchannel)->id, currentFrame); + subchannel->id, currentFrame); } // save pointer to Audio or Data Stream into correct TagESTn for EDI @@ -615,10 +607,8 @@ void DabMultiplexer::mux_frame(std::vector >& outputs index = (3 + fc->NST + FICL) * 4; - for (subchannel = ensemble->subchannels.begin(); - subchannel != ensemble->subchannels.end(); - ++subchannel) { - index += (*subchannel)->getSizeByte(); + for (auto subchannel : ensemble->subchannels) { + index += subchannel->getSizeByte(); } /******* Section EOF **************************************************/ diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index 4c81ca9..954e712 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -333,24 +333,26 @@ void DabLabel::writeLabel(uint8_t* buf) const } } -vector::iterator getSubchannel( - vector& subchannels, int id) +vec_sp_subchannel::iterator getSubchannel( + vec_sp_subchannel& subchannels, + int id) { return find_if( subchannels.begin(), subchannels.end(), - [&](const DabSubchannel* s){ return s->id == id; } + [&](shared_ptr& s){ return s->id == id; } ); } -vector::iterator getComponent( - vector& components, +vec_sp_component::iterator getComponent( + vec_sp_component& components, uint32_t serviceId, - vector::iterator current) + vec_sp_component::iterator current) { if (current == components.end()) { current = components.begin(); - } else { + } + else { ++current; } @@ -365,18 +367,18 @@ vector::iterator getComponent( } -vector::iterator getComponent( - vector& components, +vec_sp_component::iterator getComponent( + vec_sp_component& components, uint32_t serviceId) { return getComponent(components, serviceId, components.end()); } -std::vector >::iterator getService( - DabComponent* component, - std::vector >& services) +vec_sp_service::iterator getService( + std::shared_ptr component, + vec_sp_service& services) { size_t i = 0; - for (auto service : services) { + for (const auto service : services) { if (service->id == component->serviceId) { return services.begin() + i; } @@ -386,7 +388,7 @@ std::vector >::iterator getService( throw std::runtime_error("Service not included in any component"); } -bool DabComponent::isPacketComponent(vector& subchannels) const +bool DabComponent::isPacketComponent(vec_sp_subchannel& subchannels) const { if (subchId > 63) { etiLog.log(error, @@ -394,16 +396,15 @@ bool DabComponent::isPacketComponent(vector& subchannels) const "packet component before defining packet "); return false; } - if (getSubchannel(subchannels, subchId) == subchannels.end()) { + const auto subch_it = getSubchannel(subchannels, subchId); + if (subch_it == subchannels.cend()) { etiLog.log(error, "Invalid subchannel id in the packet component " "for defining packet "); return false; } - if ((*getSubchannel(subchannels, subchId))->type != subchannel_type_t::Packet) { - return false; - } - return true; + + return (*subch_it)->type == subchannel_type_t::Packet; } void DabComponent::set_parameter(const string& parameter, @@ -467,16 +468,16 @@ const string DabComponent::get_parameter(const string& parameter) const } -subchannel_type_t DabService::getType(const std::shared_ptr ensemble) const +subchannel_type_t DabService::getType( + const std::shared_ptr ensemble) const { - vector::iterator subchannel; auto component = getComponent(ensemble->components, id); if (component == ensemble->components.end()) { throw std::runtime_error("No component found for service"); } - subchannel = getSubchannel(ensemble->subchannels, (*component)->subchId); + auto subchannel = getSubchannel(ensemble->subchannels, (*component)->subchId); if (subchannel == ensemble->subchannels.end()) { throw std::runtime_error("Could not find subchannel associated with service"); } @@ -507,10 +508,11 @@ bool DabService::isProgramme(const std::shared_ptr& ensemble) const } -unsigned char DabService::nbComponent(const vector& components) const +unsigned char DabService::nbComponent(const vec_sp_component& components) const { size_t count = std::count_if(components.begin(), components.end(), - [&](const DabComponent* c) { return c->serviceId == id;} ); + [&](const shared_ptr& c) { return c->serviceId == id;} ); + if (count > 0xFF) { throw std::logic_error("Invalid number of components in service"); } diff --git a/src/MuxElements.h b/src/MuxElements.h index 4efc720..b5d1285 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -197,6 +197,11 @@ class DabSubchannel; class LinkageSet; struct FrequencyInformation; +using vec_sp_component = std::vector >; +using vec_sp_service = std::vector >; +using vec_sp_subchannel = std::vector >; + + enum class TransmissionMode_e { TM_I, TM_II, @@ -236,9 +241,9 @@ class dabEnsemble : public RemoteControllable { // 2 corresponds to program types used in north america int international_table = 1; - std::vector > services; - std::vector components; - std::vector subchannels; + vec_sp_service services; + vec_sp_component components; + vec_sp_subchannel subchannels; std::vector > clusters; std::vector > linkagesets; @@ -349,7 +354,6 @@ struct dabPacketComponent { bool datagroup; }; - class DabComponent : public RemoteControllable { public: @@ -373,7 +377,7 @@ class DabComponent : public RemoteControllable dabFidcComponent fidc; dabPacketComponent packet; - bool isPacketComponent(std::vector& subchannels) const; + bool isPacketComponent(vec_sp_subchannel& subchannels) const; /* Remote control */ virtual void set_parameter(const std::string& parameter, @@ -381,16 +385,8 @@ class DabComponent : public RemoteControllable /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; - - virtual ~DabComponent() {} - - private: - const DabComponent& operator=(const DabComponent& other); - DabComponent(const DabComponent& other); }; - - class DabService : public RemoteControllable { public: @@ -429,7 +425,7 @@ class DabService : public RemoteControllable subchannel_type_t getType(const std::shared_ptr ensemble) const; bool isProgramme(const std::shared_ptr& ensemble) const; - unsigned char nbComponent(const std::vector& components) const; + unsigned char nbComponent(const vec_sp_component& components) const; DabLabel label; @@ -439,12 +435,6 @@ class DabService : public RemoteControllable /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; - - virtual ~DabService() {} - - private: - const DabService& operator=(const DabService& other); - DabService(const DabService& other); }; enum class ServiceLinkType {DAB, FM, DRM, AMSS}; @@ -556,19 +546,20 @@ struct FrequencyInformation { std::vector frequency_information; }; -std::vector::iterator getSubchannel( - std::vector& subchannels, int id); +vec_sp_subchannel::iterator getSubchannel( + vec_sp_subchannel& subchannels, + int id); -std::vector::iterator getComponent( - std::vector& components, +vec_sp_component::iterator getComponent( + vec_sp_component& components, uint32_t serviceId, - std::vector::iterator current); + vec_sp_component::iterator current); -std::vector::iterator getComponent( - std::vector& components, +vec_sp_component::iterator getComponent( + vec_sp_component& components, uint32_t serviceId); -std::vector >::iterator getService( - DabComponent* component, - std::vector >& services); +vec_sp_service::iterator getService( + std::shared_ptr component, + vec_sp_service& services); diff --git a/src/fig/FIG0_1.h b/src/fig/FIG0_1.h index fd98037..4e8b5f5 100644 --- a/src/fig/FIG0_1.h +++ b/src/fig/FIG0_1.h @@ -45,8 +45,8 @@ class FIG0_1 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector subchannels; - std::vector::iterator subchannelFIG0_1; + vec_sp_subchannel subchannels; + vec_sp_subchannel::iterator subchannelFIG0_1; uint8_t m_watermarkData[128]; size_t m_watermarkSize; diff --git a/src/fig/FIG0_13.h b/src/fig/FIG0_13.h index 4465aef..cd9ae9f 100644 --- a/src/fig/FIG0_13.h +++ b/src/fig/FIG0_13.h @@ -46,7 +46,7 @@ class FIG0_13 : public IFIG FIGRuntimeInformation *m_rti; bool m_initialised; bool m_transmit_programme; - std::vector::iterator componentFIG0_13; + vec_sp_component::iterator componentFIG0_13; }; } diff --git a/src/fig/FIG0_17.h b/src/fig/FIG0_17.h index 2d5088b..06d0743 100644 --- a/src/fig/FIG0_17.h +++ b/src/fig/FIG0_17.h @@ -45,7 +45,7 @@ class FIG0_17 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector >::iterator serviceFIG0_17; + vec_sp_service::iterator serviceFIG0_17; }; } diff --git a/src/fig/FIG0_18.h b/src/fig/FIG0_18.h index f73687c..da0e748 100644 --- a/src/fig/FIG0_18.h +++ b/src/fig/FIG0_18.h @@ -44,7 +44,7 @@ class FIG0_18 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector >::iterator service; + vec_sp_service::iterator service; }; } diff --git a/src/fig/FIG0_2.h b/src/fig/FIG0_2.h index 2f35b21..53865db 100644 --- a/src/fig/FIG0_2.h +++ b/src/fig/FIG0_2.h @@ -45,9 +45,9 @@ class FIG0_2 : public IFIG FIGRuntimeInformation *m_rti; bool m_initialised; bool m_inserting_audio_not_data; - std::vector > m_audio_services; - std::vector > m_data_services; - std::vector >::iterator serviceFIG0_2; + vec_sp_service m_audio_services; + vec_sp_service m_data_services; + vec_sp_service::iterator serviceFIG0_2; }; } diff --git a/src/fig/FIG0_24.h b/src/fig/FIG0_24.h index 4ccbd0c..1c17f6b 100644 --- a/src/fig/FIG0_24.h +++ b/src/fig/FIG0_24.h @@ -47,7 +47,7 @@ class FIG0_24 : public IFIG FIGRuntimeInformation *m_rti; bool m_initialised; bool m_inserting_audio_not_data; - std::vector >::iterator serviceFIG0_24; + vec_sp_service::iterator serviceFIG0_24; }; } diff --git a/src/fig/FIG0_3.h b/src/fig/FIG0_3.h index d2b1563..a3a936b 100644 --- a/src/fig/FIG0_3.h +++ b/src/fig/FIG0_3.h @@ -46,7 +46,7 @@ class FIG0_3 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector::iterator componentFIG0_3; + vec_sp_component::iterator componentFIG0_3; }; } diff --git a/src/fig/FIG0_5.h b/src/fig/FIG0_5.h index 51ac177..1bfe8c3 100644 --- a/src/fig/FIG0_5.h +++ b/src/fig/FIG0_5.h @@ -49,7 +49,7 @@ class FIG0_5 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector::iterator componentFIG0_5; + vec_sp_component::iterator componentFIG0_5; }; } diff --git a/src/fig/FIG0_8.h b/src/fig/FIG0_8.h index 81d00ea..dc150aa 100644 --- a/src/fig/FIG0_8.h +++ b/src/fig/FIG0_8.h @@ -48,7 +48,7 @@ class FIG0_8 : public IFIG FIGRuntimeInformation *m_rti; bool m_initialised; bool m_transmit_programme; - std::vector::iterator componentFIG0_8; + vec_sp_component::iterator componentFIG0_8; }; } diff --git a/src/fig/FIG1.h b/src/fig/FIG1.h index 9910320..2ae0bfb 100644 --- a/src/fig/FIG1.h +++ b/src/fig/FIG1.h @@ -64,7 +64,7 @@ class FIG1_1 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector >::iterator service; + vec_sp_service::iterator service; }; // FIG type 1/4, service component label @@ -82,7 +82,7 @@ class FIG1_4 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector::iterator component; + vec_sp_component::iterator component; }; // FIG type 1/5, data service label @@ -100,7 +100,7 @@ class FIG1_5 : public IFIG private: FIGRuntimeInformation *m_rti; bool m_initialised; - std::vector >::iterator service; + vec_sp_service::iterator service; }; #ifdef _WIN32 diff --git a/src/utils.cpp b/src/utils.cpp index a4881ab..d56d08c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -239,19 +239,18 @@ void printServices(const vector >& services) } } -void printComponents(vector& components) +void printComponents(const vec_sp_component& components) { - vector::const_iterator current; unsigned int index = 0; - for (current = components.begin(); current != components.end(); ++current) { - etiLog.level(info) << "Component " << (*current)->get_rc_name(); - printComponent(*current); + for (const auto component : components) { + etiLog.level(info) << "Component " << component->get_rc_name(); + printComponent(component); ++index; } } -void printComponent(DabComponent* component) +void printComponent(const shared_ptr& component) { etiLog.log(info, " service id: 0x%x (%u)", component->serviceId, component->serviceId); @@ -318,18 +317,16 @@ void printComponent(DabComponent* component) } } -void printSubchannels(vector& subchannels) +void printSubchannels(const vec_sp_subchannel& subchannels) { - vector::iterator subchannel; int index = 0; - for (subchannel = subchannels.begin(); subchannel != subchannels.end(); - ++subchannel) { - dabProtection* protection = &(*subchannel)->protection; - etiLog.level(info) << "Subchannel " << (*subchannel)->uid; + for (auto subchannel : subchannels) { + dabProtection* protection = &subchannel->protection; + etiLog.level(info) << "Subchannel " << subchannel->uid; etiLog.log(info, " input"); - etiLog.level(info) << " URI: " << (*subchannel)->inputUri; - switch ((*subchannel)->type) { + etiLog.level(info) << " URI: " << subchannel->inputUri; + switch (subchannel->type) { case subchannel_type_t::Audio: etiLog.log(info, " type: audio"); break; @@ -347,9 +344,9 @@ void printSubchannels(vector& subchannels) break; } etiLog.log(info, " id: 0x%x (%u)", - (*subchannel)->id, (*subchannel)->id); + subchannel->id, subchannel->id); etiLog.log(info, " bitrate: %i", - (*subchannel)->bitrate); + subchannel->bitrate); if (protection->form == UEP) { etiLog.log(info, " protection: UEP %i", protection->level + 1); etiLog.log(info, " index: %i", @@ -362,12 +359,12 @@ void printSubchannels(vector& subchannels) etiLog.log(info, " option: %i", protection->eep.GetOption()); etiLog.log(info, " level: %i", - (*subchannel)->protection.level); + subchannel->protection.level); } etiLog.log(info, " SAD: %u", - (*subchannel)->startAddress); + subchannel->startAddress); etiLog.log(info, " size (CU): %i", - (*subchannel)->getSizeCu()); + subchannel->getSizeCu()); ++index; } } diff --git a/src/utils.h b/src/utils.h index 995e8b6..c9beb8e 100644 --- a/src/utils.h +++ b/src/utils.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li This file contains a set of utility functions that are used to show @@ -70,15 +70,15 @@ void printOutputs(const std::vector >& outputs); void printServices(const std::vector >& services); -void printComponents(std::vector& components); +void printComponents(const vec_sp_component& components); -void printSubchannels(std::vector& subchannels); +void printSubchannels(const vec_sp_subchannel& subchannels); /* Print information about the whole ensemble */ void printEnsemble(const std::shared_ptr& ensemble); /* Print detailed component information */ -void printComponent(DabComponent* component); +void printComponent(const std::shared_ptr& component); long hexparse(const std::string& input); -- cgit v1.2.3