MP4RawReader.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "file/svc_filerawreader.h"
  3. #include "decode/ifc_raw_media_reader.h"
  4. #include "mp4.h"
  5. #include "nswasabi/ServiceName.h"
  6. // {5CBD1F27-5A63-4D8C-9297-D74518E1EF3A}
  7. static const GUID mp4_raw_reader_guid =
  8. { 0x5cbd1f27, 0x5a63, 0x4d8c, { 0x92, 0x97, 0xd7, 0x45, 0x18, 0xe1, 0xef, 0x3a } };
  9. class MP4RawReaderService : public svc_filerawreader
  10. {
  11. public:
  12. WASABI_SERVICE_NAME("MP4 Raw Reader");
  13. static GUID GetServiceGUID() { return mp4_raw_reader_guid; }
  14. ns_error_t WASABICALL FileRawReaderService_CreateRawMediaReader(ifc_raw_media_reader **reader, nx_uri_t filename, nx_file_t file, ifc_metadata *parent_metadata);
  15. };
  16. class MP4RawReader : public ifc_raw_media_reader
  17. {
  18. public:
  19. MP4RawReader();
  20. ~MP4RawReader();
  21. int Initialize(MP4FileHandle file);
  22. int WASABICALL RawMediaReader_Read(void *buffer, size_t buffer_size, size_t *bytes_read);
  23. private:
  24. uint16_t track_num;
  25. uint32_t number_of_tracks;
  26. MP4TrackId current_track;
  27. MP4FileHandle file;
  28. MP4ChunkId chunk_id;
  29. MP4ChunkId number_of_chunks;
  30. uint32_t chunk_position, chunk_size;
  31. uint8_t *chunk_buffer;
  32. int ReadNextChunk();
  33. };