diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-02-10 12:04:23 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-02-10 12:04:23 +0100 |
commit | 97458a2e08d5bf4904553eb76467fb047e4719f4 (patch) | |
tree | 41376d5827a576e7917b98a5ceb4acc9779cae2e /src | |
parent | 9719087ebcb4bd422c592f994f2e1691191e91d6 (diff) | |
download | dabmux-97458a2e08d5bf4904553eb76467fb047e4719f4.tar.gz dabmux-97458a2e08d5bf4904553eb76467fb047e4719f4.tar.bz2 dabmux-97458a2e08d5bf4904553eb76467fb047e4719f4.zip |
Add timestamp offset to management server for EDI input
Diffstat (limited to 'src')
-rw-r--r-- | src/ManagementServer.cpp | 11 | ||||
-rw-r--r-- | src/ManagementServer.h | 4 | ||||
-rw-r--r-- | src/input/Edi.cpp | 7 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/ManagementServer.cpp b/src/ManagementServer.cpp index f3b72d9..599d744 100644 --- a/src/ManagementServer.cpp +++ b/src/ManagementServer.cpp @@ -336,7 +336,8 @@ void ManagementServer::handle_message(zmq::message_t& zmq_message) } std::string answerstr(answer.str()); - m_zmq_sock.send(answerstr.c_str(), answerstr.size()); + zmq::const_buffer message(answerstr.data(), answerstr.size()); + m_zmq_sock.send(message, zmq::send_flags::none); } catch (const std::exception& e) { etiLog.level(error) << @@ -382,6 +383,13 @@ void InputStat::notifyBuffer(long bufsize) prune_statistics(time_now); } +void InputStat::notifyTimestampOffset(double offset) +{ + unique_lock<mutex> lock(m_mutex); + + m_last_tist_offset = offset; +} + void InputStat::notifyPeakLevels(int peak_left, int peak_right) { unique_lock<mutex> lock(m_mutex); @@ -558,6 +566,7 @@ std::string InputStat::encodeValuesJSON() "\"peak_right_slow\": " << to_dB(peak_right) << ", " "\"num_underruns\": " << m_num_underruns << ", " "\"num_overruns\": " << m_num_overruns << ", " + "\"last_tist_offset\": " << m_last_tist_offset << ", " "\"version\": \"" << version << "\", " "\"uptime\": " << m_uptime_s << ", " ; diff --git a/src/ManagementServer.h b/src/ManagementServer.h index e88d233..12f5ad6 100644 --- a/src/ManagementServer.h +++ b/src/ManagementServer.h @@ -97,6 +97,7 @@ class InputStat /* This function is called for every frame read by * the multiplexer */ void notifyBuffer(long bufsize); + void notifyTimestampOffset(double offset); void notifyPeakLevels(int peak_left, int peak_right); void notifyUnderrun(void); void notifyOverrun(void); @@ -123,6 +124,9 @@ class InputStat uint32_t m_num_underruns = 0; uint32_t m_num_overruns = 0; + // last measured timestamp offset + double m_last_tist_offset = 0; + // Peak audio levels (linear 16-bit PCM) for the two channels. // Keep a FIFO of values from the last minutes, apply // a short window to also see short-term fluctuations. diff --git a/src/input/Edi.cpp b/src/input/Edi.cpp index e6a7e3e..2aa776f 100644 --- a/src/input/Edi.cpp +++ b/src/input/Edi.cpp @@ -117,6 +117,7 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size) { // Save stats data in bytes, not in frames m_stats.notifyBuffer(m_frames.size() * size); + m_stats.notifyTimestampOffset(0); EdiDecoder::sti_frame_t sti; if (m_is_prebuffering) { @@ -221,6 +222,7 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, std::time_t seconds, int utc auto ts_req = EdiDecoder::frame_timestamp_t::from_unix_epoch(seconds, utco, tsta); ts_req += m_tist_delay; const double offset = ts_req.diff_s(m_pending_sti_frame.timestamp); + m_stats.notifyTimestampOffset(offset); if (offset < 0) { // Too far in the future @@ -265,12 +267,12 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, std::time_t seconds, int utc if (num_discarded_wrong_size > 0) { etiLog.level(warn) << "EDI input " << m_name << ": " << - num_discarded_wrong_size << "packets with wrong size."; + num_discarded_wrong_size << " packets with wrong size."; } if (num_discarded_invalid_ts > 0) { etiLog.level(warn) << "EDI input " << m_name << ": " << - num_discarded_wrong_size << "packets with invalid timestamp."; + num_discarded_wrong_size << " packets with invalid timestamp."; } memset(buffer, 0, size); @@ -298,6 +300,7 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, std::time_t seconds, int utc auto ts_req = EdiDecoder::frame_timestamp_t::from_unix_epoch(seconds, utco, tsta); ts_req += m_tist_delay; const double offset = m_pending_sti_frame.timestamp.diff_s(ts_req); + m_stats.notifyTimestampOffset(offset); if (-24e-3 < offset and offset <= 0) { if (not m_pending_sti_frame.version_data.version.empty()) { |