From 6b9857cb1b2ab6b58e6e42df4b0cce54448b10a0 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 14 Feb 2014 11:14:41 +0100 Subject: improve handling of labels --- src/MuxElements.h | 56 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) (limited to 'src/MuxElements.h') diff --git a/src/MuxElements.h b/src/MuxElements.h index 09f969d..9658fb2 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -3,8 +3,8 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Includes modifications - 2012, Matthias P. Braendli, matthias.braendli@mpb.li + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li This file defines all data structures used in DabMux to represent and save ensemble data. @@ -29,6 +29,7 @@ #define _MUX_ELEMENTS #include +#include #include #include #include @@ -52,9 +53,32 @@ struct dabOutput { }; -struct dabLabel { - char text[16]; - uint16_t flag; +class DabLabel +{ + public: + /* Set a new label and short label. + * returns: 0 on success + * -1 if the short_label is not a representable + * -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); + + /* Same as above, but sets the flag to 0xff00, truncating at 8 + * characters. + * + * returns: 0 on success + * -3 if the text is too long + */ + int setLabel(const std::string& text); + + const char* text() const { return m_text; } + uint16_t flag() const { return m_flag; } + + private: + char m_text[16]; + uint16_t m_flag; + int setShortLabel(const std::string& slabel); }; @@ -64,7 +88,7 @@ struct dabSubchannel; struct dabEnsemble { uint16_t id; uint8_t ecc; - dabLabel label; + DabLabel label; uint8_t mode; vector services; vector components; @@ -136,7 +160,7 @@ struct dabPacketComponent { struct dabComponent { - dabLabel label; + DabLabel label; uint32_t serviceId; uint8_t subchId; uint8_t type; @@ -153,15 +177,17 @@ struct dabComponent { -struct dabService { - dabLabel label; - uint32_t id; - unsigned char pty; - unsigned char language; - bool program; +struct dabService +{ + uint32_t id; + unsigned char pty; + unsigned char language; + bool program; - unsigned char getType(dabEnsemble* ensemble); - unsigned char nbComponent(vector& components); + unsigned char getType(dabEnsemble* ensemble); + unsigned char nbComponent(vector& components); + + DabLabel label; }; vector::iterator getSubchannel( -- cgit v1.2.3