On Wed, 20 Jan 2016, Anton Khirnov wrote:

Now all IO should go through the IO callbacks and be interceptable by
the caller.
---
libavformat/hls.c | 69 ++++++++++++++++++++-----------------------------------
1 file changed, 25 insertions(+), 44 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index d3b4b58..42cc042 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -34,7 +34,6 @@
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
-#include "url.h"

#define INITIAL_BUFFER_SIZE 32768

@@ -73,7 +72,7 @@ struct variant {
    char url[MAX_URL_SIZE];
    AVIOContext pb;
    uint8_t* read_buffer;
-    URLContext *input;
+    AVIOContext *input;
    AVFormatContext *parent;
    int index;
    AVFormatContext *ctx;
@@ -133,7 +132,7 @@ static void free_variant_list(HLSContext *c)
        av_packet_unref(&var->pkt);
        av_free(var->pb.buffer);
        if (var->input)
-            ffurl_close(var->input);
+            ff_format_io_close(c->ctx, &var->input);
        if (var->ctx) {
            var->ctx->pb = NULL;
            avformat_close_input(&var->ctx);
@@ -214,31 +213,15 @@ static int open_in(HLSContext *c, AVIOContext **in, const 
char *url)
    return ret;
}

-static int url_connect(struct variant *var, AVDictionary *opts)
+static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
+                    const AVDictionary *opts)
{
    AVDictionary *tmp = NULL;
    int ret;

    av_dict_copy(&tmp, opts, 0);

-    if ((ret = av_opt_set_dict(var->input, &tmp)) < 0 ||
-        (ret = ffurl_connect(var->input, NULL)) < 0) {
-        ffurl_close(var->input);
-        var->input = NULL;
-    }
-
-    av_dict_free(&tmp);
-    return ret;
-}
-
-static int open_url(HLSContext *c, URLContext **uc, const char *url)
-{
-    AVDictionary *tmp = NULL;
-    int ret;
-
-    av_dict_copy(&tmp, c->avio_opts, 0);
-
-    ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);
+    ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);

    av_dict_free(&tmp);

@@ -377,22 +360,23 @@ fail:

static int open_input(struct variant *var)
{
+    HLSContext *c = var->parent->priv_data;
    struct segment *seg = var->segments[var->cur_seq_no - var->start_seq_no];
    if (seg->key_type == KEY_NONE) {
-        return  open_url(var->parent->priv_data, &var->input, seg->url);
+        return  open_url(var->parent, &var->input, seg->url, c->avio_opts);

This seems like a stray double space, I guess it could be fixed at the same time


Other than that, it seems ok, assuming that you did test codepaths for encrypted content.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to