summaryrefslogtreecommitdiffstats
path: root/src/Outputs.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-08-21 10:08:51 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-08-21 10:08:51 +0200
commitfa5f92318e7cc08ac872be18d47387cf83c23cd0 (patch)
tree118b12cf95b478fd20916f745c0d1a7873e16040 /src/Outputs.cpp
parent781c2c69c62a434bed64ff3cfa6d009ed3c479c1 (diff)
downloadODR-AudioEnc-fa5f92318e7cc08ac872be18d47387cf83c23cd0.tar.gz
ODR-AudioEnc-fa5f92318e7cc08ac872be18d47387cf83c23cd0.tar.bz2
ODR-AudioEnc-fa5f92318e7cc08ac872be18d47387cf83c23cd0.zip
Add tist support for EDI output, take code from odr-mmbtools-common
Diffstat (limited to 'src/Outputs.cpp')
-rw-r--r--src/Outputs.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/Outputs.cpp b/src/Outputs.cpp
index 31c7912..f258881 100644
--- a/src/Outputs.cpp
+++ b/src/Outputs.cpp
@@ -135,7 +135,9 @@ bool ZMQ::write_frame(const uint8_t *buf, size_t len)
return true;
}
-EDI::EDI() { }
+EDI::EDI() :
+ m_clock_tai({})
+{ }
EDI::~EDI() { }
@@ -170,20 +172,51 @@ bool EDI::enabled() const
return not m_edi_conf.destinations.empty();
}
+void EDI::set_tist(bool enable, uint32_t delay_ms)
+{
+ m_tist = enable;
+ m_delay_ms = delay_ms;
+}
+
bool EDI::write_frame(const uint8_t *buf, size_t len)
{
if (not m_edi_sender) {
m_edi_sender = make_shared<edi::Sender>(m_edi_conf);
}
- edi::TagStarPTR edi_tagStarPtr;
- edi_tagStarPtr.protocol = "DSTI";
+ if (m_edi_time == 0) {
+ using Sec = chrono::seconds;
+ const auto now = chrono::time_point_cast<Sec>(chrono::system_clock::now());
+ m_edi_time = chrono::system_clock::to_time_t(now) + (m_delay_ms / 1000);
+
+ /* TODO we still have to see if 24ms granularity is achievable, given that
+ * one DAB+ super frame is carried over more than 1 ETI frame.
+ */
+ for (int32_t sub_ms = (m_delay_ms % 1000); sub_ms > 0; sub_ms -= 24) {
+ m_timestamp += 24 << 14; // Shift 24ms by 14 to Timestamp level 2
+ }
+
+ }
+
+ edi::TagStarPTR edi_tagStarPtr("DSTI");
m_edi_tagDSTI.stihf = false;
- m_edi_tagDSTI.atstf = false;
+ m_edi_tagDSTI.atstf = m_tist;
+
+ m_timestamp += 24 << 14; // Shift 24ms by 14 to Timestamp level 2
+ if (m_timestamp > 0xf9FFff) {
+ m_timestamp -= 0xfa0000; // Substract 16384000, corresponding to one second
+ m_edi_time += 1;
+ }
+
+ m_edi_tagDSTI.set_edi_time(m_edi_time, m_clock_tai.get_offset());
+ m_edi_tagDSTI.tsta = m_timestamp & 0xffffff;
+
m_edi_tagDSTI.rfadf = false;
// DFCT is handled inside the TagDSTI
+ // TODO invent custom TAG to carry audio levels metadata
+
edi::TagSSm edi_tagPayload;
// TODO make edi_tagPayload.stid configurable
edi_tagPayload.istd_data = buf;