diff --git a/libavformat/cache.c b/libavformat/cache.c
index 6aabca2..aa9e398 100644
|
a
|
b
|
typedef struct Context {
|
| 63 | 63 | URLContext *inner; |
| 64 | 64 | int64_t cache_hit, cache_miss; |
| 65 | 65 | int read_ahead_limit; |
| | 66 | char* cache_path; |
| 66 | 67 | } Context; |
| 67 | 68 | |
| 68 | 69 | static int cmp(const void *key, const void *node) |
| … |
… |
static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **
|
| 77 | 78 | |
| 78 | 79 | av_strstart(arg, "cache:", &arg); |
| 79 | 80 | |
| 80 | | c->fd = avpriv_tempfile("ffcache", &buffername, 0, h); |
| | 81 | # ifndef O_BINARY |
| | 82 | # define O_BINARY 0 |
| | 83 | # endif |
| | 84 | if (c->cache_path) |
| | 85 | c->fd = open(c->cache_path, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0600); |
| | 86 | else |
| | 87 | c->fd = av_tempfile("ffcache", &buffername, 0, h); |
| | 88 | |
| 81 | 89 | if (c->fd < 0){ |
| 82 | 90 | av_log(h, AV_LOG_ERROR, "Failed to create tempfile\n"); |
| 83 | 91 | return c->fd; |
| 84 | 92 | } |
| 85 | 93 | |
| | 94 | if (!c->cache_path) |
| | 95 | { |
| 86 | 96 | unlink(buffername); |
| 87 | 97 | av_freep(&buffername); |
| | 98 | } |
| 88 | 99 | |
| 89 | 100 | return ffurl_open_whitelist(&c->inner, arg, flags, &h->interrupt_callback, |
| 90 | 101 | options, h->protocol_whitelist, h->protocol_blacklist, h); |
| … |
… |
static int cache_close(URLContext *h)
|
| 309 | 320 | |
| 310 | 321 | static const AVOption options[] = { |
| 311 | 322 | { "read_ahead_limit", "Amount in bytes that may be read ahead when seeking isn't supported, -1 for unlimited", OFFSET(read_ahead_limit), AV_OPT_TYPE_INT, { .i64 = 65536 }, -1, INT_MAX, D }, |
| | 323 | {"cache_path", "cache path", offsetof(Context, cache_path), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D}, |
| 312 | 324 | {NULL}, |
| 313 | 325 | }; |
| 314 | 326 | |