mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-18 05:11:09 +00:00
udp: Fix receiving RTP data over multicast
Earlier, AVIO_RDWR was handled as READ, and all the checks for the AVIO_WRONLY flag explicitly meant the write-only case. When changed from old AVIO/URL contants to AVIO_FLAG in59d96941f0
, these comparisons were updated incorrectly, by mapping checks for AVIO_WRONLY to checks for AVIO_FLAG_WRITE. When receiving RTP over UDP, the urlcontext is opened with READ_WRITE flags. This patch updates the flag comparisons to check for the same conditions as the code did prior to59d96941f0
. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
f9a6cfdd04
commit
a7ea5e3d35
@ -315,7 +315,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
|
|||||||
h->is_streamed = 1;
|
h->is_streamed = 1;
|
||||||
h->max_packet_size = 1472;
|
h->max_packet_size = 1472;
|
||||||
|
|
||||||
is_output = (flags & AVIO_FLAG_WRITE);
|
is_output = !(flags & AVIO_FLAG_READ);
|
||||||
|
|
||||||
s = av_mallocz(sizeof(UDPContext));
|
s = av_mallocz(sizeof(UDPContext));
|
||||||
if (!s)
|
if (!s)
|
||||||
@ -358,14 +358,14 @@ static int udp_open(URLContext *h, const char *uri, int flags)
|
|||||||
/* XXX: fix av_url_split */
|
/* XXX: fix av_url_split */
|
||||||
if (hostname[0] == '\0' || hostname[0] == '?') {
|
if (hostname[0] == '\0' || hostname[0] == '?') {
|
||||||
/* only accepts null hostname if input */
|
/* only accepts null hostname if input */
|
||||||
if (flags & AVIO_FLAG_WRITE)
|
if (!(flags & AVIO_FLAG_READ))
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
if (ff_udp_set_remote_url(h, uri) < 0)
|
if (ff_udp_set_remote_url(h, uri) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
|
if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
|
||||||
s->local_port = port;
|
s->local_port = port;
|
||||||
udp_fd = udp_socket_create(s, &my_addr, &len);
|
udp_fd = udp_socket_create(s, &my_addr, &len);
|
||||||
if (udp_fd < 0)
|
if (udp_fd < 0)
|
||||||
@ -382,7 +382,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
|
|||||||
|
|
||||||
/* the bind is needed to give a port to the socket now */
|
/* the bind is needed to give a port to the socket now */
|
||||||
/* if multicast, try the multicast address bind first */
|
/* if multicast, try the multicast address bind first */
|
||||||
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
|
if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) {
|
||||||
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
|
bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
|
||||||
}
|
}
|
||||||
/* bind to the local address if not multicast or if the multicast
|
/* bind to the local address if not multicast or if the multicast
|
||||||
@ -395,7 +395,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
|
|||||||
s->local_port = udp_port(&my_addr, len);
|
s->local_port = udp_port(&my_addr, len);
|
||||||
|
|
||||||
if (s->is_multicast) {
|
if (s->is_multicast) {
|
||||||
if (h->flags & AVIO_FLAG_WRITE) {
|
if (!(h->flags & AVIO_FLAG_READ)) {
|
||||||
/* output */
|
/* output */
|
||||||
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
|
if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -478,7 +478,7 @@ static int udp_close(URLContext *h)
|
|||||||
{
|
{
|
||||||
UDPContext *s = h->priv_data;
|
UDPContext *s = h->priv_data;
|
||||||
|
|
||||||
if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
|
if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
|
||||||
udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
|
udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
|
||||||
closesocket(s->udp_fd);
|
closesocket(s->udp_fd);
|
||||||
av_free(s);
|
av_free(s);
|
||||||
|
Loading…
Reference in New Issue
Block a user