]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '9b4c3f5aadf54ffd2a6e15746b1fd736379883c4'
authorJames Almer <jamrial@gmail.com>
Tue, 11 Sep 2018 16:51:22 +0000 (13:51 -0300)
committerJames Almer <jamrial@gmail.com>
Tue, 11 Sep 2018 16:54:30 +0000 (13:54 -0300)
* commit '9b4c3f5aadf54ffd2a6e15746b1fd736379883c4':
  network: Add RFC 8305 style "Happy Eyeballs"/"Fast Fallback" helper function

Merged-by: James Almer <jamrial@gmail.com>
1  2 
libavformat/network.c
libavformat/network.h

index c97e59d62049b001eb36a09e2c129adb242374f6,2d281539c640c1a0bff14edb9d567ae917304dc7..5664455d18697a5987500acc32b67a066ca9a620
@@@ -23,7 -23,7 +23,8 @@@
  #include "tls.h"
  #include "url.h"
  #include "libavcodec/internal.h"
 +#include "libavutil/avutil.h"
+ #include "libavutil/avassert.h"
  #include "libavutil/mem.h"
  #include "libavutil/time.h"
  
index 7843b908a18ed09523f2cb3a1541bb37f13da695,f4cb59e5ff1a6cc35b6f6a3d29f55e4a40de1735..7f467304a80e702bb3ea5d9f12872d2a4b2e3f12
@@@ -304,6 -256,32 +304,34 @@@ int ff_http_match_no_proxy(const char *
  
  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 */