mkv_reader.h 1.2 KB

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