[Ffmpeg-devel] [PATCH] rtsp address in use
Michael A. Kohn
mike
Wed Nov 15 03:07:15 CET 2006
Problem: Starting ffplay to an RTSP stream works great, but when going
to a second shell and starting a second RTSP stream an error of:
bind: address in use comes up on the screen in an infinite loop
Looks like the RTSP code uses the same UDP ports every time it's
started.
This patch will increment the port if the udp bind fails.
If you guys don't accept this patch I would totally understand.
Incrementing the port number from this function is probably not
proper, but hopefully it can at least be used as a proof of concept
for whoever maintains the RTSP code to fix the issue.
/mike
-------------- next part --------------
diff -Naur ffmpeg-2006-11-14/libavformat/udp.c ffmpeg/libavformat/udp.c
--- ffmpeg-2006-11-14/libavformat/udp.c 2006-11-14 18:51:07.000000000 -0600
+++ ffmpeg/libavformat/udp.c 2006-11-14 19:55:15.000000000 -0600
@@ -299,6 +299,7 @@
struct sockaddr_in my_addr, my_addr1;
int len;
#endif
+ int t;
h->is_streamed = 1;
h->max_packet_size = 1472;
@@ -392,8 +393,16 @@
#else
if (s->is_multicast && !(h->flags & URL_WRONLY))
s->local_port = port;
- udp_fd = udp_ipv6_set_local(h);
- if (udp_fd < 0)
+
+ for (t=0; t<1000; t++)
+ {
+ udp_fd = udp_ipv6_set_local(h);
+ if (udp_fd < 0)
+ { s->local_port++; }
+ else
+ { break; }
+ }
+ if (t==1000)
goto fail;
#ifndef CONFIG_BEOS_NETSERVER
if (s->is_multicast) {
More information about the ffmpeg-devel
mailing list