summaryrefslogtreecommitdiff
path: root/libavformat/network.h
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-09-11 13:51:22 -0300
committerJames Almer <jamrial@gmail.com>2018-09-11 13:54:30 -0300
commit762c2b5dcd99a08452299cd1f83070f88115f1f3 (patch)
tree5ef18e0c76d00e388389c6662e778349a2332b06 /libavformat/network.h
parent23ce57af3ad684363881cdd66d5724f40963a65c (diff)
parent9b4c3f5aadf54ffd2a6e15746b1fd736379883c4 (diff)
downloadffmpeg-762c2b5dcd99a08452299cd1f83070f88115f1f3.tar.gz
Merge commit '9b4c3f5aadf54ffd2a6e15746b1fd736379883c4'
* commit '9b4c3f5aadf54ffd2a6e15746b1fd736379883c4': network: Add RFC 8305 style "Happy Eyeballs"/"Fast Fallback" helper function Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/network.h')
-rw-r--r--libavformat/network.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/libavformat/network.h b/libavformat/network.h
index 7843b908a1..7f467304a8 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -306,4 +306,32 @@ int ff_socket(int domain, int type, int protocol);
void ff_log_net_error(void *ctx, int level, const char* prefix);
+/**
+ * Connect to any of the given addrinfo addresses, with multiple attempts
+ * running in parallel.
+ *
+ * @param addrs The list of addresses to try to connect to.
+ * This list will be mutated internally, but the list head
+ * will remain as such, so this doesn't affect the caller
+ * freeing the list afterwards.
+ * @param timeout_ms_per_address The number of milliseconds to wait for each
+ * connection attempt. Since multiple addresses are tried,
+ * some of them in parallel, the total run time will at most
+ * be timeout_ms_per_address*ceil(nb_addrs/parallel) +
+ * (parallel - 1) * NEXT_ATTEMPT_DELAY_MS.
+ * @param parallel The maximum number of connections to attempt in parallel.
+ * This is limited to an internal maximum capacity.
+ * @param h URLContext providing interrupt check
+ * callback and logging context.
+ * @param fd If successful, the connected socket is returned here.
+ * @param customize_fd Function that will be called for each socket created,
+ * to allow the caller to set socket options before calling
+ * connect() on it, may be NULL.
+ * @param customize_ctx Context parameter passed to customize_fd.
+ * @return 0 on success, AVERROR on failure.
+ */
+int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address,
+ int parallel, URLContext *h, int *fd,
+ void (*customize_fd)(void *, int), void *customize_ctx);
+
#endif /* AVFORMAT_NETWORK_H */