#pragma once

#if __cplusplus
extern "C"
{
#endif
	#include <libavformat/avformat.h>
	#include <libswscale/swscale.h>
	#include <libswresample/swresample.h>
#if __cplusplus
}
#endif

namespace mfs
{
class Pcm2AAC
{
public:
	Pcm2AAC();
	virtual ~Pcm2AAC();

	bool Init(int pcm_Sample_rate, AVSampleFormat pcm_Sample_fmt, int pcm_Channels);
	int AddData(char *pData, int size);
	bool GetData(char *&pOutData, int &iSize);
	char m_pOutData[1024 * 10];
	void AddADTS(int packetLen);
	char m_Pcm[10240];
	int m_PcmSize=0;
	char *m_PcmPointer[8];
	AVSampleFormat m_PcmFormat;
	int m_PcmChannel;
	int m_PcmSampleRate;

	AVFrame * frame;
	AVPacket *packet;
	AVCodec *codec;
	AVCodecContext *c = NULL;
	SwrContext *resample_context = NULL;
	int64_t pts;
};


}
