[FFmpeg-devel,v1] lavf/rtsp.c: Fix stimeout option not applied on http tunnel

Submitted by Jun Li on April 5, 2019, 8:20 a.m.

Details

Message ID 20190405082031.21235-1-junli1026@gmail.com
State New
Headers show

Commit Message

Jun Li April 5, 2019, 8:20 a.m.
stimeout option is already used in tcp transport, since
http is based on tcp, pass the option to http for tunneling
case.
---
 libavformat/rtsp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer April 5, 2019, 10:50 a.m.
On Fri, Apr 05, 2019 at 01:20:31AM -0700, Jun Li wrote:
> stimeout option is already used in tcp transport, since
> http is based on tcp, pass the option to http for tunneling
> case.
> ---
>  libavformat/rtsp.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 033095905d..2ca1aca94e 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1744,6 +1744,9 @@ redirect:
>          char httpname[1024];
>          char sessioncookie[17];
>          char headers[1024];
> +        AVDictionary *options = NULL;
> +        
> +        av_dict_set_int(&options, "timeout", rt->stimeout, 0);
>  
>          ff_url_join(httpname, sizeof(httpname), https_tunnel ? "https" : "http", auth, host, port, "%s", path);
>          snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x",
> @@ -1774,7 +1777,7 @@ redirect:
>          }
>  
>          /* complete the connection */
> -        if (ffurl_connect(rt->rtsp_hd, NULL)) {
> +        if (ffurl_connect(rt->rtsp_hd, &options)) {
>              err = AVERROR(EIO);
>              goto fail;
>          }
> @@ -1818,10 +1821,11 @@ redirect:
>          ff_http_init_auth_state(rt->rtsp_hd_out, rt->rtsp_hd);
>  
>          /* complete the connection */
> -        if (ffurl_connect(rt->rtsp_hd_out, NULL)) {
> +        if (ffurl_connect(rt->rtsp_hd_out, &options)) {
>              err = AVERROR(EIO);
>              goto fail;
>          }
> +        av_dict_free(&options);

wouldnt this leak options on the error path ?

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 033095905d..2ca1aca94e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1744,6 +1744,9 @@  redirect:
         char httpname[1024];
         char sessioncookie[17];
         char headers[1024];
+        AVDictionary *options = NULL;
+        
+        av_dict_set_int(&options, "timeout", rt->stimeout, 0);
 
         ff_url_join(httpname, sizeof(httpname), https_tunnel ? "https" : "http", auth, host, port, "%s", path);
         snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x",
@@ -1774,7 +1777,7 @@  redirect:
         }
 
         /* complete the connection */
-        if (ffurl_connect(rt->rtsp_hd, NULL)) {
+        if (ffurl_connect(rt->rtsp_hd, &options)) {
             err = AVERROR(EIO);
             goto fail;
         }
@@ -1818,10 +1821,11 @@  redirect:
         ff_http_init_auth_state(rt->rtsp_hd_out, rt->rtsp_hd);
 
         /* complete the connection */
-        if (ffurl_connect(rt->rtsp_hd_out, NULL)) {
+        if (ffurl_connect(rt->rtsp_hd_out, &options)) {
             err = AVERROR(EIO);
             goto fail;
         }
+        av_dict_free(&options);
     } else {
         int ret;
         /* open the tcp connection */