Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, Oct 30, 2015 at 12:26:55PM +, Lucas Andrade wrote: > Em sex, 30 de out de 2015 às 07:44, Michael Niedermayer > escreveu: > > > On Tue, Oct 27, 2015 at 11:28:32AM +, Lucas Andrade wrote: > > > Here is the patch to backport it to release/2.8. To be fixed on 2.8.2. > > > Anything else I should do? > > > > > > ps. Sorry, that's my first time on opensource project, I'm a little > > > confused that I needed to add it to the release branch. > > > > > hls.c | 31 +++ > > > 1 file changed, 15 insertions(+), 16 deletions(-) > > > 6b3c2cdc68e5fe0d9665a22a78837bca7d7b39b9 > > b3f3eab029eb429660fc1651a33dafe097cbac0e.patch > > > From b3f3eab029eb429660fc1651a33dafe097cbac0e Mon Sep 17 00:00:00 2001 > > > From: Lucas de Andrade > > > Date: Mon, 26 Oct 2015 10:47:08 -0200 > > > Subject: [PATCH] Update Cookies response with Setcookie > > > > > > Context cookies must be updated when a playlist response return > > Setcookie header. > > > Backported to release/2.8 > > > --- > > > libavformat/hls.c | 31 +++ > > > 1 file changed, 15 insertions(+), 16 deletions(-) > > > > this patch is against n2.8 not release/2.8 > > > > git checkout release/2.8 > > git cherry-pick ... > > error: patch failed: libavformat/hls.c:962 > > error: libavformat/hls.c: patch does not apply > > Patch failed at 0001 Update Cookies response with Setcookie > > The copy of the patch that failed is found in: > >ffmpeg/.git/rebase-apply/patch > > When you have resolved this problem, run "git am --continue". > > If you prefer to skip this patch, run "git am --skip" instead. > > To restore the original branch and stop patching, run "git am --abort". > > > > [...] > > > > -- > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > > > Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. > > User > > questions about the command line tools should be sent to the ffmpeg-user > > ML. > > And questions about how to use libav* should be sent to the libav-user ML. > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > Sorry, I needed to update release/2.8. It was a previous version. > Here it is. > hls.c | 31 +++ > 1 file changed, 15 insertions(+), 16 deletions(-) > 245150aacbd311302c9c7ee3e293aeae684323b0 > update_cookies_on_setcookie_response.patch > From 94b7fd78b6e4a50ffe19a3b0523fb88c9036ea5d Mon Sep 17 00:00:00 2001 > From: Lucas de Andrade > Date: Fri, 30 Oct 2015 09:51:26 -0200 > Subject: [PATCH] avformat/hls: update cookies on setcookie response > > Context cookies must be updated when a playlist response return Setcookie > header. > --- > libavformat/hls.c | 31 +++ > 1 file changed, 15 insertions(+), 16 deletions(-) applied to release/2.8 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Em sex, 30 de out de 2015 às 07:44, Michael Niedermayer escreveu: > On Tue, Oct 27, 2015 at 11:28:32AM +, Lucas Andrade wrote: > > Here is the patch to backport it to release/2.8. To be fixed on 2.8.2. > > Anything else I should do? > > > > ps. Sorry, that's my first time on opensource project, I'm a little > > confused that I needed to add it to the release branch. > > > hls.c | 31 +++ > > 1 file changed, 15 insertions(+), 16 deletions(-) > > 6b3c2cdc68e5fe0d9665a22a78837bca7d7b39b9 > b3f3eab029eb429660fc1651a33dafe097cbac0e.patch > > From b3f3eab029eb429660fc1651a33dafe097cbac0e Mon Sep 17 00:00:00 2001 > > From: Lucas de Andrade > > Date: Mon, 26 Oct 2015 10:47:08 -0200 > > Subject: [PATCH] Update Cookies response with Setcookie > > > > Context cookies must be updated when a playlist response return > Setcookie header. > > Backported to release/2.8 > > --- > > libavformat/hls.c | 31 +++ > > 1 file changed, 15 insertions(+), 16 deletions(-) > > this patch is against n2.8 not release/2.8 > > git checkout release/2.8 > git cherry-pick ... > error: patch failed: libavformat/hls.c:962 > error: libavformat/hls.c: patch does not apply > Patch failed at 0001 Update Cookies response with Setcookie > The copy of the patch that failed is found in: >ffmpeg/.git/rebase-apply/patch > When you have resolved this problem, run "git am --continue". > If you prefer to skip this patch, run "git am --skip" instead. > To restore the original branch and stop patching, run "git am --abort". > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. > User > questions about the command line tools should be sent to the ffmpeg-user > ML. > And questions about how to use libav* should be sent to the libav-user ML. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel Sorry, I needed to update release/2.8. It was a previous version. Here it is. update cookies on setcookie response.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Tue, Oct 27, 2015 at 11:28:32AM +, Lucas Andrade wrote: > Here is the patch to backport it to release/2.8. To be fixed on 2.8.2. > Anything else I should do? > > ps. Sorry, that's my first time on opensource project, I'm a little > confused that I needed to add it to the release branch. > hls.c | 31 +++ > 1 file changed, 15 insertions(+), 16 deletions(-) > 6b3c2cdc68e5fe0d9665a22a78837bca7d7b39b9 > b3f3eab029eb429660fc1651a33dafe097cbac0e.patch > From b3f3eab029eb429660fc1651a33dafe097cbac0e Mon Sep 17 00:00:00 2001 > From: Lucas de Andrade > Date: Mon, 26 Oct 2015 10:47:08 -0200 > Subject: [PATCH] Update Cookies response with Setcookie > > Context cookies must be updated when a playlist response return Setcookie > header. > Backported to release/2.8 > --- > libavformat/hls.c | 31 +++ > 1 file changed, 15 insertions(+), 16 deletions(-) this patch is against n2.8 not release/2.8 git checkout release/2.8 git cherry-pick ... error: patch failed: libavformat/hls.c:962 error: libavformat/hls.c: patch does not apply Patch failed at 0001 Update Cookies response with Setcookie The copy of the patch that failed is found in: ffmpeg/.git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Em ter, 27 de out de 2015 às 09:28, Lucas Andrade escreveu: > Here is the patch to backport it to release/2.8. To be fixed on 2.8.2. > Anything else I should do? > > ps. Sorry, that's my first time on opensource project, I'm a little > confused that I needed to add it to the release branch. > Do I need to do anything else? It hasn't been added to release/2.8 branch yet. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Here is the patch to backport it to release/2.8. To be fixed on 2.8.2. Anything else I should do? ps. Sorry, that's my first time on opensource project, I'm a little confused that I needed to add it to the release branch. b3f3eab029eb429660fc1651a33dafe097cbac0e.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Can this patch be added to 2.9-dev? I think it should be released on 2.8.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, Sep 25, 2015 at 11:23 AM, wm4 wrote: > On Fri, 25 Sep 2015 15:16:34 + > Lucas Andrade wrote: > >> Ok, I know I did it wrong with the PR. I've used the PR to create the >> patch. Sorry for trying to help. >> Anyway, here it is the all-in-one patch. > > Thanks! I applied and pushed it. Sorry for the back and forth. Anyone with write access - please close the github pull request. Thanks. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, 25 Sep 2015 15:16:34 + Lucas Andrade wrote: > Ok, I know I did it wrong with the PR. I've used the PR to create the > patch. Sorry for trying to help. > Anyway, here it is the all-in-one patch. Thanks! I applied and pushed it. Sorry for the back and forth. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Ok, I know I did it wrong with the PR. I've used the PR to create the patch. Sorry for trying to help. Anyway, here it is the all-in-one patch. Update Cookies response with Setcookie.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, Sep 25, 2015 at 9:50 AM, Lucas Andrade wrote: > Here it is. Also sent as PR on github. FYI, we don't do pull requests on github: See "Contributing" at https://github.com/FFmpeg/FFmpeg. > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, 25 Sep 2015 14:23:27 + Lucas Andrade wrote: > Ok, I'll try to merge all those patches at a single one. Should be simple enough... the reason why I want a git format-patch is that you can set your commit message, author name, and email properly. Sorry for not clarifying this earlier. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Ok, I'll try to merge all those patches at a single one. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, 25 Sep 2015 13:50:28 + Lucas Andrade wrote: > From 1fd6d3c584678917bd0a262bfbbbfaa7181add08 Mon Sep 17 00:00:00 2001 > From: Lucas de Andrade > Date: Tue, 22 Sep 2015 00:58:03 -0300 > Subject: [PATCH 1/8] Update Cookies Setcookie response > > Update Cookies Setcookie 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]; > > From d738d7b525eef2fc76b9d13e2b9ca5044d9a46d1 Mon Sep 17 00:00:00 2001 > From: Lucas de Andrade > Date: Tue, 22 Sep 2015 10:41:31 -0300 > Subject: [PATCH 2/8] Update cookies on http response with setcookies. > > If a playlist response sets a cookie, the cookies must be updated for future > requests. > --- > libavformat/hls.c | 27 +++ > 1 file changed, 15 insertions(+), 12 deletions(-) > > diff --git a/libavformat/hls.c b/libavformat/hls.c > index e5c84e1..23e59a6 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -996,8 +996,6 @@ 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]; > @@ -1044,16 +1042,21 @@ static int open_input(HLSContext *c, struct playlist > *pls) > else >ret = AVERROR(ENOSYS); > > -/* 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 > - * without a HTTP server. */ > -if (ret == 0 && seg->key_type == KEY_NONE) { > -int seekret = ffurl_seek(pls->input, seg->url_offset, SEEK_SET); > -if (seekret < 0) { > -av_log(pls->parent, AV_LOG_ERROR, "Unable to seek to offset > %"PRId64" of HLS segment '%s'\n", seg->url_offset, seg->url); > -ret = seekret; > -ffurl_close(pls->input); > -pls->input = NULL; > +if(ret == 0) { > +// update cookies on http response with setcookies. > +update_options(&c->cookies, "cookies", pls->input->priv_data); > +av_dict_set(&opts, "cookies", c->cookies, 0); > +/* 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 > + * without a HTTP server. */ > +if (seg->key_type == KEY_NONE) { > +int seekret = ffurl_seek(pls->input, seg->url_offset, SEEK_SET); > +if (seekret < 0) { > +av_log(pls->parent, AV_LOG_ERROR, "Unable to seek to offset > %"PRId64" of HLS segment '%s'\n", seg->url_offset, seg->url); > +ret = seekret; > +ffurl_close(pls->input); > +pls->input = NULL; > +} > } > } > > > From adff5975ac8a34f83ba8d644d6d8ace5d036e01c Mon Sep 17 00:00:00 2001 > From: Lucas de Andrade > Date: Tue, 22 Sep 2015 13:56:18 -0300 > Subject: [PATCH 3/8] Refactor on cookie update > > Removed opts2 as it wasn't needed anymore. Cookies update moved to open_url > function. > --- > libavformat/hls.c | 45 +++-- > 1 file changed, 19 insertions(+), 26 deletions(-) > > diff --git a/libavformat/hls.c b/libavformat/hls.c > index 23e59a6..4894e4a 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -535,7 +535,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) { > +// 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); > > @@ -971,7 +975,6 @@ static void update_options(char **dest, const char *name, > void *src) > static int open_input(HLSContext *c, struct playlist *pls) > { > AVDict
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Here it is. Also sent as PR on github. Update Cookies Setcookie response.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, 25 Sep 2015 13:38:20 + Lucas Andrade wrote: > I did test with a similar command posted on the tracker, cookies were > updated correctly. Wanted to apply, but it's only a .diff. Can you send a patch produced with git format-patch? Also, stop https://en.wikipedia.org/wiki/Posting_style#Top-posting ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
I did test with a similar command posted on the tracker, cookies were updated correctly. Em sex, 25 de set de 2015 às 10:26, wm4 escreveu: > On Fri, 25 Sep 2015 02:00:29 + > Lucas Andrade wrote: > > > diff --git a/libavformat/hls.c b/libavformat/hls.c > > index adaa33a..f9f86af 100644 > > --- a/libavformat/hls.c > > +++ b/libavformat/hls.c > > @@ -525,6 +525,14 @@ static int url_connect(struct playlist *pls, > AVDictionary *opts, AVDictionary *o > > return ret; > > } > > > > +static void update_options(char **dest, const char *name, void *src) > > +{ > > +av_freep(dest); > > +av_opt_get(src, name, 0, (uint8_t**)dest); > > +if (*dest && !strlen(*dest)) > > +av_freep(dest); > > +} > > + > > static int open_url(HLSContext *c, URLContext **uc, const char *url, > AVDictionary *opts) > > { > > AVDictionary *tmp = NULL; > > @@ -534,6 +542,12 @@ static int open_url(HLSContext *c, URLContext **uc, > const char *url, AVDictionar > > av_dict_copy(&tmp, opts, 0); > > > > ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, > &tmp); > > +if( ret >= 0) { > > +// update cookies on http response with setcookies. > > +URLContext *u = *uc; > > +update_options(&c->cookies, "cookies", u->priv_data); > > +av_dict_set(&opts, "cookies", c->cookies, 0); > > +} > > > > av_dict_free(&tmp); > > > > @@ -958,18 +972,9 @@ static void intercept_id3(struct playlist *pls, > uint8_t *buf, > > pls->is_id3_timestamped = (pls->id3_mpegts_timestamp != > AV_NOPTS_VALUE); > > } > > > > -static void update_options(char **dest, const char *name, void *src) > > -{ > > -av_freep(dest); > > -av_opt_get(src, name, 0, (uint8_t**)dest); > > -if (*dest && !strlen(*dest)) > > -av_freep(dest); > > -} > > - > > 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 +984,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 +1001,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 +1038,7 @@ static int open_input(HLSContext *c, struct > playlist *pls) > > ret = AVERROR_PATCHWELCOME; > > } > > else > > - ret = AVERROR(ENOSYS); > > +ret = AVERROR(ENOSYS); > > > > /* 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 +1055,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; > > } > > Looks good. Did you test this successfully? If so, I'll apply it. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Fri, 25 Sep 2015 02:00:29 + Lucas Andrade wrote: > diff --git a/libavformat/hls.c b/libavformat/hls.c > index adaa33a..f9f86af 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -525,6 +525,14 @@ static int url_connect(struct playlist *pls, > AVDictionary *opts, AVDictionary *o > return ret; > } > > +static void update_options(char **dest, const char *name, void *src) > +{ > +av_freep(dest); > +av_opt_get(src, name, 0, (uint8_t**)dest); > +if (*dest && !strlen(*dest)) > +av_freep(dest); > +} > + > static int open_url(HLSContext *c, URLContext **uc, const char *url, > AVDictionary *opts) > { > AVDictionary *tmp = NULL; > @@ -534,6 +542,12 @@ static int open_url(HLSContext *c, URLContext **uc, > const char *url, AVDictionar > av_dict_copy(&tmp, opts, 0); > > ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp); > +if( ret >= 0) { > +// update cookies on http response with setcookies. > +URLContext *u = *uc; > +update_options(&c->cookies, "cookies", u->priv_data); > +av_dict_set(&opts, "cookies", c->cookies, 0); > +} > > av_dict_free(&tmp); > > @@ -958,18 +972,9 @@ static void intercept_id3(struct playlist *pls, uint8_t > *buf, > pls->is_id3_timestamped = (pls->id3_mpegts_timestamp != > AV_NOPTS_VALUE); > } > > -static void update_options(char **dest, const char *name, void *src) > -{ > -av_freep(dest); > -av_opt_get(src, name, 0, (uint8_t**)dest); > -if (*dest && !strlen(*dest)) > -av_freep(dest); > -} > - > 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 +984,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 +1001,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 +1038,7 @@ static int open_input(HLSContext *c, struct playlist > *pls) > ret = AVERROR_PATCHWELCOME; > } > else > - ret = AVERROR(ENOSYS); > +ret = AVERROR(ENOSYS); > > /* 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 +1055,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; > } Looks good. Did you test this successfully? If so, I'll apply it. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Here it goes. Update Cookies on Setcookie response.diff Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Wed, 23 Sep 2015 00:55:39 + Lucas Andrade 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
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
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) { +// 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); /* 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; } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Tue, 22 Sep 2015 17:20:13 + Lucas Andrade wrote: > Sorry about top posting.. That's the gmail default. Anyway, I've double > checked and think you're right. I'll add that to open_url, but I need to > set the right HLSContext cookies. Right now it isn't passed as parameter to > open_url, that way, I'll have to pass it ahead. Ah, that's true. Well then, do whatever you think is the nicest. The patch you had (with the requested cleanups applied) would be ok too. > About the opts, it isn't trashed and is used by url_connect when the video > is encrypted. I'll remove the opts2 as it isn't needed anymore, after the > creation of open_url that creates a copy of opts2. That's also true, the function copies it. Keep in mind that some functions "trash" it by removing the entries that were used. > Later tonight I'll repost the patch. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
Sorry about top posting.. That's the gmail default. Anyway, I've double checked and think you're right. I'll add that to open_url, but I need to set the right HLSContext cookies. Right now it isn't passed as parameter to open_url, that way, I'll have to pass it ahead. About the opts, it isn't trashed and is used by url_connect when the video is encrypted. I'll remove the opts2 as it isn't needed anymore, after the creation of open_url that creates a copy of opts2. Later tonight I'll repost the patch. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Tue, 22 Sep 2015 04:37:48 + Lucas Andrade 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). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Tue, 22 Sep 2015 13:47:37 + Lucas Andrade wrote: > You're right, I should at least check if ret == 0. I'll update the patch > and check if it works. > Well, I meant, maybe this should be in open_url(), instead of adding it on every code path. Right now everything is totally inconsistent and duplicated. I've sent a patch yesterday that fixes another such case. Also, don't https://en.wikipedia.org/wiki/Posting_style#Top-posting ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
You're right, I should at least check if ret == 0. I'll update the patch and check if it works. Em ter, 22 de set de 2015 às 08:09, Lucas Andrade escreveu: > I think the other code paths already sets the cookie. > > Em Ter, 22 de set de 2015 04:41, wm4 escreveu: > >> On Tue, 22 Sep 2015 04:37:48 + >> Lucas Andrade 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]; >> >> This doesn't do the same for the other code paths. >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
I think the other code paths already sets the cookie. Em Ter, 22 de set de 2015 04:41, wm4 escreveu: > On Tue, 22 Sep 2015 04:37:48 + > Lucas Andrade 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]; > > This doesn't do the same for the other code paths. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
On Tue, 22 Sep 2015 04:37:48 + Lucas Andrade 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]; This doesn't do the same for the other code paths. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] Update Cookies on Setcookie playlist response
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]; -- 1.9.5.github.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel