aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edi
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-12-10 15:47:32 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-12-10 15:47:32 +0100
commit66c2acf2606877d00e056c1d1228b32d0a15c5bc (patch)
treeb520bf648e8c511d772266e26bccf527859dbd1a /lib/edi
parente845a4188b93a31445a780ae11f33286420cb038 (diff)
downloaddabmux-66c2acf2606877d00e056c1d1228b32d0a15c5bc.tar.gz
dabmux-66c2acf2606877d00e056c1d1228b32d0a15c5bc.tar.bz2
dabmux-66c2acf2606877d00e056c1d1228b32d0a15c5bc.zip
Make EDI input TIST delay configurable
Diffstat (limited to 'lib/edi')
-rw-r--r--lib/edi/common.cpp13
-rw-r--r--lib/edi/common.hpp2
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/edi/common.cpp b/lib/edi/common.cpp
index d6ca89c..87a15ce 100644
--- a/lib/edi/common.cpp
+++ b/lib/edi/common.cpp
@@ -73,6 +73,19 @@ double frame_timestamp_t::diff_ms(const frame_timestamp_t& other) const
return lhs - rhs;
}
+frame_timestamp_t& frame_timestamp_t::operator+=(const std::chrono::milliseconds& ms)
+{
+ tsta += (ms.count() % 1000) << 14; // Shift ms by 14 to Timestamp level 2
+ if (tsta > 0xf9FFff) {
+ tsta -= 0xfa0000; // Substract 16384000, corresponding to one second
+ seconds += 1;
+ }
+
+ seconds += (ms.count() / 1000);
+
+ return *this;
+}
+
frame_timestamp_t frame_timestamp_t::from_unix_epoch(std::time_t time, uint32_t tai_utc_offset, uint32_t tsta)
{
frame_timestamp_t ts;
diff --git a/lib/edi/common.hpp b/lib/edi/common.hpp
index 8252a7a..2a9c683 100644
--- a/lib/edi/common.hpp
+++ b/lib/edi/common.hpp
@@ -43,6 +43,8 @@ struct frame_timestamp_t {
double diff_ms(const frame_timestamp_t& other) const;
+ frame_timestamp_t& operator+=(const std::chrono::milliseconds& ms);
+
static frame_timestamp_t from_unix_epoch(std::time_t time, uint32_t tai_utc_offset, uint32_t tsta);
};