Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
avformat/dashdec: remove unused functions and process code
Based on a patch for hls by Richard Shaffer

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
  • Loading branch information
T-bagwell committed Aug 7, 2018
1 parent 0cf5e6b commit d54ae9b
Showing 1 changed file with 8 additions and 38 deletions.
46 changes: 8 additions & 38 deletions libavformat/dashdec.c
Expand Up @@ -143,9 +143,6 @@ typedef struct DASHContext {

int is_live;
AVIOInterruptCB *interrupt_callback;
char *user_agent; ///< holds HTTP user agent set as an AVOption to the HTTP protocol context
char *cookies; ///< holds HTTP cookie values set in either the initial response or as an AVOption to the HTTP protocol context
char *headers; ///< holds HTTP headers set as an AVOption to the HTTP protocol context
char *allowed_extensions;
AVDictionary *avio_opts;
int max_url_size;
Expand Down Expand Up @@ -377,24 +374,6 @@ static void free_audio_list(DASHContext *c)
c->n_audios = 0;
}

static void set_httpheader_options(DASHContext *c, AVDictionary **opts)
{
// broker prior HTTP options that should be consistent across requests
av_dict_set(opts, "user_agent", c->user_agent, 0);
av_dict_set(opts, "cookies", c->cookies, 0);
av_dict_set(opts, "headers", c->headers, 0);
if (c->is_live) {
av_dict_set(opts, "seekable", "0", 0);
}
}
static void update_options(char **dest, const char *name, void *src)
{
av_freep(dest);
av_opt_get(src, name, AV_OPT_SEARCH_CHILDREN, (uint8_t**)dest);
if (*dest)
av_freep(dest);
}

static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
AVDictionary *opts, AVDictionary *opts2, int *is_http)
{
Expand Down Expand Up @@ -448,11 +427,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
av_opt_get(*pb, "cookies", AV_OPT_SEARCH_CHILDREN, (uint8_t**)&new_cookies);

if (new_cookies) {
av_free(c->cookies);
c->cookies = new_cookies;
av_dict_set(&opts, "cookies", new_cookies, AV_DICT_DONT_STRDUP_VAL);
}

av_dict_set(&opts, "cookies", c->cookies, 0);
}

av_dict_free(&tmp);
Expand Down Expand Up @@ -1142,7 +1119,7 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
if (!in) {
close_in = 1;

set_httpheader_options(c, &opts);
av_dict_copy(&opts, c->avio_opts, 0);
ret = avio_open2(&in, url, AVIO_FLAG_READ, c->interrupt_callback, &opts);
av_dict_free(&opts);
if (ret < 0)
Expand Down Expand Up @@ -1587,7 +1564,7 @@ static int open_input(DASHContext *c, struct representation *pls, struct fragmen
if (!url) {
goto cleanup;
}
set_httpheader_options(c, &opts);

if (seg->size >= 0) {
/* try to restrict the HTTP request to the part we want
* (if this is in fact a HTTP request) */
Expand Down Expand Up @@ -1734,7 +1711,7 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size)
static int save_avio_options(AVFormatContext *s)
{
DASHContext *c = s->priv_data;
const char *opts[] = { "headers", "user_agent", "user_agent", "cookies", NULL }, **opt = opts;
const char *opts[] = { "headers", "user_agent", "cookies", NULL }, **opt = opts;
uint8_t *buf = NULL;
int ret = 0;

Expand Down Expand Up @@ -1913,24 +1890,19 @@ static void copy_init_section(struct representation *rep_dest, struct representa

static int dash_read_header(AVFormatContext *s)
{
void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
DASHContext *c = s->priv_data;
int ret = 0;
int stream_index = 0;
int i;

c->interrupt_callback = &s->interrupt_callback;
// if the URL context is good, read important options we must broker later
if (u) {
update_options(&c->user_agent, "user_agent", u);
update_options(&c->cookies, "cookies", u);
update_options(&c->headers, "headers", u);
}

if ((ret = parse_manifest(s, s->url, s->pb)) < 0)
if ((ret = save_avio_options(s)) < 0)
goto fail;

if ((ret = save_avio_options(s)) < 0)
av_dict_set(&c->avio_opts, "seekable", "0", 0);

if ((ret = parse_manifest(s, s->url, s->pb)) < 0)
goto fail;

/* If this isn't a live stream, fill the total duration of the
Expand Down Expand Up @@ -2096,8 +2068,6 @@ static int dash_close(AVFormatContext *s)
free_audio_list(c);
free_video_list(c);

av_freep(&c->cookies);
av_freep(&c->user_agent);
av_dict_free(&c->avio_opts);
av_freep(&c->base_url);
return 0;
Expand Down

0 comments on commit d54ae9b

Please sign in to comment.