summaryrefslogtreecommitdiffstats
path: root/src/EtiReader.cpp
diff options
context:
space:
mode:
authorMatthias (think) <matthias@mpb.li>2012-07-11 12:00:56 +0200
committerMatthias (think) <matthias@mpb.li>2012-07-11 12:00:56 +0200
commit4b814d92fe9787bf72ed3a9632e0866f4cedd27f (patch)
treefeb407e9f2c0658dda896c332864fe6d265aaece /src/EtiReader.cpp
parente92f9c408634810828e75d4ad6da408e1c142195 (diff)
downloaddabmod-4b814d92fe9787bf72ed3a9632e0866f4cedd27f.tar.gz
dabmod-4b814d92fe9787bf72ed3a9632e0866f4cedd27f.tar.bz2
dabmod-4b814d92fe9787bf72ed3a9632e0866f4cedd27f.zip
added crc-dabmod patch
Diffstat (limited to 'src/EtiReader.cpp')
-rw-r--r--src/EtiReader.cpp48
1 files changed, 43 insertions, 5 deletions
diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp
index d65dbe0..7e7d4af 100644
--- a/src/EtiReader.cpp
+++ b/src/EtiReader.cpp
@@ -1,6 +1,9 @@
/*
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
+
+ Includes modifications for which no copyright is claimed
+ 2012, Matthias P. Braendli, matthias.braendli@mpb.li
*/
/*
This file is part of CRC-DADMOD.
@@ -21,10 +24,12 @@
#include "EtiReader.h"
#include "PcDebug.h"
+#include "TimestampDecoder.h"
#include <stdexcept>
#include <sys/types.h>
#include <string.h>
+#include <arpa/inet.h>
enum ETI_READER_STATE {
@@ -42,15 +47,15 @@ enum ETI_READER_STATE {
};
-EtiReader::EtiReader() : state(EtiReaderStateSync),
- myFicSource(NULL)
+EtiReader::EtiReader(struct modulator_offset_config& modconf) :
+ state(EtiReaderStateSync), myFicSource(NULL)
{
PDEBUG("EtiReader::EtiReader()\n");
myCurrentFrame = 0;
+ myTimestampDecoder = new TimestampDecoder(modconf);
}
-
EtiReader::~EtiReader()
{
PDEBUG("EtiReader::~EtiReader()\n");
@@ -76,9 +81,9 @@ unsigned EtiReader::getMode()
}
-unsigned EtiReader::getFct()
+unsigned EtiReader::getFp()
{
- return eti_fc.FCT;
+ return eti_fc.FP;
}
@@ -266,5 +271,38 @@ int EtiReader::process(Buffer* dataIn)
}
}
+ // Update timestamps
+ myTimestampDecoder->updateTimestampEti(eti_fc.FP & 0x3,
+ eti_eoh.MNSC,
+ getPPSOffset());
+
+ if (getFCT() % 125 == 0) //every 3 seconds is fine enough
+ {
+ myTimestampDecoder->updateModulatorOffset();
+ }
+
return dataIn->getLength() - input_size;
}
+
+bool EtiReader::sourceContainsTimestamp()
+{
+ return (ntohl(eti_tist.TIST) & 0xFFFFFF) != 0xFFFFFF;
+ /* See ETS 300 799, Annex C.2.2 */
+}
+
+double EtiReader::getPPSOffset()
+{
+ if (!sourceContainsTimestamp())
+ return 0.0;
+
+ uint32_t timestamp = ntohl(eti_tist.TIST) & 0xFFFFFF;
+ //fprintf(stderr, "TIST 0x%x\n", timestamp);
+ double pps = timestamp / 16384000.0; // seconds
+
+ return pps;
+}
+
+uint32_t EtiReader::getFCT()
+{
+ return eti_fc.FCT;
+}