From ceb14883102e52daff611077adfe1b63837c3a76 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 20 Jan 2017 12:13:43 +0100 Subject: EDI input: decode timestamps --- src/EtiReader.cpp | 12 +++++++++++- src/EtiReader.h | 5 +---- src/TimestampDecoder.cpp | 9 +++++---- src/TimestampDecoder.h | 6 +++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index de23142..0b27126 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -291,6 +291,11 @@ bool EtiReader::sourceContainsTimestamp() /* See ETS 300 799, Annex C.2.2 */ } +void EtiReader::calculateTimestamp(struct frame_timestamp& ts) +{ + myTimestampDecoder.calculateTimestamp(ts); +} + uint32_t EtiReader::getPPSOffset() { if (!sourceContainsTimestamp()) { @@ -357,6 +362,7 @@ bool EdiReader::sourceContainsTimestamp() void EdiReader::calculateTimestamp(struct frame_timestamp& ts) { + m_timestamp_decoder.calculateTimestamp(ts); } bool EdiReader::isFrameReady() @@ -521,8 +527,12 @@ void EdiReader::assemble() /* According to Annex F * EDI = UTC + UTCO * We need UTC = EDI - UTCO + * + * The seconds value is given in number of seconds since + * 1.1.2000 */ - auto utc_ts = m_seconds - m_utco; + const std::time_t posix_timestamp_1_jan_2000 = 946684800; + auto utc_ts = posix_timestamp_1_jan_2000 + m_seconds - m_utco; m_timestamp_decoder.updateTimestampEdi( utc_ts, m_fc.tsta, m_fc.fct()); diff --git a/src/EtiReader.h b/src/EtiReader.h index 5231365..892afb4 100644 --- a/src/EtiReader.h +++ b/src/EtiReader.h @@ -88,10 +88,7 @@ public: int loadEtiData(const Buffer& dataIn); virtual bool sourceContainsTimestamp(); - virtual void calculateTimestamp(struct frame_timestamp& ts) - { - myTimestampDecoder.calculateTimestamp(ts); - } + virtual void calculateTimestamp(struct frame_timestamp& ts); virtual const std::vector > getSubchannels() const; diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp index 42d53ab..eb3a848 100644 --- a/src/TimestampDecoder.cpp +++ b/src/TimestampDecoder.cpp @@ -34,8 +34,8 @@ #include "Eti.h" #include "Log.h" -//#define MDEBUG(fmt, args...) fprintf (LOG, "*****" fmt , ## args) -#define MDEBUG(fmt, args...) PDEBUG(fmt, ## args) +//#define MDEBUG(fmt, args...) fprintf (LOG, "*****" fmt , ## args) +#define MDEBUG(fmt, args...) PDEBUG(fmt, ## args) void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts) @@ -44,7 +44,7 @@ void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts) std::make_shared(); /* Push new timestamp into queue */ - ts_queued->timestamp_valid = full_timestamp_received_mnsc; + ts_queued->timestamp_valid = full_timestamp_received; ts_queued->timestamp_sec = time_secs; ts_queued->timestamp_pps = time_pps; ts_queued->fct = latestFCT; @@ -144,7 +144,7 @@ void TimestampDecoder::pushMNSCData(int framephase, uint16_t mnsc) if (enableDecode) { - full_timestamp_received_mnsc = true; + full_timestamp_received = true; updateTimestampSeconds(mktime(&temp_time)); } break; @@ -205,6 +205,7 @@ void TimestampDecoder::updateTimestampEdi( updateTimestampPPS(pps); time_secs = seconds_utc; latestFCT = fct; + full_timestamp_received = true; } void TimestampDecoder::set_parameter( diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h index a822ee5..f2299f2 100644 --- a/src/TimestampDecoder.h +++ b/src/TimestampDecoder.h @@ -121,7 +121,7 @@ class TimestampDecoder : public RemoteControllable time_secs = 0; latestFCT = 0; enableDecode = false; - full_timestamp_received_mnsc = false; + full_timestamp_received = false; gmtime_r(0, &temp_time); offset_changed = false; @@ -193,8 +193,8 @@ class TimestampDecoder : public RemoteControllable */ bool enableDecode; - /* Disable timstamps until full time has been received in mnsc */ - bool full_timestamp_received_mnsc; + /* Disable timstamps until full time has been received */ + bool full_timestamp_received; /* when pipelining, we must shift the calculated timestamps * through this queue. Otherwise, it would not be possible to -- cgit v1.2.3