summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-07 10:58:29 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-07 10:58:29 +0100
commit39a70386994b1ab8876bd020d3755ce609903c48 (patch)
tree0d612e39420350f46f1a7b9435255ed4461a58c6
parentb92491d93d7759fefdc96552f5319d7a38e47895 (diff)
downloaddabmod-39a70386994b1ab8876bd020d3755ce609903c48.tar.gz
dabmod-39a70386994b1ab8876bd020d3755ce609903c48.tar.bz2
dabmod-39a70386994b1ab8876bd020d3755ce609903c48.zip
Add metadata to SDR output
-rw-r--r--src/output/SDR.cpp42
-rw-r--r--src/output/SDR.h6
2 files changed, 32 insertions, 16 deletions
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp
index ba296de..d7d777f 100644
--- a/src/output/SDR.cpp
+++ b/src/output/SDR.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2018
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -57,8 +57,7 @@ static constexpr double TIMESTAMP_ABORT_FUTURE = 100;
static constexpr double TIMESTAMP_MARGIN_FUTURE = 0.5;
SDR::SDR(SDRDeviceConfig& config, std::shared_ptr<SDRDevice> device) :
- ModOutput(),
- RemoteControllable("sdr"),
+ ModOutput(), ModMetadata(), RemoteControllable("sdr"),
m_config(config),
m_running(false),
m_device(device)
@@ -97,23 +96,38 @@ void SDR::stop()
int SDR::process(Buffer *dataIn)
{
- if (m_device) {
- FrameData frame;
- frame.buf.resize(dataIn->getLength());
+ const uint8_t* pDataIn = (uint8_t*)dataIn->getData();
+ m_frame.resize(dataIn->getLength());
+ std::copy(pDataIn, pDataIn + dataIn->getLength(),
+ m_frame.begin());
- const uint8_t* pDataIn = (uint8_t*)dataIn->getData();
- std::copy(pDataIn, pDataIn + dataIn->getLength(),
- frame.buf.begin());
+ // We will effectively transmit the frame once we got the metadata.
- m_eti_source->calculateTimestamp(frame.ts);
+ return dataIn->getLength();
+}
- // TODO check device running
+meta_vec_t SDR::process_metadata(const meta_vec_t& metadataIn)
+{
+ if (m_device) {
+ FrameData frame;
+ frame.buf = std::move(m_frame);
- if (frame.ts.fct == -1) {
+ if (metadataIn.empty()) {
etiLog.level(info) <<
"SDR output: dropping one frame with invalid FCT";
}
else {
+ /* In transmission modes where several ETI frames are needed to
+ * build one transmission frame (like in TM 1), we will have
+ * several entries in metadataIn. Take the first one, which
+ * comes from the earliest ETI frame.
+ * This behaviour is different to earlier versions of ODR-DabMod,
+ * which took the timestamp from the latest ETI frame.
+ */
+ frame.ts = *(metadataIn[0].ts);
+
+ // TODO check device running
+
try {
if (m_dpd_feedback_server) {
m_dpd_feedback_server->set_tx_frame(frame.buf, frame.ts);
@@ -137,10 +151,10 @@ int SDR::process(Buffer *dataIn)
else {
// Ignore frame
}
-
- return dataIn->getLength();
+ return {};
}
+
void SDR::process_thread_entry()
{
// Set thread priority to realtime
diff --git a/src/output/SDR.h b/src/output/SDR.h
index d3693da..ea787c3 100644
--- a/src/output/SDR.h
+++ b/src/output/SDR.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2018
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -43,7 +43,7 @@ namespace Output {
using complexf = std::complex<float>;
-class SDR : public ModOutput, public RemoteControllable {
+class SDR : public ModOutput, public ModMetadata, public RemoteControllable {
public:
SDR(SDRDeviceConfig& config, std::shared_ptr<SDRDevice> device);
SDR(const SDR& other) = delete;
@@ -51,6 +51,7 @@ class SDR : public ModOutput, public RemoteControllable {
~SDR();
virtual int process(Buffer *dataIn) override;
+ virtual meta_vec_t process_metadata(const meta_vec_t& metadataIn) override;
virtual const char* name() override;
@@ -76,6 +77,7 @@ class SDR : public ModOutput, public RemoteControllable {
std::atomic<bool> m_running;
std::thread m_device_thread;
+ std::vector<uint8_t> m_frame;
ThreadsafeQueue<FrameData> m_queue;
std::shared_ptr<SDRDevice> m_device;