diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-01-21 22:02:21 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-01-21 22:02:21 +0100 |
commit | b20b932571daff5621f12f760234e998d6e79fab (patch) | |
tree | 1ca7c1b70b091a77034f4aeec962ca8ac7ce4bcf /src | |
parent | 337eec371c8c86f35813d804f61176a7606bae20 (diff) | |
download | dabmux-b20b932571daff5621f12f760234e998d6e79fab.tar.gz dabmux-b20b932571daff5621f12f760234e998d6e79fab.tar.bz2 dabmux-b20b932571daff5621f12f760234e998d6e79fab.zip |
add RemoteControl, make the ZMQ input inherit from it
Diffstat (limited to 'src')
-rw-r--r-- | src/DabMux.cpp | 4 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/dabInput.h | 1 | ||||
-rw-r--r-- | src/dabInputZmq.cpp | 33 | ||||
-rw-r--r-- | src/dabInputZmq.h | 16 | ||||
-rw-r--r-- | 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 <sys/times.h> # include <sys/resource.h> -# include <linux/if_packet.h> -# include <linux/netdevice.h> +# include <net/if_packet.h> #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 <string> 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 <sys/types.h> # include <sys/socket.h> # include <sys/ioctl.h> -# include <linux/if_packet.h> -# include <linux/netdevice.h> +# include <net/if_packet.h> # include <net/if_arp.h> #endif |