// APIDemoDlg.h : header file
//

#if !defined(AFX_APIDEMODLG_H__86B6C99E_299C_43DC_8CDD_D0403D147971__INCLUDED_)
#define AFX_APIDEMODLG_H__86B6C99E_299C_43DC_8CDD_D0403D147971__INCLUDED_

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

#include "YsE1.h"
#include "TDMAddon.h"

/////////////////////////////////////////////////////////////////////////////
// CAPIDemoDlg dialog

class CAPIDemoDlg : public CDialog
{
// Construction
public:
	unsigned long	result;
	short			m_CurrAudioLen;
	BYTE			m_CurrAudioCodec;
	
	int				m_nCardNum;
	int				m_nChanNum;
	
	bool			m_IsTalking[YS_E1_MAX_CHANNEL];
	short			m_TalkTo[YS_E1_MAX_CHANNEL];
	BYTE			m_TalkToBuffer[YS_E1_MAX_CHANNEL][YS_E1_AUDIO_FRAME];
	BYTE*			m_VoiceBuf[YS_E1_MAX_CHANNEL][2];
	BYTE			m_BufSuffix[YS_E1_MAX_CHANNEL];
	BYTE			m_DelayCount[YS_E1_MAX_CHANNEL];

	long			m_IntCount[YS_E1_MAX_CHANNEL];
	CTDMAudio		m_Audio[YS_E1_MAX_CHANNEL];
	int				m_bCall[YS_E1_MAX_CHANNEL];

	char			m_sDtmf[YS_E1_MAX_CHANNEL][256];

	int		CheckChannelType(CString type);
	void	SetChannelValue(short ChannelNo);
	unsigned long CloseDevice();

	int		DoMsgFromE1(int nPort, YS_E1_MSG_TYPE type, const _e1_msg_t* param);
	int     DoAudioFromE1(int nPort, YS_CB_AUDIO_TYPE type, unsigned char* data, int length); 
	CAPIDemoDlg(CWnd* pParent = NULL);	// standard constructor

	int		AddBridgeOfPort(int nPort1, int nPort2); 
	int		DelBridgeOfPort(int nPort);
	int		GetBridgePort(int nPort);

	int		FillDtmf(int nPort, unsigned char dtmf);
// Dialog Data
	//{{AFX_DATA(CAPIDemoDlg)
	enum { IDD = IDD_APIDEMO_DIALOG };
	CComboBox	m_ComboBridgePort2;
	CComboBox	m_ComboBridgePort1;
	CComboBox	m_ComboDtmfType;
	CComboBox	m_ComboCodecType;
	CComboBox	m_DChanSel;
	CComboBox	m_SwitchList;
	CComboBox	m_ModeList;
	CRichEditCtrl	m_log;
	CSliderCtrl	m_PlayBar;
	CListCtrl	m_Report;
	CString	m_PlayFile;
	CString	m_RecFile;
	CString	m_CallerID;
	CString	m_DtmfStr;
	CString	m_CallerName;
	CString	m_CalleeID;
	CString	m_sVersion;
	BOOL	m_bLoop;
	BOOL	m_bEchoEnable;
	UINT	m_nEchoOffset;
	BOOL	m_bAutoAnswer;
	BOOL	m_bAllPort;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAPIDemoDlg)
	public:
	virtual BOOL DestroyWindow();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	virtual void PostNcDestroy();
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CAPIDemoDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	virtual void OnOK();
	afx_msg void OnOpen();
	afx_msg void OnClose();
	afx_msg void OnHangup();
	afx_msg void OnPlayfilesel();
	afx_msg void OnStartplay();
	afx_msg void OnStopplay();
	afx_msg void OnRecfilesel();
	afx_msg void OnStartrec();
	afx_msg void OnStoprec();
	afx_msg void OnStartloop();
	afx_msg void OnStoploop();
	afx_msg void OnSenddtmf();
	afx_msg void OnClickReport(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnKillfocusPlayfile();
	afx_msg void OnCustomdrawPlaybar(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnReleasedcapturePlaybar(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnPauseplay();
	afx_msg void OnLoadpcmres();
	afx_msg void OnLoadwavres();
	afx_msg void OnCallout();
	afx_msg void OnAnswer();
	afx_msg void OnCheckLoop();
	afx_msg void OnButEchoOffset();
	afx_msg void OnCheckEcho();
	afx_msg void OnButDtmfSet();
	afx_msg void OnButSetBridge();
	afx_msg void OnCheckAutoanswer();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_APIDEMODLG_H__86B6C99E_299C_43DC_8CDD_D0403D147971__INCLUDED_)
