summaryrefslogtreecommitdiffstats
path: root/lib/edi/STIWriter.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-10-01 15:16:59 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-10-01 15:16:59 +0200
commite0cf82871fe24348101a0b565ea309e074e3663b (patch)
tree3412b5b4da94a66ef56aeac2c4196a3ec50cb619 /lib/edi/STIWriter.cpp
parent5ea9d01de68fc9d0f4c6578d41b09bfe541ea20f (diff)
downloaddabmux-e0cf82871fe24348101a0b565ea309e074e3663b.tar.gz
dabmux-e0cf82871fe24348101a0b565ea309e074e3663b.tar.bz2
dabmux-e0cf82871fe24348101a0b565ea309e074e3663b.zip
Pull code from common f2a36aa
Diffstat (limited to 'lib/edi/STIWriter.cpp')
-rw-r--r--lib/edi/STIWriter.cpp44
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;
}
}
-