hls: read protocol options through the AVIOContext

This reverts commit 9f9ed79d4c.

The hlsopts member was never set anywhere and always NULL, furthermore
the HLS demuxer needs to retrieve the proper options from the underlying
http protocol (cookies, user-agent, etc), so a dummy context won't help.

Instead, use the AVIOContext directly to access the options.
This commit is contained in:
Hendrik Leppkes 2016-03-14 11:38:20 +01:00
parent fa3eecf9ab
commit 0d4b8a2c16
3 changed files with 7 additions and 10 deletions

View File

@ -24,11 +24,6 @@
#include "libavutil/log.h" #include "libavutil/log.h"
typedef struct AVIOInternal {
URLContext *h;
void *hlsopts;
} AVIOInternal;
extern const AVClass ff_avio_class; extern const AVClass ff_avio_class;
int ffio_init_context(AVIOContext *s, int ffio_init_context(AVIOContext *s,

View File

@ -42,6 +42,10 @@
*/ */
#define SHORT_SEEK_THRESHOLD 4096 #define SHORT_SEEK_THRESHOLD 4096
typedef struct AVIOInternal {
URLContext *h;
} AVIOInternal;
static void *ff_avio_child_next(void *obj, void *prev) static void *ff_avio_child_next(void *obj, void *prev)
{ {
AVIOContext *s = obj; AVIOContext *s = obj;

View File

@ -584,7 +584,7 @@ static int ensure_playlist(HLSContext *c, struct playlist **pls, const char *url
static void update_options(char **dest, const char *name, void *src) static void update_options(char **dest, const char *name, void *src)
{ {
av_freep(dest); av_freep(dest);
av_opt_get(src, name, 0, (uint8_t**)dest); av_opt_get(src, name, AV_OPT_SEARCH_CHILDREN, (uint8_t**)dest);
if (*dest && !strlen(*dest)) if (*dest && !strlen(*dest))
av_freep(dest); av_freep(dest);
} }
@ -614,8 +614,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp); ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
if (ret >= 0) { if (ret >= 0) {
// update cookies on http response with setcookies. // update cookies on http response with setcookies.
AVIOInternal *internal = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb->opaque; void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
void *u = internal ? internal->hlsopts : NULL;
update_options(&c->cookies, "cookies", u); update_options(&c->cookies, "cookies", u);
av_dict_set(&opts, "cookies", c->cookies, 0); av_dict_set(&opts, "cookies", c->cookies, 0);
} }
@ -1497,8 +1496,7 @@ static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url,
static int hls_read_header(AVFormatContext *s) static int hls_read_header(AVFormatContext *s)
{ {
AVIOInternal *internal = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb->opaque; void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
void *u = internal ? internal->hlsopts : NULL;
HLSContext *c = s->priv_data; HLSContext *c = s->priv_data;
int ret = 0, i, j, stream_offset = 0; int ret = 0, i, j, stream_offset = 0;