#ifndef __FFMPEGRESAMPLE_H__ #define __FFMPEGRESAMPLE_H__ #include #include #include struct SwrContext; class FFmpegResample { public: class Frame { public: uint8_t *data = nullptr; int32_t byteSize = 0; }; ~FFmpegResample(); void initialize(int32_t sampleRateIn, int32_t channelIn, int32_t sampleRateOut, int32_t channelOut,int32_t period); Frame resample(const uint8_t *pcm, int32_t size); private: SwrContext *m_swrContext = nullptr; uint8_t *m_buffer; std::array buffer; int32_t m_sampleRateOut = 48000; int32_t m_channelOut = 2; int32_t m_sampleRateIn = 16000; int32_t m_channelIn = 1; int32_t m_period = 20; // ms }; #endif // __FFMPEGRESAMPLE_H__