aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edioutput
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-09-23 19:58:07 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-09-23 19:58:07 +0200
commitc5185cbf27cc01d0f097254d6a8e762a13281f52 (patch)
treee3f055e6cc0cb8eb13367a03c85dd271b361b0e6 /lib/edioutput
parentb4a452791dd37c12a2f59579586433055a7eaa02 (diff)
downloaddabmux-c5185cbf27cc01d0f097254d6a8e762a13281f52.tar.gz
dabmux-c5185cbf27cc01d0f097254d6a8e762a13281f52.tar.bz2
dabmux-c5185cbf27cc01d0f097254d6a8e762a13281f52.zip
Pull common code from 547c789
Diffstat (limited to 'lib/edioutput')
-rw-r--r--lib/edioutput/TagItems.cpp66
-rw-r--r--lib/edioutput/TagItems.h24
2 files changed, 90 insertions, 0 deletions
diff --git a/lib/edioutput/TagItems.cpp b/lib/edioutput/TagItems.cpp
index 35a6852..9746469 100644
--- a/lib/edioutput/TagItems.cpp
+++ b/lib/edioutput/TagItems.cpp
@@ -379,5 +379,71 @@ std::vector<uint8_t> TagStarDMY::Assemble()
return packet;
}
+TagODRVersion::TagODRVersion(const std::string& version, uint32_t uptime_s) :
+ m_version(version),
+ m_uptime(uptime_s)
+{
+}
+
+std::vector<uint8_t> TagODRVersion::Assemble()
+{
+ std::string pack_data("ODRv");
+ std::vector<uint8_t> packet(pack_data.begin(), pack_data.end());
+
+ const size_t length = m_version.size() + sizeof(uint32_t);
+
+ packet.resize(4 + 4 + length);
+
+ const uint32_t length_bits = length * 8;
+
+ size_t i = 4;
+ packet[i++] = (length_bits >> 24) & 0xFF;
+ packet[i++] = (length_bits >> 16) & 0xFF;
+ packet[i++] = (length_bits >> 8) & 0xFF;
+ packet[i++] = length_bits & 0xFF;
+
+ copy(m_version.cbegin(), m_version.cend(), packet.begin() + i);
+ i += m_version.size();
+
+ packet[i++] = (m_uptime >> 24) & 0xFF;
+ packet[i++] = (m_uptime >> 16) & 0xFF;
+ packet[i++] = (m_uptime >> 8) & 0xFF;
+ packet[i++] = m_uptime & 0xFF;
+
+ return packet;
+}
+
+TagODRAudioLevels::TagODRAudioLevels(int16_t audiolevel_left, int16_t audiolevel_right) :
+ m_audio_left(audiolevel_left),
+ m_audio_right(audiolevel_right)
+{
+}
+
+std::vector<uint8_t> TagODRAudioLevels::Assemble()
+{
+ std::string pack_data("ODRa");
+ std::vector<uint8_t> packet(pack_data.begin(), pack_data.end());
+
+ constexpr size_t length = 2*sizeof(int16_t);
+
+ packet.resize(4 + 4 + length);
+
+ const uint32_t length_bits = length * 8;
+
+ size_t i = 4;
+ packet[i++] = (length_bits >> 24) & 0xFF;
+ packet[i++] = (length_bits >> 16) & 0xFF;
+ packet[i++] = (length_bits >> 8) & 0xFF;
+ packet[i++] = length_bits & 0xFF;
+
+ packet[i++] = (m_audio_left >> 8) & 0xFF;
+ packet[i++] = m_audio_left & 0xFF;
+
+ packet[i++] = (m_audio_right >> 8) & 0xFF;
+ packet[i++] = m_audio_right & 0xFF;
+
+ return packet;
+}
+
}
diff --git a/lib/edioutput/TagItems.h b/lib/edioutput/TagItems.h
index 25daa14..5c81b01 100644
--- a/lib/edioutput/TagItems.h
+++ b/lib/edioutput/TagItems.h
@@ -225,5 +225,29 @@ class TagStarDMY : public TagItem
uint32_t length_;
};
+// Custom TAG that carries version information of the EDI source
+class TagODRVersion : public TagItem
+{
+ public:
+ TagODRVersion(const std::string& version, uint32_t uptime_s);
+ std::vector<uint8_t> Assemble();
+
+ private:
+ std::string m_version;
+ uint32_t m_uptime;
+};
+
+// Custom TAG that carries audio level metadata
+class TagODRAudioLevels : public TagItem
+{
+ public:
+ TagODRAudioLevels(int16_t audiolevel_left, int16_t audiolevel_right);
+ std::vector<uint8_t> Assemble();
+
+ private:
+ int16_t m_audio_left;
+ int16_t m_audio_right;
+};
+
}