From 9c5b00e8cd05d3e484d6bbfbee351845598cd2ec Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 17 Feb 2025 08:05:36 +0100 Subject: Add tist_at_fct0 configuration --- doc/advanced.mux | 3 +++ src/DabMultiplexer.cpp | 12 +++++++++--- src/DabMultiplexer.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/advanced.mux b/doc/advanced.mux index 246f981..618a6b6 100644 --- a/doc/advanced.mux +++ b/doc/advanced.mux @@ -36,6 +36,9 @@ general { ; in seconds. ; tist_offset 0 + ; Specify the TIST value for the frame with FCT==0, in microseconds + ; tist_at_fct0 768000 + ; The management server is a simple TCP server that can present ; statistics data (buffers, overruns, underruns, etc) ; which can then be graphed a tool like Munin diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index 095a835..a68f09a 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -46,7 +46,7 @@ static vector split_pipe_separated_string(const std::string& s) return components; } -uint64_t MuxTime::init() +uint64_t MuxTime::init(uint32_t tist_at_fct0_us) { /* At startup, derive edi_time, TIST and CIF count such that there is * a consistency across mux restarts. Ensure edi_time and TIST represent @@ -83,7 +83,12 @@ uint64_t MuxTime::init() int64_t offset_ms = chrono::duration_cast(offset).count(); offset_ms += 1000 * (t_now - m_edi_time); - m_timestamp = 0; + if (tist_at_fct0_us >= 1000000) { + etiLog.level(error) << "tist_at_fct0 may not be larger than 1s"; + throw MuxInitException(); + } + + m_timestamp = (uint64_t)tist_at_fct0_us * 16384 / 1000; while (offset_ms >= 24) { increment_timestamp(); currentFrame++; @@ -177,7 +182,8 @@ void DabMultiplexer::prepare(bool require_tai_clock) throw MuxInitException(); } - currentFrame = m_time.init(); + const uint32_t tist_at_fct0_us = m_pt.get("general.tist_at_fct0", 0); + currentFrame = m_time.init(tist_at_fct0_us); m_time.mnsc_increment_time = false; bool tist_enabled = m_pt.get("general.tist", false); diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h index 92fa2c0..aa6adfb 100644 --- a/src/DabMultiplexer.h +++ b/src/DabMultiplexer.h @@ -67,7 +67,7 @@ class MuxTime { std::time_t mnsc_time = 0; /* Setup the time and return the initial currentFrame counter value */ - uint64_t init(); + uint64_t init(uint32_t tist_at_fct0_us); void increment_timestamp(); }; -- cgit v1.2.3