aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edi/STIWriter.hpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-08-21 10:11:35 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-08-21 10:11:35 +0200
commit86ea8cd8b8b5af7917db28ae30cfb2d2886868fe (patch)
tree7222d8e077dd2155eecac68b8c78330bcfe5dc80 /lib/edi/STIWriter.hpp
parent86fbf91f7323a2c5626a357b8414b15e20c19c9e (diff)
parent5ee85c4ac41337e383eb1a735bc05f1e5d46a98f (diff)
downloaddabmux-86ea8cd8b8b5af7917db28ae30cfb2d2886868fe.tar.gz
dabmux-86ea8cd8b8b5af7917db28ae30cfb2d2886868fe.tar.bz2
dabmux-86ea8cd8b8b5af7917db28ae30cfb2d2886868fe.zip
Merge branch 'ediInput' into next
Diffstat (limited to 'lib/edi/STIWriter.hpp')
-rw-r--r--lib/edi/STIWriter.hpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/edi/STIWriter.hpp b/lib/edi/STIWriter.hpp
new file mode 100644
index 0000000..a75cb69
--- /dev/null
+++ b/lib/edi/STIWriter.hpp
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2019
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
+
+ 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 2 of the License, or
+ (at your option) any later version.
+
+ 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 this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#pragma once
+
+#include "common.hpp"
+#include "STIDecoder.hpp"
+#include <cstdint>
+#include <string>
+#include <vector>
+#include <list>
+
+namespace EdiDecoder {
+
+struct sti_frame_t {
+ std::vector<uint8_t> frame;
+ frame_timestamp_t timestamp;
+};
+
+class STIWriter : public STIDataCollector {
+ public:
+ // Tell the ETIWriter what EDI protocol we receive in *ptr.
+ // This is not part of the ETI data, but is used as check
+ virtual void update_protocol(
+ const std::string& proto,
+ uint16_t major,
+ uint16_t minor);
+
+ virtual void update_stat(uint8_t stat, uint16_t spid);
+
+ virtual void update_edi_time(
+ uint32_t utco,
+ uint32_t seconds);
+
+ virtual void update_rfad(std::array<uint8_t, 9> rfad);
+ virtual void update_sti_management(const sti_management_data& data);
+ virtual void add_payload(sti_payload_data&& payload);
+
+ virtual void assemble(void);
+
+ // Return the assembled frame or an empty frame if not ready
+ sti_frame_t getFrame();
+
+ private:
+ void reinit(void);
+
+ bool m_proto_valid = false;
+
+ bool m_management_data_valid = false;
+ sti_management_data m_management_data;
+
+ bool m_stat_valid = false;
+ uint8_t m_stat = 0;
+ uint16_t m_spid = 0;
+
+ bool m_time_valid = false;
+ uint32_t m_utco = 0;
+ uint32_t m_seconds = 0;
+
+ bool m_payload_valid = false;
+ sti_payload_data m_payload;
+
+ sti_frame_t m_stiFrame;
+};
+
+}
+