AudioContainers.cpp 641 B

123456789101112131415161718192021222324
  1. #include "AudioContainers.h"
  2. using namespace bell;
  3. std::unique_ptr<bell::AudioContainer> AudioContainers::guessAudioContainer(
  4. std::istream& istr) {
  5. std::byte tmp[14];
  6. istr.read((char*)tmp, sizeof(tmp));
  7. if (memcmp(tmp, "\xFF\xF1", 2) == 0 ||
  8. memcmp(tmp, "\xFF\xF9", 2) == 0) {
  9. // AAC found
  10. std::cout << "AAC" << std::endl;
  11. return std::make_unique<bell::AACContainer>(istr);
  12. } else if (memcmp(tmp, "\xFF\xFB", 2) == 0 ||
  13. memcmp(tmp, "\x49\x44\x33", 3) == 0) {
  14. // MP3 Found
  15. std::cout << "MP3" << std::endl;
  16. return std::make_unique<bell::MP3Container>(istr);
  17. }
  18. return nullptr;
  19. }