[FFmpeg-cvslog] avformat/dashdec: remove unused functions and process code

Steven Liu git at videolan.org
Tue Aug 7 09:42:18 EEST 2018


ffmpeg | branch: master | Steven Liu <lq at chinaffmpeg.org> | Tue Aug  7 12:37:02 2018 +0800| [d54ae9b782c85e626a1e49a8ee204728746227d1] | committer: Steven Liu

avformat/dashdec: remove unused functions and process code

Based on a patch for hls by Richard Shaffer

Signed-off-by: Steven Liu <lq at chinaffmpeg.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d54ae9b782c85e626a1e49a8ee204728746227d1
---

 libavformat/dashdec.c | 46 ++++++++--------------------------------------
 1 file changed, 8 insertions(+), 38 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index c710e56727..09b06ef3ed 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -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;
@@ -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)
 {
@@ -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);
@@ -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)
@@ -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) */
@@ -1734,7 +1711,7 @@ end:
 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;
 
@@ -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
@@ -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;



More information about the ffmpeg-cvslog mailing list