2
0

BaseCodec.cpp 725 B

1234567891011121314151617181920212223242526272829303132
  1. #include "BaseCodec.h"
  2. #include "AudioContainer.h" // for AudioContainer
  3. #include "CodecType.h" // for bell
  4. using namespace bell;
  5. bool BaseCodec::setup(AudioContainer* container) {
  6. return false;
  7. }
  8. uint8_t* BaseCodec::decode(AudioContainer* container, uint32_t& outLen) {
  9. auto* data = container->readSample(lastSampleLen);
  10. if (data == nullptr) {
  11. outLen = 0;
  12. return nullptr;
  13. }
  14. if (lastSampleLen == 0) {
  15. outLen = 0;
  16. return nullptr;
  17. }
  18. availableBytes = lastSampleLen;
  19. auto* result = decode((uint8_t*)data, availableBytes, outLen);
  20. if (result == nullptr) {
  21. container->consumeBytes(1);
  22. } else {
  23. container->consumeBytes(lastSampleLen - availableBytes);
  24. }
  25. return result;
  26. }