#ifndef _OPUS_ENCODER_H_ #define _OPUS_ENCODER_H_ #include #include #include #include #include "lwip/sockets.h" #include "opus.h" class OpusEncoder { public: OpusEncoder(); ~OpusEncoder(); void Configure(int sample_rate, int channels, int duration_ms = 60); void SetComplexity(int complexity); void Encode(const iovec pcm, std::function handler); bool IsBufferEmpty() const { return in_buffer_.empty(); } void ResetState(); private: struct OpusEncoder* audio_enc_ = nullptr; int frame_size_; std::vector out_buffer_; std::vector in_buffer_; }; #endif // _OPUS_ENCODER_H_