summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-28 11:13:54 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-28 11:13:54 +0100
commit2346b17f650e56f70046e95a54f356a8e3e29107 (patch)
treeba427ff50ce2f58b6a7e293237d7c40560faeac6 /src
parent0aaa6989c86eb6f15f49faee7ab0c013ebe89171 (diff)
downloaddabmux-2346b17f650e56f70046e95a54f356a8e3e29107.tar.gz
dabmux-2346b17f650e56f70046e95a54f356a8e3e29107.tar.bz2
dabmux-2346b17f650e56f70046e95a54f356a8e3e29107.zip
EDI: correct value of ATST seconds field
Diffstat (limited to 'src')
-rw-r--r--src/DabMultiplexer.cpp26
-rw-r--r--src/dabOutput/edi/TagItems.cpp10
-rw-r--r--src/dabOutput/edi/TagItems.h8
3 files changed, 22 insertions, 22 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp
index 15c57a5..5763c8a 100644
--- a/src/DabMultiplexer.cpp
+++ b/src/DabMultiplexer.cpp
@@ -662,20 +662,18 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
edi_tagDETI.tsta = 0xffffff;
}
- edi_tagDETI.atstf = 1;
- edi_tagDETI.utco = 0;
- edi_tagDETI.seconds = 0;
#if HAVE_OUTPUT_EDI
- try {
- const bool tist_enabled = m_pt.get("general.tist", false);
+ const bool tist_enabled = m_pt.get("general.tist", false);
- if (tist_enabled and m_tai_clock_required) {
- edi_tagDETI.set_seconds(edi_time +
- std::chrono::seconds(m_tist_edioffset));
-
- // In case get_offset fails, we still want to update the EDI seconds
+ if (tist_enabled and m_tai_clock_required) {
+ try {
const auto tai_utc_offset = m_clock_tai.get_offset();
- edi_tagDETI.set_tai_utc_offset(tai_utc_offset);
+
+ edi_tagDETI.set_edi_time(edi_time +
+ std::chrono::seconds(m_tist_edioffset),
+ tai_utc_offset);
+
+ edi_tagDETI.atstf = true;
for (auto output : outputs) {
shared_ptr<OutputMetadata> md_utco =
@@ -691,9 +689,9 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
output->setMetadata(md_dlfc);
}
}
- }
- catch (std::runtime_error& e) {
- etiLog.level(error) << "Could not get UTC-TAI offset for EDI timestamp";
+ catch (const std::runtime_error& e) {
+ etiLog.level(error) << "Could not get UTC-TAI offset for EDI timestamp";
+ }
}
#endif
diff --git a/src/dabOutput/edi/TagItems.cpp b/src/dabOutput/edi/TagItems.cpp
index ed8517d..631b88d 100644
--- a/src/dabOutput/edi/TagItems.cpp
+++ b/src/dabOutput/edi/TagItems.cpp
@@ -132,12 +132,14 @@ std::vector<uint8_t> TagDETI::Assemble()
return packet;
}
-void TagDETI::set_seconds(std::chrono::system_clock::time_point t)
+void TagDETI::set_edi_time(const std::chrono::system_clock::time_point& t, int tai_utc_offset)
{
- std::time_t posix_timestamp_1_jan_2000 = 946684800;
- seconds = std::chrono::system_clock::to_time_t(t) - posix_timestamp_1_jan_2000;
-}
+ utco = tai_utc_offset - 32;
+
+ const std::time_t posix_timestamp_1_jan_2000 = 946684800;
+ seconds = std::chrono::system_clock::to_time_t(t) - posix_timestamp_1_jan_2000 + utco;
+}
std::vector<uint8_t> TagESTn::Assemble()
{
diff --git a/src/dabOutput/edi/TagItems.h b/src/dabOutput/edi/TagItems.h
index 19284d2..8666053 100644
--- a/src/dabOutput/edi/TagItems.h
+++ b/src/dabOutput/edi/TagItems.h
@@ -85,15 +85,15 @@ class TagDETI : public TagItem
*/
uint8_t utco = 0;
- void set_tai_utc_offset(int tai_utc_offset) { utco = tai_utc_offset - 32; }
+ /* Update the EDI time. t is in UTC */
+ void set_edi_time(const std::chrono::system_clock::time_point &t, int tai_utc_offset);
/* The number of SI seconds since 2000-01-01 T 00:00:00 UTC as an
- * unsigned 32-bit quantity
+ * unsigned 32-bit quantity. Contrary to POSIX, this value also
+ * counts leap seconds.
*/
uint32_t seconds = 0;
- void set_seconds(std::chrono::system_clock::time_point t);
-
/* TSTA: Shall be the 24 least significant bits of the Time Stamp
* (TIST) field from the STI-D(LI) Frame. The full definition for the
* STI TIST can be found in annex B of EN 300 797 [4]. The most