/********************************************************************************************
*** Copyright (c) 2010, Topsee,Inc.
*** File name  : CFunctionInf.h
*** Module     : IPVS client 
*** Author     : Lionel Liao
*** Version    : 1.0
*** Created On : 2010.05.06
*** Description:
***            
*** Modification histroy:
*********************************************************************************************/
#ifndef _FUNCINF_H_
#define _FUNCINF_H_

#include "DeviceInfo.h"

extern S8    g_szUsrId[32];
extern S8    g_szGrpId[32];
extern S8    g_szUsrName[32];
extern S8    g_szPswd[32];
extern U16   g_nUserPriority;

typedef struct{
	S32  nWndNo;
	U32  nStreamNo;
	S8   szDevId[32];
	U32  nPatrol;
}RecentlySurStatus_t;

typedef struct
{	
	U32 userManagerRight;//用户管理
	U32 puManagerRight;//设备管理
	U32 videoSuvRight;//视频浏览
	U32 ptzSetRight;//云镜控制
	U32 alarmManagerRight;//告警管理	
	U32 videoPalybackRight;//录像回放
	U32 conManagerRight;//内容管理
	U32 conDeleteRight;//内容删除
	U32 tvwallManagerRight;//电视墙
	U32 audioTwoWayRight;//语音对讲
	U32 audioBrardCastRight;//语音广播
	U16 nUserPriority;//用户优先级
}UserRight;

typedef  struct{
	S8     szDevId[32];		//Camera ID
	U32    nDateTime;
	U32    nType;
	U32    nLevel;
	U32    nIsRaise;
	S8     szDesc[64];
}SearchAlarmInfo_t;

typedef struct
{
	U32 nDateTime;//GPS信息产生的时间点
	S8  szLongitude[32];//经度:经度信息，根据字符串后4位为小数部分。表示eee°ee.eeee’第一位字符为+/-，+表示东经，-表示西经
	S8  szLatitude[32];//纬度:纬度信息，后4位为小数部分。表示aa°aa.aaaa’第一位字符为+/-，+表示东经，-表示西经
	S32 nAltitude;//高度:海拔/高度信息，以米为单位
	U32 nbAccurate;//0:非精确定位，1:精确定位
	U32 nDirection;//方向，单位是10度，正北为0度，顺时针方向
	U32 nSpeed;//速度，km/h
}GPSTrackInfo_t;

/*---------------------------------------------------------------------
                          Initial SDK 
----------------------------------------------------------------------*/
/*
FC_Init
input:
hwnd : use for message commnunication
return:
0 success otherwise
error code
*/
int FC_Init( HWND hwnd);
int FC_Free();
/*---------------------------------------------------------------------
                          LogIn LogOut 
----------------------------------------------------------------------*/
/*
Client User login CMS
input:
@str_UID: user ID
@strPWD:  user PWD

return:
0 success otherwise
error code
*/
int FC_ClientLogin(const char*  szUsrName, const char* strPWD, U32 CMSIp, U16 CMSPort, UserRight &oUserRight);

int FC_GetLoginInfo(const char*  szUsrName, const char* strPWD, U32 CMSIp, U16 CMSPort, UserRight &oUserRight);
/*
Client User logout CMS
input:
return:
0 success otherwise
error code
*/
int FC_ClientLogOut();

/* password error */
#define LOGIN_OLD_PASSWORD_ERROR   2006
/*
Change user password
input:
@strPsw: old password
@str_UID: user ID
@strNewPsw: new password
return:
0 success otherwise
error code
*/
int FC_ClientChgPW(const char * strPsw, const char *strUid, const char *strNewPsw);

int FC_DecodeOneStreaming(S8 *szDecId, S8 *szDevId, S8 *szVssIp, U16 nVssPort);
int FC_StartTVWallPatrol(S8 *szDecId);
int FC_StopTVWallPatrol(S8 *szDecId);

/*---------------------------------------------------------------------
                          Get Device List
----------------------------------------------------------------------*/
/*
Init MataData interface
input:
return:
0 success otherwise
error code
*/
int FC_InitMataDataInf();

