[FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response

wm4 nfxjfg at googlemail.com
Tue Sep 22 17:47:15 CEST 2015


On Tue, 22 Sep 2015 04:37:48 +0000
Lucas Andrade <lucas at mindello.com.br> wrote:

> This fixes the https://trac.ffmpeg.org/ticket/4808, as it sets the cookie
> on playlist response with setcookie header.
> 
> Update Cookies on Setcookie playlist response
> ---
>  libavformat/hls.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 82dd744..e5c84e1 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -996,6 +996,8 @@ static int open_input(HLSContext *c, struct playlist
> *pls)
> 
>      if (seg->key_type == KEY_NONE) {
>          ret = open_url(pls->parent->priv_data, &pls->input, seg->url,
> opts);
> +        update_options(&c->cookies, "cookies", pls->input->priv_data);
> +        av_dict_set(&opts, "cookies", c->cookies, 0);
>      } else if (seg->key_type == KEY_AES_128) {
>  //         HLSContext *c = var->parent->priv_data;
>          char iv[33], key[33], url[MAX_URL_SIZE];

I've looked at it again. opts is actually unused after your added
lines, so it doesn't make sense to update it with the current cookies.
(In fact, opts gets trashed by the open_url() call, so it can't be used
for anything.)

update_options() might make sense: it copies the cookies set by the
server back into the HLS context. But it should do that only on
success. Also, there's another caller of open_url(), and maybe the code
shouldn't be duplicated. Bonus points if someone manages to get rid if
url_connect() (or removes the redundant code for setting up cookies).


More information about the ffmpeg-devel mailing list