1
0

RawMediaReader.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include "../Agave/DecodeFile/svc_raw_media_reader.h"
  3. #include "../Agave/DecodeFile/ifc_raw_media_reader.h"
  4. #include <mp4.h>
  5. // {5CBD1F27-5A63-4D8C-9297-D74518E1EF3A}
  6. static const GUID mpeg4_raw_reader_guid =
  7. { 0x5cbd1f27, 0x5a63, 0x4d8c, { 0x92, 0x97, 0xd7, 0x45, 0x18, 0xe1, 0xef, 0x3a } };
  8. class RawMediaReaderService : public svc_raw_media_reader
  9. {
  10. public:
  11. static const char *getServiceName() { return "MPEG-4 Raw Reader"; }
  12. static GUID getServiceGuid() { return mpeg4_raw_reader_guid; }
  13. int CreateRawMediaReader(const wchar_t *filename, ifc_raw_media_reader **reader);
  14. protected:
  15. RECVS_DISPATCH;
  16. };
  17. class RawMediaReader : public ifc_raw_media_reader
  18. {
  19. public:
  20. RawMediaReader(MP4FileHandle file, void *reader);
  21. ~RawMediaReader();
  22. int Read(void *buffer, size_t buffer_size, size_t *bytes_read);
  23. size_t Release();
  24. protected:
  25. RECVS_DISPATCH;
  26. private:
  27. uint16_t track_num;
  28. uint32_t number_of_tracks;
  29. MP4TrackId current_track;
  30. MP4FileHandle file;
  31. void *reader;
  32. MP4ChunkId chunk_id;
  33. MP4ChunkId number_of_chunks;
  34. uint32_t chunk_position, chunk_size;
  35. uint8_t *chunk_buffer;
  36. int ReadNextChunk();
  37. };