[vlc-devel] [PATCH 4/4] chromecast: don't close the client connection

Thomas Guillem thomas at gllm.fr
Wed Oct 28 13:34:37 CET 2020


Fixes #25151
Fixes #25192
---
 modules/stream_out/chromecast/cast.cpp | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index 8f0470127b8..e30b8693621 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -60,7 +60,7 @@ struct sout_access_out_sys_t
     void clear();
     void stop();
     void prepare(sout_stream_t *p_stream, const std::string &mime);
-    int url_cb(httpd_client_t *cl, httpd_message_t *answer, const httpd_message_t *query);
+    int url_cb(httpd_client_t *cl, httpd_message_t *answer, const httpd_message_t *query, vlc_tick_t *timeout);
     void fifo_put_back(block_t *);
     ssize_t write(sout_access_out_t *p_access, block_t *p_block);
     void close();
@@ -332,10 +332,10 @@ static int ProxyOpen(vlc_object_t *p_this)
 
 static int httpd_url_cb(httpd_callback_sys_t *data, httpd_client_t *cl,
                         httpd_message_t *answer, const httpd_message_t *query,
-                        vlc_tick_t *)
+                        vlc_tick_t *timeout)
 {
     sout_access_out_sys_t *p_sys = reinterpret_cast<sout_access_out_sys_t *>(data);
-    return p_sys->url_cb(cl, answer, query);
+    return p_sys->url_cb(cl, answer, query, timeout);
 }
 
 sout_access_out_sys_t::sout_access_out_sys_t(httpd_host_t *httpd_host,
@@ -453,7 +453,8 @@ void sout_access_out_sys_t::fifo_put_back(block_t *p_block)
 }
 
 int sout_access_out_sys_t::url_cb(httpd_client_t *cl, httpd_message_t *answer,
-                                  const httpd_message_t *query)
+                                  const httpd_message_t *query,
+                                  vlc_tick_t *cl_timeout)
 {
     if (!answer || !query || !cl)
         return VLC_SUCCESS;
@@ -467,6 +468,13 @@ int sout_access_out_sys_t::url_cb(httpd_client_t *cl, httpd_message_t *answer,
          * should also serve data used by the old client to the new one. */
         restoreCopy();
         m_client = cl;
+
+        /* 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 */
+        *cl_timeout = 0;
     }
 
     /* Send data per 512kB minimum */
-- 
2.28.0



More information about the vlc-devel mailing list