#if !defined(AFX_CONFIGCHANNEL_H__5DA36722_EFE2_4845_8215_F44E5FB41BDB__INCLUDED_)
#define AFX_CONFIGCHANNEL_H__5DA36722_EFE2_4845_8215_F44E5FB41BDB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ConfigChannel.h : header file
#include <map>
using namespace std;
//
#define MAX_RESOLUTION_NUM 9
/////////////////////////////////////////////////////////////////////////////
// CConfigChannel dialog
typedef struct  
{
	CString strText;
	DWORD dwSize;
	DWORD dsMask;
}SResolution;

class CConfigChannel : public CDialog
{
// Construction
public:
    void InitDlgInfo(int ChannnelNum,NET_SDK_EncodeConfigAll *pEncodeSimpl,
		NET_SDK_CONFIG_NORMAL *pNormalCfg,NET_SDK_CONFIG_EncodeAbility *pEncodeAbility,
								 NET_SDK_CombineEncodeConfigAll *pCmbEncode,NET_SDK_SystemFunction *pSysFunc,
								 DEV_ATTRIBUTE *pDevAttribute,NET_SDK_CombEncodeModeAll *pCmbEncodeMode);
	CConfigChannel(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
	//{{AFX_DATA(CConfigChannel)
	enum { IDD = IDD_CONFIG_CHANNEL };
	CComboBox	m_ctlBitRate;
	CComboBox	m_ctlGop;
	CComboBox	m_ctlExpandGop;
	CComboBox	m_ctlQuality;
	CComboBox	m_ctlExpandQuality;
	CComboBox	m_ctlExpandBitControl;
	CComboBox	m_ctlBitControl;
	CComboBox	m_ChanNo;
	//}}AFX_DATA

	virtual BOOL OnInitDialog();
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CConfigChannel)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CConfigChannel)
	afx_msg void OnButtonApply();
	
	afx_msg void OnSelchangeComboChanno();
	afx_msg void OnButtonReadall();
	afx_msg void OnSelchangeComboResolution();
	afx_msg void OnSelchangeComboBitcontrol();
	afx_msg void OnSelchangeComboQuality();
	afx_msg void OnSelchangeComboFrame();
	afx_msg void OnSelchangeComboExpandBitcontrol();
	afx_msg void OnSelchangeComboExpandBitRate();
	afx_msg void OnSelchangeComboExpandResolution();
	afx_msg void OnSelchangeComboExpandQuality();
	afx_msg void OnSelchangeComboExpandFrame();
	afx_msg void OnCheckExpandVideo();
	afx_msg void OnCheckMainAudio();
	afx_msg void OnCheckExpandAudio();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
private:
	map<int, CString> m_mapCaptureComp;
	NET_SDK_CONFIG_ENCODE m_allData;
	int m_nFrame;
	int m_niQuality;
	int m_nResolution;
	void ShowStream(int resolution,int iQuality,int Frame);
	int GetMaxFrame(int nResolution, long lFreePower);
	void ChangeChannel(int CurChannel , NET_SDK_EncodeConfigAll *m_EncodeConfig);
	void InitCombo();
	bool AllStructToWinData(int nChannelNum, NET_SDK_CONFIG_ENCODE *pConfigEncode, int nEncodeType);
	bool StructToWinData(int nChannelNum, NET_SDK_CONFIG_ENCODE *pConfigEncode, int nEncodeType, DWORD dwPower, DWORD dwMask = -1, DWORD dwBitrate = -1);
    DWORD GetExpandUsed();
	DWORD GetComboBoxData(UINT nID, int nIndex = -1);
	BOOL SetComBoxCurSel(UINT nID, DWORD dwData);
	void GetMaxResolAndRate(int &nResolu, int &nRate, long lFreePower );
	void EnableMainVideo(BOOL bEnable);
	DWORD GetMainUsed();
	void EnableExpandVideo(BOOL bEnable);
	void AddCmbResolution( UINT nID, int maxSize, DWORD dwMask );
	void AddCmbFPS( UINT nID, int maxSize );
	int NearBitrate(UINT nID, DWORD dwData);
	bool StructToWin();
	void UpdateCodeFormat(int nStream, UINT nComboBoxID);
	bool NormalStructToWinData(int nChannelNum, NET_SDK_CONFIG_ENCODE *pConfigEncode, int nEncodeType);
	DWORD GetFreeDspPower(int nChannelNo);
	DWORD GetFreeBitratePower(int nChannelNo);
	bool CombineStructToWinData(int nChannelNum, NET_SDK_CONFIG_ENCODE *pConfigEncode, int nEncodeType);
	bool AllWinDataToStruct(int nChannelNum);
	bool NomalWinDataToStruct(int nChannelNum);
	bool WinDataToStruct(NET_SDK_MEDIA_FORMAT &dstFmt, int nEncodeType);
	DWORD GetUsedEnable(UINT nResID, UINT nFrameID, UINT nEnableID);
	void SelchangeComboResolution(NET_SDK_MEDIA_FORMAT &dstFormat, int nEncodeType, DWORD dwPower);
	void SelchangeComboBitcontrol(NET_SDK_MEDIA_FORMAT &dstFormat, int nEncodeType);
	void SelchangeComboFrame(NET_SDK_MEDIA_FORMAT &dstFormat, int nEncodeType);
	bool WinToStruct();
	bool CombineWinDataToStruct(int nChannelNum);
public:
	int m_nAudioInNum;
	int m_nChannelNum;
	void InitResData();
	void CleanAll();
	NET_SDK_EncodeConfigAll m_EncodeConfig;
	int m_nLastChannelNum;
	int m_nVideoStandard;
	int m_nLastResolutionExtra;
	NET_SDK_CONFIG_EncodeAbility m_pEncodeAbility;
	int m_maxBitRate[NET_SDK_CAPTURE_SIZE_NR];
	SResolution m_resolution[NET_SDK_CAPTURE_SIZE_NR];
	NET_SDK_CombineEncodeConfigAll m_CmbEncodeCfg;
	NET_SDK_SystemFunction m_SysFunc;
	DEV_ATTRIBUTE m_DevAttribute;
	bool	m_bMultiStream;
	char m_cVersion[64];
	bool m_bCombineEncode;
	bool m_bCombineSet;
	NET_SDK_CombEncodeModeAll m_CmbEncodeMode;
};

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

#endif // !defined(AFX_CONFIGCHANNEL_H__5DA36722_EFE2_4845_8215_F44E5FB41BDB__INCLUDED_)
