/********************************************************************************************
*** Copyright (c) 2010, Topsee,Inc.
*** File name  : ClientMsg.h
*** Module     : IPVS client 
*** Author     : LionelLiao
*** Version    : 1.0
*** Created On : 2010.05.14
*** Description:
***            
*** Modification histroy:
*********************************************************************************************/
#ifndef _CLIENT_MSG_H_
#define _CLIENT_MSG_H_

//#include "DeviceInfo.h"

#define WM_USR_MSGGUI WM_USER+1000

/* message type range */
#define VS_MSG_INTER_MOD_BEGIN  (0x4000)   /* 16384 */
#define VS_MSG_INTER_MOD_END     (0x4e00)   /* 19968 */


typedef enum
{
	/*  Request  */
	VS_MAP_MSG_PLAY = VS_MSG_INTER_MOD_BEGIN + 0x600,
	VS_MAP_MSG_DEVPROPERTY,	
	VS_MAP_MSG_ALARMINFO,
	/* Confirm */

	/*  Notify */
	VS_IPC_STATUS_NOTIFY,//前端设备是否在线通知
	VS_SET_PSW_RSP,
	VS_DOWNLOAD_REC_FILE,
	VS_DOWNLOAD_SPECIFIC_REC_FILE,
	VS_RSP_DOWNLOAD_DVR_FILE,
	VS_NOTIFY_PROGRESS_DVR_FILE,
	VS_NOTIFY_UPLOAD_FAILED,
	VS_ALL_IPC_STATUS_NOTIFY,
	VS_ALL_CAM_REGINFO_NOTIFY,
	VS_CONFIG_CHANGE_NOTIFY,

	/* Video Window */
	VS_VIDEO_MSG_INVITE = VS_MSG_INTER_MOD_BEGIN + 0x300,	
	VS_MSG_RECORD_STATUS,//设备是否在进行录像
	VS_MSG_PLAYER,
	VS_TIMESHIFT_MSG_STOP,
	VS_TIMESHIFT_MSG_PLAY,
	VS_MSG_WATCH_ERROR,
	VS_MSG_INVALIDATE_WND,//刷新窗口

	/* Survaillance Window*/
	VS_PTZ_MSG_REQPRIVI = VS_MSG_INTER_MOD_BEGIN + 0x100,
	VS_PTZ_MSG_ACT,
	VS_MSG_TACKBACK = VS_MSG_INTER_MOD_BEGIN + 0x110,//监控、对讲、广播、云台控制抢占通知消息
	VS_AUDIO_MSG_REQPRIVI = VS_MSG_INTER_MOD_BEGIN + 0x200,	//对讲消息
	VS_AUDIO_BC_MSG_REQPRIVI = VS_MSG_INTER_MOD_BEGIN + 0x201,	//广播消息
	VS_MSG_MANUL_REC,
	VS_MSG_NO_RIGHT, // PTZ and audio of device vest
	VS_MSG_REC_STOP,
	VS_AUDIO_MSG_CLOSE,//对讲停止消息
	VS_AUDIO_REQ_AGAIN,

	/* Alarm Event*/
	VS_MSG_ERROR = VS_MSG_INTER_MOD_BEGIN + 0x310, 
	VS_MSG_EVENT,//事件消息
	VS_MSG_ALARM,//实时报警消息
	VS_MSG_ALARM_OUT_STATUS,
	VS_MSG_SUR_TACKBACK,


	/* Replay: 0x400~0x4ff */
	/* notify-response */
	VS_REPLAY_MSG_PLAY = VS_MSG_INTER_MOD_BEGIN + 0x400,
	VS_MSG_REC_FILE,//录像查询结果通知消息
	VS_MSG_NEXT_REC_FILE,
	VS_MSG_DVR_STATUS,
	VS_MSG_DVR_REC_STATUS,
	VS_MSG_REC_DISTRIBUTE_FILE,

	VS_MSG_CLI_TYPE_MAX
}VSMsgType_e;

//Message body 
//------------------------------------------------------------------------
// Video Window 
//VS_VIDEO_MSG_INVITE
typedef struct{
	U32 result;
	HWND hwnd;								//for display windows
	S8  szDevId[VS_DEV_ID_LEN];		        //for Decoder device ID
}MSG_Invite_t;

#define ERROR_UNKNOW_STMTYPE  1
typedef struct{
	U32 result;
	HWND hwnd;								//for display windows
	S8  szDevId[VS_DEV_ID_LEN];		        //for Decoder device ID
}MSG_Watch_t;

//VS_MSG_RECORD_STATUS
typedef struct{
	U32 result;				//Record status  1 recording
	HWND hwnd;				//for display windows
	S8  szDevId[VS_DEV_ID_LEN];		//for camera device
}MSG_Record_t;

//VS_MSG_PLAYER
//VS_TIMESHIFT_MSG_STOP
#define RESULT_PLAY_NO_STREAM	1	//no stream data received
typedef struct{
	U32 result;								//player status
	HWND hwnd;								//for display windows
	U32 nhandle;							//handle if TVWall decoder card 
}MSG_Player_t;

//------------------------------------------------------------------------
// Survaillance Window 
//VS_PTZ_MSG_REQPRIVI
typedef struct{
	U32 result;
	S8  szDevId[VS_DEV_ID_LEN];		//for ptz device
}MSG_PTZ_Req_t;

//VS_PTZ_MSG_ACT
typedef struct{
	U32 result;
	S8 devId[VS_DEV_ID_LEN];
	U32 dataLen; 
	S8 data[MAX_PTZ_ACT_DATA_LEN]; 
}MSG_PTZ_ACT_t;

//VS_MSG_TACKBACK
typedef struct{
	U32 nTakebackType; 		
	//VS_TAKEBACK_TYPE_STREAM / VS_TAKEBACK_TYPE_PTZ / VS_TAKEBACK_TYPE_AUDIO_TALK / VS_TAKEBACK_TYPE_AUDIO_BROARDCAST
	S8 devId[VS_DEV_ID_LEN]; 
	S8 grabedByUser[MAX_USR_NAME];//告知用户被何方神圣抢占
}MSG_Takeback_t;

//VS_AUDIO_MSG_REQPRIVI
typedef struct{
	U32 result;
	S8  szDevId[VS_DEV_ID_LEN];		//for audio out device
}MSG_Talk_Req_t;

//VS_AUDIO_BC_MSG_REQPRIVI
//VS_AUDIO_MSG_TACKBACK
typedef struct{
	U32 result;
}MSG_response_t;

//VS_MSG_ALARM
typedef struct{
	TabDevAlmInfo_t oTabDevAlmInfo_t;
}MSG_Alarm_t;

//VS_MSG_EVENT
typedef struct{
	TabDevEventInfo_t oTabDevEventInfo_t;
}MSG_Event_t;

//----------------------------------------------------------------------------
//query record file
typedef struct{
	U32 result;
	S8  szDevId[VS_DEV_ID_LEN];
	U16	nTotalNum;		//总记录数
	U16 nRecordNum;	//本次记录个数
	content_fileinfo_t  oFileInf_t[VS_CONTENT_PAGE_SIZE];
}MSG_RecordFile_t;

typedef struct
{	
	U32 result;// see constants prefixed CM_ERR_
	S8 szDevId[VS_DEV_ID_LEN];
	vs_time_t date; //年月日有效
	S8 szRecordDistribution[VS_RECORD_DISTRIBUTE_LEN+4];//指示客户端一天内录像分布
}MSG_RecDistrition_t;

typedef struct 
{
	S8 szDevId[VS_DEV_ID_LEN];
	U32	nState;	//状态0:  STATUS_OFFLINE	1: STATUS_HBLOST	2: STATUS_ACTIVE
}MSG_IPCStatus_t;

typedef struct
{
	U32 nResult;
	S8 szFilePath[VS_FILE_PATH_LEN];//指示客户端下载的FTP路径
	S8 szFtpUsrName[VS_FTP_USER_NAME_LEN];	//下载文件所用的临时分配的用户名
	S8 szFtpUsrPwd[VS_FTP_USER_NAME_LEN];
}MSG_DownloadFile_t;

typedef struct
{
	S8 szDevId[VS_DEV_ID_LEN];
	U8 bDoubleStream;
	U8 bWithPTZ;
	U8 bWithAudioIn;
	U8 bWithAudioOut;
}MSG_CamRegInfo_t;

class CCameraDevice;
typedef struct{
	CCameraDevice* pDev;
	U32 nChannel;
	U32 stayseconds;
	U32 ptzposition;
	HWND HWnd;
}PatrolPoint;

//patrol
typedef struct{
	int patrolId;
	bool bpatrol;
	bool bPause;
	int VSDuration;
	int VSCurStaytime;
	int VSCurIndex;
	std::list<PatrolPoint> lstPoint;
}PatrolList;


#endif