#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 #include #include 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> encode(std::span interleaved); private: SwrContext* swr_ = nullptr; OpusEncoder* enc_ = nullptr; int inRate_ = 192000; std::vector pcm_; // resampled 48 kHz interleaved stereo }; } // namespace Echoion::Standalone