summaryrefslogtreecommitdiffstats
path: root/src/dabInputZmq.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/dabInputZmq.h')
-rw-r--r--src/dabInputZmq.h54
1 files changed, 33 insertions, 21 deletions
diff --git a/src/dabInputZmq.h b/src/dabInputZmq.h
index fdca9e6..bb37a94 100644
--- a/src/dabInputZmq.h
+++ b/src/dabInputZmq.h
@@ -43,11 +43,10 @@
#ifdef HAVE_INPUT_ZEROMQ
-#include <zmq.h>
+#include <zmq.hpp>
#include <list>
#include <string>
#include "dabInput.h"
-#include "dabInputFifo.h"
#include "StatsServer.h"
/* The frame_buffer contains DAB logical frames as defined in
@@ -62,27 +61,40 @@
#define INPUT_ZMQ_MAX_BUFFER_SIZE (5*8) // 960ms
-extern struct dabInputOperations dabInputZmqOperations;
-
-struct dabInputZmqData {
- void* zmq_context;
- void* zmq_sock;
- std::list<char*> frame_buffer; //stores elements of type char[<framesize>]
- int prebuffering;
- std::string uri;
+class DabInputZmq : public DabInputBase, public RemoteControllable {
+ public:
+ DabInputZmq(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]");
+ }
+
+ 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);
+
+ std::string m_name;
+ zmq::context_t m_zmq_context;
+ zmq::socket_t m_zmq_sock; // handle for the zmq socket
+ int m_prebuffering;
+ std::list<char*> m_frame_buffer; //stores elements of type char[<framesize>]
+ int m_bitrate;
};
-
-int dabInputZmqInit(void** args);
-int dabInputZmqOpen(void* args, const char* inputUri);
-int dabInputZmqReadFrame(dabInputOperations* ops, void* args, void* buffer, int size);
-int dabInputZmqClose(void* args);
-int dabInputZmqClean(void** args);
-
-// Get new message from ZeroMQ
-int dabInputZmqReadFromSocket(dabInputZmqData* input, int framesize);
-
-
#endif // HAVE_INPUT_ZMQ
#endif // DAB_INPUT_ZMQ_H