[PATCH] Implement support to the seek operation with the whence parameter set to AVSEEK_SIZE in the file url protocol.
Stefano Sabatini
stefano.sabatini-lala
Sat Mar 27 21:49:50 CET 2010
---
libavformat/file.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavformat/file.c b/libavformat/file.c
index 9b60a5f..d42a678 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -26,6 +26,7 @@
#include <io.h>
#endif
#include <unistd.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <stdlib.h>
#include "os_support.h"
@@ -73,8 +74,11 @@ static int file_write(URLContext *h, unsigned char *buf, int size)
static int64_t file_seek(URLContext *h, int64_t pos, int whence)
{
int fd = (intptr_t) h->priv_data;
- if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)
- return AVERROR_NOTSUPP;
+ if (whence == AVSEEK_SIZE) {
+ struct stat st;
+ int ret = fstat(fd, &st);
+ return ret < 0 ? AVERROR(errno) : st.st_size;
+ }
return lseek(fd, pos, whence);
}
--
1.7.0
--FL5UXtIhxfXey3p5--
More information about the ffmpeg-devel
mailing list