You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3KB

  1. #ifndef _mkv_buffer_h_
  2. #define _mkv_buffer_h_
  3. #include <stdio.h>
  4. #include <stdint.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. struct mkv_buffer_t
  9. {
  10. /// read data from buffer
  11. /// @param[in] param user-defined parameter
  12. /// @param[out] data user buffer
  13. /// @param[in] bytes data buffer size
  14. /// @return 0-ok, <0-error
  15. int (*read)(void* param, void* data, uint64_t bytes);
  16. /// write data to buffer
  17. /// @param[in] param user-defined parameter
  18. /// @param[in] data user buffer
  19. /// @param[in] bytes data buffer size
  20. /// @return 0-ok, <0-error
  21. int (*write)(void* param, const void* data, uint64_t bytes);
  22. /// mkve buffer position
  23. /// @param[in] param user-defined parameter
  24. /// @param[in] offset >=0-seek buffer read/write position to offset(from buffer begin), <0-seek from file end(SEEK_END)
  25. /// @return 0-ok, <0-error
  26. int (*seek)(void* param, int64_t offset);
  27. /// get buffer read/write position
  28. /// @return <0-error, other-current read/write position
  29. int64_t (*tell)(void* param);
  30. };
  31. struct mkv_file_cache_t
  32. {
  33. FILE* fp;
  34. uint8_t ptr[800];
  35. unsigned int len;
  36. unsigned int off;
  37. uint64_t tell;
  38. };
  39. const struct mkv_buffer_t* mkv_file_cache_buffer(void);
  40. const struct mkv_buffer_t* mkv_file_buffer(void);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif /* !_mkv_buffer_h_ */