diff options
Diffstat (limited to 'src/MuxElements.h')
-rw-r--r-- | src/MuxElements.h | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/src/MuxElements.h b/src/MuxElements.h index 3653ea4..ebcf708 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2014 + Copyright (C) 2014, 2015 Matthias P. Braendli, matthias.braendli@mpb.li This file defines all data structures used in DabMux to represent @@ -29,6 +29,7 @@ #define _MUX_ELEMENTS #include <vector> +#include <memory> #include <string> #include <functional> #include <algorithm> @@ -51,6 +52,7 @@ struct dabOutput { DabOutput* output; }; +#define DABLABEL_LENGTH 16 class DabLabel { @@ -61,7 +63,7 @@ class DabLabel * -2 if the short_label is too long * -3 if the text is too long */ - int setLabel(const std::string& text, const std::string& short_label); + int setLabel(const std::string& label, const std::string& short_label); /* Same as above, but sets the flag to 0xff00, truncating at 8 * characters. @@ -69,17 +71,28 @@ class DabLabel * returns: 0 on success * -3 if the text is too long */ - int setLabel(const std::string& text); + int setLabel(const std::string& label); + + /* Write the label to the 16-byte buffer given in buf + * In the DAB standard, the label is 16 bytes long, and is + * padded using spaces. + */ + void writeLabel(uint8_t* buf) const; - const char* text() const { return m_text; } uint16_t flag() const { return m_flag; } + const std::string long_label() const { return m_label; } const std::string short_label() const; private: - // In the DAB standard, the label is 16 chars. - // We keep it here zero-terminated - char m_text[17]; + /* The flag field selects which label characters make + * up the short label + */ uint16_t m_flag; + + /* The m_label is not padded in any way */ + std::string m_label; + + /* Checks and calculates the flag */ int setShortLabel(const std::string& slabel); }; @@ -87,7 +100,7 @@ class DabLabel class DabService; class DabComponent; -struct dabSubchannel; +class dabSubchannel; class dabEnsemble : public RemoteControllable { public: dabEnsemble() @@ -118,7 +131,7 @@ class dabEnsemble : public RemoteControllable { int international_table; - std::vector<DabService*> services; + std::vector<std::shared_ptr<DabService> > services; std::vector<DabComponent*> components; std::vector<dabSubchannel*> subchannels; }; @@ -166,7 +179,16 @@ enum dab_subchannel_type_t { Packet = 3 }; -struct dabSubchannel { +class dabSubchannel +{ +public: + dabSubchannel(std::string& uid) : + uid(uid) + { + } + + std::string uid; + std::string inputUri; DabInputBase* input; unsigned char id; @@ -220,12 +242,15 @@ struct dabPacketComponent { class DabComponent : public RemoteControllable { public: - DabComponent(std::string uid) : - RemoteControllable(uid) + DabComponent(std::string& uid) : + RemoteControllable(uid), + uid(uid) { RC_ADD_PARAMETER(label, "Label and shortlabel [label,short]"); } + std::string uid; + DabLabel label; uint32_t serviceId; uint8_t subchId; @@ -258,18 +283,21 @@ class DabComponent : public RemoteControllable class DabService : public RemoteControllable { public: - DabService(std::string uid) : - RemoteControllable(uid) + DabService(std::string& uid) : + RemoteControllable(uid), + uid(uid) { RC_ADD_PARAMETER(label, "Label and shortlabel [label,short]"); } + std::string uid; + uint32_t id; unsigned char pty; unsigned char language; bool program; - unsigned char getType(dabEnsemble* ensemble); + unsigned char getType(boost::shared_ptr<dabEnsemble> ensemble); unsigned char nbComponent(std::vector<DabComponent*>& components); DabLabel label; @@ -300,9 +328,9 @@ std::vector<DabComponent*>::iterator getComponent( std::vector<DabComponent*>& components, uint32_t serviceId); -std::vector<DabService*>::iterator getService( +std::vector<std::shared_ptr<DabService> >::iterator getService( DabComponent* component, - std::vector<DabService*>& services); + std::vector<std::shared_ptr<DabService> >& services); unsigned short getSizeCu(dabSubchannel* subchannel); @@ -312,5 +340,5 @@ unsigned short getSizeByte(dabSubchannel* subchannel); unsigned short getSizeWord(dabSubchannel* subchannel); - #endif + |