40 #include <netinet/in.h> 41 #include <netinet/sctp.h> 74 socklen_t *fromlen,
struct sctp_sndrcvinfo *sinfo,
79 char incmsg[CMSG_SPACE(
sizeof(
struct sctp_sndrcvinfo))];
80 struct msghdr inmsg = { 0 };
81 struct cmsghdr *cmsg =
NULL;
86 inmsg.msg_name =
from;
87 inmsg.msg_namelen = fromlen ? *fromlen : 0;
90 inmsg.msg_control = incmsg;
91 inmsg.msg_controllen =
sizeof(incmsg);
93 if ((recvb = recvmsg(s, &inmsg, msg_flags ? *msg_flags : 0)) < 0)
97 *fromlen = inmsg.msg_namelen;
99 *msg_flags = inmsg.msg_flags;
101 for (cmsg = CMSG_FIRSTHDR(&inmsg); cmsg !=
NULL;
102 cmsg = CMSG_NXTHDR(&inmsg, cmsg)) {
103 if ((IPPROTO_SCTP == cmsg->cmsg_level) &&
104 (SCTP_SNDRCV == cmsg->cmsg_type))
110 memcpy(sinfo, CMSG_DATA(cmsg),
sizeof(
struct sctp_sndrcvinfo));
116 const struct sctp_sndrcvinfo *sinfo,
int flags)
118 struct msghdr outmsg;
121 outmsg.msg_name =
NULL;
122 outmsg.msg_namelen = 0;
123 outmsg.msg_iov = &iov;
124 iov.iov_base = (
void*)msg;
126 outmsg.msg_iovlen = 1;
127 outmsg.msg_controllen = 0;
130 char outcmsg[CMSG_SPACE(
sizeof(
struct sctp_sndrcvinfo))];
131 struct cmsghdr *cmsg;
133 outmsg.msg_control = outcmsg;
134 outmsg.msg_controllen =
sizeof(outcmsg);
135 outmsg.msg_flags = 0;
137 cmsg = CMSG_FIRSTHDR(&outmsg);
138 cmsg->cmsg_level = IPPROTO_SCTP;
139 cmsg->cmsg_type = SCTP_SNDRCV;
140 cmsg->cmsg_len = CMSG_LEN(
sizeof(
struct sctp_sndrcvinfo));
142 outmsg.msg_controllen = cmsg->cmsg_len;
143 memcpy(CMSG_DATA(cmsg), sinfo,
sizeof(
struct sctp_sndrcvinfo));
146 return sendmsg(s, &outmsg, flags);
160 struct sctp_event_subscribe event = { 0 };
161 struct sctp_initmsg initparams = { 0 };
167 int ret, listen_socket = 0;
168 char hostname[1024], proto[1024], path[1024];
172 &port, path,
sizeof(path), uri);
173 if (strcmp(proto,
"sctp"))
175 if (port <= 0 || port >= 65536) {
181 p = strchr(uri,
'?');
191 snprintf(portstr,
sizeof(portstr),
"%d", port);
201 fd = socket(cur_ai->
ai_family, SOCK_STREAM, IPPROTO_SCTP);
219 event.sctp_data_io_event = 1;
222 if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event,
223 sizeof(event)) != 0) {
225 "SCTP ERROR: Unable to subscribe to events\n");
232 if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &initparams,
233 sizeof(initparams)) < 0)
235 "SCTP ERROR: Unable to initialize socket max streams %d\n",
253 int ev = write ? POLLOUT : POLLIN;
254 struct pollfd p = { .fd =
fd, .events = ev, .revents = 0 };
257 ret = poll(&p, 1, 100);
274 struct sctp_sndrcvinfo info = { 0 };
276 AV_WB16(buf, info.sinfo_stream);
277 ret = ret < 0 ? ret : ret + 2;
279 ret = recv(s->
fd, buf, size, 0);
297 struct sctp_sndrcvinfo info = { 0 };
298 info.sinfo_stream =
AV_RB16(buf);
305 ret = send(s->
fd, buf, size, 0);
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
struct sockaddr_storage dest_addr
static int ff_sctp_recvmsg(int s, void *msg, size_t len, struct sockaddr *from, socklen_t *fromlen, struct sctp_sndrcvinfo *sinfo, int *msg_flags)
#define URL_PROTOCOL_FLAG_NETWORK
int is_streamed
true if streamed (no seek possible), default = false
struct SCTPContext SCTPContext
static int sctp_write(URLContext *h, const uint8_t *buf, int size)
URLProtocol ff_sctp_protocol
miscellaneous OS support macros and functions.
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
Attempt to find a specific tag in a URL.
static int sctp_close(URLContext *h)
void av_log(void *avcl, int level, const char *fmt,...)
static int sctp_get_file_handle(URLContext *h)
static int sctp_wait_fd(int fd, int write)
int ff_socket_nonblock(int socket, int enable)
static int ff_sctp_send(int s, const void *msg, size_t len, const struct sctp_sndrcvinfo *sinfo, int flags)
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
static int sctp_open(URLContext *h, const char *uri, int flags)
static int sctp_read(URLContext *h, uint8_t *buf, int size)
unbuffered private I/O API
struct sockaddr * ai_addr