45#define OFFSET(x) offsetof(UnixContext, x)
46#define ED AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_ENCODING_PARAM
51 {
"stream",
"Stream (reliable stream-oriented)", 0,
AV_OPT_TYPE_CONST, { .i64 = SOCK_STREAM }, INT_MIN, INT_MAX,
ED, .unit =
"type" },
52 {
"datagram",
"Datagram (unreliable packet-oriented)", 0,
AV_OPT_TYPE_CONST, { .i64 = SOCK_DGRAM }, INT_MIN, INT_MAX,
ED, .unit =
"type" },
53 {
"seqpacket",
"Seqpacket (reliable packet-oriented)", 0,
AV_OPT_TYPE_CONST, { .i64 = SOCK_SEQPACKET }, INT_MIN, INT_MAX,
ED, .unit =
"type" },
71 s->addr.sun_family = AF_UNIX;
72 av_strlcpy(
s->addr.sun_path, filename,
sizeof(
s->addr.sun_path));
77 if (
s->timeout < 0 &&
h->rw_timeout)
78 s->timeout =
h->rw_timeout / 1000;
81 if (
s->type == SOCK_DGRAM) {
82 ret = bind(fd, (
struct sockaddr *)&
s->addr,
sizeof(
s->addr));
89 sizeof(
s->addr),
s->timeout,
h);
96 sizeof(
s->addr),
s->timeout,
h, 0);
104 if ((
s->type == SOCK_DGRAM ||
s->type == SOCK_SEQPACKET) &&
s->pkt_size > 0)
105 h->max_packet_size =
s->pkt_size;
110 if (
s->listen &&
AVUNERROR(ret) != EADDRINUSE)
111 unlink(
s->addr.sun_path);
127 ret = recv(
s->fd, buf,
size, 0);
128 if (!ret &&
s->type == SOCK_STREAM)
151 unlink(
s->addr.sun_path);
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
#define flags(name, subs,...)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AVERROR_EOF
End of file.
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.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
#define LIBAVUTIL_VERSION_INT
int ff_socket(int af, int type, int proto, void *logctx)
int ff_listen_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next)
Connect to a file descriptor and poll for result.
int ff_listen_bind(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h)
Bind to a file descriptor and poll for a connection.
int ff_network_wait_fd(int fd, int write)
miscellaneous OS support macros and functions.
const URLProtocol ff_unix_protocol
Describe the class of an AVClass context structure.
static int unix_get_file_handle(URLContext *h)
static int unix_open(URLContext *h, const char *filename, int flags)
static int unix_close(URLContext *h)
static int unix_write(URLContext *h, const uint8_t *buf, int size)
static const AVClass unix_class
static int unix_read(URLContext *h, uint8_t *buf, int size)
static const AVOption unix_options[]
unbuffered private I/O API
#define URL_PROTOCOL_FLAG_NETWORK