MP3Container.h 687 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. #include <cstring>
  3. #include <cstddef>
  4. #include <vector>
  5. #include "AudioContainer.h"
  6. #include "mp3dec.h"
  7. namespace bell {
  8. class MP3Container : public AudioContainer {
  9. public:
  10. ~MP3Container(){};
  11. MP3Container(std::istream& istr);
  12. std::byte* readSample(uint32_t& len) override;
  13. void parseSetupData() override;
  14. bell::AudioCodec getCodec() override { return bell::AudioCodec::MP3; }
  15. private:
  16. static constexpr auto MP3_MAX_FRAME_SIZE = 2100;
  17. static constexpr auto BUFFER_SIZE = 1024 * 10;
  18. std::vector<std::byte> buffer = std::vector<std::byte>(BUFFER_SIZE);
  19. size_t bytesInBuffer = 0;
  20. size_t dataOffset = 0;
  21. bool fillBuffer();
  22. };
  23. } // namespace bell