// AudioFile.h: interface for the CAudioFile class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_AUDIOFILE_H__D8A0CB41_EB04_11D4_A31E_5254AB104E6A__INCLUDED_)
#define AFX_AUDIOFILE_H__D8A0CB41_EB04_11D4_A31E_5254AB104E6A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CAudioFile : public CFile 
{
	DECLARE_DYNAMIC(CAudioFile)
public:
	CAudioFile();
	~CAudioFile();

	virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags = CFile::modeRead, CFileException* pError = NULL);
	virtual UINT Read(void* lpBuf, UINT nCount);
	virtual void Write(const void* lpBuf, UINT nCount);
	virtual void Close(); 

	int SetOptions(int iType, BOOL bUseAcm, BOOL bUseVAD, BOOL bUseHighRate);

public:
	static int EncodeG711a(short * pSample, unsigned char * pCode, int iSampleLength);
	static int EncodeG711u(short * pSample, unsigned char * pCode, int iSampleLength);
	static int DecodeG711a(unsigned char * pCode, short * pSample, int iCodeLength);
	static int DecodeG711u(unsigned char * pCode, short * pSample, int iCodeLength);

	static void InitG721();
	static int EncodeG721(short * pSample, unsigned char * pCode, int iSampleLength);
	static int DecodeG721(unsigned char * pCode, short * pSample, int iCodeLength);

	static void InitGSM();
	static void FreeGSM();
	static int EncodeGSM(short * pSample, unsigned char * pCode, int iSampleLength);
	static int DecodeGSM(unsigned char * pCode, short * pSample, int iCodeLength);

	static void InitG729cp(BOOL bUseVAD);
	static int EncodeG729cp(short * pSample, unsigned char * pCode, int iSampleLength);
	static int DecodeG729cp(unsigned char * pCode, short * pSample, int iCodeLength);

	static void InitG723f(BOOL bUseVAD, BOOL bUseHighRate);
	static int EncodeG723f(short * pSample, unsigned char * pCode, int iSampleLength);
	static int DecodeG723f(unsigned char * pCode, short * pSample, int iCodeLength);

	static void InitILBCf();
	static int EncodeILBCf(short * pSample, unsigned char * pCode, int iSampleLength);
	static int DecodeILBCf(unsigned char * pCode, short * pSample, int iCodeLength);

protected:
	int Decode(unsigned char * pCode, short * pSample, int iCodeLength);
	int Encode(short * pSample, unsigned char * pCode, int iSampleLength);

protected:
	int m_iType;
	BOOL m_bUseAcm;
};

#endif // !defined(AFX_AUDIOFILE_H__D8A0CB41_EB04_11D4_A31E_5254AB104E6A__INCLUDED_)