/*
refresh head end device list
input:
output:
return 
0 success otherwise
error code
*/
int FC_RefreshHeadendDeviceList();


/*
refresh related device list
input:
output:
return 
0 success otherwise
error code
*/
int FC_RefreshRelatedDeviceList();


/*
Get head end device list
input:
output:
return 
list<CMasterDevice *>&
*/
list<CMasterDevice *>& FC_GetHeadendDeviceList();

/*
Get related device list
input:
output:
return 
list<CMasterDevice *>&
*/
list<CMasterDevice *>& FC_GetRelatedDeviceList();

list<DevBaseInfo_t>& FC_GetDevBaseInfoList();
list<CameraSettingInfo_t>& FC_GetCameraSettingInfoList();
list<CameraRegInfo_t>& FC_GetCameraRegInfoList();
list<DevRelationInfo_t>& FC_GetDevRelationInfoList();
list<AlmActTypeInfo_t>& FC_GetAlmActInfoList();
list<MSG_IPCStatus_t>&FC_GetAllIPCStatusList();
list<MSG_CamRegInfo_t>&FC_GetAllCamRegInfoList();

/*---------------------------------------------------------------------
                          Live Video Surveillance
----------------------------------------------------------------------*/
/*Add a moniter channel for displaying in GUI
input:
HWnd:     Window Handle for displaying
pDev:     Camera Device 
return 
0 success otherwise
error code	
*/
int FC_addWatch(int nWndNo, HWND HWnd, CCameraDevice* pDev, U32 nStreamNo,U32 patrolId=0);
/*remove a moniter channel 
input:
HWnd:     Window Handle for displaying
return 
0 success otherwise
error code
*/
int FC_RemoveWatch(HWND HWnd);

int FC_RemoveAllWatch();


int FC_GetZoomRectStatus(HWND HWnd);

/*---------------------------------------------------------------------
Save recently surveillance status information
----------------------------------------------------------------------*/
/*save recently display mode
*/
int FC_SaveRecenetlyDispMode(int nMode);
int FC_GetRecenetlyDispMode();

/*save recently surveillance status
*/
int FC_SaveRecentlySurStatus();
int FC_GetRecentlySurStatus(std::list<RecentlySurStatus_t>& lstSurStatus);

/*---------------------------------------------------------------------
                         Talk & Audio Broadcast
----------------------------------------------------------------------*/
/*start talk
input:
pDev:     Camera Device
return 
0 success otherwise
error code
*/
int FC_StartTalk(CCameraDevice* pDev);
/*stop talk
input:
pDev:     Camera Device
return 
0 success otherwise
error code
*/
int FC_StopTalk(CCameraDevice* pDev);

/*Release talk
Release local talk session, havn't send stop message to server.
*/
int FC_ReleaseTalk();

/*start audio broadcast
input:
return 
0 success otherwise
error code
*/
int FC_StartAudioBroadcast();
/*start audio broadcast
input:
return 
0 success otherwise
error code
*/
int FC_StopAudioBroadcast(BOOL  bSendMsg=TRUE);

/*Enable audio
input:
return 
0 success otherwise
*/
int FC_EnableAudio(HWND HWnd, BOOL  bEnable);

/*---------------------------------------------------------------------
                         PTZ Control
----------------------------------------------------------------------*/
/*PTZ Action 
input:
HWnd:    surveillance handle
PtzCmd:  Ptz command
return 
0 success otherwise
error code
*/
int FC_PTZAction(HWND HWnd, char* PtzCmd);


/*---------------------------------------------------------------------
                        Record & Snapshot
----------------------------------------------------------------------*/
/*stop local record 
input:
HWND:     Window handle
pDev:     Camera Device
szRecFileName:     storage file path
return 
0 success otherwise
error code
*/
int FC_StartLocalRecord(HWND HWnd,char* szRecFileName);
/*stop local record 
input:
HWND:     Window handle
return 
0 success otherwise
error code
*/
int FC_StopLocalRecord(HWND HWnd);

int FC_FullWndDisp(HWND HWnd, BOOL bFullDisp);

