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,
195 const char *include_sources,
196 const char *exclude_sources)
198 ff_url_join(buf, buf_size,
"udp", NULL, hostname, port, NULL);
200 url_add_option(buf, buf_size,
"localport=%d", local_port);
202 url_add_option(buf, buf_size,
"ttl=%d", ttl);
203 if (max_packet_size >=0)
204 url_add_option(buf, buf_size,
"pkt_size=%d", max_packet_size);
206 url_add_option(buf, buf_size,
"connect=1");
207 url_add_option(buf, buf_size,
"fifo_size=0");
208 if (include_sources && include_sources[0])
209 url_add_option(buf, buf_size,
"sources=%s", include_sources);
210 if (exclude_sources && exclude_sources[0])
211 url_add_option(buf, buf_size,
"block=%s", exclude_sources);
216 int *address_list_size_ptr)
220 char tmp =
'\0', *p =
buf, *next;
225 next = strchr(p,
',');
240 dynarray_add(address_list_ptr, address_list_size_ptr, source_addr);
277 int rtp_port, rtcp_port,
279 local_rtp_port, local_rtcp_port, max_packet_size;
280 char hostname[256], include_sources[1024] =
"", exclude_sources[1024] =
"";
284 int i, max_retry_count = 3;
286 av_url_split(NULL, 0, NULL, 0, hostname,
sizeof(hostname), &rtp_port,
287 path,
sizeof(path), uri);
290 rtcp_port = rtp_port+1;
292 local_rtcp_port = -1;
293 max_packet_size = -1;
296 p = strchr(uri,
'?');
299 ttl = strtol(buf, NULL, 10);
302 rtcp_port = strtol(buf, NULL, 10);
305 local_rtp_port = strtol(buf, NULL, 10);
308 local_rtp_port = strtol(buf, NULL, 10);
311 local_rtcp_port = strtol(buf, NULL, 10);
314 max_packet_size = strtol(buf, NULL, 10);
317 connect = strtol(buf, NULL, 10);
323 av_strlcpy(include_sources, buf,
sizeof(include_sources));
327 av_strlcpy(exclude_sources, buf,
sizeof(exclude_sources));
332 for (i = 0;i < max_retry_count;i++) {
334 hostname, rtp_port, local_rtp_port, ttl, max_packet_size,
335 connect, include_sources, exclude_sources);
339 if(local_rtp_port == 65535) {
343 if (local_rtcp_port<0) {
344 local_rtcp_port = local_rtp_port + 1;
346 hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
347 connect, include_sources, exclude_sources);
349 local_rtp_port = local_rtcp_port = -1;
355 hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
356 connect, include_sources, exclude_sources);
383 struct pollfd p[2] = {{s->
rtp_fd, POLLIN, 0}, {s->
rtcp_fd, POLLIN, 0}};
391 n = poll(p, 2, poll_delay);
394 for (i = 1; i >= 0; i--) {
395 if (!(p[i].revents & POLLIN))
397 *addr_lens[i] =
sizeof(*addrs[i]);
398 len = recvfrom(p[i].fd, buf, size, 0,
399 (
struct sockaddr *)addrs[i], addr_lens[i]);
433 socklen_t *source_len, temp_len;
436 "Unable to send packet to source, no packets received yet\n");
447 source = &s->last_rtp_source;
451 source = &temp_source;
452 source_len = &temp_len;
454 temp_source = s->last_rtp_source;
458 "Not received any RTCP packets yet, inferring peer port "
459 "from the RTP port\n");
465 "Not received any RTP packets yet, inferring peer port "
466 "from the RTCP port\n");
475 ret = sendto(fd, buf, size, 0, (
struct sockaddr *) source,
544 int *hs = *handles =
av_malloc(
sizeof(**handles) * 2);