diff mbox

[FFmpeg-devel] Consistent use of user_agent in hls.c

Message ID 20170217110040.87157-1-jan@berkel.fr
State Accepted
Commit aff80aa4ecadd0a2aa8da839f289b815db2ef078
Headers show

Commit Message

Jan Berkel Feb. 17, 2017, 11 a.m. UTC
This came up while debugging a problem with mpv:
https://github.com/mpv-player/mpv/issues/4155
---
 libavformat/hls.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Carl Eugen Hoyos Feb. 17, 2017, 11:08 a.m. UTC | #1
2017-02-17 12:00 GMT+01:00 Jan Berkel <jan@berkel.fr>:
> This came up while debugging a problem with mpv:
> https://github.com/mpv-player/mpv/issues/4155
> ---
>  libavformat/hls.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 3ae3c7cc5c..e1163a7927 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -670,7 +670,7 @@ static int parse_playlist(HLSContext *c, const char *url,
>          av_dict_set(&opts, "seekable", "0", 0);
>
>          // broker prior HTTP options that should be consistent across requests
> -        av_dict_set(&opts, "user-agent", c->user_agent, 0);
> +        av_dict_set(&opts, "user_agent", c->user_agent, 0);

Why is the code in http.c line 1048 not triggered that
should use the "user-agent" in case it was defined?

Carl Eugen
Jan Berkel Feb. 17, 2017, 3:16 p.m. UTC | #2
> 2017-02-17 12:00 GMT+01:00 Jan Berkel <jan@berkel.fr>:
> > This came up while debugging a problem with mpv:
> > https://github.com/mpv-player/mpv/issues/4155
> > ---
> >  libavformat/hls.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > index 3ae3c7cc5c..e1163a7927 100644
> > --- a/libavformat/hls.c
> > +++ b/libavformat/hls.c
> > @@ -670,7 +670,7 @@ static int parse_playlist(HLSContext *c, const char *url,
> >          av_dict_set(&opts, "seekable", "0", 0);
> >
> >          // broker prior HTTP options that should be consistent across requests
> > -        av_dict_set(&opts, "user-agent", c->user_agent, 0);
> > +        av_dict_set(&opts, "user_agent", c->user_agent, 0);
> 
> Why is the code in http.c line 1048 not triggered that
> should use the "user-agent" in case it was defined?. 

In my case the user_agent_* properties on HTTPContext never got set.

The problem is that there is some client  code (mpv in this case) 
which uses "user_agent":

https://github.com/mpv-player/mpv/blob/master/stream/stream_lavf.c#L205
 av_dict_set(dict, "user_agent", opts->useragent, 0);

This value should then be read from hls.c:1626

update_options(&c->user_agent, "user-agent", u);

I'm new to both mpv and ffmeg development so not exactly sure 
how this should be fixed. The result of the discussion on the mpv
github issue was that ffmpeg needs to be changed, since user-agent
is deprecated. 

         Jan
Steven Liu Feb. 17, 2017, 3:51 p.m. UTC | #3
2017-02-17 23:16 GMT+08:00 Jan Berkel <jan@berkel.fr>:

>
> > 2017-02-17 12:00 GMT+01:00 Jan Berkel <jan@berkel.fr>:
> > > This came up while debugging a problem with mpv:
> > > https://github.com/mpv-player/mpv/issues/4155
> > > ---
> > >  libavformat/hls.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > > index 3ae3c7cc5c..e1163a7927 100644
> > > --- a/libavformat/hls.c
> > > +++ b/libavformat/hls.c
> > > @@ -670,7 +670,7 @@ static int parse_playlist(HLSContext *c, const
> char *url,
> > >          av_dict_set(&opts, "seekable", "0", 0);
> > >
> > >          // broker prior HTTP options that should be consistent across
> requests
> > > -        av_dict_set(&opts, "user-agent", c->user_agent, 0);
> > > +        av_dict_set(&opts, "user_agent", c->user_agent, 0);
> >
> > Why is the code in http.c line 1048 not triggered that
> > should use the "user-agent" in case it was defined?.
>
> In my case the user_agent_* properties on HTTPContext never got set.
>
> The problem is that there is some client  code (mpv in this case)
> which uses "user_agent":
>
> https://github.com/mpv-player/mpv/blob/master/stream/stream_lavf.c#L205
>  av_dict_set(dict, "user_agent", opts->useragent, 0);
>
> This value should then be read from hls.c:1626
>
> update_options(&c->user_agent, "user-agent", u);
>
> I'm new to both mpv and ffmeg development so not exactly sure
> how this should be fixed. The result of the discussion on the mpv
> github issue was that ffmpeg needs to be changed, since user-agent
> is deprecated.
>
>          Jan
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


Yes, the user-agent will deprecated.

And I think this can test with ticket #1291
https://trac.ffmpeg.org/ticket/1291
wm4 March 23, 2017, 11:55 a.m. UTC | #4
On Fri, 17 Feb 2017 12:00:40 +0100
Jan Berkel <jan@berkel.fr> wrote:

> This came up while debugging a problem with mpv:
> https://github.com/mpv-player/mpv/issues/4155
> ---
>  libavformat/hls.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 3ae3c7cc5c..e1163a7927 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -670,7 +670,7 @@ static int parse_playlist(HLSContext *c, const char *url,
>          av_dict_set(&opts, "seekable", "0", 0);
>  
>          // broker prior HTTP options that should be consistent across requests
> -        av_dict_set(&opts, "user-agent", c->user_agent, 0);
> +        av_dict_set(&opts, "user_agent", c->user_agent, 0);
>          av_dict_set(&opts, "cookies", c->cookies, 0);
>          av_dict_set(&opts, "headers", c->headers, 0);
>          av_dict_set(&opts, "http_proxy", c->http_proxy, 0);
> @@ -1084,7 +1084,7 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg)
>      int is_http = 0;
>  
>      // broker prior HTTP options that should be consistent across requests
> -    av_dict_set(&opts, "user-agent", c->user_agent, 0);
> +    av_dict_set(&opts, "user_agent", c->user_agent, 0);
>      av_dict_set(&opts, "cookies", c->cookies, 0);
>      av_dict_set(&opts, "headers", c->headers, 0);
>      av_dict_set(&opts, "http_proxy", c->http_proxy, 0);
> @@ -1623,7 +1623,7 @@ static int hls_read_header(AVFormatContext *s)
>  
>      if (u) {
>          // get the previous user agent & set back to null if string size is zero
> -        update_options(&c->user_agent, "user-agent", u);
> +        update_options(&c->user_agent, "user_agent", u);
>  
>          // get the previous cookies & set back to null if string size is zero
>          update_options(&c->cookies, "cookies", u);

Pushed. (This apparently got forgotten.)
diff mbox

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3ae3c7cc5c..e1163a7927 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -670,7 +670,7 @@  static int parse_playlist(HLSContext *c, const char *url,
         av_dict_set(&opts, "seekable", "0", 0);
 
         // broker prior HTTP options that should be consistent across requests
-        av_dict_set(&opts, "user-agent", c->user_agent, 0);
+        av_dict_set(&opts, "user_agent", c->user_agent, 0);
         av_dict_set(&opts, "cookies", c->cookies, 0);
         av_dict_set(&opts, "headers", c->headers, 0);
         av_dict_set(&opts, "http_proxy", c->http_proxy, 0);
@@ -1084,7 +1084,7 @@  static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg)
     int is_http = 0;
 
     // broker prior HTTP options that should be consistent across requests
-    av_dict_set(&opts, "user-agent", c->user_agent, 0);
+    av_dict_set(&opts, "user_agent", c->user_agent, 0);
     av_dict_set(&opts, "cookies", c->cookies, 0);
     av_dict_set(&opts, "headers", c->headers, 0);
     av_dict_set(&opts, "http_proxy", c->http_proxy, 0);
@@ -1623,7 +1623,7 @@  static int hls_read_header(AVFormatContext *s)
 
     if (u) {
         // get the previous user agent & set back to null if string size is zero
-        update_options(&c->user_agent, "user-agent", u);
+        update_options(&c->user_agent, "user_agent", u);
 
         // get the previous cookies & set back to null if string size is zero
         update_options(&c->cookies, "cookies", u);