From b20b932571daff5621f12f760234e998d6e79fab Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 21 Jan 2014 22:02:21 +0100 Subject: add RemoteControl, make the ZMQ input inherit from it --- src/DabMux.cpp | 4 ++-- src/Makefile.am | 1 + src/dabInput.h | 1 + src/dabInputZmq.cpp | 33 +++++++++++++++++++++++++++++++++ src/dabInputZmq.h | 16 +++++++++++++--- src/dabOutput/dabOutputUdp.cpp | 3 +-- 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 2e6e1a6..d1198f1 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -74,8 +74,7 @@ typedef DWORD32 uint32_t; # include # include -# include -# include +# include #endif #ifdef _WIN32 @@ -119,6 +118,7 @@ typedef DWORD32 uint32_t; #include "ParserConfigfile.h" #include "StatsServer.h" #include "Log.h" +#include "RemoteControl.h" using namespace std; diff --git a/src/Makefile.am b/src/Makefile.am index 910d5bc..3bcf54e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,6 +71,7 @@ crc_dabmux_SOURCES =DabMux.cpp \ bridge.h bridge.c \ utils.cpp utils.h \ MuxElements.cpp MuxElements.h \ + RemoteControl.cpp RemoteControl.h \ ParserCmdline.cpp ParserCmdline.h \ ParserConfigfile.cpp ParserConfigfile.h \ Eti.h Eti.cpp \ diff --git a/src/dabInput.h b/src/dabInput.h index 56d3fbf..e5c89da 100644 --- a/src/dabInput.h +++ b/src/dabInput.h @@ -26,6 +26,7 @@ # include "config.h" #endif #include "Log.h" +#include "RemoteControl.h" #include extern Logger etiLog; diff --git a/src/dabInputZmq.cpp b/src/dabInputZmq.cpp index 9b61033..4a2114a 100644 --- a/src/dabInputZmq.cpp +++ b/src/dabInputZmq.cpp @@ -235,5 +235,38 @@ int DabInputZmq::setBitrate(int bitrate) return bitrate; // TODO do a nice check here } +/********* REMOTE CONTROL ***********/ + +void DabInputZmq::set_parameter(string parameter, string value) +{ + stringstream ss(value); + ss.exceptions ( stringstream::failbit | stringstream::badbit ); + + if (parameter == "buffer") { + throw ParameterError("Parameter 'ntaps' is read-only"); + } + else { + stringstream ss; + ss << "Parameter '" << parameter << + "' is not exported by controllable " << get_rc_name(); + throw ParameterError(ss.str()); + } +} + +string DabInputZmq::get_parameter(string parameter) +{ + stringstream ss; + if (parameter == "buffer") { + ss << INPUT_ZMQ_MAX_BUFFER_SIZE; + } + else { + ss << "Parameter '" << parameter << + "' is not exported by controllable " << get_rc_name(); + throw ParameterError(ss.str()); + } + return ss.str(); + +} + #endif diff --git a/src/dabInputZmq.h b/src/dabInputZmq.h index b012cf6..72bd348 100644 --- a/src/dabInputZmq.h +++ b/src/dabInputZmq.h @@ -60,19 +60,29 @@ #define INPUT_ZMQ_MAX_BUFFER_SIZE (5*8) // 960ms -class DabInputZmq : public DabInputBase { +class DabInputZmq : public DabInputBase, public RemoteControllable { public: DabInputZmq(const std::string name) - : m_name(name), m_zmq_context(1), + : RemoteControllable(name), + m_name(name), m_zmq_context(1), m_zmq_sock(m_zmq_context, ZMQ_SUB), m_prebuffering(INPUT_ZMQ_PREBUFFERING), - m_bitrate(0) {} + m_bitrate(0) { + RC_ADD_PARAMETER(buffer, + "Size of the input buffer [aac superframes]"); + } virtual int open(const std::string inputUri); virtual int readFrame(void* buffer, int size); virtual int setBitrate(int bitrate); virtual int close(); + /* Remote control */ + virtual void set_parameter(string parameter, string value); + + /* Getting a parameter always returns a string. */ + virtual string get_parameter(string parameter); + private: int readFromSocket(int framesize); diff --git a/src/dabOutput/dabOutputUdp.cpp b/src/dabOutput/dabOutputUdp.cpp index 459120f..607fe71 100644 --- a/src/dabOutput/dabOutputUdp.cpp +++ b/src/dabOutput/dabOutputUdp.cpp @@ -38,8 +38,7 @@ # include # include # include -# include -# include +# include # include #endif -- cgit v1.2.3