memory_buffer.h 591 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #include "defs.h"
  3. namespace ffmpeg {
  4. /**
  5. * Class uses external memory buffer and implements a seekable interface.
  6. */
  7. class MemoryBuffer {
  8. public:
  9. explicit MemoryBuffer(const uint8_t* buffer, size_t size);
  10. int64_t seek(int64_t offset, int whence);
  11. int read(uint8_t* buf, int size);
  12. // static constructor for decoder callback.
  13. static DecoderInCallback getCallback(const uint8_t* buffer, size_t size);
  14. private:
  15. const uint8_t* buffer_; // set at construction time
  16. long pos_{0}; // current position
  17. long len_{0}; // bytes in buffer
  18. };
  19. } // namespace ffmpeg