// WaveFile.h: interface for the CWaveFile class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WAVEFILE_H__F5B5B2E3_E60F_11D3_8AB6_5254AB104A0B__INCLUDED_)
#define AFX_WAVEFILE_H__F5B5B2E3_E60F_11D3_8AB6_5254AB104A0B__INCLUDED_

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

#define WAVE_FILE_PCM			0	// pass without codec
#define WAVE_FILE_ALAW			1
#define WAVE_FILE_MULAW			2
#define WAVE_FILE_ADPCM			3	//"Microsoft ADPCM";
#define WAVE_FILE_GSM610		4
#define WAVE_FILE_G729			5	
#define WAVE_FILE_G723_1		6

#define WAVE_FORMAT_GFDVR	WAVE_FORMAT_DEVELOPMENT

class CWaveFile  
{
public:
	CWaveFile();
	virtual ~CWaveFile();

	//iMode could be: MMIO_READ, MMIO_WRITE, MMIO_CREATE    
	BOOL Open(CString strFileName, int iMode);
	void Close();

	int Read(unsigned char * pData, int iLength);

	//Set the format of the wave data you want to write
	BOOL SetFormat(WAVEFORMATEX * pFormat, int iFormatSize);
	BOOL SetFormat(int iType);
	BOOL Write(unsigned char * pData, int iLength);

	inline int GetDataLength()	{	return m_iDataSize;	}
	inline WAVEFORMATEX * GetWaveFormat()	{	return m_pWaveFormat;	}
	inline int GetFormatSize()	{	return (int)m_dwFormatSize;	}

protected:
	HMMIO		m_hMmio;              // file handle for open file 
    MMCKINFO    m_mmckinfoParent;     // parent chunk information 
    MMCKINFO    m_mmckinfoSubchunk;   // subchunk information structure 
	WAVEFORMATEX	* m_pWaveFormat;
	DWORD			m_dwFormatSize;
	int m_iDataSize;
	int m_iMode;

protected:
	BOOL ReadChunk();
	BOOL WriteChunk(int iFormatSize);
};

#endif // !defined(AFX_WAVEFILE_H__F5B5B2E3_E60F_11D3_8AB6_5254AB104A0B__INCLUDED_)
