commit
cf48f2f350
6 files changed
+992
No files matched your search
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
// Converts Echoion's internal PCM (192 kHz stereo S16, delivered in 20 ms
|
||||
// chunks) into TeamSpeak-ready Opus frames: resample to 48 kHz stereo, then
|
||||
// Opus-encode in exact 20 ms (960 samples/ch) frames. A small PCM ring absorbs
|
||||
// the resampler's priming latency so every emitted frame is exactly 960/ch.
|
||||
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
struct SwrContext;
|
||||
struct OpusEncoder;
|
||||
|
||||
namespace Echoion::Standalone
|
||||
{
|
||||
|
||||
class AudioEncoder
|
||||
{
|
||||
public:
|
||||
|
||||
// inRate defaults to Echoion's 192 kHz internal pipeline.
|
||||
explicit AudioEncoder(int bitrate = 96000, int inRate = 192000);
|
||||
~AudioEncoder();
|
||||
|
||||
AudioEncoder(const AudioEncoder&) = delete;
|
||||
AudioEncoder& operator=(const AudioEncoder&) = delete;
|
||||
|
||||
// Feed one chunk of interleaved stereo S16 at inRate. Returns zero or
|
||||
// more complete Opus frames (each a 20 ms packet).
|
||||
std::vector<std::vector<uint8_t>>
|
||||
encode(std::span<const short> interleaved);
|
||||
|
||||
private:
|
||||
|
||||
SwrContext* swr_ = nullptr;
|
||||
OpusEncoder* enc_ = nullptr;
|
||||
int inRate_ = 192000;
|
||||
std::vector<short> pcm_; // resampled 48 kHz interleaved stereo
|
||||
};
|
||||
|
||||
} // namespace Echoion::Standalone
|
||||
Reference in new issue
Block a user