Skip to content

Commit

Permalink
http add reconnect_first_delay opt
Browse files Browse the repository at this point in the history
  • Loading branch information
debugly committed Nov 12, 2024
1 parent 09868f6 commit c181b08
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From 43d61d6f8a698efa92d5cf586db38cc380c48efc Mon Sep 17 00:00:00 2001
From afb9fa8e856b5f1fa0d1e5d67192567167507aeb Mon Sep 17 00:00:00 2001
From: qianlongxu <qianlongxu@gmail.com>
Date: Thu, 7 Nov 2024 18:39:45 +0800
Date: Tue, 12 Nov 2024 14:40:18 +0800
Subject: [PATCH 23] fix http open and http_seek (redirect) authentication bug

---
libavformat/http.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 06f1bdd..4280614 100644
index 06f1bdd..7c60a66 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -78,6 +78,7 @@ typedef struct HTTPContext {
Expand Down Expand Up @@ -58,7 +58,7 @@ index 06f1bdd..4280614 100644
+ if (err != 0 && cur_auth_type != s->auth_state.auth_type && s->http_code == 401) {
+ //reverte the off,otherwise can't seek the target position.
+ s->off = off;
+ av_log(NULL, AV_LOG_ERROR, "http 401 error,need authenticate,s->off:%llu\n", s->buffer, s->off);
+ av_log(NULL, AV_LOG_ERROR, "http 401 error,need authenticate:%s,at:%llu\n", s->buffer, s->off);
+ err = 0;
+ }
done:
Expand Down
41 changes: 41 additions & 0 deletions patches/ffmpeg-n6.1/0026-http-add-reconnect_first_delay-opt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 18f90d0efc60ba8bee97bbe1c7c1a6f139b9ff24 Mon Sep 17 00:00:00 2001
From: qianlongxu <qianlongxu@gmail.com>
Date: Tue, 12 Nov 2024 14:42:37 +0800
Subject: [PATCH 26] http add reconnect_first_delay opt

---
libavformat/http.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 7c60a66..c8fad90 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -127,6 +127,7 @@ typedef struct HTTPContext {
int reconnect_on_network_error;
int reconnect_streamed;
int reconnect_delay_max;
+ int reconnect_first_delay;
char *reconnect_on_http_error;
int listen;
char *resource;
@@ -181,6 +182,7 @@ static const AVOption options[] = {
{ "reconnect_on_http_error", "list of http status codes to reconnect on", OFFSET(reconnect_on_http_error), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
{ "reconnect_streamed", "auto reconnect streamed / non seekable streams", OFFSET(reconnect_streamed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
{ "reconnect_delay_max", "max reconnect delay in seconds after which to give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000, D },
+ { "reconnect_first_delay", "first reconnect delay in seconds", OFFSET(reconnect_first_delay), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT_MAX/1000/1000, D },
{ "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E },
{ "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
{ "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E},
@@ -371,7 +373,7 @@ static int http_open_cnx(URLContext *h, AVDictionary **options)
HTTPAuthType cur_auth_type, cur_proxy_auth_type;
HTTPContext *s = h->priv_data;
int ret, attempts = 0, redirects = 0;
- int reconnect_delay = 0;
+ int reconnect_delay = s->reconnect_first_delay;
uint64_t off;
char *cached;

--
2.39.5 (Apple Git-154)

0 comments on commit c181b08

Please sign in to comment.