From 1d833b718845b97a5b1d90f33b547b1772bc0708 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 7 Jan 2018 08:49:29 +0100 Subject: Add new flowgraph path for metadata --- src/Flowgraph.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 8 deletions(-) (limited to 'src/Flowgraph.cpp') diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index 465ef41..0b80a8c 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -26,6 +26,8 @@ #include "Flowgraph.h" #include "PcDebug.h" +#include "Log.h" +#include "TimestampDecoder.h" #include #include #include @@ -57,9 +59,10 @@ Node::~Node() assert(myOutputBuffers.size() == 0); } -void Node::addOutputBuffer(Buffer::sptr& buffer) +void Node::addOutputBuffer(Buffer::sptr& buffer, Metadata_vec_sptr& md) { myOutputBuffers.push_back(buffer); + myOutputMetadata.push_back(md); #if DEBUG std::string fname = string(myPlugin->name()) + "-" + to_string(myDebugFiles.size()) + @@ -71,7 +74,7 @@ void Node::addOutputBuffer(Buffer::sptr& buffer) #endif } -void Node::removeOutputBuffer(Buffer::sptr& buffer) +void Node::removeOutputBuffer(Buffer::sptr& buffer, Metadata_vec_sptr& md) { auto it = std::find( myOutputBuffers.begin(), @@ -89,14 +92,23 @@ void Node::removeOutputBuffer(Buffer::sptr& buffer) #endif myOutputBuffers.erase(it); } + + auto mdit = std::find( + myOutputMetadata.begin(), + myOutputMetadata.end(), + md); + if (mdit != myOutputMetadata.end()) { + myOutputMetadata.erase(mdit); + } } -void Node::addInputBuffer(Buffer::sptr& buffer) +void Node::addInputBuffer(Buffer::sptr& buffer, Metadata_vec_sptr& md) { myInputBuffers.push_back(buffer); + myInputMetadata.push_back(md); } -void Node::removeInputBuffer(Buffer::sptr& buffer) +void Node::removeInputBuffer(Buffer::sptr& buffer, Metadata_vec_sptr& md) { auto it = std::find( myInputBuffers.begin(), @@ -105,6 +117,14 @@ void Node::removeInputBuffer(Buffer::sptr& buffer) if (it != myInputBuffers.end()) { myInputBuffers.erase(it); } + + auto mdit = std::find( + myInputMetadata.begin(), + myInputMetadata.end(), + md); + if (mdit != myInputMetadata.end()) { + myInputMetadata.erase(mdit); + } } int Node::process() @@ -127,6 +147,36 @@ int Node::process() } int ret = myPlugin->process(inBuffers, outBuffers); + + // Collect all incoming metadata into a single vector + meta_vec_t all_input_mds; + for (auto& md_vec_sp : myInputMetadata) { + if (md_vec_sp) { + copy(md_vec_sp->begin(), md_vec_sp->end(), + back_inserter(all_input_mds)); + } + } + + auto mod_meta = dynamic_pointer_cast(myPlugin); + if (mod_meta) { + auto outputMetadata = mod_meta->process_metadata(all_input_mds); + // Distribute the result metadata to all outputs + for (auto& out_md : myOutputMetadata) { + out_md->clear(); + std::move(outputMetadata.begin(), outputMetadata.end(), + std::back_inserter(*out_md)); + } + } + else { + // Propagate the unmodified input metadata to all outputs + for (auto& out_md : myOutputMetadata) { + out_md->clear(); + std::move(all_input_mds.begin(), all_input_mds.end(), + std::back_inserter(*out_md)); + } + } + + #if DEBUG assert(myDebugFiles.size() == myOutputBuffers.size()); @@ -158,8 +208,10 @@ Edge::Edge(shared_ptr& srcNode, shared_ptr& dstNode) : this); myBuffer = make_shared(); - srcNode->addOutputBuffer(myBuffer); - dstNode->addInputBuffer(myBuffer); + myMetadata = make_shared >(); + + srcNode->addOutputBuffer(myBuffer, myMetadata); + dstNode->addInputBuffer(myBuffer, myMetadata); } @@ -168,8 +220,8 @@ Edge::~Edge() PDEBUG("Edge::~Edge() @ %p\n", this); if (myBuffer) { - mySrcNode->removeOutputBuffer(myBuffer); - myDstNode->removeInputBuffer(myBuffer); + mySrcNode->removeOutputBuffer(myBuffer, myMetadata); + myDstNode->removeInputBuffer(myBuffer, myMetadata); } } -- cgit v1.2.3 From 7ddaefab49e31a3ff360225b929633e7be161947 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 7 Jan 2018 11:50:35 +0100 Subject: Avoid some includes, remove unused variables, update comments --- src/BlockPartitioner.cpp | 1 - src/Flowgraph.cpp | 3 +-- src/Flowgraph.h | 2 +- src/Resampler.h | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src/Flowgraph.cpp') diff --git a/src/BlockPartitioner.cpp b/src/BlockPartitioner.cpp index 54405d9..5767650 100644 --- a/src/BlockPartitioner.cpp +++ b/src/BlockPartitioner.cpp @@ -27,7 +27,6 @@ #include "BlockPartitioner.h" #include "PcDebug.h" #include "Log.h" -#include "TimestampDecoder.h" #include #include diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index 0b80a8c..e12ff1e 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -2,7 +2,7 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -27,7 +27,6 @@ #include "Flowgraph.h" #include "PcDebug.h" #include "Log.h" -#include "TimestampDecoder.h" #include #include #include diff --git a/src/Flowgraph.h b/src/Flowgraph.h index 2742824..b074ee6 100644 --- a/src/Flowgraph.h +++ b/src/Flowgraph.h @@ -2,7 +2,7 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org diff --git a/src/Resampler.h b/src/Resampler.h index d9d9d89..ed94a8c 100644 --- a/src/Resampler.h +++ b/src/Resampler.h @@ -59,7 +59,6 @@ protected: FFT_PLAN myFftPlan2; size_t L; size_t M; - size_t K; size_t myFftSizeIn; size_t myFftSizeOut; FFT_TYPE* myFftIn; -- cgit v1.2.3 From 28d794ab7d47e4f2585ac73f8a69c9c68962b678 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 7 Jan 2018 11:51:03 +0100 Subject: Make frame_timestamp movable --- src/Flowgraph.cpp | 3 ++- src/OutputFile.cpp | 17 ++++++++++++----- src/TimestampDecoder.h | 16 ---------------- 3 files changed, 14 insertions(+), 22 deletions(-) (limited to 'src/Flowgraph.cpp') diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index e12ff1e..ae86417 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -151,8 +151,9 @@ int Node::process() meta_vec_t all_input_mds; for (auto& md_vec_sp : myInputMetadata) { if (md_vec_sp) { - copy(md_vec_sp->begin(), md_vec_sp->end(), + move(md_vec_sp->begin(), md_vec_sp->end(), back_inserter(all_input_mds)); + md_vec_sp->clear(); } } diff --git a/src/OutputFile.cpp b/src/OutputFile.cpp index 1c2f5ed..b7bf59a 100644 --- a/src/OutputFile.cpp +++ b/src/OutputFile.cpp @@ -71,21 +71,28 @@ meta_vec_t OutputFile::process_metadata(const meta_vec_t& metadataIn) { stringstream ss; - if (metadataIn.empty()) { - etiLog.level(debug) << "OutputFile: no mdIn"; - } - for (const auto& md : metadataIn) { if (md.ts) { ss << " FCT=" << md.ts->fct << " FP=" << (int)md.ts->fp; + if (md.ts->timestamp_valid) { + ss << " TS=" << md.ts->timestamp_sec << ";"; + } + else { + ss << " No TS;"; + } } else { ss << " void, "; } } - etiLog.level(debug) << "Output File got metadata: " << ss.str(); + if (metadataIn.empty()) { + etiLog.level(debug) << "Output File got no mdIn"; + } + else { + etiLog.level(debug) << "Output File got metadata: " << ss.str(); + } return {}; } diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h index cffba2f..ff52e4c 100644 --- a/src/TimestampDecoder.h +++ b/src/TimestampDecoder.h @@ -47,22 +47,6 @@ struct frame_timestamp bool timestamp_valid = false; bool timestamp_refresh; - frame_timestamp() = default; - frame_timestamp(const frame_timestamp& other) = default; - frame_timestamp& operator=(const frame_timestamp &rhs) - { - if (this != &rhs) { - this->timestamp_sec = rhs.timestamp_sec; - this->timestamp_pps = rhs.timestamp_pps; - this->timestamp_valid = rhs.timestamp_valid; - this->timestamp_refresh = rhs.timestamp_refresh; - this->fct = rhs.fct; - this->fp = rhs.fp; - } - - return *this; - } - frame_timestamp& operator+=(const double& diff) { double offset_pps, offset_secs; -- cgit v1.2.3 From b48fb779024138a760b5c6309d097b712d2bb853 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 14 Jan 2018 07:09:39 +0100 Subject: Reduce stringstram scope in ~Flowgraph --- src/Flowgraph.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Flowgraph.cpp') diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index ae86417..506832c 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -238,9 +238,8 @@ Flowgraph::~Flowgraph() { PDEBUG("Flowgraph::~Flowgraph() @ %p\n", this); - stringstream ss; - if (myProcessTime) { + stringstream ss; ss << "Process time:\n"; char node_time_sz[1024] = {}; -- cgit v1.2.3