comparison rtsp.c @ 6412:6d6b63b7e5e3 libavformat

Handle IPv6 in the RTSP code
author mstorsjo
date Wed, 25 Aug 2010 15:32:29 +0000
parents f0669792a6bd
children e3eb93b5a119
comparison
equal deleted inserted replaced
6411:f0669792a6bd 6412:6d6b63b7e5e3
694 if (*p == '=') { 694 if (*p == '=') {
695 p++; 695 p++;
696 th->ttl = strtol(p, (char **)&p, 10); 696 th->ttl = strtol(p, (char **)&p, 10);
697 } 697 }
698 } else if (!strcmp(parameter, "destination")) { 698 } else if (!strcmp(parameter, "destination")) {
699 struct in_addr ipaddr;
700
701 if (*p == '=') { 699 if (*p == '=') {
702 p++; 700 p++;
703 get_word_sep(buf, sizeof(buf), ";,", &p); 701 get_word_sep(buf, sizeof(buf), ";,", &p);
704 if (ff_inet_aton(buf, &ipaddr)) 702 get_sockaddr(buf, &th->destination);
705 th->destination = ntohl(ipaddr.s_addr);
706 } 703 }
707 } 704 }
708 while (*p != ';' && *p != '\0' && *p != ',') 705 while (*p != ';' && *p != '\0' && *p != ',')
709 p++; 706 p++;
710 if (*p == ';') 707 if (*p == ';')
1172 if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) && s->iformat) 1169 if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) && s->iformat)
1173 rtp_send_punch_packets(rtsp_st->rtp_handle); 1170 rtp_send_punch_packets(rtsp_st->rtp_handle);
1174 break; 1171 break;
1175 } 1172 }
1176 case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: { 1173 case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: {
1177 char url[1024]; 1174 char url[1024], namebuf[50];
1178 struct in_addr in; 1175 struct sockaddr_storage addr;
1179 int port, ttl; 1176 int port, ttl;
1180 1177
1181 if (reply->transports[0].destination) { 1178 if (reply->transports[0].destination.ss_family) {
1182 in.s_addr = htonl(reply->transports[0].destination); 1179 addr = reply->transports[0].destination;
1183 port = reply->transports[0].port_min; 1180 port = reply->transports[0].port_min;
1184 ttl = reply->transports[0].ttl; 1181 ttl = reply->transports[0].ttl;
1185 } else { 1182 } else {
1186 in = ((struct sockaddr_in*)&rtsp_st->sdp_ip)->sin_addr; 1183 addr = rtsp_st->sdp_ip;
1187 port = rtsp_st->sdp_port; 1184 port = rtsp_st->sdp_port;
1188 ttl = rtsp_st->sdp_ttl; 1185 ttl = rtsp_st->sdp_ttl;
1189 } 1186 }
1190 ff_url_join(url, sizeof(url), "rtp", NULL, inet_ntoa(in), 1187 getnameinfo((struct sockaddr*) &addr, sizeof(addr),
1188 namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
1189 ff_url_join(url, sizeof(url), "rtp", NULL, namebuf,
1191 port, "?ttl=%d", ttl); 1190 port, "?ttl=%d", ttl);
1192 if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { 1191 if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
1193 err = AVERROR_INVALIDDATA; 1192 err = AVERROR_INVALIDDATA;
1194 goto fail; 1193 goto fail;
1195 } 1194 }