#include "Resampler.h" #include "ffcpp.h" #include extern "C" { #include } namespace ffcpp { Resampler::Resampler(int inChannelLayout, int inSampleRate, AVSampleFormat inSampleFormat, int outChannelLayout, int outSampleRate, AVSampleFormat outSampleFormat) { _swrContext = swr_alloc(); if(!_swrContext) { throw new std::runtime_error("cannot create resampler"); } av_opt_set_int(_swrContext, "in_channel_layout", inChannelLayout, 0); av_opt_set_int(_swrContext, "in_sample_rate", inSampleRate, 0); av_opt_set_sample_fmt(_swrContext, "in_sample_fmt", inSampleFormat, 0); av_opt_set_int(_swrContext, "out_channel_layout", outChannelLayout, 0); av_opt_set_int(_swrContext, "out_sample_rate", outSampleRate, 0); av_opt_set_sample_fmt(_swrContext, "out_sample_fmt", outSampleFormat, 0); int res = swr_init(_swrContext); throwIfError(res, "cannot init resampler"); } Resampler::~Resampler() { if(_swrContext) { swr_free(&_swrContext); } } Frame Resampler::Resample(Frame& inFrame) { return Frame(); } }