summaryrefslogtreecommitdiff
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-03-09 14:59:40 +0000
committerMartin Storsjö <martin@martin.st>2010-03-09 14:59:40 +0000
commit03f8fc0897c128028111182e6276139fa00b891b (patch)
treed6c79c70be2908a2d516cb1fc9585d23f0db2d4f /libavformat/rtsp.c
parent0c8cc2c4d86faea15e5225870b787f8f42ff52bb (diff)
RTSP: Resolve and use the actual IP address of the peer we're connected to,
instead of using the original host name, since the RTP (and UDP) protocols may choose another IP address if the host name resolves into several different addresses. Originally committed as revision 22398 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 8550bf2912..0a7adfbbe0 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1381,10 +1381,12 @@ int ff_rtsp_connect(AVFormatContext *s)
char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128];
char *option_list, *option, *filename;
URLContext *rtsp_hd;
- int port, err;
+ int port, err, tcp_fd;
RTSPMessageHeader reply1, *reply = &reply1;
int lower_transport_mask = 0;
char real_challenge[64];
+ struct sockaddr_storage peer;
+ socklen_t peer_len = sizeof(peer);
if (!ff_network_init())
return AVERROR(EIO);
@@ -1455,6 +1457,12 @@ redirect:
rt->rtsp_hd = rtsp_hd;
rt->seq = 0;
+ tcp_fd = url_get_file_handle(rtsp_hd);
+ if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) {
+ getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host),
+ NULL, 0, NI_NUMERICHOST);
+ }
+
/* request options supported by the server; this also detects server
* type */
av_strlcpy(rt->control_uri, s->filename,