diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-09-18 11:49:11 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-09-18 11:49:11 +0200 |
commit | 015427d9e74f34dc7d0f7fbad4ad1eaad6537cce (patch) | |
tree | 01ae9249194fbff234e32b59c07f7894aef16878 /lib/edi/STIDecoder.cpp | |
parent | 9c2e691744f96ae7ace8b82385b080ee9d858906 (diff) | |
download | dabmux-015427d9e74f34dc7d0f7fbad4ad1eaad6537cce.tar.gz dabmux-015427d9e74f34dc7d0f7fbad4ad1eaad6537cce.tar.bz2 dabmux-015427d9e74f34dc7d0f7fbad4ad1eaad6537cce.zip |
EDI in: add audio levels metadata and source version
Diffstat (limited to 'lib/edi/STIDecoder.cpp')
-rw-r--r-- | lib/edi/STIDecoder.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/edi/STIDecoder.cpp b/lib/edi/STIDecoder.cpp index aab93e0..1f5d45e 100644 --- a/lib/edi/STIDecoder.cpp +++ b/lib/edi/STIDecoder.cpp @@ -44,6 +44,10 @@ STIDecoder::STIDecoder(STIDataCollector& data_collector, bool verbose) : std::bind(&STIDecoder::decode_ssn, this, _1, _2)); m_dispatcher.register_tag("*dmy", std::bind(&STIDecoder::decode_stardmy, this, _1, _2)); + m_dispatcher.register_tag("ODRa", + std::bind(&STIDecoder::decode_odraudiolevel, this, _1, _2)); + m_dispatcher.register_tag("ODRv", + std::bind(&STIDecoder::decode_odrversion, this, _1, _2)); } void STIDecoder::push_bytes(const vector<uint8_t> &buf) @@ -183,6 +187,37 @@ bool STIDecoder::decode_stardmy(const vector<uint8_t>& /*value*/, uint16_t) return true; } +bool STIDecoder::decode_odraudiolevel(const vector<uint8_t>& value, uint16_t) +{ + constexpr size_t expected_length = 2 * sizeof(int16_t); + + audio_level_data audio_level; + + if (value.size() == expected_length) { + audio_level.left = read_16b(value.begin()); + audio_level.right = read_16b(value.begin() + 2); + } + else { + audio_level.left = 0; + audio_level.right = 0; + etiLog.level(warn) << "EDI: ODR AudioLevel TAG has wrong length!"; + } + + m_data_collector.update_audio_levels(audio_level); + + // Not being able to decode the audio level is a soft-failure, it should + // not disrupt decoding the actual audio data. + return true; +} + +bool STIDecoder::decode_odrversion(const vector<uint8_t>& value, uint16_t) +{ + const auto vd = parse_odr_version_data(value); + m_data_collector.update_odr_version(vd); + + return true; +} + void STIDecoder::packet_completed() { m_data_collector.assemble(); |