29 #define ZMQ_STRERROR zmq_strerror(zmq_errno())
39 #define OFFSET(x) offsetof(ZMQContext, x)
40 #define D AV_OPT_FLAG_DECODING_PARAM
41 #define E AV_OPT_FLAG_ENCODING_PARAM
43 {
"pkt_size",
"Maximum send/read packet size",
OFFSET(pkt_size),
AV_OPT_TYPE_INT, { .i64 = 131072 }, -1, INT_MAX, .flags =
D |
E },
50 int ev = write ? ZMQ_POLLOUT : ZMQ_POLLIN;
51 zmq_pollitem_t items = { .socket = socket, .fd = 0, .events = ev, .revents = 0 };
57 return items.revents & ev ? 0 :
AVERROR(EAGAIN);
84 s->pkt_size_overflow = 0;
88 h->max_packet_size =
s->pkt_size;
90 s->context = zmq_ctx_new();
104 s->socket = zmq_socket(
s->context, ZMQ_PUB);
110 ret = zmq_bind(
s->socket, uri);
119 s->socket = zmq_socket(
s->context, ZMQ_SUB);
125 ret = zmq_setsockopt(
s->socket, ZMQ_SUBSCRIBE,
"", 0);
131 ret = zmq_connect(
s->socket, uri);
140 zmq_close(
s->socket);
142 zmq_ctx_term(
s->context);
154 ret = zmq_send(
s->socket, buf,
size, 0);
170 ret = zmq_recv(
s->socket, buf,
size, 0);
176 s->pkt_size_overflow =
FFMAX(
s->pkt_size_overflow, ret);
177 av_log(
h,
AV_LOG_WARNING,
"Message exceeds available space in the buffer. Message will be truncated. Setting -pkt_size %d may resolve the issue.\n",
s->pkt_size_overflow);
186 zmq_close(
s->socket);
187 zmq_ctx_term(
s->context);
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
#define AVIO_FLAG_READ
read-only
#define AVIO_FLAG_WRITE
write-only
#define flags(name, subs,...)
const AVIOInterruptCB int_cb
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
#define LIBAVUTIL_VERSION_INT
static int zmq_proto_read(URLContext *h, unsigned char *buf, int size)
const URLProtocol ff_libzmq_protocol
static const AVClass zmq_context_class
static int zmq_proto_wait(URLContext *h, void *socket, int write)
static int zmq_proto_close(URLContext *h)
static const AVOption options[]
static int zmq_proto_wait_timeout(URLContext *h, void *socket, int write, int64_t timeout, AVIOInterruptCB *int_cb)
static int zmq_proto_write(URLContext *h, const unsigned char *buf, int size)
static int zmq_proto_open(URLContext *h, const char *uri, int flags)
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Callback for checking whether to abort blocking functions.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
unbuffered private I/O API
#define URL_PROTOCOL_FLAG_NETWORK