diff options
author | Martin Storsjö <martin@martin.st> | 2015-02-05 15:06:42 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2016-03-24 10:33:59 +0200 |
commit | 933dec0e29ec4d2cb83474279a6c52d62fdb7310 (patch) | |
tree | a5dc9d46edec0e3dbed784f6c32c2457834bb67f /libavformat/file.c | |
parent | ccea588f831906084b8c8235222920e6984beb72 (diff) | |
download | ffmpeg-933dec0e29ec4d2cb83474279a6c52d62fdb7310.tar.gz |
file: Add an option for following a file that is being written
Using this requires setting the rw_timeout option to make it
terminate, alternatively using the interrupt callback (if used via
the API).
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/file.c')
-rw-r--r-- | libavformat/file.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libavformat/file.c b/libavformat/file.c index 4f581cfae7..8683c1bedd 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -42,10 +42,12 @@ typedef struct FileContext { const AVClass *class; int fd; int trunc; + int follow; } FileContext; static const AVOption file_options[] = { { "truncate", "Truncate existing files on write", offsetof(FileContext, trunc), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM }, + { "follow", "Follow a file as it is being written", offsetof(FileContext, follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { NULL } }; @@ -60,6 +62,8 @@ static int file_read(URLContext *h, unsigned char *buf, int size) { FileContext *c = h->priv_data; int ret = read(c->fd, buf, size); + if (ret == 0 && c->follow) + return AVERROR(EAGAIN); return (ret == -1) ? AVERROR(errno) : ret; } |