X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fcache.c;h=25b28d585f9cb9548cf45662649623db897aaf18;hb=6372c9dc9972318e75a5889ad6c52500b8294099;hp=8e8b9e841242e696cfc0338b9190a99d2a5f58d4;hpb=2cfb34a4e8b464d790513ad42860869677ef79d9;p=ffmpeg diff --git a/libavformat/cache.c b/libavformat/cache.c index 8e8b9e84124..25b28d585f9 100644 --- a/libavformat/cache.c +++ b/libavformat/cache.c @@ -29,7 +29,7 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" -#include "libavutil/file.h" +#include "libavutil/internal.h" #include "libavutil/opt.h" #include "libavutil/tree.h" #include "avformat.h" @@ -77,7 +77,7 @@ static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary ** av_strstart(arg, "cache:", &arg); - c->fd = av_tempfile("ffcache", &buffername, 0, h); + c->fd = avpriv_tempfile("ffcache", &buffername, 0, h); if (c->fd < 0){ av_log(h, AV_LOG_ERROR, "Failed to create tempfile\n"); return c->fd; @@ -87,7 +87,7 @@ static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary ** av_freep(&buffername); return ffurl_open_whitelist(&c->inner, arg, flags, &h->interrupt_callback, - options, h->protocol_whitelist); + options, h->protocol_whitelist, h->protocol_blacklist); } static int add_entry(URLContext *h, const unsigned char *buf, int size) @@ -283,6 +283,12 @@ resolve_eof: return ret; } +static int enu_free(void *opaque, void *elem) +{ + av_free(elem); + return 0; +} + static int cache_close(URLContext *h) { Context *c= h->priv_data; @@ -292,6 +298,7 @@ static int cache_close(URLContext *h) close(c->fd); ffurl_close(c->inner); + av_tree_enumerate(c->root, NULL, NULL, enu_free); av_tree_destroy(c->root); return 0; @@ -312,7 +319,7 @@ static const AVClass cache_context_class = { .version = LIBAVUTIL_VERSION_INT, }; -URLProtocol ff_cache_protocol = { +const URLProtocol ff_cache_protocol = { .name = "cache", .url_open2 = cache_open, .url_read = cache_read,