73 av_url_split(NULL, 0, NULL, 0, hostname,
sizeof(hostname), &port,
74 path,
sizeof(path), uri);
80 rtcp_port = strtol(buf, NULL, 10);
84 ff_url_join(buf,
sizeof(buf),
"udp", NULL, hostname, port,
"%s", path);
87 ff_url_join(buf,
sizeof(buf),
"udp", NULL, hostname, rtcp_port,
"%s", path);
95 struct addrinfo hints = { 0 }, *res = 0;
99 snprintf(service,
sizeof(service),
"%d", port);
103 if ((error =
getaddrinfo(hostname, service, &hints, &res))) {
117 return (((
const struct sockaddr_in *)a)->sin_addr.s_addr !=
118 ((
const struct sockaddr_in *)b)->sin_addr.s_addr);
121 #if HAVE_STRUCT_SOCKADDR_IN6
123 const uint8_t *s6_addr_a = ((
const struct sockaddr_in6 *)a)->sin6_addr.s6_addr;
124 const uint8_t *s6_addr_b = ((
const struct sockaddr_in6 *)b)->sin6_addr.s6_addr;
125 return memcmp(s6_addr_a, s6_addr_b, 16);
134 return ntohs(((
const struct sockaddr_in *)ss)->sin_port);
135 #if HAVE_STRUCT_SOCKADDR_IN6
137 return ntohs(((
const struct sockaddr_in6 *)ss)->sin6_port);
145 ((
struct sockaddr_in *)ss)->sin_port = htons(port);
146 #if HAVE_STRUCT_SOCKADDR_IN6
147 else if (ss->ss_family == AF_INET6)
148 ((
struct sockaddr_in6 *)ss)->sin6_port = htons(port);
182 if (strchr(buf,
'?'))
192 const char *hostname,
int port,
193 int local_port,
int ttl,
194 int max_packet_size,
int connect,
196 const char *include_sources,
197 const char *exclude_sources)
199 ff_url_join(buf, buf_size,
"udp", NULL, hostname, port, NULL);
201 url_add_option(buf, buf_size,
"localport=%d", local_port);
203 url_add_option(buf, buf_size,
"ttl=%d", ttl);
204 if (max_packet_size >=0)
205 url_add_option(buf, buf_size,
"pkt_size=%d", max_packet_size);
207 url_add_option(buf, buf_size,
"connect=1");
209 url_add_option(buf, buf_size,
"dscp=%d", dscp);
210 url_add_option(buf, buf_size,
"fifo_size=0");
211 if (include_sources && include_sources[0])
212 url_add_option(buf, buf_size,
"sources=%s", include_sources);
213 if (exclude_sources && exclude_sources[0])
214 url_add_option(buf, buf_size,
"block=%s", exclude_sources);
219 int *address_list_size_ptr)
223 char tmp =
'\0', *p =
buf, *next;
228 next = strchr(p,
',');
245 dynarray_add(address_list_ptr, address_list_size_ptr, source_addr);
283 int rtp_port, rtcp_port,
285 local_rtp_port, local_rtcp_port, max_packet_size, dscp;
286 char hostname[256], include_sources[1024] =
"", exclude_sources[1024] =
"";
290 int i, max_retry_count = 3;
292 av_url_split(NULL, 0, NULL, 0, hostname,
sizeof(hostname), &rtp_port,
293 path,
sizeof(path), uri);
296 rtcp_port = rtp_port+1;
298 local_rtcp_port = -1;
299 max_packet_size = -1;
303 p = strchr(uri,
'?');
306 ttl = strtol(buf, NULL, 10);
309 rtcp_port = strtol(buf, NULL, 10);
312 local_rtp_port = strtol(buf, NULL, 10);
315 local_rtp_port = strtol(buf, NULL, 10);
318 local_rtcp_port = strtol(buf, NULL, 10);
321 max_packet_size = strtol(buf, NULL, 10);
324 connect = strtol(buf, NULL, 10);
330 dscp = strtol(buf, NULL, 10);
333 av_strlcpy(include_sources, buf,
sizeof(include_sources));
337 av_strlcpy(exclude_sources, buf,
sizeof(exclude_sources));
342 for (i = 0;i < max_retry_count;i++) {
344 hostname, rtp_port, local_rtp_port, ttl, max_packet_size,
345 connect, dscp, include_sources, exclude_sources);
349 if(local_rtp_port == 65535) {
353 if (local_rtcp_port<0) {
354 local_rtcp_port = local_rtp_port + 1;
356 hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
357 connect, dscp, include_sources, exclude_sources);
359 local_rtp_port = local_rtcp_port = -1;
365 hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
366 connect, dscp, include_sources, exclude_sources);
393 struct pollfd p[2] = {{s->
rtp_fd, POLLIN, 0}, {s->
rtcp_fd, POLLIN, 0}};
401 n = poll(p, 2, poll_delay);
404 for (i = 1; i >= 0; i--) {
405 if (!(p[i].revents & POLLIN))
407 *addr_lens[i] =
sizeof(*addrs[i]);
408 len = recvfrom(p[i].fd, buf, size, 0,
409 (
struct sockaddr *)addrs[i], addr_lens[i]);
443 socklen_t *source_len, temp_len;
446 "Unable to send packet to source, no packets received yet\n");
457 source = &s->last_rtp_source;
461 source = &temp_source;
462 source_len = &temp_len;
464 temp_source = s->last_rtp_source;
468 "Not received any RTCP packets yet, inferring peer port "
469 "from the RTP port\n");
475 "Not received any RTP packets yet, inferring peer port "
476 "from the RTCP port\n");
485 ret = sendto(fd, buf, size, 0, (
struct sockaddr *) source,
554 int *hs = *handles =
av_malloc(
sizeof(**handles) * 2);