Browse code

Handle IPv6 in the RTSP code

Originally committed as revision 24925 to svn://svn.ffmpeg.org/ffmpeg/trunk

Martin Storsjö authored on 2010/08/26 00:32:29
Showing 2 changed files
... ...
@@ -696,13 +696,10 @@ static void rtsp_parse_transport(RTSPMessageHeader *reply, const char *p)
696 696
                     th->ttl = strtol(p, (char **)&p, 10);
697 697
                 }
698 698
             } else if (!strcmp(parameter, "destination")) {
699
-                struct in_addr ipaddr;
700
-
701 699
                 if (*p == '=') {
702 700
                     p++;
703 701
                     get_word_sep(buf, sizeof(buf), ";,", &p);
704
-                    if (ff_inet_aton(buf, &ipaddr))
705
-                        th->destination = ntohl(ipaddr.s_addr);
702
+                    get_sockaddr(buf, &th->destination);
706 703
                 }
707 704
             }
708 705
             while (*p != ';' && *p != '\0' && *p != ',')
... ...
@@ -1174,20 +1171,22 @@ static int make_setup_request(AVFormatContext *s, const char *host, int port,
1174 1174
             break;
1175 1175
         }
1176 1176
         case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: {
1177
-            char url[1024];
1178
-            struct in_addr in;
1177
+            char url[1024], namebuf[50];
1178
+            struct sockaddr_storage addr;
1179 1179
             int port, ttl;
1180 1180
 
1181
-            if (reply->transports[0].destination) {
1182
-                in.s_addr = htonl(reply->transports[0].destination);
1181
+            if (reply->transports[0].destination.ss_family) {
1182
+                addr      = reply->transports[0].destination;
1183 1183
                 port      = reply->transports[0].port_min;
1184 1184
                 ttl       = reply->transports[0].ttl;
1185 1185
             } else {
1186
-                in        = ((struct sockaddr_in*)&rtsp_st->sdp_ip)->sin_addr;
1186
+                addr      = rtsp_st->sdp_ip;
1187 1187
                 port      = rtsp_st->sdp_port;
1188 1188
                 ttl       = rtsp_st->sdp_ttl;
1189 1189
             }
1190
-            ff_url_join(url, sizeof(url), "rtp", NULL, inet_ntoa(in),
1190
+            getnameinfo((struct sockaddr*) &addr, sizeof(addr),
1191
+                        namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
1192
+            ff_url_join(url, sizeof(url), "rtp", NULL, namebuf,
1191 1193
                         port, "?ttl=%d", ttl);
1192 1194
             if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
1193 1195
                 err = AVERROR_INVALIDDATA;
... ...
@@ -96,7 +96,7 @@ typedef struct RTSPTransportField {
96 96
      * packets will be allowed to make before being discarded. */
97 97
     int ttl;
98 98
 
99
-    uint32_t destination; /**< destination IP address */
99
+    struct sockaddr_storage destination; /**< destination IP address */
100 100
 
101 101
     /** data/packet transport protocol; e.g. RTP or RDT */
102 102
     enum RTSPTransport transport;