summaryrefslogtreecommitdiffstats
path: root/src/dabInputZmq.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-01-19 22:32:27 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-01-19 22:32:27 +0100
commitca4fb30104c5f883794c40f2516636447ea5dd0f (patch)
tree052c4f300cb04908feac5812c5a9ef4b6f3571b7 /src/dabInputZmq.h
parent6c482c8f1fdd74f6e7a8a9481b9f2211c559ebad (diff)
downloaddabmux-ca4fb30104c5f883794c40f2516636447ea5dd0f.tar.gz
dabmux-ca4fb30104c5f883794c40f2516636447ea5dd0f.tar.bz2
dabmux-ca4fb30104c5f883794c40f2516636447ea5dd0f.zip
make DabInputZMQ a new-style input
Diffstat (limited to 'src/dabInputZmq.h')
-rw-r--r--src/dabInputZmq.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/dabInputZmq.h b/src/dabInputZmq.h
index 56708f9..3902963 100644
--- a/src/dabInputZmq.h
+++ b/src/dabInputZmq.h
@@ -42,11 +42,10 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#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
@@ -61,26 +60,28 @@
#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:
+ DabInputZmq(const std::string name)
+ : m_name(name), m_zmq_context(1),
+ m_zmq_sock(m_zmq_context, ZMQ_SUB),
+ m_prebuffering(INPUT_ZMQ_PREBUFFERING) {}
+ virtual int open(const std::string inputUri);
+ virtual int readFrame(void* buffer, int size);
+ virtual int setBitrate(int bitrate);
+ virtual int close();
-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);
+ 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;
+};
#endif // HAVE_INPUT_ZMQ