From d930ee6b9a52f0eb9939b3fe55afd2361944edb2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli (think)" Date: Fri, 8 Nov 2013 18:14:57 +0100 Subject: add support for ZeroMQ output --- src/dabOutput/dabOutputZMQ.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/dabOutput/dabOutputZMQ.cpp (limited to 'src/dabOutput/dabOutputZMQ.cpp') diff --git a/src/dabOutput/dabOutputZMQ.cpp b/src/dabOutput/dabOutputZMQ.cpp new file mode 100644 index 0000000..271cfa1 --- /dev/null +++ b/src/dabOutput/dabOutputZMQ.cpp @@ -0,0 +1,78 @@ +/* + Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the Queen in + Right of Canada (Communications Research Center Canada) + + Copyright (C) 2013 Matthias P. Braendli + http://mpb.li + + ZeroMQ output. see www.zeromq.org for more info + + From the ZeroMQ manpage 'zmq': + + The 0MQ lightweight messaging kernel is a library which extends the standard + socket interfaces with features traditionally provided by specialised + messaging middleware products. 0MQ sockets provide an abstraction of + asynchronous message queues, multiple messaging patterns, message filtering + (subscriptions), seamless access to multiple transport protocols and more. + + */ +/* + This file is part of CRC-DabMux. + + CRC-DabMux is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + CRC-DabMux is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with CRC-DabMux. If not, see . + */ +#include "config.h" + +#if defined(HAVE_OUTPUT_ZEROMQ) + +#include +#include +#include +#include +#include +#include +#include +#include +#include "dabOutput.h" + +using namespace std; + +int DabOutputZMQ::Open(const char* endpoint) + // the format for endpoint shall be as defined in the zmq_bind manpage + // but without specifying the protocol. The protocol has been given in + // the constructor +{ + // bind to uri + string proto_endpoint = zmq_proto_ + "://" + std::string(endpoint); + std::cerr << "ZMQ socket " << proto_endpoint << std::endl; + zmq_pub_sock_.bind(proto_endpoint.c_str()); + + return 0; +} + + +int DabOutputZMQ::Write(void* buffer, int size) +{ + int flags = 0; + + return zmq_send(zmq_pub_sock_, buffer, size, flags); +} + + +int DabOutputZMQ::Close() +{ + return zmq_close(zmq_pub_sock_); +} + +#endif -- cgit v1.2.3