Browse code

hls: read protocol options through the AVIOContext

This reverts commit 9f9ed79d4cb40e5d9093899f8a79086ff23da844.

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.

Hendrik Leppkes authored on 2016/03/14 19:38:20
Showing 3 changed files
... ...
@@ -24,11 +24,6 @@
24 24
 
25 25
 #include "libavutil/log.h"
26 26
 
27
-typedef struct AVIOInternal {
28
-    URLContext *h;
29
-    void *hlsopts;
30
-} AVIOInternal;
31
-
32 27
 extern const AVClass ff_avio_class;
33 28
 
34 29
 int ffio_init_context(AVIOContext *s,
... ...
@@ -42,6 +42,10 @@
42 42
  */
43 43
 #define SHORT_SEEK_THRESHOLD 4096
44 44
 
45
+typedef struct AVIOInternal {
46
+    URLContext *h;
47
+} AVIOInternal;
48
+
45 49
 static void *ff_avio_child_next(void *obj, void *prev)
46 50
 {
47 51
     AVIOContext *s = obj;
... ...
@@ -584,7 +584,7 @@ static int ensure_playlist(HLSContext *c, struct playlist **pls, const char *url
584 584
 static void update_options(char **dest, const char *name, void *src)
585 585
 {
586 586
     av_freep(dest);
587
-    av_opt_get(src, name, 0, (uint8_t**)dest);
587
+    av_opt_get(src, name, AV_OPT_SEARCH_CHILDREN, (uint8_t**)dest);
588 588
     if (*dest && !strlen(*dest))
589 589
         av_freep(dest);
590 590
 }
... ...
@@ -614,8 +614,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
614 614
     ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
615 615
     if (ret >= 0) {
616 616
         // update cookies on http response with setcookies.
617
-        AVIOInternal *internal = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb->opaque;
618
-        void *u = internal ? internal->hlsopts : NULL;
617
+        void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
619 618
         update_options(&c->cookies, "cookies", u);
620 619
         av_dict_set(&opts, "cookies", c->cookies, 0);
621 620
     }
... ...
@@ -1497,8 +1496,7 @@ static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url,
1497 1497
 
1498 1498
 static int hls_read_header(AVFormatContext *s)
1499 1499
 {
1500
-    AVIOInternal *internal = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb->opaque;
1501
-    void *u = internal ? internal->hlsopts : NULL;
1500
+    void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
1502 1501
     HLSContext *c = s->priv_data;
1503 1502
     int ret = 0, i, j, stream_offset = 0;
1504 1503