[vlc-devel] [PATCH VLC 3.0.x] chromecast: disable httpd timeout
Thomas Guillem
thomas at gllm.fr
Thu Oct 29 13:34:47 CET 2020
Fixes #25151
Fixes #25192
This is a hotfix for VLC 3.0 only. A proper solution need to be found in
VLC 4.0 (likely using a hls or dash server).
---
modules/stream_out/chromecast/cast.cpp | 9 +++++++++
src/network/httpd.c | 7 +++++++
2 files changed, 16 insertions(+)
diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index f3840cf4c4..d09c8a8b88 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -1415,7 +1415,16 @@ static int Open(vlc_object_t *p_this)
var_SetInteger(p_stream, "http-port", i_local_server_port);
var_Create(p_stream, "http-host", VLC_VAR_STRING);
var_SetString(p_stream, "http-host", "");
+
+ /* Chromecast clients buffer lot of data (burst mode) and can wait more
+ * than 10 seconds between 2 consecutive I/O. Tell httpd that the
+ * timeout of this client should not be handled (infinite timeout) to
+ * avoid closing the client connection after 10 seconds without any
+ * socket activity */
+ var_Create(p_stream, "http-no-timeout", VLC_VAR_VOID);
+
httpd_host = vlc_http_HostNew(VLC_OBJECT(p_stream));
+ var_Destroy(p_stream, "http-no-timeout");
if (httpd_host == NULL)
goto error;
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 3197fb2ec9..69e6399483 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -93,6 +93,7 @@ struct httpd_host_t
int i_url;
httpd_url_t **url;
+ bool b_no_timeout;
int i_client;
httpd_client_t **client;
@@ -947,6 +948,10 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
vlc_cond_init(&host->wait);
host->i_ref = 1;
+ host->b_no_timeout = var_Type(p_this, "http-no-timeout") != 0;
+ if (host->b_no_timeout)
+ msg_Warn(p_this, "httpd timeout disabled");
+
char *hostname = var_InheritString(p_this, hostvar);
host->fds = net_ListenTCP(p_this, hostname, port);
@@ -2031,6 +2036,8 @@ static void httpdLoop(httpd_host_t *host)
}
cl = httpd_ClientNew(sk, now);
+ if (host->b_no_timeout)
+ cl->i_activity_timeout = 0;
if (host->p_tls != NULL)
cl->i_state = HTTPD_CLIENT_TLS_HS_OUT;
--
2.28.0
More information about the vlc-devel
mailing list