30 lines
859 B
C
30 lines
859 B
C
|
#pragma once
|
||
|
|
||
|
extern "C" {
|
||
|
#include <libswresample/swresample.h>
|
||
|
}
|
||
|
|
||
|
class SwrUtil {
|
||
|
public:
|
||
|
struct Param {
|
||
|
int sample_rate;
|
||
|
int channels;
|
||
|
AVSampleFormat format;
|
||
|
} _input, _output;
|
||
|
private:
|
||
|
SwrContext *_swrCtx = nullptr;
|
||
|
public:
|
||
|
SwrUtil() : _swrCtx(swr_alloc()) {}
|
||
|
int init(Param in, Param out) {
|
||
|
_swrCtx = swr_alloc_set_opts(_swrCtx,
|
||
|
av_get_default_channel_layout(out.channels),
|
||
|
out.format,
|
||
|
out.sample_rate,
|
||
|
av_get_default_channel_layout(in.channels),
|
||
|
in.format,
|
||
|
in.sample_rate,
|
||
|
0, nullptr);
|
||
|
return _swrCtx ? 0 : -1;
|
||
|
}
|
||
|
int convert(){}
|
||
|
};
|