[vlc-devel] [PATCH 3/4] httpd: let UrlCatch users handling the timeout

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


Refs #25151
Refs #25192
---
 include/vlc_httpd.h                    |  2 +-
 modules/stream_out/chromecast/cast.cpp |  3 ++-
 modules/stream_out/rtsp.c              | 10 ++++++----
 src/network/httpd.c                    | 24 ++++++++++++++++--------
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/include/vlc_httpd.h b/include/vlc_httpd.h
index 0b8f8c26bd9..b093a2d773a 100644
--- a/include/vlc_httpd.h
+++ b/include/vlc_httpd.h
@@ -106,7 +106,7 @@ typedef struct httpd_message_t
 
 typedef struct httpd_url_t      httpd_url_t;
 typedef struct httpd_callback_sys_t httpd_callback_sys_t;
-typedef int    (*httpd_callback_t)( httpd_callback_sys_t *, httpd_client_t *, httpd_message_t *answer, const httpd_message_t *query );
+typedef int    (*httpd_callback_t)( httpd_callback_sys_t *, httpd_client_t *, httpd_message_t *answer, const httpd_message_t *query, vlc_tick_t *timeout );
 /* register a new url */
 VLC_API httpd_url_t * httpd_UrlNew( httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password ) VLC_USED;
 /* register callback on a url */
diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index 08defbd5a1b..8f0470127b8 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -331,7 +331,8 @@ 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)
+                        httpd_message_t *answer, const httpd_message_t *query,
+                        vlc_tick_t *)
 {
     sout_access_out_sys_t *p_sys = reinterpret_cast<sout_access_out_sys_t *>(data);
     return p_sys->url_cb(cl, answer, query);
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index 8d79803c8e0..225acdc6c7e 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -74,10 +74,10 @@ struct rtsp_stream_t
 
 static int  RtspCallback( httpd_callback_sys_t *p_args,
                           httpd_client_t *cl, httpd_message_t *answer,
-                          const httpd_message_t *query );
+                          const httpd_message_t *query, vlc_tick_t *timeout );
 static int  RtspCallbackId( httpd_callback_sys_t *p_args,
                             httpd_client_t *cl, httpd_message_t *answer,
-                            const httpd_message_t *query );
+                            const httpd_message_t *query, vlc_tick_t *timeout );
 static void RtspClientDel( rtsp_stream_t *rtsp, rtsp_session_t *session );
 
 static void RtspTimeOut( void *data );
@@ -1052,8 +1052,9 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
 static int RtspCallback( httpd_callback_sys_t *p_args,
                          httpd_client_t *cl,
                          httpd_message_t *answer,
-                         const httpd_message_t *query )
+                         const httpd_message_t *query, vlc_tick_t *timeout )
 {
+    (void) timeout;
     return RtspHandler( (rtsp_stream_t *)p_args, NULL, cl, answer, query );
 }
 
@@ -1062,8 +1063,9 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
 static int RtspCallbackId( httpd_callback_sys_t *p_args,
                            httpd_client_t *cl,
                            httpd_message_t *answer,
-                           const httpd_message_t *query )
+                           const httpd_message_t *query, vlc_tick_t *timeout )
 {
+    (void) timeout;
     rtsp_stream_id_t *id = (rtsp_stream_id_t *)p_args;
     return RtspHandler( id->stream, id, cl, answer, query );
 }
diff --git a/src/network/httpd.c b/src/network/httpd.c
index fd232dce8e2..39c6a3a083e 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -306,8 +306,10 @@ struct httpd_file_t
 
 static int
 httpd_FileCallBack(httpd_callback_sys_t *p_sys, httpd_client_t *cl,
-                    httpd_message_t *answer, const httpd_message_t *query)
+                    httpd_message_t *answer, const httpd_message_t *query,
+                    vlc_tick_t *cl_timeout)
 {
+    (void) cl_timeout;
     httpd_file_t *file = (httpd_file_t*)p_sys;
     uint8_t **pp_body, *p_body;
     int *pi_body, i_body;
@@ -412,8 +414,10 @@ struct httpd_handler_t
 
 static int
 httpd_HandlerCallBack(httpd_callback_sys_t *p_sys, httpd_client_t *cl,
-                       httpd_message_t *answer, const httpd_message_t *query)
+                       httpd_message_t *answer, const httpd_message_t *query,
+                       vlc_tick_t *cl_timeout)
 {
+    (void) cl_timeout;
     httpd_handler_t *handler = (httpd_handler_t*)p_sys;
     char psz_remote_addr[NI_MAXNUMERICHOST];
 
@@ -528,11 +532,12 @@ struct httpd_redirect_t
 
 static int httpd_RedirectCallBack(httpd_callback_sys_t *p_sys,
                                    httpd_client_t *cl, httpd_message_t *answer,
-                                   const httpd_message_t *query)
+                                   const httpd_message_t *query,
+                                   vlc_tick_t *cl_timeout)
 {
     httpd_redirect_t *rdir = (httpd_redirect_t*)p_sys;
     char *p_body;
-    (void)cl;
+    (void)cl; (void) cl_timeout;
 
     if (!answer || !query)
         return VLC_SUCCESS;
@@ -625,8 +630,10 @@ struct httpd_stream_t
 
 static int httpd_StreamCallBack(httpd_callback_sys_t *p_sys,
                                  httpd_client_t *cl, httpd_message_t *answer,
-                                 const httpd_message_t *query)
+                                 const httpd_message_t *query,
+                                 vlc_tick_t *cl_timeout)
 {
+    (void) cl_timeout;
     httpd_stream_t *stream = (httpd_stream_t*)p_sys;
 
     if (!answer || !query || !cl)
@@ -1641,7 +1648,7 @@ static int httpd_ClientSend(httpd_client_t *cl)
             cl->answer.i_body_offset = i_offset;
 
             cl->url->catch[i_msg].cb(cl->url->catch[i_msg].p_sys, cl,
-                                     &cl->answer, &cl->query);
+                                     &cl->answer, &cl->query, &cl->i_activity_timeout);
         }
 
         if (cl->answer.i_body > 0) {
@@ -1879,7 +1886,8 @@ static void httpdLoop(httpd_host_t *host)
                                    break;
                             }
 
-                            if (url->catch[i_msg].cb(url->catch[i_msg].p_sys, cl, answer, query))
+                            if (url->catch[i_msg].cb(url->catch[i_msg].p_sys, cl, answer, query,
+                                                     &cl->i_activity_timeout))
                                 continue;
 
                             if (answer->i_proto == HTTPD_PROTO_NONE)
@@ -1975,7 +1983,7 @@ static void httpdLoop(httpd_host_t *host)
                 cl->answer.i_body_offset = i_offset;
 
                 cl->url->catch[i_msg].cb(cl->url->catch[i_msg].p_sys, cl,
-                        &cl->answer, &cl->query);
+                        &cl->answer, &cl->query, &cl->i_activity_timeout);
                 if (cl->answer.i_type != HTTPD_MSG_NONE) {
                     /* we have new data, so re-enter send mode */
                     cl->i_buffer      = 0;
-- 
2.28.0



More information about the vlc-devel mailing list