/*Snapshot
input:
HWND:     Window handle
pDev:     Camera Device
szRecFileName:     storage file path
return 
0 success otherwise
error code
*/
int FC_Snapshot(HWND HWnd, char* szPicFileName);

/*---------------------------------------------------------------------
                        Query Record & Replay
----------------------------------------------------------------------*/
/*download record file
input:
pCameraDev: the download camera device
nType:download 0:platform,1:DVR or 2:alarm up file
szFilePath: the file path from record file search result
*/
int FC_DownloadRecFile(CCameraDevice* pCameraDev, S8* szFilePath, U32 nType, S8* szLocPath);

int FC_DVRFileDownloadCancel();

int FC_DownloadSpecificTimeRec(CCameraDevice* pCameraDev, U32 nStartTime, U32 nEndTime);

/*Query Record file
input:
pDev:     Camera Device
return 
0 success otherwise
error code
*/
int FC_QueryRecordFile(CCameraDevice* pDev, U32 beginTime, U32 endTime, U32 nStoreType, U32 nRecType, U32 nPage=0, U32 nMediaType=MEDIA_TYPE_ALL, U32 nStreamType=STREAM_TYPE_ALL);

int FC_QueryRecDistribution(CCameraDevice* pDev, U32 nDateTime);

/*---------------------------------------------------------------------
                      Search Alarm Recs
--------------------------------------------------------------------- */
/*Get alarm record count
*/
int FC_GetAlarmRecCount(S8 *pszDevId,U32 nStartTime, U32 nEndTime, U32 nSearchType);

/*
 input:
	pszDevId: the search camera device id
 output:
	lstAlarmInfo
 return:
	0 success otherwise
 */
int FC_SearchAlarmRec(S8 *pszDevId, std::list<SearchAlarmInfo_t>& lstAlarmInfo, U32 nStartTime, U32 nEndTime, U32 nSearchType, U32 nCount, U32 nStart);

/*-------------------------------------------------------------------------
                      Search GPS information
 -------------------------------------------------------------------------*/
/*
input:
	pszDevId: the search IPC device id
	nStartTime: begin time for search
	nEndTime: end time for search
output:
	lstGPSInfo
return: 
	0 success otherwise
*/
int FC_SearchGPSInfo(S8 *pszDevId, U32 nStartTime, U32 nEndTime, std::list<GPSTrackInfo_t>& lstGPSInfo);

/*
 *	refresh master device status
 */
int FC_RefreshMasterDevStatus();

int FC_SetFullDispMode(int nMode);

/*add patrol point
input:
patrolId: ID 1-36 window index
HWnd:     Window Handle for displaying
point:    patrol point
return 
0 success otherwise
error code
*/
int FC_AddPatrolPoint(U32 patrolId,HWND HWnd,PatrolPoint point);

/*delete patrol point
input:
patrolId:  1-36 window index
return 
0 success otherwise
error code
*/
int FC_DelPatrolPoint(U32 patrolId, PatrolPoint point);

/*start patrol
input:
patrolId:  1-36 window index
return 
0 success otherwise
error code
*/
int FC_StartPatrol(U32 patrolId);

/*stop patrol
input:
lstDev:     list point for patrol
return 
0 success otherwise
error code
*/
int FC_StopPatrol(U32 patrolId);

/*Save patrol information
input:
patrolId: 1-36 window index
strPatrolInfo: patrol information
*/
int FC_SavePatrolCfgInfo(U32 patrolId, char* strPatrolInfo);

/*Get patrol information
input:
patrolId: 1-36 window index
strPatrolInfo: patrol information
*/
int FC_GetPatrolCfgInfo(U32 patrolId, char* strPatrolInfo);

int FC_GetWndPatrolCamera(HWND hWnd, char* pDevId);

int FC_SaveTVWallPatrolInfo(S8 *pDecId, S8 *pCfgInfo);

int FC_GetTVWallPatrolCfgInfo(S8 *pDecId, S8 *pCfgInfo);

int FC_SetZoomRectOn(U32  nValue);

int FC_InputMouseEvent(HWND hWnd, LONG nMsgType,WPARAM wp,LPARAM lp);

#endif