1
0

avi_reader.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <bfc/platform/types.h>
  3. #include <stdio.h>
  4. #include "read.h" // for the error codes
  5. namespace nsavi
  6. {
  7. // return codes from avi_reader functions
  8. enum
  9. {
  10. READ_OK = 0,
  11. READ_EOF = 1,
  12. READ_FAILED = 2,
  13. READ_INVALID_DATA = 3, // read was successful but data didn't make any sense
  14. READ_INVALID_CALL = 4, // wrong time to call this function
  15. READ_NOT_FOUND = 5, // requested item doesn't exist in the file
  16. READ_OUT_OF_MEMORY = 6, // some malloc failed and so we're aborting
  17. READ_DISCONNECT = 7,
  18. };
  19. class avi_reader
  20. {
  21. public:
  22. virtual int Read(void *buffer, uint32_t read_length, uint32_t *bytes_read)=0;
  23. // TODO: need to put an upper bound on Peek buffer sizes
  24. virtual int Peek(void *buffer, uint32_t read_length, uint32_t *bytes_read)=0;
  25. // in_avi will call this before descending into certain chunks that will be read entirely (e.g. avih)
  26. // you aren't required to do anything in response
  27. virtual void OverlappedHint(uint32_t read_length){}
  28. virtual int Seek(uint64_t position)=0;
  29. virtual uint64_t Tell()=0;
  30. // skip ahead a certain number of bytes. equivalent to fseek(..., SEEK_CUR)
  31. virtual int Skip(uint32_t skip_bytes)=0;
  32. virtual uint64_t GetContentLength()=0;
  33. virtual void GetFilename(wchar_t *fn, size_t len)=0;
  34. };
  35. }