diff --git a/FFmpegSource/stdiostream.c b/FFmpegSource/stdiostream.c index 3002d9f03..98200e533 100644 --- a/FFmpegSource/stdiostream.c +++ b/FFmpegSource/stdiostream.c @@ -1,12 +1,4 @@ -/* first we need to create an I/O object that the parser will use to read the - * source file - */ -struct StdIoStream { - struct InputStream base; - FILE *fp; - int error; -}; -typedef struct StdIoStream StdIoStream; +#include "stdiostream.h" #define CACHESIZE 65536 @@ -79,4 +71,4 @@ void StdIoFree(StdIoStream *st, void *mem) { */ int StdIoProgress(StdIoStream *st, ulonglong cur, ulonglong max) { return 1; -} \ No newline at end of file +} diff --git a/FFmpegSource/stdiostream.h b/FFmpegSource/stdiostream.h new file mode 100644 index 000000000..3a5fc35db --- /dev/null +++ b/FFmpegSource/stdiostream.h @@ -0,0 +1,58 @@ +#ifndef STDIOSTREAM_H +#define STDIOSTREAM_H + +#include "MatroskaParser.h" + + +/************\ +* Structures * +\************/ + + +/* first we need to create an I/O object that the parser will use to read the + * source file + */ +struct StdIoStream { + struct InputStream base; + FILE *fp; + int error; +}; + +typedef struct StdIoStream StdIoStream; + + + +/***********\ +* Functions * +\***********/ + +/* read count bytes into buffer starting at file position pos + * return the number of bytes read, -1 on error or 0 on EOF + */ +int StdIoRead(StdIoStream *st, ulonglong pos, void *buffer, int count); + +/* scan for a signature sig(big-endian) starting at file position pos + * return position of the first byte of signature or -1 if error/not found + */ +longlong StdIoScan(StdIoStream *st, ulonglong start, unsigned signature); + +/* return cache size, this is used to limit readahead */ +unsigned StdIoGetCacheSize(StdIoStream *st); + +/* return last error message */ +const char *StdIoGetLastError(StdIoStream *st); + +/* memory allocation, this is done via stdlib */ +void *StdIoMalloc(StdIoStream *st, size_t size); + +void *StdIoRealloc(StdIoStream *st, void *mem, size_t size); + +void StdIoFree(StdIoStream *st, void *mem); + +/* progress report handler for lengthy operations + * returns 0 to abort operation, nonzero to continue + */ +int StdIoProgress(StdIoStream *st, ulonglong cur, ulonglong max); + + +#endif /* #ifndef STDIOSTREAM_H */