summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-11-01 13:45:25 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-11-01 13:45:25 +0100
commit7f5faf87e6373d27ae6709a1185154ca8e98276b (patch)
treea375504ea4152c2ce2c6e1f96fffc2bfe5d18846 /src
parent76e7347f63a09c4e0b860798cd8abaecdff1d302 (diff)
downloaddabmod-7f5faf87e6373d27ae6709a1185154ca8e98276b.tar.gz
dabmod-7f5faf87e6373d27ae6709a1185154ca8e98276b.tar.bz2
dabmod-7f5faf87e6373d27ae6709a1185154ca8e98276b.zip
Add new ZeroMQ IQ output
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp33
-rw-r--r--src/Makefile.am9
-rw-r--r--src/OutputZeroMQ.cpp67
-rw-r--r--src/OutputZeroMQ.h62
4 files changed, 157 insertions, 14 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 67ad12d..f27d720 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -38,6 +38,7 @@
#if defined(HAVE_OUTPUT_UHD)
# include "OutputUHD.h"
#endif
+#include "OutputZeroMQ.h"
#include "InputReader.h"
#include "PcDebug.h"
#include "TimestampDecoder.h"
@@ -166,6 +167,7 @@ int main(int argc, char* argv[])
std::string inputTransport = "file";
std::string outputName;
+ int useZeroMQOutput = 0;
int useFileOutput = 0;
int useUHDOutput = 0;
@@ -399,7 +401,7 @@ int main(int argc, char* argv[])
clockRate = pt.get("modulator.dac_clk_rate", (size_t)0);
digitalgain = pt.get("modulator.digital_gain", digitalgain);
outputRate = pt.get("modulator.rate", outputRate);
-
+
// FIR Filter parameters:
if (pt.get("firfilter.enabled", 0) == 1) {
try {
@@ -531,6 +533,12 @@ int main(int argc, char* argv[])
useUHDOutput = 1;
}
#endif
+#if defined(HAVE_OUTPUT_ZEROMQ)
+ else if (output_selected == "zmq") {
+ outputName = pt.get<std::string>("zmqoutput.listen");
+ useZeroMQOutput = 1;
+ }
+#endif
else {
std::cerr << "Error: Invalid output defined.\n";
goto END_MAIN;
@@ -612,7 +620,7 @@ int main(int argc, char* argv[])
goto END_MAIN;
}
- if (!useFileOutput && !useUHDOutput) {
+ if (!useFileOutput && !useUHDOutput && !useZeroMQOutput) {
logger.level(error) << "Output not specified";
fprintf(stderr, "Must specify output !");
goto END_MAIN;
@@ -623,8 +631,12 @@ int main(int argc, char* argv[])
fprintf(stderr, " Type: %s\n", inputTransport.c_str());
fprintf(stderr, " Source: %s\n", inputName.c_str());
fprintf(stderr, "Output\n");
+
+ if (useFileOutput) {
+ fprintf(stderr, " Name: %s\n", outputName.c_str());
+ }
#if defined(HAVE_OUTPUT_UHD)
- if (useUHDOutput) {
+ else if (useUHDOutput) {
fprintf(stderr, " UHD\n"
" Device: %s\n"
" Type: %s\n"
@@ -633,12 +645,13 @@ int main(int argc, char* argv[])
outputuhd_conf.usrpType.c_str(),
outputuhd_conf.masterClockRate);
}
- else if (useFileOutput) {
-#else
- if (useFileOutput) {
#endif
- fprintf(stderr, " Name: %s\n", outputName.c_str());
+ else if (useZeroMQOutput) {
+ fprintf(stderr, " ZeroMQ\n"
+ " Listening on: %s\n",
+ outputName.c_str());
}
+
fprintf(stderr, " Sampling rate: ");
if (outputRate > 1000) {
if (outputRate > 1000000) {
@@ -713,6 +726,12 @@ int main(int argc, char* argv[])
}
}
#endif
+ else if (useZeroMQOutput) {
+ /* We normalise the same way as for the UHD output */
+ normalise = 1.0f/50000.0f;
+
+ output = new OutputZeroMQ(outputName);
+ }
flowgraph = new Flowgraph();
data.setLength(6144);
diff --git a/src/Makefile.am b/src/Makefile.am
index 6c83cb1..635a3d8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,12 +22,6 @@ else
GITVERSION_FLAGS =
endif
-if HAVE_INPUT_ZEROMQ_TEST
-ZMQ_LIBS = -lzmq
-else
-ZMQ_LIBS =
-endif
-
if HAVE_OUTPUT_UHD_TEST
UHD_SOURCES = OutputUHD.cpp OutputUHD.h
else
@@ -76,7 +70,7 @@ endif
odr_dabmod_CPPFLAGS = -Wall \
$(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS)
-odr_dabmod_LDADD = $(ZMQ_LIBS) $(FFT_LDADD)
+odr_dabmod_LDADD = $(FFT_LDADD)
odr_dabmod_SOURCES = DabMod.cpp \
PcDebug.h \
porting.c porting.h \
@@ -96,6 +90,7 @@ odr_dabmod_SOURCES = DabMod.cpp \
Flowgraph.cpp Flowgraph.h \
GainControl.cpp GainControl.h \
OutputMemory.cpp OutputMemory.h \
+ OutputZeroMQ.cpp OutputZeroMQ.h \
TimestampDecoder.h TimestampDecoder.cpp \
$(UHD_SOURCES) \
ModOutput.cpp ModOutput.h \
diff --git a/src/OutputZeroMQ.cpp b/src/OutputZeroMQ.cpp
new file mode 100644
index 0000000..0e759dd
--- /dev/null
+++ b/src/OutputZeroMQ.cpp
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
+ Right of Canada (Communications Research Center Canada)
+
+ Copyright (C) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
+ */
+/*
+ This file is part of ODR-DabMod.
+
+ ODR-DabMod is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ ODR-DabMod is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "OutputZeroMQ.h"
+#include "PcDebug.h"
+#include <stdexcept>
+#include <string.h>
+#include <sstream>
+
+#if defined(HAVE_OUTPUT_ZEROMQ)
+
+OutputZeroMQ::OutputZeroMQ(std::string endpoint, Buffer* dataOut)
+ : ModOutput(ModFormat(1), ModFormat(0)),
+ m_zmq_context(1),
+ m_zmq_pub_sock(m_zmq_context, ZMQ_PUB),
+ m_endpoint(endpoint)
+{
+ PDEBUG("OutputZeroMQ::OutputZeroMQ(%p) @ %p\n", dataOut, this);
+
+ std::stringstream ss;
+ ss << "OutputZeroMQ(" << m_endpoint << ")";
+ m_name = ss.str();
+
+ m_zmq_pub_sock.bind(m_endpoint.c_str());
+}
+
+OutputZeroMQ::~OutputZeroMQ()
+{
+ PDEBUG("OutputZeroMQ::~OutputZeroMQ() @ %p\n", this);
+}
+
+int OutputZeroMQ::process(Buffer* dataIn, Buffer* dataOut)
+{
+ PDEBUG("OutputZeroMQ::process"
+ "(dataIn: %p, dataOut: %p)\n",
+ dataIn, dataOut);
+
+ m_zmq_pub_sock.send(dataIn->getData(), dataIn->getLength());
+
+ return dataIn->getLength();
+}
+
+#endif // HAVE_OUTPUT_ZEROMQ_H
+
diff --git a/src/OutputZeroMQ.h b/src/OutputZeroMQ.h
new file mode 100644
index 0000000..a3ac060
--- /dev/null
+++ b/src/OutputZeroMQ.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
+ Right of Canada (Communications Research Center Canada)
+
+ Copyright (C) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
+ */
+/*
+ This file is part of ODR-DabMod.
+
+ ODR-DabMod is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ ODR-DabMod is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OUTPUT_ZEROMQ_H
+#define OUTPUT_ZEROMQ_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if defined(HAVE_OUTPUT_ZEROMQ)
+
+#include "ModOutput.h"
+#include "zmq.hpp"
+
+class OutputZeroMQ : public ModOutput
+{
+ public:
+ OutputZeroMQ(std::string endpoint, Buffer* dataOut = NULL);
+ virtual ~OutputZeroMQ();
+ virtual int process(Buffer* dataIn, Buffer* dataOut);
+ const char* name() { return m_name.c_str(); }
+
+ protected:
+ zmq::context_t m_zmq_context; // handle for the zmq context
+ zmq::socket_t m_zmq_pub_sock; // handle for the zmq publisher socket
+
+ std::string m_endpoint; // On which port to listen: e.g.
+ // tcp://*:58300
+
+ std::string m_name;
+
+ Buffer* m_data_out;
+};
+
+#endif // HAVE_OUTPUT_ZEROMQ_H
+
+#endif // OUTPUT_ZEROMQ_H
+