[FFmpeg-devel] [PATCH] HTTP options in HLS (again)
Micah Galizia
micahgalizia at gmail.com
Fri Jan 18 03:06:54 CET 2013
On Wed, Jan 16, 2013 at 12:29 PM, Stefano Sabatini <stefasab at gmail.com>wrote:
> On date Tuesday 2013-01-15 21:39:09 -0500, Micah Galizia encoded:
>
[...]
> > static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
> > @@ -216,6 +218,9 @@ static int parse_playlist(HLSContext *c, const char
> *url,
> > close_in = 1;
> > /* Some HLS servers dont like being sent the range header */
> > av_dict_set(&opts, "seekable", "0", 0);
> > + /* Broker prior HTTP options that should be consistant across
> reqs */
> > + if (c->user_agent) av_dict_set(&opts, "user-agent",
> c->user_agent, 0);
> > + if (c->cookies) av_dict_set(&opts, "cookies", c->cookies, 0);
>
> nit: vertical align
>
> I think you can skip the if() checks.
>
I'm going to assume that "vertical align" means add a blank line?
> > ret = avio_open2(&in, url, AVIO_FLAG_READ,
> > c->interrupt_callback, &opts);
> > av_dict_free(&opts);
> > @@ -328,11 +333,13 @@ fail:
> > return ret;
> > }
> >
> > -static int open_input(struct variant *var)
> > +static int open_input(HLSContext *c, struct variant *var)
> > {
> > AVDictionary *opts = NULL;
> > int ret;
> > struct segment *seg = var->segments[var->cur_seq_no -
> var->start_seq_no];
> > + if (c->user_agent) av_dict_set(&opts, "user-agent", c->user_agent,
> 0);
> > + if (c->cookies) av_dict_set(&opts, "cookies", c->cookies, 0);
>
> same
>
> > av_dict_set(&opts, "seekable", "0", 0);
> > if (seg->key_type == KEY_NONE) {
> > ret = ffurl_open(&var->input, seg->url, AVIO_FLAG_READ,
> > @@ -429,7 +436,7 @@ reload:
> > goto reload;
> > }
> >
> > - ret = open_input(v);
> > + ret = open_input(c, v);
> > if (ret < 0)
> > return ret;
> > }
> > @@ -461,11 +468,25 @@ reload:
> >
> > static int hls_read_header(AVFormatContext *s)
> > {
> > + URLContext *u = s->pb->opaque;
> > HLSContext *c = s->priv_data;
> > int ret = 0, i, j, stream_offset = 0;
> >
> > c->interrupt_callback = &s->interrupt_callback;
> >
>
> > + // if the URL context is good, read important options we must
> broker later
> > + if (u) {
>
> > + // get the previous user agent & set back to null if string
> size is zero
> > + av_opt_get(u->priv_data, "user-agent", 0,
> (uint8_t**)&(c->user_agent));
> > + if (!strlen(c->user_agent))
> > + av_freep(c->user_agent);
>
> Note: an av_opt_get_string() may solve the ""/NULL confusion.
>
IDK if that used to exist and has been removed but I couldn't find it or
anything like it. Or did you want me to add it? Also, av_freep should be on
&c->user_agent and &c->cookies (fixed in this patch).
> > +
> > + // get the previous cookies & set back to null if string size
> is zero
> > + av_opt_get(u->priv_data, "cookies", 0,
> (uint8_t**)&(c->cookies));
> > + if (!strlen(c->cookies))
> > + av_freep(c->cookies);
>
> Aren't you leaking c->user_agent/cookies?
>
Yes. I free them with all of the variants now.
--
"The mark of an immature man is that he wants to die nobly for a cause,
while the mark of the mature man is that he wants to live humbly for
one." --W. Stekel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hls_http_options6.patch
Type: application/octet-stream
Size: 2939 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130117/30eaa679/attachment.obj>
More information about the ffmpeg-devel
mailing list