add some code

This commit is contained in:
2025-09-05 13:25:11 +08:00
parent 9ff0a99e7a
commit 3cf1229a85
8911 changed files with 2535396 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
#ifndef _OPUS_DECODER_WRAPPER_H_
#define _OPUS_DECODER_WRAPPER_H_
#include <functional>
#include <vector>
#include <cstdint>
#include <mutex>
#include "opus.h"
class OpusDecoderWrapper {
public:
OpusDecoderWrapper(int sample_rate, int channels, int duration_ms = 60);
~OpusDecoderWrapper();
bool Decode(std::vector<uint8_t>&& opus, std::vector<int16_t>& pcm);
void ResetState();
inline int sample_rate() const {
return sample_rate_;
}
inline int duration_ms() const {
return duration_ms_;
}
private:
std::mutex mutex_;
struct OpusDecoder* audio_dec_ = nullptr;
int frame_size_;
int sample_rate_;
int duration_ms_;
};
#endif // _OPUS_DECODER_WRAPPER_H_