aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/advanced.mux3
-rw-r--r--src/DabMultiplexer.cpp12
-rw-r--r--src/DabMultiplexer.h2
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<string> 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<chrono::milliseconds>(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<double>("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();
};