aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-07 12:04:46 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-07 12:04:46 +0100
commit770703c9c5c926be760af836bee26e554e81a71c (patch)
treef9368db373d91d48d9476790d9dbdcbbcf3dc5dc /src
parent28d794ab7d47e4f2585ac73f8a69c9c68962b678 (diff)
downloaddabmod-770703c9c5c926be760af836bee26e554e81a71c.tar.gz
dabmod-770703c9c5c926be760af836bee26e554e81a71c.tar.bz2
dabmod-770703c9c5c926be760af836bee26e554e81a71c.zip
Add option to show metadata for file output
Diffstat (limited to 'src')
-rw-r--r--src/ConfigParser.cpp14
-rw-r--r--src/ConfigParser.h9
-rw-r--r--src/DabMod.cpp6
-rw-r--r--src/OutputFile.cpp42
-rw-r--r--src/OutputFile.h3
5 files changed, 40 insertions, 34 deletions
diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp
index 0e641c0..a4219af 100644
--- a/src/ConfigParser.cpp
+++ b/src/ConfigParser.cpp
@@ -204,13 +204,15 @@ static void parse_configfile(
if (output_selected == "file") {
try {
mod_settings.outputName = pt.get<std::string>("fileoutput.filename");
+ mod_settings.fileOutputShowMetadata =
+ (pt.get("fileoutput.show_metadata", 0) > 0);
}
catch (std::exception &e) {
std::cerr << "Error: " << e.what() << "\n";
std::cerr << " Configuration does not specify file name for file output\n";
throw std::runtime_error("Configuration error");
}
- mod_settings.useFileOutput = 1;
+ mod_settings.useFileOutput = true;
mod_settings.fileOutputFormat = pt.get("fileoutput.format", mod_settings.fileOutputFormat);
}
@@ -283,7 +285,7 @@ static void parse_configfile(
sdr_device_config.dpdFeedbackServerPort = pt.get<long>("uhdoutput.dpd_port", 0);
mod_settings.sdr_device_config = sdr_device_config;
- mod_settings.useUHDOutput = 1;
+ mod_settings.useUHDOutput = true;
}
#endif
#if defined(HAVE_SOAPYSDR)
@@ -310,14 +312,14 @@ static void parse_configfile(
throw std::runtime_error("Configuration error");
}
- mod_settings.useSoapyOutput = 1;
+ mod_settings.useSoapyOutput = true;
}
#endif
#if defined(HAVE_ZEROMQ)
else if (output_selected == "zmq") {
mod_settings.outputName = pt.get<std::string>("zmqoutput.listen");
mod_settings.zmqOutputSocketType = pt.get<std::string>("zmqoutput.socket_type");
- mod_settings.useZeroMQOutput = 1;
+ mod_settings.useZeroMQOutput = true;
}
#endif
else {
@@ -399,7 +401,7 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings)
}
#endif
mod_settings.outputName = optarg;
- mod_settings.useFileOutput = 1;
+ mod_settings.useFileOutput = true;
break;
case 'F':
#if defined(HAVE_OUTPUT_UHD)
@@ -442,7 +444,7 @@ void parse_args(int argc, char **argv, mod_settings_t& mod_settings)
mod_settings.sdr_device_config.refclk_src = "internal";
mod_settings.sdr_device_config.pps_src = "none";
mod_settings.sdr_device_config.pps_polarity = "pos";
- mod_settings.useUHDOutput = 1;
+ mod_settings.useUHDOutput = true;
#endif
break;
case 'V':
diff --git a/src/ConfigParser.h b/src/ConfigParser.h
index 0463470..dc5ac4f 100644
--- a/src/ConfigParser.h
+++ b/src/ConfigParser.h
@@ -42,12 +42,13 @@
struct mod_settings_t {
std::string outputName;
- int useZeroMQOutput = 0;
+ bool useZeroMQOutput = false;
std::string zmqOutputSocketType = "";
- int useFileOutput = 0;
+ bool useFileOutput = false;
std::string fileOutputFormat = "complexf";
- int useUHDOutput = 0;
- int useSoapyOutput = 0;
+ bool fileOutputShowMetadata = false;
+ bool useUHDOutput = false;
+ bool useSoapyOutput = false;
size_t outputRate = 2048000;
size_t clockRate = 0;
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 31fa76d..ce2f249 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -177,7 +177,7 @@ static shared_ptr<ModOutput> prepare_output(
if (s.useFileOutput) {
if (s.fileOutputFormat == "complexf") {
- output = make_shared<OutputFile>(s.outputName);
+ output = make_shared<OutputFile>(s.outputName, s.fileOutputShowMetadata);
}
else if (s.fileOutputFormat == "complexf_normalised") {
if (s.gainMode == GainMode::GAIN_FIX)
@@ -186,7 +186,7 @@ static shared_ptr<ModOutput> prepare_output(
s.normalise = 1.0f / normalise_factor_file_max;
else if (s.gainMode == GainMode::GAIN_VAR)
s.normalise = 1.0f / normalise_factor_file_var;
- output = make_shared<OutputFile>(s.outputName);
+ output = make_shared<OutputFile>(s.outputName, s.fileOutputShowMetadata);
}
else if (s.fileOutputFormat == "s8" or
s.fileOutputFormat == "u8") {
@@ -195,7 +195,7 @@ static shared_ptr<ModOutput> prepare_output(
// [0; 255]
s.normalise = 127.0f / normalise_factor;
- output = make_shared<OutputFile>(s.outputName);
+ output = make_shared<OutputFile>(s.outputName, s.fileOutputShowMetadata);
}
else {
throw runtime_error("File output format " + s.fileOutputFormat +
diff --git a/src/OutputFile.cpp b/src/OutputFile.cpp
index b7bf59a..f5a1997 100644
--- a/src/OutputFile.cpp
+++ b/src/OutputFile.cpp
@@ -36,9 +36,9 @@
using namespace std;
-OutputFile::OutputFile(std::string filename) :
- ModOutput(),
- ModMetadata(),
+OutputFile::OutputFile(const std::string& filename, bool show_metadata) :
+ ModOutput(), ModMetadata(),
+ myShowMetadata(show_metadata),
myFilename(filename)
{
PDEBUG("OutputFile::OutputFile(filename: %s) @ %p\n",
@@ -69,31 +69,33 @@ int OutputFile::process(Buffer* dataIn)
meta_vec_t OutputFile::process_metadata(const meta_vec_t& metadataIn)
{
- stringstream ss;
-
- 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 << ";";
+ if (myShowMetadata) {
+ stringstream ss;
+
+ 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 << " No TS;";
+ ss << " void, ";
}
}
+
+ if (metadataIn.empty()) {
+ etiLog.level(debug) << "Output File got no mdIn";
+ }
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/OutputFile.h b/src/OutputFile.h
index fedea40..745e672 100644
--- a/src/OutputFile.h
+++ b/src/OutputFile.h
@@ -42,7 +42,7 @@
class OutputFile : public ModOutput, public ModMetadata
{
public:
- OutputFile(std::string filename);
+ OutputFile(const std::string& filename, bool show_metadata);
virtual int process(Buffer* dataIn) override;
const char* name() override { return "OutputFile"; }
@@ -51,6 +51,7 @@ public:
const meta_vec_t& metadataIn) override;
protected:
+ bool myShowMetadata = false;
std::string myFilename;
struct FILEDeleter{ void operator()(FILE* fd){ if (fd) fclose(fd); }};