[FFmpeg-cvslog] r25032 - in trunk/libavformat: os_support.h rtsp.c rtsp.h

rbultje subversion
Fri Sep 3 21:25:59 CEST 2010


Author: rbultje
Date: Fri Sep  3 21:25:59 2010
New Revision: 25032

Log:
Send NAT punching messages to the address specified in the Transport:
message, if available (RFC 2326, section 12.39), fixes issue 2212.

Patch by John Wimer <john at god vtic net>.

Modified:
   trunk/libavformat/os_support.h
   trunk/libavformat/rtsp.c
   trunk/libavformat/rtsp.h

Modified: trunk/libavformat/os_support.h
==============================================================================
--- trunk/libavformat/os_support.h	Fri Sep  3 18:52:46 2010	(r25031)
+++ trunk/libavformat/os_support.h	Fri Sep  3 21:25:59 2010	(r25032)
@@ -55,6 +55,10 @@ typedef int socklen_t;
 #define closesocket close
 #endif
 
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN INET_ADDRSTRLEN
+#endif
+
 #if CONFIG_FFSERVER
 #if !HAVE_POLL_H
 typedef unsigned long nfds_t;

Modified: trunk/libavformat/rtsp.c
==============================================================================
--- trunk/libavformat/rtsp.c	Fri Sep  3 18:52:46 2010	(r25031)
+++ trunk/libavformat/rtsp.c	Fri Sep  3 21:25:59 2010	(r25032)
@@ -701,7 +701,14 @@ static void rtsp_parse_transport(RTSPMes
                     get_word_sep(buf, sizeof(buf), ";,", &p);
                     get_sockaddr(buf, &th->destination);
                 }
+            } else if (!strcmp(parameter, "source")) {
+                if (*p == '=') {
+                    p++;
+                    get_word_sep(buf, sizeof(buf), ";,", &p);
+                    av_strlcpy(th->source, buf, sizeof(th->source));
+                }
             }
+
             while (*p != ';' && *p != '\0' && *p != ',')
                 p++;
             if (*p == ';')
@@ -1154,9 +1161,15 @@ static int make_setup_request(AVFormatCo
         case RTSP_LOWER_TRANSPORT_UDP: {
             char url[1024];
 
-            /* XXX: also use address if specified */
+            /* Use source address if specified */
+            if (reply->transports[0].source[0]) {
+                ff_url_join(url, sizeof(url), "rtp", NULL,
+                            reply->transports[0].source,
+                            reply->transports[0].server_port_min, NULL);
+            } else {
             ff_url_join(url, sizeof(url), "rtp", NULL, host,
                         reply->transports[0].server_port_min, NULL);
+            }
             if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
                 rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
                 err = AVERROR_INVALIDDATA;

Modified: trunk/libavformat/rtsp.h
==============================================================================
--- trunk/libavformat/rtsp.h	Fri Sep  3 18:52:46 2010	(r25031)
+++ trunk/libavformat/rtsp.h	Fri Sep  3 21:25:59 2010	(r25032)
@@ -97,6 +97,7 @@ typedef struct RTSPTransportField {
     int ttl;
 
     struct sockaddr_storage destination; /**< destination IP address */
+    char source[INET6_ADDRSTRLEN + 1]; /**< source IP address */
 
     /** data/packet transport protocol; e.g. RTP or RDT */
     enum RTSPTransport transport;



More information about the ffmpeg-cvslog mailing list