mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-12 06:27:12 +03:00
move to new cspot
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include "AudioContainer.h"
|
||||
#include "aacdec.h"
|
||||
|
||||
namespace bell {
|
||||
class AACContainer : public AudioContainer {
|
||||
public:
|
||||
~AACContainer(){};
|
||||
AACContainer(std::istream& istr);
|
||||
|
||||
std::byte* readSample(uint32_t& len) override;
|
||||
void parseSetupData() override;
|
||||
|
||||
bell::AudioCodec getCodec() override { return bell::AudioCodec::AAC; }
|
||||
|
||||
private:
|
||||
static constexpr auto AAC_MAX_FRAME_SIZE = 2100;
|
||||
static constexpr auto BUFFER_SIZE = 1024 * 10;
|
||||
|
||||
std::vector<std::byte> buffer = std::vector<std::byte>(BUFFER_SIZE);
|
||||
|
||||
size_t bytesInBuffer = 0;
|
||||
size_t dataOffset = 0;
|
||||
|
||||
bool fillBuffer();
|
||||
};
|
||||
} // namespace bell
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <istream>
|
||||
#include <cstring>
|
||||
#include "CodecType.h"
|
||||
#include "StreamInfo.h"
|
||||
|
||||
namespace bell {
|
||||
class AudioContainer {
|
||||
protected:
|
||||
std::istream& istr;
|
||||
uint32_t toConsume = 0;
|
||||
|
||||
public:
|
||||
bell::SampleRate sampleRate;
|
||||
bell::BitWidth bitWidth;
|
||||
int channels;
|
||||
|
||||
AudioContainer(std::istream& istr) : istr(istr) {}
|
||||
|
||||
virtual std::byte* readSample(uint32_t& len) = 0;
|
||||
void consumeBytes(uint32_t bytes) { this->toConsume = bytes; }
|
||||
virtual void parseSetupData() = 0;
|
||||
virtual bell::AudioCodec getCodec() = 0;
|
||||
};
|
||||
} // namespace bell
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include "AACContainer.h"
|
||||
#include "AudioContainer.h"
|
||||
#include "MP3Container.h"
|
||||
|
||||
namespace bell::AudioContainers {
|
||||
std::unique_ptr<bell::AudioContainer> guessAudioContainer(std::istream& istr);
|
||||
} // namespace bell::AudioContainers
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include "AudioContainer.h"
|
||||
#include "mp3dec.h"
|
||||
|
||||
namespace bell {
|
||||
class MP3Container : public AudioContainer {
|
||||
public:
|
||||
~MP3Container(){};
|
||||
MP3Container(std::istream& istr);
|
||||
|
||||
std::byte* readSample(uint32_t& len) override;
|
||||
void parseSetupData() override;
|
||||
bell::AudioCodec getCodec() override { return bell::AudioCodec::MP3; }
|
||||
|
||||
private:
|
||||
static constexpr auto MP3_MAX_FRAME_SIZE = 2100;
|
||||
static constexpr auto BUFFER_SIZE = 1024 * 10;
|
||||
|
||||
std::vector<std::byte> buffer = std::vector<std::byte>(BUFFER_SIZE);
|
||||
|
||||
size_t bytesInBuffer = 0;
|
||||
size_t dataOffset = 0;
|
||||
|
||||
bool fillBuffer();
|
||||
};
|
||||
} // namespace bell
|
||||
Reference in New Issue
Block a user