+ av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
+ path, sizeof(path), uri);
+ rtcp_port = port + 1;
+
+ p = strchr(uri, '?');
+ if (p) {
+ if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
+ rtcp_port = strtol(buf, NULL, 10);
+ }
+ }
+
+ ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path);
+ ff_udp_set_remote_url(s->rtp_hd, buf);
+
+ ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, rtcp_port, "%s", path);
+ ff_udp_set_remote_url(s->rtcp_hd, buf);
+ return 0;
+}
+
+static struct addrinfo* rtp_resolve_host(const char *hostname, int port,
+ int type, int family, int flags)
+{
+ struct addrinfo hints = { 0 }, *res = 0;
+ int error;
+ char service[16];
+
+ snprintf(service, sizeof(service), "%d", port);
+ hints.ai_socktype = type;
+ hints.ai_family = family;
+ hints.ai_flags = flags;
+ if ((error = getaddrinfo(hostname, service, &hints, &res))) {
+ res = NULL;
+ av_log(NULL, AV_LOG_ERROR, "rtp_resolve_host: %s\n", gai_strerror(error));
+ }
+
+ return res;
+}
+
+static int compare_addr(const struct sockaddr_storage *a,
+ const struct sockaddr_storage *b)
+{
+ if (a->ss_family != b->ss_family)
+ return 1;
+ if (a->ss_family == AF_INET) {
+ return (((const struct sockaddr_in *)a)->sin_addr.s_addr !=
+ ((const struct sockaddr_in *)b)->sin_addr.s_addr);
+ }
+
+#if HAVE_STRUCT_SOCKADDR_IN6
+ if (a->ss_family == AF_INET6) {
+ const uint8_t *s6_addr_a = ((const struct sockaddr_in6 *)a)->sin6_addr.s6_addr;
+ const uint8_t *s6_addr_b = ((const struct sockaddr_in6 *)b)->sin6_addr.s6_addr;
+ return memcmp(s6_addr_a, s6_addr_b, 16);
+ }
+#endif
+ return 1;
+}
+
+static int get_port(const struct sockaddr_storage *ss)
+{
+ if (ss->ss_family == AF_INET)
+ return ntohs(((const struct sockaddr_in *)ss)->sin_port);
+#if HAVE_STRUCT_SOCKADDR_IN6
+ if (ss->ss_family == AF_INET6)
+ return ntohs(((const struct sockaddr_in6 *)ss)->sin6_port);
+#endif
+ return 0;
+}