On Wed, 23 Sep 2015 00:55:39 +0000 Lucas Andrade <lu...@mindello.com.br> wrote:
> I've tested and this works. Cookies is being set correctly. As you can see, > I've removed the opts2 as it isn't needed anymore. I've added the cookie > update to open_url (setting the HLSContext->cookies and the opts (maybe > used on ciphered stream). > > diff --git a/libavformat/hls.c b/libavformat/hls.c > index adaa33a..a654924 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -533,7 +533,11 @@ static int open_url(HLSContext *c, URLContext **uc, > const char *url, AVDictionar > av_dict_copy(&tmp, c->avio_opts, 0); > av_dict_copy(&tmp, opts, 0); > > - ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp); > + if(ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, > &tmp) == 0) { Missing (...). If I remember my operator precedences correctly, this will compare the ffurl_open() result with 0, and then assign it to ret - which is wrong. (Also, generally, successful returns are 0 or positive by convention, so you should compare with "< 0" too. But it's not so important, because ffurl_open() explicitly documents returning 0 on success, and some existing code in this file also compares directly with 0). > + // update cookies on http response with setcookies. > + update_options(&c->cookies, "cookies", uc->priv_data); > + av_dict_set(&opts, "cookies", c->cookies, 0); > + } > > av_dict_free(&tmp); > > @@ -969,7 +973,6 @@ static void update_options(char **dest, const char > *name, void *src) > static int open_input(HLSContext *c, struct playlist *pls) > { > AVDictionary *opts = NULL; > - AVDictionary *opts2 = NULL; > int ret; > struct segment *seg = pls->segments[pls->cur_seq_no - > pls->start_seq_no]; > > @@ -979,9 +982,6 @@ static int open_input(HLSContext *c, struct playlist > *pls) > av_dict_set(&opts, "headers", c->headers, 0); > av_dict_set(&opts, "seekable", "0", 0); > > - // Same opts for key request (ffurl_open mutilates the opts so it > cannot be used twice) > - av_dict_copy(&opts2, opts, 0); > - > if (seg->size >= 0) { > /* try to restrict the HTTP request to the part we want > * (if this is in fact a HTTP request) */ > @@ -999,14 +999,12 @@ static int open_input(HLSContext *c, struct playlist > *pls) > char iv[33], key[33], url[MAX_URL_SIZE]; > if (strcmp(seg->key, pls->key_url)) { > URLContext *uc; > - if (open_url(pls->parent->priv_data, &uc, seg->key, opts2) == > 0) { > + if (open_url(pls->parent->priv_data, &uc, seg->key, opts) == > 0) { > if (ffurl_read_complete(uc, pls->key, sizeof(pls->key)) > != sizeof(pls->key)) { > av_log(NULL, AV_LOG_ERROR, "Unable to read key file > %s\n", > seg->key); > } > - update_options(&c->cookies, "cookies", uc->priv_data); > - av_dict_set(&opts, "cookies", c->cookies, 0); > ffurl_close(uc); > } else { > av_log(NULL, AV_LOG_ERROR, "Unable to open key file %s\n", > @@ -1038,7 +1036,7 @@ static int open_input(HLSContext *c, struct playlist > *pls) > ret = AVERROR_PATCHWELCOME; > } > else > - ret = AVERROR(ENOSYS); > + ret = AVERROR(ENOSYS); Stray indentation fix. Normally we try to separate cosmetics and functional changes, though I don't care at all in this case. > /* Seek to the requested position. If this was a HTTP request, the > offset > * should already be where want it to, but this allows e.g. local > testing > @@ -1055,7 +1053,6 @@ static int open_input(HLSContext *c, struct playlist > *pls) > > cleanup: > av_dict_free(&opts); > - av_dict_free(&opts2); > pls->cur_seg_offset = 0; > return ret; > } I think your patch is corrupted - you probably pasted this into your mail client, and it wrapped some lines. Either attach the patch as text file to your mail, or use git send-email (the latter might be too much effort to setup if you don't plan to post a lot of patches). _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel