#include "stdafx.h"
#include "NetSDKDemo.h"
#include "DevInfo.h"

CAVPlayer::CAVPlayer(HWND hWnd)
{
	m_hWnd = hWnd;
	//m_lPlayHandle = NULL;
	//pAVParam = NULL;
	m_bLocal = 0;
	m_lPlayID = 0;
}

CAVPlayer::~CAVPlayer()
{
	m_hWnd = NULL;
	//m_lPlayHandle = NULL;
	//SAFE_FREE(pAVParam);
}

// void CAVPlayer::SetPlayHandle(long lPlayHandle)
// {
// 	//m_lPlayHandle = lPlayHandle;
// }


CDevInfo::CDevInfo(IPC_ENTRY *pEntry)
{
	memcpy(&m_IPCEntry, pEntry, sizeof(IPC_ENTRY));
	pDevceIP = NULL;
	iUserID = 0;
	lPlayerID = 0;
	lRealHandle = 0;
	pPresetList = NULL;
	pRecordFileList = NULL;
	iOpenAudio = 0;
	iStatusEvent = -1;
	pAVParam = NULL;
	lInputStreamHandle = 0;
	iUpgradeEvent = 0;
	bAddTalk = 0;
	hRealPlayWnd = NULL; 
	bAutoReconnect = TRUE;
	iAlive = 0; 
	iLoginStatus = 0;
	hTreeItem = NULL;
	hSubItem = NULL;
	bSubStream = TRUE;
	bDVSDevice = FALSE;
	m_pRemotePlayBack = NULL;
	pLogFileList = NULL;
	iDownLoad = 0;
	iOpenStream = 0;
	bTCPConnect = 1;

	isNVR = 0;
	iNVRChannelNums = 0;
	memset(szNVRCHStatus, 0, sizeof(szNVRCHStatus));
	//memset(PNVRCHannel, 0, sizeof(PNVRCHannel));

}

CDevInfo::~CDevInfo()
{
	SAFE_FREE(pAVParam);
	SAFE_FREE(pPresetList);
	SAFE_FREE(pDevceIP);
	SAFE_FREE(pRecordFileList);
	SAFE_FREE(pLogFileList);
	iUserID = 0;
	lPlayerID = 0;
	lRealHandle = 0;
	iOpenAudio = 0;
	iStatusEvent = -1;
	lInputStreamHandle = 0;
	iUpgradeEvent = 0;
	bAddTalk = 0;
	hRealPlayWnd = NULL; 
	bAutoReconnect = TRUE;
	iAlive = 0; 
	iLoginStatus = 0;
	hTreeItem = NULL;
	hSubItem = NULL;
	bSubStream = TRUE;
	bDVSDevice = FALSE;
	SAFE_DELETE(m_pRemotePlayBack);
	iDownLoad = 0;
}
void CDevInfo::ReInit()
{
	SAFE_FREE(pAVParam);
	SAFE_FREE(pPresetList);
	SAFE_FREE(pDevceIP);
	SAFE_FREE(pRecordFileList);
	SAFE_FREE(pLogFileList);
	iUserID = 0;
	lPlayerID = 0;
	lRealHandle = 0;
	iOpenAudio = 0;
	iStatusEvent = -1;
	lInputStreamHandle = 0;
	iUpgradeEvent = 0;
	bAddTalk = 0;
	hRealPlayWnd = NULL; 
	bAutoReconnect = TRUE;
	iAlive = 0; 
	iLoginStatus = 0;
	bSubStream = TRUE;
	bDVSDevice = FALSE;
	SAFE_DELETE(m_pRemotePlayBack);
	iDownLoad = 0;
}

void CDevInfo::IPModify(const char *pIP)
{
	CMapAutoLock Lock;
	SAFE_FREE(pDevceIP);
	pDevceIP = strdup(pIP);
}

int CDevInfo::AddPresetList(CString &StrPreset)
{
	if (pPresetList)
	{
		if (StrPreset.Compare(pPresetList) == 0) return 0;
		
		SAFE_FREE(pPresetList);
		pPresetList = strdup(StrPreset.GetBuffer());
		
	}
	else
	{
		pPresetList = strdup(StrPreset.GetBuffer());
	}

	return 1;
}
