if (connect(s->udp_fd, (struct sockaddr *) &s->dest_addr,
s->dest_addr_len)) {
s->is_connected = 0;
- av_log(NULL, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
+ av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
return AVERROR(EIO);
}
}
* streams at the same time.
* @param h media file context
*/
-#if !FF_API_UDP_GET_FILE
-static
-#endif
-int udp_get_file_handle(URLContext *h)
+static int udp_get_file_handle(URLContext *h)
{
UDPContext *s = h->priv_data;
return s->udp_fd;
h->is_streamed = 1;
h->max_packet_size = 1472;
- is_output = (flags & AVIO_WRONLY);
+ is_output = (flags & AVIO_FLAG_WRITE);
s = av_mallocz(sizeof(UDPContext));
if (!s)
/* XXX: fix av_url_split */
if (hostname[0] == '\0' || hostname[0] == '?') {
/* only accepts null hostname if input */
- if (flags & AVIO_WRONLY)
+ if (flags & AVIO_FLAG_WRITE)
goto fail;
} else {
if (ff_udp_set_remote_url(h, uri) < 0)
goto fail;
}
- if (s->is_multicast && !(h->flags & AVIO_WRONLY))
+ if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len);
if (udp_fd < 0)
/* the bind is needed to give a port to the socket now */
/* if multicast, try the multicast address bind first */
- if (s->is_multicast && !(h->flags & AVIO_WRONLY)) {
+ if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
}
/* bind to the local address if not multicast or if the multicast
s->local_port = udp_port(&my_addr, len);
if (s->is_multicast) {
- if (h->flags & AVIO_WRONLY) {
+ if (h->flags & AVIO_FLAG_WRITE) {
/* output */
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
goto fail;
/* limit the tx buf size to limit latency */
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
- av_log(NULL, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
+ av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
goto fail;
}
} else {
* avoid losing data on OSes that set this too low by default. */
tmp = s->buffer_size;
if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
- av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
+ av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
}
/* make the socket non-blocking */
ff_socket_nonblock(udp_fd, 1);
}
if (s->is_connected) {
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
- av_log(NULL, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
+ av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
goto fail;
}
}
{
UDPContext *s = h->priv_data;
- if (s->is_multicast && !(h->flags & AVIO_WRONLY))
+ if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
closesocket(s->udp_fd);
av_free(s);