diff options
Diffstat (limited to 'lib/edi/STIWriter.cpp')
-rw-r--r-- | lib/edi/STIWriter.cpp | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/lib/edi/STIWriter.cpp b/lib/edi/STIWriter.cpp index ea3bfe8..b0e2bc2 100644 --- a/lib/edi/STIWriter.cpp +++ b/lib/edi/STIWriter.cpp @@ -34,6 +34,11 @@ namespace EdiDecoder { using namespace std; +STIWriter::STIWriter(std::function<void(sti_frame_t&&)>&& frame_callback) : + m_frame_callback(move(frame_callback)) +{ +} + void STIWriter::update_protocol( const std::string& proto, uint16_t major, @@ -46,16 +51,6 @@ void STIWriter::update_protocol( } } -void STIWriter::reinit() -{ - m_proto_valid = false; - m_management_data_valid = false; - m_stat_valid = false; - m_time_valid = false; - m_payload_valid = false; - m_audio_levels = audio_level_data(); - m_stiFrame.frame.clear(); -} void STIWriter::update_stat(uint8_t stat, uint16_t spid) { @@ -127,26 +122,19 @@ void STIWriter::assemble() // TODO check time validity - // Do copies so as to preserve existing payload data - m_stiFrame.frame = m_payload.istd; - m_stiFrame.audio_levels = m_audio_levels; - m_stiFrame.version_data = m_version_data; - m_stiFrame.timestamp.seconds = m_seconds; - m_stiFrame.timestamp.utco = m_utco; - m_stiFrame.timestamp.tsta = m_management_data.tsta; -} + sti_frame_t stiFrame; + stiFrame.frame = move(m_payload.istd); + stiFrame.timestamp.seconds = m_seconds; + stiFrame.timestamp.utco = m_utco; + stiFrame.timestamp.tsta = m_management_data.tsta; -sti_frame_t STIWriter::getFrame() -{ - if (m_stiFrame.frame.empty()) { - return {}; - } + m_frame_callback(move(stiFrame)); - sti_frame_t sti; - swap(sti, m_stiFrame); - reinit(); - return sti; + m_proto_valid = false; + m_management_data_valid = false; + m_stat_valid = false; + m_time_valid = false; + m_payload_valid = false; } } - |