diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ParserConfigfile.cpp | 6 | ||||
-rw-r--r-- | src/dabInputZmq.cpp | 38 | ||||
-rw-r--r-- | src/dabInputZmq.h | 34 |
3 files changed, 45 insertions, 33 deletions
diff --git a/src/ParserConfigfile.cpp b/src/ParserConfigfile.cpp index 9468a32..883f5fc 100644 --- a/src/ParserConfigfile.cpp +++ b/src/ParserConfigfile.cpp @@ -538,7 +538,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, } else if (strcmp(subchan->inputProto, "tcp") == 0) { input_is_old_style = false; - DabInputZmq* inzmq = new DabInputZmq(subchanuid); + DabInputZmqAAC* inzmq = new DabInputZmqAAC(subchanuid); inzmq->enrol_at(*rc); subchan->input = inzmq; subchan->inputName = full_inputName; @@ -546,7 +546,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, else if (strcmp(subchan->inputProto, "epmg") == 0) { etiLog.level(warn) << "Using untested epmg:// zeromq input"; input_is_old_style = false; - DabInputZmq* inzmq = new DabInputZmq(subchanuid); + DabInputZmqAAC* inzmq = new DabInputZmqAAC(subchanuid); inzmq->enrol_at(*rc); subchan->input = inzmq; subchan->inputName = full_inputName; @@ -554,7 +554,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, else if (strcmp(subchan->inputProto, "ipc") == 0) { etiLog.level(warn) << "Using untested ipc:// zeromq input"; input_is_old_style = false; - DabInputZmq* inzmq = new DabInputZmq(subchanuid); + DabInputZmqAAC* inzmq = new DabInputZmqAAC(subchanuid); inzmq->enrol_at(*rc); subchan->input = inzmq; subchan->inputName = full_inputName; diff --git a/src/dabInputZmq.cpp b/src/dabInputZmq.cpp index b54cddc..8bd351a 100644 --- a/src/dabInputZmq.cpp +++ b/src/dabInputZmq.cpp @@ -57,7 +57,9 @@ extern StatsServer* global_stats; -int DabInputZmq::open(const std::string inputUri) +/***** Common functions (MPEG and AAC) ******/ + +int DabInputZmqBase::open(const std::string inputUri) { // Prepare the ZMQ socket to accept connections try { @@ -84,8 +86,22 @@ int DabInputZmq::open(const std::string inputUri) return 0; } +int DabInputZmqBase::close() +{ + m_zmq_sock.close(); + return 0; +} + +int DabInputZmqBase::setBitrate(int bitrate) +{ + m_bitrate = bitrate; + return bitrate; // TODO do a nice check here +} + +/******** AAC+ input ******/ + // size corresponds to a frame size. It is constant for a given bitrate -int DabInputZmq::readFrame(void* buffer, int size) +int DabInputZmqAAC::readFrame(void* buffer, int size) { int rc; @@ -171,7 +187,7 @@ int DabInputZmq::readFrame(void* buffer, int size) } // Read a superframe from the socket, cut it into five frames, and push to list -int DabInputZmq::readFromSocket(int framesize) +int DabInputZmqAAC::readFromSocket(int framesize) { int rc; bool messageReceived; @@ -226,21 +242,9 @@ int DabInputZmq::readFromSocket(int framesize) return msg.size(); } -int DabInputZmq::close() -{ - m_zmq_sock.close(); - return 0; -} - -int DabInputZmq::setBitrate(int bitrate) -{ - m_bitrate = bitrate; - return bitrate; // TODO do a nice check here -} - /********* REMOTE CONTROL ***********/ -void DabInputZmq::set_parameter(string parameter, string value) +void DabInputZmqBase::set_parameter(string parameter, string value) { stringstream ss(value); ss.exceptions ( stringstream::failbit | stringstream::badbit ); @@ -256,7 +260,7 @@ void DabInputZmq::set_parameter(string parameter, string value) } } -string DabInputZmq::get_parameter(string parameter) +string DabInputZmqBase::get_parameter(string parameter) { stringstream ss; if (parameter == "buffer") { diff --git a/src/dabInputZmq.h b/src/dabInputZmq.h index 7420c4b..97dd911 100644 --- a/src/dabInputZmq.h +++ b/src/dabInputZmq.h @@ -60,21 +60,16 @@ // Maximum frame_buffer size in number of elements #define INPUT_ZMQ_MAX_BUFFER_SIZE (5*8) // 960ms - -class DabInputZmq : public DabInputBase, public RemoteControllable { +class DabInputZmqBase : public DabInputBase, public RemoteControllable { public: - DabInputZmq(const std::string name) + DabInputZmqBase(const std::string name) : 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) { - RC_ADD_PARAMETER(buffer, - "Size of the input buffer [aac superframes]"); - } + m_bitrate(0) { } virtual int open(const std::string inputUri); - virtual int readFrame(void* buffer, int size); + virtual int readFrame(void* buffer, int size) = 0; virtual int setBitrate(int bitrate); virtual int close(); @@ -84,15 +79,28 @@ class DabInputZmq : public DabInputBase, public RemoteControllable { /* Getting a parameter always returns a string. */ virtual string get_parameter(string parameter); - private: - int readFromSocket(int framesize); - + protected: std::string m_name; zmq::context_t m_zmq_context; zmq::socket_t m_zmq_sock; // handle for the zmq socket + int m_bitrate; +}; + +class DabInputZmqAAC : public DabInputZmqBase { + public: + DabInputZmqAAC(const std::string name) + : DabInputZmqBase(name), + m_prebuffering(INPUT_ZMQ_PREBUFFERING) { + RC_ADD_PARAMETER(buffer, + "Size of the input buffer [aac superframes]"); + } + + virtual int readFrame(void* buffer, int size); + private: + int readFromSocket(int framesize); + int m_prebuffering; std::list<char*> m_frame_buffer; //stores elements of type char[<framesize>] - int m_bitrate; }; #endif // HAVE_INPUT_ZMQ |