diff options
Diffstat (limited to 'lib/edi/STIDecoder.cpp')
-rw-r--r-- | lib/edi/STIDecoder.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/edi/STIDecoder.cpp b/lib/edi/STIDecoder.cpp index d387f1e..0499c53 100644 --- a/lib/edi/STIDecoder.cpp +++ b/lib/edi/STIDecoder.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 + Copyright (C) 2025 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -20,7 +20,6 @@ */ #include "STIDecoder.hpp" #include "buffer_unpack.hpp" -#include "crc.h" #include "Log.h" #include <cstdio> #include <cassert> @@ -70,6 +69,12 @@ void STIDecoder::setMaxDelay(int num_af_packets) m_dispatcher.setMaxDelay(num_af_packets); } +void STIDecoder::filter_stream_index(bool enable, uint16_t index) +{ + m_filter_stream = enable; + m_filtered_stream_index = index; +} + #define AFPACKET_HEADER_LEN 10 // includes SYNC bool STIDecoder::decode_starptr(const std::vector<uint8_t>& value, const tag_name_t& /*n*/) @@ -173,6 +178,20 @@ bool STIDecoder::decode_ssn(const std::vector<uint8_t>& value, const tag_name_t& n = (uint16_t)(name[2]) << 8; n |= (uint16_t)(name[3]); + if (n == 0) { + if (not m_ssnn_zero_warning_printed) { + etiLog.level(warn) << "EDI: Stream index SSnn tag is zero"; + } + m_ssnn_zero_warning_printed = true; + } + else { + m_ssnn_zero_warning_printed = false; + } + + if (m_filter_stream and m_filtered_stream_index != n) { + return true; + } + sti.stream_index = n - 1; // n is 1-indexed sti.rfa = value[0] >> 3; sti.tid = value[0] & 0x07; @@ -183,14 +202,20 @@ bool STIDecoder::decode_ssn(const std::vector<uint8_t>& value, const tag_name_t& sti.stid = istc & 0xFFF; if (sti.rfa != 0) { - etiLog.level(warn) << "EDI: rfa field in SSnn tag non-null"; + if (not m_rfa_nonnull_warning_printed) { + etiLog.level(warn) << "EDI: rfa field in SSnn tag non-null"; + } + m_rfa_nonnull_warning_printed = true; + } + else { + m_rfa_nonnull_warning_printed = false; } copy( value.cbegin() + 3, value.cend(), back_inserter(sti.istd)); - m_data_collector.add_payload(move(sti)); + m_data_collector.add_payload(std::move(sti)); return true; } |