#ifndef MS_IPC_SDK_H
#define MS_IPC_SDK_H

#ifdef WIN32//Windows

#ifdef MSIPCSDK_EXPORTS
#ifndef MSIPC_SDK
#define MSIPC_SDK __declspec(dllexport)
#endif//MSIPCSDK
#else
#ifndef MSIPC_SDK
#define MSIPC_SDK __declspec(dllimport)
#endif//MSIPCSDK
#endif//MSIPCSDK_EXPORTS

//#define __stdcall 
#define CALLBACK __stdcall

#define snprintf _snprintf
typedef unsigned char       BYTE;
typedef unsigned long       DWORD;
typedef long LONG;
typedef int                 BOOL;

#else //Linux

#endif//Platform


#ifdef __cplusplus
extern "C" {
#endif

//Type Define
//////////////////////////////////////////////////////////////////////////
#define MAX_SERIAL_LEN 32
#define MAX_IP_ADDRESS 32
#define MAX_MAC_ADDRESS 24//XX:XX:XX:XX:XX:XX
#define MAX_BUFFER_STRING 32
#define MAX_OSD_TEXT_LEN 32

#define MAX_USER_NUM 10

#define IPC_POS_TOP_LEFT		0
#define IPC_POS_TOP_RIGHT		1
#define IPC_POS_BOTTOM_LEFT     2
#define IPC_POS_BOTTOM_RIGHT	3

enum ErrorType{
	MS_IPC_SDK_NOERROR=	0,
	MS_IPC_SDK_NOTINIT=	1,//Not init SDK
	MS_IPC_SDK_SEARCH_NOT_FINISHED,//the last search is not finished
	MS_IPC_LOGIN_ERROR_UNUTHORIZED,//401 Unauthorized
	MS_IPC_SDK_NOLOGIN,
	MS_IPC_SDK_FAIL_CONNECT,
	MS_IPC_SDK_HTTP_PORT_INVALID,
	MS_IPC_SDK_USER_NO_PEMIT,	//Current User not permition
	MS_IPC_IPC_OPEN_FAIL,
	MS_IPC_NOT_OPEN,//Not Connect to Ipc Stream (RTSP URL)
	MS_IPC_NOT_PLAY_RECORD_FILE,
	MS_IPC_FIREWARE_NAME_INVALID,
	MS_IPC_LOGIN_ERROR_NOT_FOUND, //404 Not found
};

typedef struct {
	BYTE  		sSerialNumber[MAX_SERIAL_LEN];//摄像头出厂序列号
	BYTE 		byWifi;
	BYTE  		byReserve;
}Ms_Ipc_DeviceInfo, *LpMs_Ipc_DeviceInfo;

typedef struct
{
	char sIP[MAX_BUFFER_STRING*2];
	int nPort;
	char sMacAddr[MAX_BUFFER_STRING*2];
	char sName[MAX_BUFFER_STRING*4];
	char sModel[MAX_BUFFER_STRING];
}Ms_Ipc_Device;


enum WIFI_AUTH_MODE{
	IPC_WIFI_AUTH_NONE = 0,			//"None"
	IPC_WIFI_AUTH_WEP,				//"WEP:Shared or Open"
	//WIFI_AUTH_WEP_SHARE,		//"WEP/Shared"
	//WIFI_AUTH_WEP_OPEN,			//"WEP/Open"
	IPC_WIFI_AUTH_WPA,				//"WPA:TKIP or AES"
	//WIFI_AUTH_WPA_PSK_TKIP,		//"WPA PSK TKIP"
	//WIFI_AUTH_WPA_PSK_AES,		//"WPA PSK AES"
	IPC_WIFI_AUTH_WPA2,				//"WPA2:TKIP or AES"
	//WIFI_AUTH_WPA2_PSK_TKIP,	//"WPA2 PSK TKIP"
	//WIFI_AUTH_WPA2_PSK_AES,		//"WPA2 PSK AES"
	IPC_WIFI_AUTH_WPA_WPA2,			//"WPA/WPA2:AUTO or TKIP or AES"
};

enum WIFI_WORK_MODE{
	IPC_WIFI_WORK_AS_MANAGE=0,		//"manage / infrastructure"
	IPC_WIFI_WORK_AS_ADHOC,			//"ad-hoc"
};

enum WIFI_WEP_TYPE{
	IPC_WIFI_WEP_OPEN=0,			//"open"
	IPC_WIFI_WEP_SHARED,			//"shared"
};

enum WIFI_WEP_KEY_FORMAT{
	IPC_WIFI_WEP_HEX=0,				//"hex"
	IPC_WIFI_WEP_ASCII,				//"ascii"
};

enum WIFI_WEP_KEY_LENGTH{
	IPC_WIFI_WEP_64_BIT=0,			//"64bit"
	IPC_WIFI_WEP_128_BIT,			//"128bit"
};

enum WIFI_WPS_CONN_TYPE{
	IPC_WIFI_WPS_CONNBY_PIN=0,			//"pincode generated by ipc"
	IPC_WIFI_WPS_CONNBY_PBC,			//"pbc"
	IPC_WIFI_WPS_CONNBY_ROUTERPIN,		//"pincode generated by router"
};

typedef struct  
{
//	BYTE bEnableWifi; // [deprecated]
	char sSSID[MAX_BUFFER_STRING*2];
//	char sKey[MAX_BUFFER_STRING*2];			//[deprecated]
//	char sNetworkType[MAX_BUFFER_STRING];	//[deprecated]
	BYTE nWifiMode;		//WIFI_WORK_MODE
	BYTE nAuthMode;		//WIFI_AUTH_MODE
	//wep follow
	BYTE nWepType;		//WIFI_WEP_TYPE
	BYTE nWepKeyLen;	//WIFI_WEP_KEY_LENGTH
	BYTE nWepKeyFmt;	//WIFI_WEP_KEY_FORMAT
	BYTE nWepKeyIndex;	//0~3
	char sWepKey1[MAX_BUFFER_STRING];
	char sWepKey2[MAX_BUFFER_STRING];
	char sWepKey3[MAX_BUFFER_STRING];
	char sWepKey4[MAX_BUFFER_STRING];
	//wpa follow
	BYTE nWpaType;
	char sWpaKey[MAX_BUFFER_STRING*2];
	//wps follow
	BYTE nWpsEnable;
	char sWpsPinCode[MAX_BUFFER_STRING];
	int  nWpsConnType;//WIFI_WPS_CONN_TYPE
	char sWpsRouterSSID[MAX_BUFFER_STRING*2];
	char sWpsRouterPin[MAX_BUFFER_STRING];
	//configuration
	BYTE nEnableDhcp; //1:enable 0:disable
	char sWifiNIp[MAX_BUFFER_STRING];
	char sWifiNMask[MAX_BUFFER_STRING];
	char sWifiGateWay[MAX_BUFFER_STRING];
	char sWifiDNS[MAX_BUFFER_STRING];
//	int nDefaultKeyID; // [deprecated]
}Ms_Ipc_WifiInfo;

typedef struct Ms_Ipc_WifiList  
{
	int nSingalPercent;
	char sSSID[MAX_BUFFER_STRING*2];
	BYTE nWifiMode;//WIFI_WORK_MODE
	BYTE nAuthMode;//WIFI_AUTH_MODE
	int nSpeed;//Mbps
	int nChannelCnt;
//	int nDefaultKeyID; // [deprecated]
	struct Ms_Ipc_WifiList *pNext;
}Ms_Ipc_WifiList;

typedef struct  
{
	BYTE bDHCP;
	char sIP[MAX_IP_ADDRESS];
	char sNetmask[MAX_IP_ADDRESS];
	char sGateway[MAX_IP_ADDRESS];
	char sDNS[MAX_IP_ADDRESS];
	int nHttpPort;//[1,65535] // [deprecated]
	char sMacAddress[MAX_MAC_ADDRESS];//Only Get
}Ms_Ipc_Network;

typedef struct  
{
	char sSmtpName[MAX_BUFFER_STRING];
	char sSmtpSender[MAX_BUFFER_STRING*8];
	char sSmtpPassword[MAX_BUFFER_STRING/2];
	char sSmtpServer[MAX_BUFFER_STRING];
	int nSmtpServerPort;
	char sStmpReceiver[MAX_BUFFER_STRING*8];
	int nSmtpAuth; // 0:none 1:tls 2:ssl
}Ms_Ipc_SMTP;

typedef struct  
{
	char sFtpServer[MAX_BUFFER_STRING];
	int nFtpPort;
	char sFtpUserName[MAX_BUFFER_STRING];
	char sFtpPassword[MAX_BUFFER_STRING/2];
	char sFilePath[MAX_BUFFER_STRING*4];//"default_folder"
}Ms_Ipc_FTP;

typedef struct  
{
	BYTE bEnable;
	char sDdnsServer[MAX_BUFFER_STRING*2];
	char sDdnsUserName[MAX_BUFFER_STRING];
	char sDdnsPassword[MAX_BUFFER_STRING];
	char sDdnsHash[MAX_BUFFER_STRING*4];
	char sDdnsHostName[MAX_BUFFER_STRING*4];

	BYTE bPlnt;//special use
	BYTE nEasyMode;//special use, 0 or 1
	char sDeviceMacAddr[MAX_BUFFER_STRING];//special use, only read
}Ms_Ipc_DDNS;

typedef struct 
{
	BYTE bEnable;
	char szName[64];
	BYTE nType;
	int nHttpExtPort;
	int nHttpIntPort;
	BYTE nHttpStatus;
	int nRtspExtPort;
	int nRtspIntPort;
	BYTE nRtspStatus;
}Ms_Ipc_Upnp_PortMapping;

typedef struct  
{
	BYTE nType;//0:Manual;1:Ntp;2:computer;3:current time Based on timezone;//Set Only
	char sDate[MAX_BUFFER_STRING/2];//Format(Year/Month/Day)
	char sTime[MAX_BUFFER_STRING/2];//Format(Hour:Minute:Second)
	BYTE bDaylightSaving;//Daylight saving time
	char sNtpServer[MAX_BUFFER_STRING*2];
	int nTimeZone;//enum TIMEZONE
}Ms_Ipc_SystemDate;

enum TIMEZONE {
	TIME_ZONE_GMT_W11_Samoa = 0,//"-11 Samoa"
	TIME_ZONE_GMT_W10_Cook = 1,	//"-10 Cook Islands(Rarotonga)"
	TIME_ZONE_GMT_W10_Polynesia,//"-10 Tahiti"
	TIME_ZONE_GMT_W10_USA,		//"-10 United States - Hawaii-Aleutian"
	TIME_ZONE_GMT_W10_USA2,		//"-10 United States - Alaska-Aleutian"
	TIME_ZONE_GMT_W9_USA,		//"-9 United States - Alaska Time"
	TIME_ZONE_GMT_W8_CAN,		//"-8 Canada (Vancouver, Whitehorse)"
	TIME_ZONE_GMT_W8_MEX,		//"-8 Mexico (Tijuana, Mexicali)"
	TIME_ZONE_GMT_W8_USA,		//"-8 United States - Pacific Time"
	TIME_ZONE_GMT_W7_CAN,		//"-7 Canada (Edmonton, Calgary)"
	TIME_ZONE_GMT_W7_MEX,		//"-7 Mexico (Mazatlan, Chihuahua)"
	TIME_ZONE_GMT_W7_USA,		//"-7 United States - Mountain Time"
	TIME_ZONE_GMT_W6_CAN,		//"-6 Canada - Manitoba (Winnipeg)"
	TIME_ZONE_GMT_W6_CHL,		//"-6 Chile (Easter Islands)"
	TIME_ZONE_GMT_W6_MEX,		//"-6 Mexico (Mexico City, Acapulco)"
	TIME_ZONE_GMT_W6_USA,		//"-6 United States - Central Time"
	TIME_ZONE_GMT_W5_BHS,		//"-5 Bahamas (Nassau)"
	TIME_ZONE_GMT_W5_CAN,		//"-5 Canada (Montreal, Ottawa, Quebec)"
	TIME_ZONE_GMT_W5_CUB,		//"-5 Cuba (Havana)"
	TIME_ZONE_GMT_W5_USA,		//"-5 United States - Eastern Time"
	TIME_ZONE_GMT_W4_30_VEN,	//"-4.5 Venezuela (Caracas)"
	TIME_ZONE_GMT_W4_CAN,		//"-4 Canada (Halifax, Saint John)"
	TIME_ZONE_GMT_W4_CHL,		//"-4 Chile (Santiago)"
	TIME_ZONE_GMT_W4_PRY,		//"-4 Paraguay (Asuncion)"
	TIME_ZONE_GMT_W4_BMU,		//"-4 United Kingdom - Bermuda (Bermuda)"
	TIME_ZONE_GMT_W4_FLK,		//"-4 United Kingdom (Falkland Islands)"
	TIME_ZONE_GMT_W4_TTB,		//"-4 Trinidad&amp;Tobago"
	TIME_ZONE_GMT_W3_30_CAN,	//"-3.5 Canada - New Foundland (St. Johns)"
	TIME_ZONE_GMT_W3_GRL,		//"-3 Denmark - Greenland (Nuuk)"
	TIME_ZONE_GMT_W3_ARG,		//"-3 Argentina (Buenos Aires)"
	TIME_ZONE_GMT_W3_BRA2,		//"-3 Brazil (no DST)"
	TIME_ZONE_GMT_W3_BRA1,		//"-3 Brazil (DST)"
	TIME_ZONE_GMT_W2_BRA,		//"-2 Brazil (no DST)"
	TIME_ZONE_GMT_W1_PRT,		//"-1 Portugal (Azores)"
	TIME_ZONE_GMT_0_FRO,		//"0 Denmark - Faroe Islands (Torshavn)"
	TIME_ZONE_GMT_0_IRL,		//"0 Ireland (Dublin)"
	TIME_ZONE_GMT_0_PRT,		//"0 Portugal (Lisboa, Porto, Funchal)"
	TIME_ZONE_GMT_0_ESP,		//"0 Spain - Canary Islands (Las Palmas)"
	TIME_ZONE_GMT_0_GBR,		//"0 United Kingdom (London)"
	TIME_ZONE_GMT_E1_ALB,		//"1 Albania (Tirane)"
	TIME_ZONE_GMT_E1_AUT,		//"1 Austria (Vienna)"
	TIME_ZONE_GMT_E1_BEL,		//"1 Belgium (Brussels)"
	TIME_ZONE_GMT_E1_HRV,		//"1 Croatia (Zagreb)"
	TIME_ZONE_GMT_E1_CZE,		//"1 Czech Republic (Prague)"
	TIME_ZONE_GMT_E1_DNK,		//"1 Denmark (Copenhagen)"
	TIME_ZONE_GMT_E1_FRA,		//"1 France (Nice, Paris)"
	TIME_ZONE_GMT_E1_GER,		//"1 Germany (Berlin)"
	TIME_ZONE_GMT_E1_HUN,		//"1 Hungary (Budapest)"
	TIME_ZONE_GMT_E1_ITA,		//"1 Italy (Rome)"
	TIME_ZONE_GMT_E1_LUX,		//"1 Luxembourg (Luxembourg)"
	TIME_ZONE_GMT_E1_MAK,		//"1 Makedonia (Skopje)"
	TIME_ZONE_GMT_E1_NLD,		//"1 Netherlands (Amsterdam)"
	TIME_ZONE_GMT_E1_NAM,		//"1 Namibia (Windhoek)"
	TIME_ZONE_GMT_E1_NOR,		//"1 Norway (Oslo)"
	TIME_ZONE_GMT_E1_POL,		//"1 Poland (Warsaw)"
	TIME_ZONE_GMT_E1_SVK,		//"1 Slovak Republic (Bratislava)"
	TIME_ZONE_GMT_E1_ESP,		//"1 Spain (Madrid, Palma)"
	TIME_ZONE_GMT_E1_SWE,		//"1 Sweden (Stockholm)"
	TIME_ZONE_GMT_E1_CHE,		//"1 Swiss ( Bern, Zurich)"
	TIME_ZONE_GMT_E1_GIB,		//"1 United Kingdom (Gibraltar)"
	TIME_ZONE_GMT_E1_YUG,		//"1 Serbia (Beograd)"
	TIME_ZONE_GMT_E1_WAT,		//"1 West Africa Time"
	TIME_ZONE_GMT_E2_BLR,		//"2 Belarus (Minsk)"
	TIME_ZONE_GMT_E2_BGR,		//"2 Bulgaria (Sofia)"
	TIME_ZONE_GMT_E2_CYP,		//"2 Cyprus (Nicosia)"
	TIME_ZONE_GMT_E2_CAT,		//"2 Central Africa Time"
	TIME_ZONE_GMT_E2_EGY,		//"2 Egypt (Cairo)"
	TIME_ZONE_GMT_E2_EST,		//"2 Estonia (Tallinn)"
	TIME_ZONE_GMT_E2_FIN,		//"2 Finland (Helsinki)"
	TIME_ZONE_GMT_E2_GAZ,		//"2 Gaza Strip (Gaza)"
	TIME_ZONE_GMT_E2_GRC,		//"2 Greece (Athens)"
	TIME_ZONE_GMT_E2_ISR,		//"2 Israel (Jerusalem, Tel Aviv)"
	TIME_ZONE_GMT_E2_JOR,		//"2 Jordan (Amman)"
	TIME_ZONE_GMT_E2_LVA,		//"2 Latvia (Riga)"
	TIME_ZONE_GMT_E2_LBN,		//"2 Lebanon (Beirut)"
	TIME_ZONE_GMT_E2_MDA,		//"2 Moldova (Chisinau)"
	TIME_ZONE_GMT_E2_RUS,		//"2 Russia (Kaliningrad)"
	TIME_ZONE_GMT_E2_ROU,		//"2 Romania (Bucharest)"
	TIME_ZONE_GMT_E2_SYR,		//"2 Syria (Damascus)"
	TIME_ZONE_GMT_E2_TUR,		//"2 Turkey (Ankara, Istanbul)"
	TIME_ZONE_GMT_E2_UKR,		//"2 Ukraine (Kyiv, Odessa)"
	TIME_ZONE_GMT_E3_EAT,		//"3 East Africa Time"
	TIME_ZONE_GMT_E3_IRQ,		//"3 Iraq (Baghdad)"
	TIME_ZONE_GMT_E3_RUS,		//"3 Russia (Moscow)"
	TIME_ZONE_GMT_E3_30_IRN,	//"3.5 Iran (Teheran)"
	TIME_ZONE_GMT_E4_ARM,		//"4 Armenia (Yerevan)"
	TIME_ZONE_GMT_E4_AZE,		//"4 Azerbaijan (Baku)"
	TIME_ZONE_GMT_E4_GEO,		//"4 Georgia (Tbilisi)"
	TIME_ZONE_GMT_E4_RUS,		//"4 Russia (Samara)"
	TIME_ZONE_GMT_E4_UAE,		//"4 United Arab Emirates (Dubai)"
	TIME_ZONE_GMT_E5_KAZ1,		//"5 Kazakstan (Aqtau)"
	TIME_ZONE_GMT_E5_KAZ,		//"5 Kazakstan (Aqtobe)"
	TIME_ZONE_GMT_E5_PAK,		//"5 Pakistan (Islamabad)"
	TIME_ZONE_GMT_E5_RUS,		//"5 Russia (Chelyabinsk, Yekaterinburg)"
	TIME_ZONE_GMT_E5_30_IND,	//"5.5 India (Calcutta)"
	TIME_ZONE_GMT_E6_KAZ,		//"6 Kazakstan (Astana, Almaty)"
	TIME_ZONE_GMT_E6_KGZ,		//"6 Kyrgyzstan (Bishkek)"
	TIME_ZONE_GMT_E6_RUS,		//"6 Russia (Novosibirsk, Omsk)"
	TIME_ZONE_GMT_E7_RUS,		//"7 Russia (Krasnoyarsk)"
	TIME_ZONE_GMT_E7_THA,		//"7 Thailand (Bangkok)"
	TIME_ZONE_GMT_E8_CHN,		//"8 China (Beijing, Taipei)"
	TIME_ZONE_GMT_E8_SGP,		//"8 Singapore (Singapore)"
	TIME_ZONE_GMT_E8_AUS,		//"8 Australia (Perth)"
	TIME_ZONE_GMT_E9_KOR,		//"9 Korea (Seoul)"
	TIME_ZONE_GMT_E9_JPN,		//"9 Japan (Tokyo)"
	TIME_ZONE_GMT_E9_30_AUS,	//"9.5 Australia (Adelaide)"
	TIME_ZONE_GMT_E9_30_AUS2,	//"9.5 Australia (Darwin)"
	TIME_ZONE_GMT_E10_AUS,		//"10 Australia (Sydney, Melbourne, Canberra)"
	TIME_ZONE_GMT_E10_AUS2,		//"10 Australia (Brisbane)"
	TIME_ZONE_GMT_E10_AUS3,		//"10 Australia (Hobart)"
	TIME_ZONE_GMT_E10_RUS,		//"10 Russia (Vladivostok)"
	TIME_ZONE_GMT_E10_30_AUS,	//"10.5_Australia (Lord Howe Islands)"
	TIME_ZONE_GMT_E11_NCL,		//"11 New Caledonia (Noumea)"
	TIME_ZONE_GMT_E12_NZL,		//"12 New Zealand (Wellington, Auckland)"
	TIME_ZONE_GMT_E12_RUS,		//"12 Russia (Anadyr, Kamchatka)"
	TIME_ZONE_GMT_E12_45_NZL,	//"12.75 New Zealand (Chatham Islands)"
	TIME_ZONE_GMT_E13_TON,		//"13 Tonga (Nukualofa)"
};

typedef struct  
{
	char sDeviceName[32];
	char sModel[MAX_BUFFER_STRING/2];
	char sSoftwareVersion[MAX_BUFFER_STRING/2];
	char sHardwareVersion[MAX_BUFFER_STRING/2];
}Ms_Ipc_SystemInfo;

typedef struct  
{
	char sUserName[MAX_BUFFER_STRING];
	char sPassword[MAX_BUFFER_STRING/2];
	BYTE nUserType;//0:admin;1:Operator;2:Viewer;9:None
}Ms_Ipc_UserInfo;

enum PTZ
{
	IPC_PTZ_DIR_TOP,
	IPC_PTZ_DIR_BOTTOM,
	IPC_PTZ_DIR_LEFT,
	IPC_PTZ_DIR_RIGHT,
	IPC_PTZ_DIR_TOPLEFT,
	IPC_PTZ_DIR_TOPRIGHT,
	IPC_PTZ_DIR_BOTTOMLEFT,
	IPC_PTZ_DIR_BOTTOMRIGHT,
	
	IPC_PTZ_AUTO_SCAN,
	IPC_PTZ_DIR_STOP,

	IPC_PTZ_ZOOM_IN,
	IPC_PTZ_ZOOM_OUT,
	IPC_PTZ_FOCUS_IN,
	IPC_PTZ_FOCUS_OUT,
	IPC_PTZ_IRIS_IN,
	IPC_PTZ_IRIS_OUT,
	IPC_PTZ_LIGHT_OFF,
	IPC_PTZ_LIGHT_ON,
	IPC_PTZ_BRUSH_OFF,
	IPC_PTZ_BRUSH_ON,

	IPC_PTZ_AUTO_FOCUS,

	//IPC_PTZ_SET_BRIGHTNESS,
	//IPC_PTZ_SET_CONTRAST,
	//IPC_PTZ_SET_SUTIRATION,
};

typedef struct  
{
	BYTE nProtocol;//0,Pelco-D;1,Pelco-P
	DWORD dwBaudRate;//2400,4800,9600,19200
}Ms_Ipc_PTZ;

enum OSD_DATE_FORMAT
{
	IPC_OSD_DATE_YYYYMMDD = 0,
	IPC_OSD_DATE_MMDDYYYY,
	IPC_OSD_DATE_DDMMYYYY,
};
enum OSD_POSITION
{
	IPC_OSD_POS_TOPLEFT = IPC_POS_TOP_LEFT,
	IPC_OSD_POS_TOPRIGHT = IPC_POS_TOP_RIGHT,
	IPC_OSD_POS_BOTTOMLEFT = IPC_POS_BOTTOM_LEFT,
	IPC_OSD_POS_BOTTOMRIGHT = IPC_POS_BOTTOM_RIGHT,
};

typedef struct  
{
	BYTE bDisplayText;
	BYTE bDisplayDate;
	char sText[MAX_OSD_TEXT_LEN*3];
	BYTE nTextPos;//OSD_POSITION
	BYTE nDatePos;//OSD_POSITION
	BYTE nDateFormat;//OSD_DATE_FORMAT(0:YYYY-MM-DD,1:MM/DD/YYYY,2:DD/MM/YYYY)
}Ms_Ipc_OSD;

enum VIDEO_ENCODING_TYPE
{
	IPC_VIDEO_ENCODING_H264 = 0,
	IPC_VIDEO_ENCODING_MPEG4,
	IPC_VIDEO_ENCODING_JPEG,
	IPC_VIDEO_ENCODING_H265,

	IPC_VIDEO_ENCODING_LAST_XX, // Add new type before this value
};

enum VIDEO_MAIN_RESOLUTION_TYPE
{
	//Main Stream
	IPC_RESOLUTION_5M = 0,
	IPC_RESOLUTION_4M, // 2015.10.19 added
	IPC_RESOLUTION_3M,
	IPC_RESOLUTION_1080P,
	IPC_RESOLUTION_2M,
	IPC_RESOLUTION_1_3M,//1.3M
	IPC_RESOLUTION_720P,
	IPC_RESOLUTION_D1,
};
enum VIDEO_SUB_RESOLUTION_TYPE
{
	//Sub Stream
	IPC_RESOLUTION_704_576 = 0, // 2015.10.19 added
	IPC_RESOLUTION_640_480,
	IPC_RESOLUTION_640_360,
	IPC_RESOLUTION_352_288,
	IPC_RESOLUTION_320_240,
	IPC_RESOLUTION_320_192,
	IPC_RESOLUTION_320_176,
};
enum VIDEO_THIRD_RESOLUTION_TYPE
{// 2015.10.19 added
	//Third Stream
	IPC_RES_THIRD_1280_720 = 0,
	IPC_RES_THIRD_704_576,
	IPC_RES_THIRD_640_480,
	IPC_RES_THIRD_640_360,
	IPC_RES_THIRD_320_240,
	IPC_RES_THIRD_320_192,
	IPC_RES_THIRD_320_176,
};

typedef struct  
{
	BYTE nStreamIndex; // STREAM_TYPE
	BYTE bEnableSubStream;
	BYTE bEnableThirdStream;
	BYTE nCodecType;//VIDEO_ENCODING_TYPE
//	int nResolution;// [Deprecated 2015.10.20] VIDEO_MAIN_RESOLUTION_TYPE / VIDEO_SUB_RESOLUTION_TYPE / VIDEO_THIRD_RESOLUTION_TYPE
	int nMaxFrameRate;
	int nBitRate;
	BYTE nBitRateControl;//0,CBR(Constants Bit Rate);1,VBR(Variable Bit Rate)
	int nIFrameInterval;
	int nRtspPort;
	int nResWidth;
	int nResHeight;
}Ms_Ipc_VideoConfig;

enum AUDIO_ENCODING_TYPE
{
	IPC_AUDIO_ENCODING_G711_ULAW = 0,
	IPC_AUDIO_ENCODING_G711_ALAW,
	IPC_AUDIO_ENCODING_AAC_LC,
};

typedef struct  
{
	BYTE bEnableAudio;
	BYTE nAudioMode;//0,Only Mic;1,Only Speaker;2,Both
	int nInputGain;//(0,100)
	int nAlarmLevel;//(1,100)
	int nOutputVolume;//(0,100)
	BYTE bDenoiseEnable;//1:enable	0:disable
	int nEncoding;	//AUDIO_ENCODING_TYPE
	//[Reserve]
	int nSampleRate;
	int nAudioBitRate;
}Ms_Ipc_AudioConfig;

typedef struct  
{
	int nHour;
	int nMinute;
	int nSecond;//[deprecated]
}Ms_Ipc_Time;

typedef struct  
{
	BYTE bBackLightCompensation;
	BYTE nBackLightRegion;
	int nFlickerControl;//50HZ, 60HZ
	BYTE nIRCUTMode;//0,Night;1,Day;2,Auto;3,Customize
	Ms_Ipc_Time custimeStartTime;
	Ms_Ipc_Time custimeStopTime;
	BYTE nLocalDisplay;
	BYTE nMirror;//0,Normal;1,Flip Horizontal;2,Flip Vertical;3,Rotating 180°
	BYTE bNoiseSpaceReduction; // [deprecated]
	BYTE bNoiseTemporalReduction; // [deprecated]
	BYTE bIsWideDynamic;
	BYTE bOutInDoorMode;
	BYTE bExposureLevel;
	BYTE bExposureTime;
}Ms_Ipc_ImagingConfig;

typedef struct  
{
	int nBrightness;	//(0,100)
	int nContrast;		//(0,100)
	int nSaturation;	//(0,100)
	int nSharpness;		//(0,100)
	int nFLevel;		//(0,100)降噪等级
}Ms_Ipc_ImagingSettings;

enum RTSP_PROTOCOL
{
	IPC_RTSP_PROTOCOL_UDP = 0,
	IPC_RTSP_PROTOCOL_TCP = 1,
	IPC_RTSP_PROTOCOL_HTTP,
};

enum STREAM_TYPE
{
	IPC_STREAM_TYPE_MAIN = 0,
	IPC_STREAM_TYPE_SUB,
	IPC_STREAM_TYPE_THIRD,
};

typedef struct  
{
	BYTE nProtocol;//0,UDP;1,TCP;2,HTTP
	BYTE nDisplayStream;//0,Main Stream;1,Sub Stream
	HWND hPlayWnd;
	char sMultiCastIP[MAX_BUFFER_STRING];
}Ms_Ipc_ClientInfo,*LpMs_Ipc_ClientInfo;

enum SCHEDULE_TYPE
{
	// record
	IPC_SCHEDULE_TYPE_RECORD_SD = 0,
	IPC_SCHEDULE_TYPE_RECORD_NAS = 1,
	// alarm
	IPC_SCHEDULE_TYPE_MOTION = 2,
	IPC_SCHEDULE_TYPE_AUDIO_IN = 3,
	IPC_SCHEDULE_TYPE_DI = 4,
	IPC_SCHEDULE_TYPE_DO = 5,
	IPC_SCHEDULE_TYPE_PIR = 6,
	// other
	IPC_SCHEDULE_TYPE_RECORD_SNAPSHOT = 7,
	IPC_SCHEDULE_TYPE_SIP_CALLOUT = 8,		// not used
};

typedef struct  
{
	BYTE bEnable;
	BYTE nWeekDay;//(1:Mon 2:Tue 3:Wed 4:Thr 5:Fri 6:Sat 7:Sun 8:Everyday)
	Ms_Ipc_Time tStart[4];
	Ms_Ipc_Time tStop[4];//start and stop must be in the same day.stop hour must be more than start hour
}Ms_Ipc_Schedule;

typedef struct  
{
	BYTE nScheduleType;			// SCHEDULE_TYPE
	Ms_Ipc_Schedule schedule[7];// you must set schedule. Index 0:Sunday  1~6:Mon to Sat
}Ms_Ipc_Schedule_Week;

#define MOTION_MAP_ROW_CNT	13
#define MOTION_MAP_COL_CNT	23
typedef struct  
{
	BYTE bEnable;
	BYTE nLevel; // Sensitivity
	BYTE nMotionBlock[3];//4*3block		 [deprecated], see szMotionMap
	Ms_Ipc_Schedule motionSchedule[7];// you must set schedule. Index 0:Sunday

	char szMotionMap[MOTION_MAP_ROW_CNT][MOTION_MAP_COL_CNT];// 13*23, row by row, 23 per row
}Ms_Ipc_MotionConfig;

enum ALARM_DURATION_LEVEL
{
	IPC_ALARM_DURATION_LEVEL_10 = 0, //10 seconds
	IPC_ALARM_DURATION_LEVEL_30,
	IPC_ALARM_DURATION_LEVEL_60,
	IPC_ALARM_DURATION_LEVEL_300,
	IPC_ALARM_DURATION_LEVEL_600,
//	IPC_ALARM_DURATION_LEVEL_NON_STOP,	//Alarm all the time. [deprecated]
};

typedef struct  
{
	Ms_Ipc_MotionConfig *pMotionConfig;
	BYTE bNetworkLostAlarm;		// 0 or 1
	BYTE bAudioInputAlarm;		// 0 or 1
	BYTE bExternalInputAlarm;	// (I/O) 0 or 1
	BYTE nAlarmDuration;		// ALARM_DURATION_LEVEL
	BYTE nPIR;	// only ti cube, 0 or 1

	BYTE bTampering;	// only mini, 0 or 1
	BYTE bIpAddrConflict;		// 0 or 1, only a5s now
	BYTE nExtInput; // 0 or 1 (Low or High)
	BYTE nExtInputCurrentStatus; // 0 or 1, only read

	Ms_Ipc_Schedule_Week *pScheduleWeek;
}Ms_Ipc_AlarmEvent;

/////////////////////////////////////////////
// Alarm Action
typedef struct  
{
	BYTE bUploadToFtp;
	BYTE bUploadToSmtp;
	BYTE bUploadSdCard;//ftp,smtp,sd file format is avi.
	BYTE bExternalOutput;
	BYTE bPlayAudio;
	BYTE nAudioFile;//0 or 1
	BYTE bVoiceToSip;//0 or 1
	BYTE bHttpNotification;//0 or 1

	BYTE bUploadToNas;
	BYTE nNasFormat;
	BYTE nFtpFormat;
	BYTE nSmtpFormat;
	BYTE nSDFormat;
	BYTE nExtOutput; // 0 or 1 (Grounded or Open)
	BYTE nExtOutputCurrentStatus;
	BYTE bPlayBuzzer; // only mini
	char szHttpUser[32];
	char szHttpPassword[32];
	char szHttpMsg[1024];	
}Ms_Ipc_AlarmAction;

////////////////////////////////////////////
// Alarm Setting
enum ALAM_RECORD_TIME_LEVEL
{
	IPC_ALAM_RECORD_TIME_LEVEL_5 = 0,
	IPC_ALAM_RECORD_TIME_LEVEL_10,
	IPC_ALAM_RECORD_TIME_LEVEL_15,
	IPC_ALAM_RECORD_TIME_LEVEL_20,
	IPC_ALAM_RECORD_TIME_LEVEL_25,
	IPC_ALAM_RECORD_TIME_LEVEL_30,
};

enum ALAM_PRE_RECORD_TIME_LEVEL
{
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_0 = 0,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_1,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_2,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_3,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_4,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_5,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_6,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_7,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_8,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_9,
	IPC_ALAM_PRE_RECORD_TIME_LEVEL_10,
};

enum ALAM_SNAPSHOT_COUNT
{
	IPC_ALAM_SNAPSHOT_COUNT_1 = 1,
	IPC_ALAM_SNAPSHOT_COUNT_2,
	IPC_ALAM_SNAPSHOT_COUNT_3,
	IPC_ALAM_SNAPSHOT_COUNT_4,
	IPC_ALAM_SNAPSHOT_COUNT_5,
};

enum ALAM_SNAPSHOT_UNIT
{
	IPC_ALAM_SNAPSHOT_UNIT_MILLISEC = 0,	// ms
	IPC_ALAM_SNAPSHOT_UNIT_SECOND,			// s
};

typedef struct
{
	BYTE nAlarmDurationSec;		// ALARM_DURATION_LEVEL			seconds
	BYTE nAviDurationSec;		// ALAM_RECORD_TIME_LEVEL		seconds
	BYTE nAlarmPrecordSec;		// ALAM_PRE_RECORD_TIME_LEVEL	seconds
	BYTE nSnapCount;			// ALAM_SNAPSHOT_COUNT
	int nSnapInterval;
	BYTE nSnapUnit;				// ALAM_SNAPSHOT_UNIT
	BYTE nJPGStream;			// STREAM_TYPE					[reserve]
}Ms_Ipc_AlarmSetting;

//Alarm Type
enum ALARM_EVENT_TYPE
{
	IPC_ALARM_EVENT_TYPE_MOTION = 0,
	IPC_ALARM_EVENT_TYPE_NETWORK_LOST = 1,
	IPC_ALARM_EVENT_TYPE_AUDIO_IN = 2,
	IPC_ALARM_EVENT_TYPE_DINPUT = 3,	// External Input
	IPC_ALARM_EVENT_TYPE_TAMPER = 4,
	IPC_ALARM_EVENT_TYPE_PIR = 5,
	IPC_ALARM_EVENT_TYPE_IP_CONFLICT = 6,
};

typedef struct  
{
	BYTE bEnable;
	Ms_Ipc_AlarmEvent alarmEvent;
	Ms_Ipc_AlarmAction alarmAction;
	Ms_Ipc_AlarmSetting alarmSettings;
	
	BYTE nAlarmType;			// ALARM_EVENT_TYPE
}Ms_Ipc_Alarm;

//////////////////////////////////////////////
enum MASK_TYPE
{
	IPC_MASK_TYPE_WHITE = 0,
	IPC_MASK_TYPE_BLACK,
	IPC_MASK_TYPE_BLACK_WHITE_MOSAIC,
	IPC_MASK_TYPE_BLUE = IPC_MASK_TYPE_BLACK_WHITE_MOSAIC,
};

typedef struct
{
	BYTE nMaskEnable;
	int nMaskLeft;		// means left for ti, percent of left.x for others
	int nMaskTop;		// means top for ti, percent of top.y for others
	int	nMaskRight;		// means right for ti, percent of width for others
	int	nMaskBottom;	// means bottom for ti, percent of height for others
	BYTE nMaskType;//MASK_TYPE
}Mask_Config;

typedef struct  
{
	BYTE bEnable;
	Mask_Config maskConfig[4];
}Ms_Ipc_Mask;

typedef struct  
{
	BYTE nSdStatus;//0,not insert sd card;1,insert but not mount;2,active
	DWORD dwSdVolume;//(KByte)
	DWORD dwSdFreeSpace;//(KByte)
}Ms_Ipc_SdCard;

typedef struct  
{
	int nHttpPort;
	int nOnvifPort; // [deprecated]
	int nMainRtspPort;
	int nSubRtspPort; // [deprecated]
	int nOtherPort;
}Ms_Ipc_Port;

// Record Setting
enum RECORD_TYPE{
	IPC_RECORD_TYPE_NAS = 0,
	IPC_RECORD_TYPE_SD,
};

enum RECORD_FRAME_TYPE{
	IPC_RECORD_FRAME_TYPE_ALL = 0,
	IPC_RECORD_FRAME_TYPE_KEY,
};

typedef struct
{
	int nStorageType;		// RECORD_TYPE
	int nSdFileSize;		// 10 ~ 256 (MB)
	int nSdFrameType;		// RECORD_FRAME_TYPE
	int nNasFileSize;		// 10 ~ 256 (MB)
	int nNasFrameType;		// RECORD_FRAME_TYPE
}Ms_Ipc_Record_Config;
//////////////////////////////////////////////////////////////////////////

//SDK Interface Function
//////////////////////////////////////////////////////////////////////////
//SDK Initialization
MSIPC_SDK LONG __stdcall Ms_Sdk_Init();
//SDK Clean Up
MSIPC_SDK void __stdcall Ms_Sdk_Destroy();
//Other Functions
MSIPC_SDK DWORD __stdcall Ms_Sdk_GetLastError();
MSIPC_SDK LONG __stdcall Ms_Sdk_SearchIpc(void (CALLBACK *fSearchCallBack)(Ms_Ipc_Device *pDevice, void *pUser), void *pUser);

MSIPC_SDK LONG __stdcall Ms_Ipc_Login(char *sCameraName, char *sIpcIP, int nPort, char *sUserName, char *sPassword, LpMs_Ipc_DeviceInfo lpDeviceInfo);
MSIPC_SDK LONG __stdcall Ms_Ipc_Logout(LONG nUserId);
//////////////////////////////////////////////////////////////////////////

//Parameter Settings
//////////////////////////////////////////////////////////////////////////
//Network
MSIPC_SDK LONG __stdcall Ms_Ipc_GetNetwork(LONG nUserId, Ms_Ipc_Network *pNetwork);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetNetwork(LONG nUserId, Ms_Ipc_Network *pNetwork);
MSIPC_SDK LONG __stdcall Ms_Ipc_SearchWifiList(LONG nUserId, Ms_Ipc_WifiList *pWifiList);
MSIPC_SDK LONG __stdcall Ms_Ipc_GetWifiInfo(LONG nUserId, Ms_Ipc_WifiInfo *pNetwork);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetWifiInfo(LONG nUserId, Ms_Ipc_WifiInfo *pNetwork);

MSIPC_SDK LONG __stdcall Ms_Ipc_GetDDNS(LONG nUserId, Ms_Ipc_DDNS *pDdns);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetDDNS(LONG nUserId, Ms_Ipc_DDNS *pDdns);

MSIPC_SDK LONG __stdcall Ms_Ipc_GetSMTP(LONG nUserId, Ms_Ipc_SMTP *pSmtp);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetSMTP(LONG nUserId, Ms_Ipc_SMTP *pSmtp);

MSIPC_SDK LONG __stdcall Ms_Ipc_GetFTP(LONG nUserId, Ms_Ipc_FTP *pFtp);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetFTP(LONG nUserId, Ms_Ipc_FTP *pFtp);

//UPNP
MSIPC_SDK BOOL __stdcall Ms_Ipc_IsUpnpEnable(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetUpnpEnable(LONG nUserId, BOOL bEnable);

MSIPC_SDK LONG __stdcall Ms_Ipc_GetUpnpPortMapping(LONG nUserId, Ms_Ipc_Upnp_PortMapping *pUpnpInfo);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetUpnpPortMapping(LONG nUserId, Ms_Ipc_Upnp_PortMapping *pUpnpInfo);

//////////////////////////////////////////////////////////////////////////
//System Settings
MSIPC_SDK LONG __stdcall Ms_Ipc_GetSystemDate(LONG nUserId, Ms_Ipc_SystemDate *pSystemDate);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetSystemDate(LONG nUserId, Ms_Ipc_SystemDate *pSystemDate);

MSIPC_SDK LONG __stdcall Ms_Ipc_GetSystemInfo(LONG nUserId, Ms_Ipc_SystemInfo *pSystemInfo);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetDeviceName(LONG nUserId, char *sDeviceName);
MSIPC_SDK LONG __stdcall Ms_Ipc_RebootSystem(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_Ipc_RestoreSystem(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_Ipc_UploadOemConfigFile(LONG nUserId, char *sFilePath);
MSIPC_SDK LONG __stdcall Ms_Ipc_EraseOemConfig(LONG nUserId);

//////////////////////////////////////////////////////////////////////////
//User Settings
MSIPC_SDK LONG __stdcall Ms_Ipc_GetUserType(LONG nUserId, char *sUserName);
MSIPC_SDK LONG __stdcall Ms_Ipc_AddUser(LONG nUserId, Ms_Ipc_UserInfo *pNewUserInfo);
MSIPC_SDK LONG __stdcall Ms_Ipc_DeleteUser(LONG nUserId, char *sUserName);
MSIPC_SDK LONG __stdcall Ms_Ipc_ModifyPassword(LONG nUserId, char *sUserName, char *sNewPassword);
MSIPC_SDK LONG __stdcall Ms_Ipc_GetAllUser(LONG nUserId, Ms_Ipc_UserInfo ipcUserInfo[MAX_USER_NUM]);
//////////////////////////////////////////////////////////////////////////
//PTZ Settings
MSIPC_SDK LONG __stdcall Ms_Ipc_GetPTZ(LONG nUserId, Ms_Ipc_PTZ *pPtz);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetPTZ(LONG nUserId, Ms_Ipc_PTZ *pPtz);

MSIPC_SDK LONG __stdcall Ms_Ipc_PTZControl(LONG nUserId, DWORD dwCommand, DWORD dwSpeed=-1);

//////////////////////////////////////////////////////////////////////////
//Media:Video Settings(OSD,MAIN/SUB STREAMER)
MSIPC_SDK LONG __stdcall Ms_Ipc_GetOSD(LONG nUserId, Ms_Ipc_OSD *pOsd);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetOSD(LONG nUserId, Ms_Ipc_OSD *pOsd);

MSIPC_SDK LONG __stdcall Ms_Ipc_GetVideoConfig(LONG nUserId, Ms_Ipc_VideoConfig *pVideoConfig);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetVideoConfig(LONG nUserId, Ms_Ipc_VideoConfig *pVideoConfig);

//////////////////////////////////////////////////////////////////////////
//Media:Audio Settings
MSIPC_SDK LONG __stdcall Ms_Ipc_GetAudioConfig(LONG nUserId, Ms_Ipc_AudioConfig *pAudioConfig);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetAudioConfig(LONG nUserId, Ms_Ipc_AudioConfig *pAudioConfig);

//////////////////////////////////////////////////////////////////////////
//Media:CMOS(IMAGE) Settings(Brightness....)
MSIPC_SDK LONG __stdcall Ms_Ipc_GetImagingConfig(LONG nUserId, Ms_Ipc_ImagingConfig *pImagingConfig);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetImagingConfig(LONG nUserId, Ms_Ipc_ImagingConfig *pImagingConfig);

MSIPC_SDK LONG __stdcall Ms_Ipc_GetImagingSettings(LONG nUserId, Ms_Ipc_ImagingSettings *pImagingSetting);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetImagingSettings(LONG nUserId, Ms_Ipc_ImagingSettings *pImagingSetting);
//////////////////////////////////////////////////////////////////////////
//Event:Alaram
MSIPC_SDK LONG __stdcall Ms_Ipc_GetAlarmConfig(LONG nUserId, Ms_Ipc_Alarm *pAlarmConfig); // Set Type First
MSIPC_SDK LONG __stdcall Ms_Ipc_SetAlarmConfig(LONG nUserId, Ms_Ipc_Alarm *pAlarmConfig);
MSIPC_SDK LONG __stdcall Ms_Ipc_GetMotionConifg(LONG nUserId, Ms_Ipc_MotionConfig *pMotionConfig);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetMotionConifg(LONG nUserId, Ms_Ipc_MotionConfig *pMotionConfig);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetAlarmCallBack(LONG nUserId, void (CALLBACK *fAlarmCallBack)(DWORD dwType, void *pUser), void *pUser);//FLG_UI_MOTION

//////////////////////////////////////////////////////////////////////////
//Other:Privacy Mask
MSIPC_SDK LONG __stdcall Ms_Ipc_GetPrivacyMask(LONG nUserId, Ms_Ipc_Mask *pMask);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetPrivacyMask(LONG nUserId, Ms_Ipc_Mask *pMask);
MSIPC_SDK LONG __stdcall Ms_Ipc_GetPrivacyMaskConfig(LONG nUserId, int nRegion, Mask_Config *pMaskConfig);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetPrivacyMaskConfig(LONG nUserId, int nRegion, Mask_Config *pMaskConfig);

//////////////////////////////////////////////////////////////////////////
//Other:SD Card
MSIPC_SDK LONG __stdcall Ms_Ipc_GetSdCardInfo(LONG nUserId, Ms_Ipc_SdCard *pSdCard);
MSIPC_SDK LONG __stdcall Ms_Ipc_MountSdCard(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_Ipc_UnMountSdCard(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_Ipc_FormatSdCard(LONG nUserId);

//////////////////////////////////////////////////////////////////////////
//Firmware Upgrate
MSIPC_SDK LONG __stdcall Ms_Ipc_UpdateFirmware(LONG nUserId, char *sFilePath);
MSIPC_SDK LONG __stdcall Ms_Ipc_UpdateKernal(LONG nUserId, char *sFilePath);
//////////////////////////////////////////////////////////////////////////
//DBFileDownload
MSIPC_SDK LONG __stdcall Ms_Ipc_DownloadLog(LONG nUserId, char *sFilePath);
MSIPC_SDK LONG __stdcall Ms_Ipc_DownloadCfg(LONG nUserId, char *sFilePath);
MSIPC_SDK LONG __stdcall Ms_Ipc_DownloadCustom(LONG nUserId, char *sFilePath, int nFileType, char *sFileName);
//////////////////////////////////////////////////////////////////////////
//Port
MSIPC_SDK LONG __stdcall Ms_Ipc_GetPortInfo(LONG nUserId, Ms_Ipc_Port *pPortInfo);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetPortInfo(LONG nUserId, Ms_Ipc_Port *pPortInfo);

//////////////////////////////////////////////////////////////////////////
//Schedule
MSIPC_SDK LONG __stdcall Ms_Ipc_GetSchedule(LONG nUserId, Ms_Ipc_Schedule_Week *pSchedule); // must set schedule type
MSIPC_SDK LONG __stdcall Ms_Ipc_SetSchedule(LONG nUserId, Ms_Ipc_Schedule_Week *pSchedule); // must set schedule type

//////////////////////////////////////////////////////////////////////////
//Record
MSIPC_SDK LONG __stdcall Ms_Ipc_GetRecordConfig(LONG nUserId, Ms_Ipc_Record_Config *pRecordCfg);
MSIPC_SDK LONG __stdcall Ms_Ipc_SetRecordConfig(LONG nUserId, Ms_Ipc_Record_Config *pRecordCfg);

//////////////////////////////////////////////////////////////////////////
//Interface or model
// CHIP_INTERFACE
MSIPC_SDK LONG __stdcall Ms_Ipc_GetAllChipInterface(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_Ipc_HasAudioInterface(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_Ipc_HasSDInterface(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_Ipc_HasAlarmInterface(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_Ipc_HasBNCInterface(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_Ipc_HasPTZInterface(LONG nUserId);
// Model judgement
MSIPC_SDK BOOL __stdcall Ms_Ipc_IsMini(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_Ipc_IsCube(LONG nUserId);

//////////////////////////////////////////////////////////////////////////
//SDK For VMS Client
//DWORD dwDataType
enum DATA_TYPE
{
	IPC_DATA_TYPE_VIDEO,
	IPC_DATA_TYPE_AUDIO,	
};

enum MS_FILE_TYPE
{
	IPC_FILE_TYPE_ALL = 0,
	IPC_FILE_TYPE_MANAUL,
	IPC_FILE_TYPE_MOTION,
	IPC_FILE_TYPE_AUTO,
};

typedef struct  
{
	LONG nYear;
	LONG nMonth;
	LONG nDay;
	LONG nHour;
	LONG nMinute;
	LONG nSecond;
}Ms_Ipc_Date;

typedef struct Ms_Ipc_FileInfo
{
	char sFilePath[MAX_BUFFER_STRING*4];
	Ms_Ipc_Date dtStartTime;
	DWORD dwFileDuration;
	DWORD dwFileType;
	Ms_Ipc_FileInfo *pNext;
}Ms_Ipc_FileInfo;

enum PLAY_COMMAND{
	IPC_PLAY_COMMAND_NORMAL,
	IPC_PLAY_COMMAND_QUICK,
	IPC_PLAY_COMMAND_SLOW,	
};
enum PLAY_SPEED {
	IPC_PLAY_SPEED_1 = 0,	
	IPC_PLAY_SPEED_2,
	IPC_PLAY_SPEED_4,
	IPC_PLAY_SPEED_8,
	IPC_PLAY_SPEED_16,
};
enum CHIP_INTERFACE {
	IPC_CHIP_INTERFACE_NONE = 0,
	IPC_CHIP_INTERFACE_SD = 1,	
	IPC_CHIP_INTERFACE_AUDIO = 2,
	IPC_CHIP_INTERFACE_ALARM = 4,
	IPC_CHIP_INTERFACE_BNC = 8,
	IPC_CHIP_INTERFACE_PTZ = 16,
	IPC_CHIP_INTERFACE_USB = 32,
};

typedef struct  
{
	BYTE nWeekDay;
	int nStartHour;
	int nStartMin;
	int nEndHour;
	int nEndMin;
}Ms_Ipc_RecordTime;

typedef struct  
{
	BYTE nMotionLevel;//0,Low;1,Middle;2,Hight
	int nMotionInterval;//(seconds)
	BYTE motionMap[32][24];//Motion Map Block 32*24.motionMap[1][2] = 0 or 1.
	BYTE nMotionSaveType;//0,save video;1,save images;2,save both
	int nImageCnt;//<=5
	int nVideoDuration;//(seconds)<=1800
}Ms_Ipc_MotionSettings;
//RTSP Url
MSIPC_SDK LONG __stdcall Ms_IpcClient_GetRtspUrl(LONG nUserId, BYTE nStreamType, char *sRtspUrl, int nUrlLen);

//Save Path
MSIPC_SDK LONG __stdcall Ms_IpcClient_SetSaveDir(LONG nUserId, const char *sDiskPath);

//Live
//CallBack pBuffer:video data(unsighted char*);audio data(unsigned short*)
MSIPC_SDK LONG __stdcall Ms_IpcClient_LivePlay(LONG nUserId, Ms_Ipc_ClientInfo *pClientInfo, void (CALLBACK *fLiveDataCallBack)(LONG nUserId, DWORD dwDataType, void *pBuffer, DWORD dwBuffSize, int nWidth, int nHeight, void *pUser)=NULL, void *pUser = NULL);
MSIPC_SDK LONG __stdcall Ms_IpcClient_SetLiveDataCallBack(LONG nUserId, void (CALLBACK *fLiveDataCallBack)(LONG nUserId, DWORD dwDataType, void *pBuffer, DWORD dwBuffSize, int nWidth, int nHeight, void *pUser), void *pUser=NULL);
MSIPC_SDK BOOL __stdcall Ms_IpcClient_StopLivePlay(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_IpcClient_SaveLiveData(LONG nUserId, const char *sDiskPath = NULL);//sDiskPath example:"C:\\".
MSIPC_SDK BOOL __stdcall Ms_IpcClient_StopSaveLiveData(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_IpcClient_CaptureImage(LONG nUserId, char *sFilePath, int nPathLen, const char *sDiskPath = NULL);//sDiskPath example:"C:\\".
MSIPC_SDK LONG __stdcall Ms_IpcClient_DrawGrid(LONG nUserId, BOOL bShowGrid, BYTE (*motionMap)[24]);//Display for Motion Settings

//PlayBack and files lookup
MSIPC_SDK LONG __stdcall Ms_IpcClient_PlayBack(LONG nUserId, char *sFilePath, HWND hWnd, void (CALLBACK *fPlayDataCallBack)(LONG nUserId, DWORD dwDataType, void *pBuffer, DWORD dwBuffSize, int nWidth, int nHeight, void *pUser)=NULL, void *pUser=NULL);
MSIPC_SDK LONG __stdcall Ms_IpcClient_SetPlayDataCallBack(LONG nUserId, void (CALLBACK *fPlayDataCallBack)(LONG nUserId, DWORD dwDataType, void *pBuffer, DWORD dwBuffSize, int nWidth, int nHeight, void *pUser), void *pUser=NULL);
MSIPC_SDK BOOL __stdcall Ms_IpcClient_StopPlayBack(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_IpcClient_PlayBackPause(LONG nUserId);
MSIPC_SDK BOOL __stdcall Ms_IpcClient_PlayBackResume(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_IpcClient_PlayBackControl(LONG nUserId, DWORD dwCmd, DWORD dwParam);//play quickly,slowly
MSIPC_SDK LONG __stdcall Ms_IpcClient_GetCurrentTime(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_IpcClient_GetFileDuration(LONG nUserId);
MSIPC_SDK LONG __stdcall Ms_IpcClient_SeekPlayTime(LONG nUserId, LONG nSeconds);
MSIPC_SDK LONG __stdcall Ms_IpcClient_IsPlayFinished(LONG nUserId);

MSIPC_SDK LONG __stdcall Ms_IpcClient_FindFiles(LONG nUserId, const char *sDiskPath, DWORD dwFileType, Ms_Ipc_Date *pStartTime, Ms_Ipc_Date *pStopTime, Ms_Ipc_FileInfo *pFileInfo);
MSIPC_SDK LONG __stdcall Ms_IpcClient_DestroyFindFiles(Ms_Ipc_FileInfo *pFileInfo);

//Motion and Record
//should initialize every time after playing live stream.
MSIPC_SDK LONG __stdcall Ms_IpcClient_SetMotionSettings(LONG nUserId, Ms_Ipc_MotionSettings *pMotionSettings);
MSIPC_SDK LONG __stdcall Ms_IpcClient_AddMotionSchedule(LONG nUserId, Ms_Ipc_RecordTime *pRecordTime);
MSIPC_SDK LONG __stdcall Ms_IpcClient_AddAutoSaveSchedule(LONG nUserId, Ms_Ipc_RecordTime *pRecordTime);

//Other
MSIPC_SDK LONG __stdcall Ms_IpcClient_GetMaxConnectionLimit(LONG nUserId, int *pCurMaxNum);
MSIPC_SDK LONG __stdcall Ms_IpcClient_SetMaxConnectionLimit(LONG nUserId, int nCurMaxNum);
MSIPC_SDK LONG __stdcall Ms_IpcClient_GetCurrentConnectionNum(LONG nUserId, int *pCurMaxNum);

#ifdef __cplusplus
}
#endif

#endif//MS_IPC_SDK_H