diff options
Diffstat (limited to 'avserver.c')
-rw-r--r-- | avserver.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/avserver.c b/avserver.c index 6b01b15b6f..994edcd04c 100644 --- a/avserver.c +++ b/avserver.c @@ -39,6 +39,7 @@ #include "libavutil/avstring.h" #include "libavutil/lfg.h" #include "libavutil/dict.h" +#include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/random_seed.h" #include "libavutil/parseutils.h" @@ -323,6 +324,37 @@ static AVLFG random_state; static FILE *logfile = NULL; +static int64_t ffm_read_write_index(int fd) +{ + uint8_t buf[8]; + + lseek(fd, 8, SEEK_SET); + if (read(fd, buf, 8) != 8) + return AVERROR(EIO); + return AV_RB64(buf); +} + +static int ffm_write_write_index(int fd, int64_t pos) +{ + uint8_t buf[8]; + int i; + + for(i=0;i<8;i++) + buf[i] = (pos >> (56 - i * 8)) & 0xff; + lseek(fd, 8, SEEK_SET); + if (write(fd, buf, 8) != 8) + return AVERROR(EIO); + return 8; +} + +static void ffm_set_write_index(AVFormatContext *s, int64_t pos, + int64_t file_size) +{ + FFMContext *ffm = s->priv_data; + ffm->write_index = pos; + ffm->file_size = file_size; +} + /* FIXME: make avserver work with IPv6 */ /* resolve host with also IP address parsing */ static int resolve_host(struct in_addr *sin_addr, const char *hostname) |