diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-08-21 10:08:51 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-08-21 10:08:51 +0200 |
commit | fa5f92318e7cc08ac872be18d47387cf83c23cd0 (patch) | |
tree | 118b12cf95b478fd20916f745c0d1a7873e16040 /contrib/edi/TagItems.h | |
parent | 781c2c69c62a434bed64ff3cfa6d009ed3c479c1 (diff) | |
download | ODR-AudioEnc-fa5f92318e7cc08ac872be18d47387cf83c23cd0.tar.gz ODR-AudioEnc-fa5f92318e7cc08ac872be18d47387cf83c23cd0.tar.bz2 ODR-AudioEnc-fa5f92318e7cc08ac872be18d47387cf83c23cd0.zip |
Add tist support for EDI output, take code from odr-mmbtools-common
Diffstat (limited to 'contrib/edi/TagItems.h')
-rw-r--r-- | contrib/edi/TagItems.h | 104 |
1 files changed, 97 insertions, 7 deletions
diff --git a/contrib/edi/TagItems.h b/contrib/edi/TagItems.h index 73e745a..25daa14 100644 --- a/contrib/edi/TagItems.h +++ b/contrib/edi/TagItems.h @@ -10,21 +10,21 @@ */ /* - This file is part of ODR-DabMux. + This file is part of the ODR-mmbTools. - ODR-DabMux is free software: you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - ODR-DabMux is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with ODR-DabMux. If not, see <http://www.gnu.org/licenses/>. - */ + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #pragma once @@ -33,7 +33,7 @@ #include <array> #include <chrono> #include <string> -#include <stdint.h> +#include <cstdint> namespace edi { @@ -47,8 +47,94 @@ class TagItem class TagStarPTR : public TagItem { public: - std::string protocol = ""; + TagStarPTR(const std::string& protocol); std::vector<uint8_t> Assemble(); + + private: + std::string m_protocol = ""; +}; + +// ETSI TS 102 693, 5.1.3 DAB ETI(LI) Management (deti) +class TagDETI : public TagItem +{ + public: + std::vector<uint8_t> Assemble(); + + /***** DATA in intermediary format ****/ + // For the ETI Header: must be defined ! + uint8_t stat = 0; + uint8_t mid = 0; + uint8_t fp = 0; + uint8_t rfa = 0; + uint8_t rfu = 0; // MNSC is valid + uint16_t mnsc = 0; + uint16_t dlfc = 0; // modulo 5000 frame counter + + // ATST (optional) + bool atstf = false; // presence of atst data + + /* UTCO: Offset (in seconds) between UTC and the Seconds value. The + * value is expressed as an unsigned 8-bit quantity. As of February + * 2009, the value shall be 2 and shall change as a result of each + * modification of the number of leap seconds, as proscribed by + * International Earth Rotation and Reference Systems Service (IERS). + * + * According to Annex F + * EDI = TAI - 32s (constant) + * EDI = UTC + UTCO + * we derive + * UTCO = TAI-UTC - 32 + * where the TAI-UTC offset is given by the USNO bulletin using + * the ClockTAI module. + */ + uint8_t utco = 0; + + /* Update the EDI time. t is in UTC */ + void set_edi_time(const std::time_t t, int tai_utc_offset); + + /* The number of SI seconds since 2000-01-01 T 00:00:00 UTC as an + * unsigned 32-bit quantity. Contrary to POSIX, this value also + * counts leap seconds. + */ + uint32_t seconds = 0; + + /* TSTA: Shall be the 24 least significant bits of the Time Stamp + * (TIST) field from the STI-D(LI) Frame. The full definition for the + * STI TIST can be found in annex B of EN 300 797 [4]. The most + * significant 8 bits of the TIST field of the incoming STI-D(LI) + * frame, if required, may be carried in the RFAD field. + */ + uint32_t tsta = 0xFFFFFF; + + // the FIC (optional) + bool ficf = false; + const unsigned char* fic_data; + size_t fic_length; + + // rfu + bool rfudf = false; + uint32_t rfud = 0; + + +}; + +// ETSI TS 102 693, 5.1.5 ETI Sub-Channel Stream <n> +class TagESTn : public TagItem +{ + public: + std::vector<uint8_t> Assemble(); + + // SSTCn + uint8_t scid; + uint16_t sad; + uint8_t tpl; + uint8_t rfa; + + // Pointer to MSTn data + uint8_t* mst_data; + size_t mst_length; // STLn * 8 bytes + + uint8_t id; }; // ETSI TS 102 693, 5.1.2 DAB STI-D(LI) Management @@ -101,6 +187,10 @@ class TagDSTI : public TagItem uint32_t tsta = 0xFFFFFF; std::array<uint8_t, 9> rfad; + + private: + int tai_offset_cache = 0; + std::time_t tai_offset_cache_updated_at = 0; }; // ETSI TS 102 693, 5.1.4 STI-D Payload Stream <m> |