72 char host[1024], path[1024], url[1024], announce_addr[50] =
"";
74 int port = 9875, base_port = 5004, i, pos = 0, same_port = 0, ttl = 255;
78 socklen_t addrlen =
sizeof(localaddr);
86 av_url_split(NULL, 0, NULL, 0, host,
sizeof(host), &base_port,
92 option_list = strrchr(path,
'?');
96 port = strtol(buf, NULL, 10);
99 same_port = strtol(buf, NULL, 10);
102 ttl = strtol(buf, NULL, 10);
105 av_strlcpy(announce_addr, buf,
sizeof(announce_addr));
109 if (!announce_addr[0]) {
110 struct addrinfo hints = { 0 }, *ai = NULL;
117 if (ai->ai_family == AF_INET) {
119 av_strlcpy(announce_addr,
"224.2.127.254",
sizeof(announce_addr));
120 #if HAVE_STRUCT_SOCKADDR_IN6
121 }
else if (ai->ai_family == AF_INET6) {
125 av_strlcpy(announce_addr,
"ff0e::2:7ffe",
sizeof(announce_addr));
130 "address family\n", host);
147 ff_url_join(url,
sizeof(url),
"rtp", NULL, host, base_port,
160 av_strlcpy(contexts[i]->filename, url,
sizeof(contexts[i]->filename));
166 ff_url_join(url,
sizeof(url),
"udp", NULL, announce_addr, port,
167 "?ttl=%d&connect=1", ttl);
176 if (getsockname(udp_fd, (
struct sockaddr*) &localaddr, &addrlen)) {
181 #
if HAVE_STRUCT_SOCKADDR_IN6
195 sap->
ann[pos] = (1 << 5);
196 #if HAVE_STRUCT_SOCKADDR_IN6
198 sap->
ann[pos] |= 0x10;
205 memcpy(&sap->
ann[pos], &((
struct sockaddr_in*)&localaddr)->sin_addr,
206 sizeof(
struct in_addr));
207 pos +=
sizeof(
struct in_addr);
208 #if HAVE_STRUCT_SOCKADDR_IN6
210 memcpy(&sap->
ann[pos], &((
struct sockaddr_in6*)&localaddr)->sin6_addr,
211 sizeof(
struct in6_addr));
212 pos +=
sizeof(
struct in6_addr);
217 pos += strlen(&sap->
ann[pos]) + 1;
226 pos += strlen(&sap->
ann[pos]);
252 if (ret < 0 && ret !=
AVERROR(ECONNREFUSED))
263 .priv_data_size =
sizeof(
struct SAPState),