using System.Runtime.InteropServices; namespace EC.Util.CameraSDK; public static class DaHuaOriSDK { #region Lib Attr private const string LibDhNetSDK = @"./libs/dh-win64/dhnetsdk.dll"; #endregion Lib Attr static DaHuaOriSDK() { GlobalInit(); } #region Global public static bool InitSuccess { get; private set; } public static bool GlobalInit() { if (InitSuccess) return true; bool ret = CLIENT_InitEx(null, IntPtr.Zero, IntPtr.Zero); InitSuccess = ret; if (!ret) throw new Exception("DaHuaOriSDK global init failure."); return ret; } public static bool GlobalDestory() { if (!InitSuccess) return true; CLIENT_Cleanup(); InitSuccess = false; return true; } #endregion Global #region SDK Const public const int PtzSpeedMin = 1; public const int PtzSpeedMax = 8; #endregion SDK Const #region SDK Enum /// /// login device mode enumeration /// 登陆设备方式枚举 /// public enum EM_LOGIN_SPAC_CAP_TYPE { /// /// TCP login, default /// TCP登陆, 默认方式 /// TCP = 0, /// /// No criteria login /// 无条件登陆 /// ANY = 1, /// /// auto sign up login /// 主动注册的登入 /// SERVER_CONN = 2, /// /// multicast login, default /// 组播登陆 /// MULTICAST = 3, /// /// UDP method login /// UDP方式下的登入 /// UDP = 4, /// /// only main connection login /// 只建主连接下的登入 /// MAIN_CONN_ONLY = 6, /// /// SSL encryption login /// SSL加密方式登陆 /// SSL = 7, /// /// login IVS box remote device /// 登录智能盒远程设备 /// INTELLIGENT_BOX = 9, /// /// login device do not config /// 登录设备后不做取配置操作 /// NO_CONFIG = 10, /// /// USB key device login /// 用U盾设备的登入 /// U_LOGIN = 11, /// /// LDAP login /// LDAP方式登录 /// LDAP = 12, /// /// AD login /// AD(ActiveDirectory)登录方式 /// AD = 13, /// /// Radius login /// Radius 登录方式 /// RADIUS = 14, /// /// Socks5 login /// Socks5登陆方式 /// SOCKET_5 = 15, /// /// cloud login /// 云登陆方式 /// CLOUD = 16, /// /// dual authentication loin /// 二次鉴权登陆方式 /// AUTH_TWICE = 17, /// /// TS stream client login /// TS码流客户端登陆方式 /// TS = 18, /// /// web private login /// 为P2P登陆方式 /// P2P = 19, /// /// mobile client login /// 手机客户端登陆 /// MOBILE = 20, /// /// invalid login /// 无效的登陆方式 /// INVALID = 21, } /// /// device type enumeration /// 设备类型枚举 /// public enum EM_NET_DEVICE_TYPE { /// /// Unknow // 未知 /// NET_PRODUCT_NONE = 0, /// /// Non real-time MACE /// 非实时MACE /// NET_DVR_NONREALTIME_MACE, /// /// Non real-time /// 非实时 /// NET_DVR_NONREALTIME, /// /// Network video server /// 网络视频服务器 /// NET_NVS_MPEG1, /// /// MPEG1 2-ch DVR /// MPEG1二路录像机 /// NET_DVR_MPEG1_2, /// /// MPEG1 8-ch DVR /// MPEG1八路录像机 /// NET_DVR_MPEG1_8, /// /// MPEG4 8-ch DVR /// MPEG4八路录像机 /// NET_DVR_MPEG4_8, /// /// MPEG4 16-ch DVR /// MPEG4 十六路录像机 /// NET_DVR_MPEG4_16, /// /// LB series DVR /// LB系列录像机 /// NET_DVR_MPEG4_SX2, /// /// GB series DVR /// GB系列录像机 /// NET_DVR_MEPG4_ST2, /// /// HB series DVR /// HB系列录像机 /// NET_DVR_MEPG4_SH2, /// /// GBE series DVR /// GBE系列录像机 /// NET_DVR_MPEG4_GBE, /// /// II network video server /// II代网络视频服务器 /// NET_DVR_MPEG4_NVSII, /// /// New standard configuration protocol /// 新标准配置协议 /// NET_DVR_STD_NEW, /// /// DDNS server /// DDNS服务器 /// NET_DVR_DDNS, /// /// ATM series /// ATM机 /// NET_DVR_ATM, /// /// 2nd non real-time NB series DVR /// 二代非实时NB系列机器 /// NET_NB_SERIAL, /// /// LN series /// LN系列产品 /// NET_LN_SERIAL, /// /// BAV series /// BAV系列产品 /// NET_BAV_SERIAL, /// /// SDIP series /// SDIP系列产品 /// NET_SDIP_SERIAL, /// /// IPC series /// IPC系列产品 /// NET_IPC_SERIAL, /// /// NVS B series /// NVS B系列 /// NET_NVS_B, /// /// NVS H series /// NVS H系列 /// NET_NVS_C, /// /// NVS S series /// NVS S系列 /// NET_NVS_S, /// /// NVS E series /// NVS E系列 /// NET_NVS_E, /// /// Search device type from QueryDevState. it is in string format /// 从QueryDevState中查询设备类型,以字符串格式 /// NET_DVR_NEW_PROTOCOL, /// /// NVD /// 解码器 /// NET_NVD_SERIAL, /// /// N5 /// N5 /// NET_DVR_N5, /// /// HDVR /// 混合DVR /// NET_DVR_MIX_DVR, /// /// SVR series /// SVR系列 /// NET_SVR_SERIAL, /// /// SVR-BS /// SVR-BS /// NET_SVR_BS, /// /// NVR series /// NVR系列 /// NET_NVR_SERIAL, /// /// N51 /// N51 /// NET_DVR_N51, /// /// ITSE Intelligent Analysis Box /// ITSE 智能分析盒 /// NET_ITSE_SERIAL, /// /// Intelligent traffic camera equipment /// 智能交通像机设备 /// NET_ITC_SERIAL, /// /// radar speedometer HWS /// 雷达测速仪HWS /// NET_HWS_SERIAL, /// /// portable video record /// 便携式音视频录像机 /// NET_PVR_SERIAL, /// /// IVS(intelligent video server series) /// IVS(智能视频服务器系列) /// NET_IVS_SERIAL, /// /// universal intelligent detect video server series /// 通用智能视频侦测服务器 /// NET_IVS_B, /// /// face recognisation server /// 人脸识别服务器 /// NET_IVS_F, /// /// video quality diagnosis server /// 视频质量诊断服务器 /// NET_IVS_V, /// /// matrix /// 矩阵 /// NET_MATRIX_SERIAL, /// /// N52 /// N52 /// NET_DVR_N52, /// /// N56 /// N56 /// NET_DVR_N56, /// /// ESS /// ESS /// NET_ESS_SERIAL, /// /// 人数统计服务器 /// NET_IVS_PC, /// /// pc-nvr /// pc-nvr /// NET_PC_NVR, /// /// screen controller /// 大屏控制器 /// NET_DSCON, /// /// network video storage server /// 网络视频存储服务器 /// NET_EVS, /// /// an embedded intelligent video analysis system /// 嵌入式智能分析视频系统 /// NET_EIVS, /// /// DVR-N6 /// DVR-N6 /// NET_DVR_N6, /// /// K-Lite Codec Pack /// 万能解码器 /// NET_UDS, /// /// Bank alarm host /// 银行报警主机 /// NET_AF6016, /// /// Video network alarm host /// 视频网络报警主机 /// NET_AS5008, /// /// Network alarm host /// 网络报警主机 /// NET_AH2008, /// /// Alarm host series /// 报警主机系列 /// NET_A_SERIAL, /// /// Access control series of products /// 门禁系列产品 /// NET_BSC_SERIAL, /// /// NVS series product /// NVS系列产品 /// NET_NVS_SERIAL, /// /// VTO series product /// VTO系列产品 /// NET_VTO_SERIAL, /// /// VTNC series product /// VTNC系列产品 /// NET_VTNC_SERIAL, /// /// TPC series product, it is the thermal device /// TPC系列产品, 即热成像设备 /// NET_TPC_SERIAL, /// /// ASM series product /// 无线中继设备 /// NET_ASM_SERIAL, /// /// VTS series product /// 管理机 /// NET_VTS_SERIAL, /// /// Alarm host-ARC2016C /// 报警主机ARC2016C /// NET_ARC2016C, /// /// ASA Attendance machine /// 考勤机 /// NET_ASA, /// /// Industry terminal walkie-talkie /// 行业对讲终端 /// NET_VTT_SERIAL, /// /// Alarm column /// 报警柱 /// NET_VTA_SERIAL, /// /// SIP Server /// SIP服务器 /// NET_VTNS_SERIAL, /// /// Indoor unit /// 室内机 /// NET_VTH_SERIAL, } /// /// 查询设备信息参数 /// public enum EM_DEVICE_STATE { /// /// Query device online state(return a DWORD value, 1-online, 0-offline) /// 查询设备的在线状态(返回一个DWORD, 1表示在线, 0表示断线) /// ONLINE = 0x0035, /// /// Query ptz state(struct DH_PTZ_LOCATION_INFO) /// 查询云台状态信息(对应结构体 DH_PTZ_LOCATION_INFO) /// PTZ_LOCATION = 0x0036, } /// /// PTZ control command enumeration /// 云台控制命令 /// public enum EM_EXTPTZ_ControlType : int { /// /// Up /// 上 /// UP_CONTROL = 0, /// /// Down /// 下 /// DOWN_CONTROL, /// /// Left /// 左 /// LEFT_CONTROL, /// /// Right /// 右 /// RIGHT_CONTROL, /// /// +Zoom in /// 变倍+ /// ZOOM_ADD_CONTROL, /// /// -Zoom out /// 变倍- /// ZOOM_DEC_CONTROL, /// /// +Focus /// 调焦+ /// FOCUS_ADD_CONTROL, /// /// -Focus /// 调焦- /// FOCUS_DEC_CONTROL, /// /// + Aperture /// 光圈+ /// APERTURE_ADD_CONTROL, /// /// -Aperture /// 光圈- /// APERTURE_DEC_CONTROL, /// /// Go to preset /// 转至预置点 /// POINT_MOVE_CONTROL, /// /// Set /// 设置 /// POINT_SET_CONTROL, /// /// Delete /// 删除 /// POINT_DEL_CONTROL, /// /// Tour /// 点间巡航 /// POINT_LOOP_CONTROL, /// /// Light and wiper /// 灯光雨刷 /// LAMP_CONTROL, /// /// Upper left /// 左上 /// LEFTTOP = 0x20, /// /// Upper right /// 右上 /// RIGHTTOP, /// /// Down left /// 左下 /// LEFTDOWN, /// /// Down right /// 右下 /// RIGHTDOWN, /// /// Add preset to tour tour preset value /// 加入预置点到巡航 巡航线路 预置点值 /// ADDTOLOOP, /// /// Delete preset in tour tour preset value /// 删除巡航中预置点 巡航线路 预置点值 /// DELFROMLOOP, /// /// Delete tour tour /// 清除巡航 巡航线路 /// CLOSELOOP, /// /// Begin pan rotation /// 开始水平旋转 /// STARTPANCRUISE, /// /// Stop pan rotation /// 停止水平旋转 /// STOPPANCRUISE, /// /// Set left limit /// 设置左边界 /// SETLEFTBORDER, /// /// Set right limit /// 设置右边界 /// SETRIGHTBORDER, /// /// Begin scanning /// 开始线扫 /// STARTLINESCAN, /// /// Stop scanning /// 停止线扫 /// CLOSELINESCAN, /// /// Start mode mode line /// 设置模式开始 模式线路 /// SETMODESTART, /// /// Stop mode mode line /// 设置模式结束 模式线路 /// SETMODESTOP, /// /// Enable mode Mode line /// 运行模式 模式线路 /// RUNMODE, /// /// Disable mode Mode line /// 停止模式 模式线路 /// STOPMODE, /// /// Delete mode Mode line /// 清除模式 模式线路 /// DELETEMODE, /// /// Flip /// 翻转命令 /// REVERSECOMM, /// /// 3D position X address(8192) Y address(8192) zoom(4) /// 快速定位 水平坐标(8192) 垂直坐标(8192) 变倍(4) /// FASTGOTO, /// /// auxiliary open Auxiliary point(param4 corresponding struct PTZ_CONTROL_AUXILIARY,param1、param2、param3 is invalid,dwStop set to FALSE) /// 辅助开关开 辅助点(param4对应 PTZ_CONTROL_AUXILIARY,param1、param2、param3无效,dwStop设置为FALSE) /// AUXIOPEN, /// /// Auxiliary close Auxiliary point(param4 corresponding struct PTZ_CONTROL_AUXILIARY,param1、param2、param3 is invalid,dwStop set to FALSE) /// 辅助开关关 辅助点(param4对应 PTZ_CONTROL_AUXILIARY,param1、param2、param3无效,dwStop设置为FALSE) /// AUXICLOSE, /// /// Open dome menu /// 打开球机菜单 /// OPENMENU = 0x36, /// /// Close menu /// 关闭菜单 /// CLOSEMENU, /// /// Confirm menu /// 菜单确定 /// MENUOK, /// /// Cancel menu /// 菜单取消 /// MENUCANCEL, /// /// menu up /// 菜单上 /// MENUUP, /// /// menu down /// 菜单下 /// MENUDOWN, /// /// menu left /// 菜单左 /// MENULEFT, /// /// Menu right /// 菜单右 /// MENURIGHT, /// /// Alarm activate PTZ parm1:Alarm input channel;parm2:Alarm activation type 1-preset 2-scan 3-tour;parm 3:activation value,such as preset value. /// 报警联动云台 parm1:报警输入通道;parm2:报警联动类型1-预置点2-线扫3-巡航;parm3:联动值,如预置点号 /// ALARMHANDLE = 0x40, /// /// Matrix switch parm1:monitor number(video output number);parm2:video input number;parm3:matrix number /// 矩阵切换 parm1:监视器号(视频输出号);parm2:视频输入号;parm3:矩阵号 /// MATRIXSWITCH = 0x41, /// /// Light controller /// 灯光控制器 /// LIGHTCONTROL, /// /// 3D accurately positioning parm1:Pan degree(0~3600); parm2: tilt coordinates(0~900); parm3:zoom(1~128) /// 三维精确定位 parm1:水平角度(0~3600);parm2:垂直坐标(0~900);parm3:变倍(1~128) /// EXACTGOTO, /// /// Reset 3D positioning as zero /// 三维定位重设零位 /// RESETZERO, /// /// Absolute motion control command,param4 corresponding struct NET_PTZ_CONTROL_ABSOLUTELY /// 绝对移动控制命令,param4对应结构 NET_PTZ_CONTROL_ABSOLUTELY /// MOVE_ABSOLUTELY, /// /// Continuous motion control command,param4 corresponding struct NET_PTZ_CONTROL_CONTINUOUSLY /// 持续移动控制命令,param4对应结构 NET_PTZ_CONTROL_CONTINUOUSLY /// MOVE_CONTINUOUSLY, /// /// PTZ control command, at a certain speed to preset locu,parm4 corresponding struct NET_PTZ_CONTROL_GOTOPRESET /// 云台控制命令,以一定速度转到预置位点,parm4对应结构NET_PTZ_CONTROL_GOTOPRESET /// GOTOPRESET, /// /// Set to horizon(param4 corresponding struct NET_PTZ_VIEW_RANGE_INFO) /// 设置可视域(param4对应结构 NET_PTZ_VIEW_RANGE_INFO) /// SET_VIEW_RANGE = 0x49, /// /// Absolute focus(param4 corresponding struct NET_PTZ_FOCUS_ABSOLUTELY) /// 绝对聚焦(param4对应结构NET_PTZ_FOCUS_ABSOLUTELY) /// FOCUS_ABSOLUTELY = 0x4A, /// /// Level fan sweep(param4 corresponding NET_PTZ_CONTROL_SECTORSCAN,param1,param2,param3 is invalid) /// 水平扇扫(param4对应PTZ_CONTROL_SECTORSCAN,param1、param2、param3无效) /// HORSECTORSCAN = 0x4B, /// /// Vertical sweep fan(param4 corresponding NET_PTZ_CONTROL_SECTORSCAN,param1,param2,param3 is invalid) /// 垂直扇扫(param4对应PTZ_CONTROL_SECTORSCAN,param1、param2、param3无效) /// VERSECTORSCAN = 0x4C, /// /// Set absolute focus, focus on value, param1 for focal length, range: [0255], param2 as the focus, scope: [0255], param3, param4 is invalid /// 设定绝对焦距、聚焦值,param1为焦距,范围:[0,255],param2为聚焦,范围:[0,255],param3、param4无效 /// SET_ABS_ZOOMFOCUS = 0x4D, /// /// Control fish eye PTZ,param4corresponding to structure NET_PTZ_CONTROL_SET_FISHEYE_EPTZ /// 控制鱼眼电子云台,param4对应结构 PTZ_CONTROL_SET_FISHEYE_EPTZ /// SET_FISHEYE_EPTZ = 0x4E, /// /// Track start control(param4 corresponding to structure NET_PTZ_CONTROL_SET_TRACK_CONTROL,dwStop set as FALSE, param1、param2、param3 is invalid) /// 轨道机开始控制(param4对应结构体为 PTZ_CONTROL_SET_TRACK_CONTROL,dwStop传FALSE, param1、param2、param3无效) /// SET_TRACK_START = 0x4F, /// /// Track stop control (param4 corresponding to structure NET_PTZ_CONTROL_SET_TRACK_CONTROL,dwStop set as FALSE,param1、param2、param3 is invalid) /// 轨道机停止控制(param4对应结构体为 PTZ_CONTROL_SET_TRACK_CONTROL,dwStop传FALSE,param1、param2、param3无效) /// SET_TRACK_STOP = 0x50, /// /// Up + TELE param1=speed (1-8) /// 上 + TELE param1=速度(1-8),下同 /// UP_TELE = 0x70, /// /// Down + TELE /// 下 + TELE /// DOWN_TELE, /// /// Left + TELE /// 左 + TELE /// LEFT_TELE, /// /// Right + TELE /// 右 + TELE /// RIGHT_TELE, /// /// Upper left + TELE /// 左上 + TELE /// LEFTUP_TELE, /// /// Down left + TELE /// 左下 + TELE /// LEFTDOWN_TELE, /// /// Upper right + TELE /// 右上 + TELE /// TIGHTUP_TELE, /// /// Down right + TELE /// 右下 + TELE /// RIGHTDOWN_TELE, /// /// Up + WIDE param1=speed (1-8) /// 上 + WIDE param1=速度(1-8),下同 /// UP_WIDE, /// /// Down + WIDE /// 下 + WIDE /// DOWN_WIDE, /// /// Left + WIDE /// 左 + WIDE /// LEFT_WIDE, /// /// Right + WIDE /// 右 + WIDE /// RIGHT_WIDE, /// /// Upper left + WIDE /// 左上 + WIDE /// LEFTUP_WIDE, /// /// Down left+ WIDE /// 左下 + WIDE /// LEFTDOWN_WIDE, /// /// Upper right + WIDE /// 右上 + WIDE /// TIGHTUP_WIDE, /// /// Down right + WIDE /// 右下 + WIDE /// RIGHTDOWN_WIDE, /// /// Go to preset point and take a picture /// 至预置点并抓图 /// GOTOPRESETSNAP = 0x80, /// /// Calibrate the PTZ direction (two-way calibration) /// 校准云台方向(双方向校准) /// DIRECTIONCALIBRATION = 0x82, /// /// Calibrate the PTZ direction (one-way calibration) param4 -> NET_IN_CALIBRATE_SINGLEDIRECTION /// 校准云台方向(单防线校准), param4 -> NET_IN_CALIBRATE_SINGLEDIRECTION /// SINGLEDIRECTIONCALIBRATION = 0x83, /// /// Relative positioning of PTZ, param4 -> NET_IN_MOVERELATIVELY_INFO /// 云台相对定位, param4 -> NET_IN_MOVERELATIVELY_INFO /// MOVE_RELATIVELY = 0x84, /// /// Set direction for PTZ, param4 -> NET_IN_SET_DIRECTION_INFO /// 设置云台方向, param4 -> NET_IN_SET_DIRECTION_INFO /// SET_DIRECTION = 0x85, /// /// Precisely and absolutely movement control command, param4 -> NET_IN_PTZBASE_MOVEABSOLUTELY_INFO use CFG_CAP_CMD_PTZ command to get the capability of PTZ /// if CFG_PTZ_PROTOCOL_CAPS_INFO -> bSupportReal equals TRUE means this device supports this feature /// 精准绝对移动控制命令, param4 -> NET_IN_PTZBASE_MOVEABSOLUTELY_INFO(通过 CFG_CAP_CMD_PTZ 命令获取云台能力集( CFG_PTZ_PROTOCOL_CAPS_INFO ) /// 若bSupportReal为TRUE则设备支持该操作) /// BASE_MOVE_ABSOLUTELY = 0x86, /// /// Continuously movement control command, param4 -> NET_IN_PTZBASE_MOVECONTINUOUSLY_INFO. use CFG_CAP_CMD_PTZ command to get the capability of PTZ /// if CFG_PTZ_PROTOCOL_CAPS_INFO -> stuMoveContinuously equals -> stuType.bSupportExtra equals TRUE means this device supports this feature /// 云台连续移动控制命令, param4 -> NET_IN_PTZBASE_MOVECONTINUOUSLY_INFO. 通过 CFG_CAP_CMD_PTZ 命令获取云台能力集 /// 若 CFG_PTZ_PROTOCOL_CAPS_INFO 中 stuMoveContinuously 字段的 为 TRUE, 表示设备支持该操作 /// BASE_MOVE_CONTINUOUSLY, /// /// Maximum command value /// 最大命令值 /// TOTAL, } /// /// 预置点状态枚举 /// public enum EM_DH_PTZ_PRESET_STATUS { UNKNOWN, // 未知 REACH, // 预置点到达 UNREACH, // 预置点未到达 } /// /// realplay type /// 监视类型 /// public enum EM_RealPlayType { /// /// Real-time preview /// 实时预览 /// Realplay = 0, /// /// Multiple-channel preview /// 多画面预览 /// Multiplay, /// /// Real-time monitor-main stream. It is the same as EM_RealPlayType.Realplay /// 实时监视-主码流,等同于EM_RealPlayType.Realplay /// Realplay_0, /// /// Real-time monitor -- extra stream 1 /// 实时监视-从码流1 /// Realplay_1, /// /// Real-time monitor -- extra stream 2 /// 实时监视-从码流2 /// Realplay_2, /// /// Real-time monitor -- extra stream 3 /// 实时监视-从码流3 /// Realplay_3, /// /// Multiple-channel preview--1-window /// 多画面预览-1画面 /// Multiplay_1, /// /// Multiple-channel preview--4-window /// 多画面预览-4画面 /// Multiplay_4, /// /// Multiple-channel preview--8-window /// 多画面预览-8画面 /// Multiplay_8, /// /// Multiple-channel preview--9-window /// 多画面预览-9画面 /// Multiplay_9, /// /// Multiple-channel preview--16-window /// 多画面预览-16画面 /// Multiplay_16, /// /// Multiple-channel preview--6-window /// 多画面预览-6画面 /// Multiplay_6, /// /// Multiple-channel preview--12-window /// 多画面预览-12画面 /// Multiplay_12, /// /// Multiple-channel preview--25-window /// 多画面预览-25画面 /// Multiplay_25, /// /// Multiple-channel preview--36-window /// 多画面预览-36画面 /// Multiplay_36, /// /// test stream /// 带宽测试码流 /// Realplay_Test = 255, } #endregion SDK Enum #region SDK Struct /// /// CLIENT_LoginWithHighLevelSecurity 输入参数 /// public struct NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY { public uint dwSize;// 结构体大小 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string szIP; // IP public int nPort; // 端口 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string szUserName; // 用户名 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string szPassword; // 密码 public EM_LOGIN_SPAC_CAP_TYPE emSpecCap; // 登录模式 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] byReserved; // 字节对齐 public IntPtr pCapParam; // 见 CLIENT_LoginEx 接口 pCapParam 与 nSpecCap 关系 } /// /// device information structure /// 设备信息结构体 /// public struct NET_DEVICEINFO_Ex { /// /// serial number /// 序列号 /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 48)] public string sSerialNumber; /// /// count of alarm input /// 报警输入个数 /// public int nAlarmInPortNum; /// /// count of alarm output /// 报警输出个数 /// public int nAlarmOutPortNum; /// /// number of disk /// 硬盘个数 /// public int nDiskNum; /// /// device type, refer to EM_NET_DEVICE_TYPE /// 设备类型,见枚举NET_DEVICE_TYPE /// public EM_NET_DEVICE_TYPE nDVRType; /// /// number of channel /// 通道个数 /// public int nChanNum; /// /// Online Timeout, Not Limited Access to 0, not 0 Minutes Limit Said /// 在线超时时间,为0表示不限制登陆,非0表示限制的分钟数 /// public byte byLimitLoginTime; /// /// When login failed due to password error, notice user by this parameter.This parameter is invalid when remaining login times is zero /// 当登陆失败原因为密码错误时,通过此参数通知用户,剩余登陆次数,为0时表示此参数无效 /// public byte byLeftLogTimes; /// /// keep bytes for aligned /// 保留字节,字节对齐 /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] bReserved; /// /// when log in failed,the left time for users to unlock (seconds), -1 indicate the device haven't set the parameter /// 当登陆失败,用户解锁剩余时间(秒数), -1表示设备未设置该参数 /// public int nLockLeftTime; /// /// reserved /// 保留字节 /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] Reserved; } /// /// CLIENT_LoginWithHighLevelSecurity 输出参数 /// public struct NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY { public uint dwSize;// 结构体大小 public NET_DEVICEINFO_Ex stuDeviceInfo; // 设备信息 public int nError; // 错误码,见 CLIENT_Login 接口错误码 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 132)] public byte[] byReserved; // 保留字节 } /// /// 云台定位中非归一化坐标和变倍 /// public struct NET_PTZSPACE_UNNORMALIZED { public int nPosX; // x坐标 public int nPosY; // y坐标 public int nZoom; // 放大倍率 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 52)] public byte[] byReserved; // 预留字节 } /// /// 云台定位信息 /// //云台定位信息 public struct DH_PTZ_LOCATION_INFO { public int nChannelID; // 通道号 public int nPTZPan; // 云台水平运动位置,有效范围:[0,3600] public int nPTZTilt; // 云台垂直运动位置,有效范围:[-1800,1800] public int nPTZZoom; // 云台光圈变动位置,有效范围:[0,128] public byte bState; // 云台运动状态, 0-未知 1-运动 2-空闲 public byte bAction; // 云台动作,255-未知,0-预置点,1-线扫,2-巡航,3-巡迹,4-水平旋转,5-普通移动,6-巡迹录制,7-全景云台扫描,8-热度图 // 9-精确定位,10-设备校正,11-智能配置,12-云台重启 public byte bFocusState; // 云台聚焦状态, 0-未知, 1-运动状态, 2-空闲 public byte bEffectiveInTimeSection; // 在时间段内预置点状态是否有效 //如果当前上报的预置点是时间段内的预置点,则为1,其他情况为0 public int nPtzActionID; // 巡航ID号 public uint dwPresetID; // 云台所在预置点编号 public float fFocusPosition; // 聚焦位置 public byte bZoomState; // 云台ZOOM状态,0-未知,1-ZOOM,2-空闲 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] bReserved; // 对齐 public uint dwSequence; // 包序号,用于校验是否丢包 public uint dwUTC; // 对应的UTC(1970-1-1 00:00:00)秒数。 public EM_DH_PTZ_PRESET_STATUS emPresetStatus; // 预置点位置 /// /// 保留字段 /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 248)] public int[] reserved; }; #endregion SDK Struct #region Common Method /// /// network disconnection callback function original shape /// 断线回调函数 /// /// user LoginID:Login's returns value 登陆ID /// device IP 设备IP /// device prot 设备端口 /// user data from Init function 用户数据 public delegate void fDisConnectCallBack(IntPtr lLoginID, IntPtr pchDVRIP, int nDVRPort, IntPtr dwUser); /// /// network re-connection callback function original shape /// 重连回调函数 /// /// user LoginID:Login's returns value 登陆ID /// device IP,string type 设备IP /// device prot 设备端口 /// user data from SetAutoReconnect function 用户数据 public delegate void fHaveReConnectCallBack(IntPtr lLoginID, IntPtr pchDVRIP, int nDVRPort, IntPtr dwUser); [DllImport(LibDhNetSDK)] public static extern bool CLIENT_InitEx(fDisConnectCallBack? cbDisConnect, IntPtr dwUser, IntPtr lpInitParam); [DllImport(LibDhNetSDK)] public static extern void CLIENT_Cleanup(); [DllImport(LibDhNetSDK)] public static extern int CLIENT_GetLastError(); [DllImport(LibDhNetSDK)] public static extern IntPtr CLIENT_LoginWithHighLevelSecurity(ref NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY pstInParam, ref NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam); [DllImport(LibDhNetSDK)] public static extern bool CLIENT_Logout(IntPtr lLoginID); [DllImport(LibDhNetSDK)] public static extern void CLIENT_SetAutoReconnect(fHaveReConnectCallBack cbAutoConnect, IntPtr dwUser); [DllImport(LibDhNetSDK)] public static extern bool CLIENT_QueryDevState(IntPtr lLoginID, int nType, IntPtr pBuf, int nBufLen, ref int pRetLen, int waittime); /// /// PTZ control /// PTZ控制接口 /// /// user LoginID:Login's returns value 登陆ID,Login返回值 /// channel number 通道号 /// PTZ control commands 控制命令 /// Parameter1 details refer to EM_EXTPTZ_ControlType 控制命令的参数1 /// Parameter2 details refer to EM_EXTPTZ_ControlType 控制命令的参数2 /// Parameter3 details refer to EM_EXTPTZ_ControlType 控制命令的参数3 /// stop or not, effective to PTZ eight-directions operation and lens operation. During other operation, this parameter should fill in false 是否停止 /// support PTZ control extensive command,support these commands: 控制命令的参数4 /// EM_EXTPTZ_ControlType.MOVE_ABSOLUTELY:Absolute motion control commands,param4 corresponding struct NET_PTZ_CONTROL_ABSOLUTELY /// EM_EXTPTZ_ControlType.MOVE_CONTINUOUSLY:Continuous motion control commands,param4 corresponding struct NET_PTZ_CONTROL_CONTINUOUSLY /// EM_EXTPTZ_ControlType.GOTOPRESET:PTZ control command, at a certain speed to preset locus,parm4 corresponding struct NET_PTZ_CONTROL_GOTOPRESET /// EM_EXTPTZ_ControlType.SET_VIEW_RANGE:Set to horizon(param4 corresponding struct NET_PTZ_VIEW_RANGE_INFO /// EM_EXTPTZ_ControlType.FOCUS_ABSOLUTELY:Absolute focus(param4 corresponding struct NET_PTZ_FOCUS_ABSOLUTELY /// EM_EXTPTZ_ControlType.HORSECTORSCAN:Level fan sweep(param4 corresponding NET_PTZ_CONTROL_SECTORSCAN,param1、param2、param3 is invalid /// EM_EXTPTZ_ControlType.VERSECTORSCAN:Vertical sweep fan(param4 corresponding NET_PTZ_CONTROL_SECTORSCAN,param1、param2、param3 is invalid /// EM_EXTPTZ_ControlType.SET_FISHEYE_EPTZ:Control fish eye PTZ,param4corresponding to structure NET_PTZ_CONTROL_SET_FISHEYE_EPTZ /// EM_EXTPTZ_ControlType.SET_TRACK_START/SET_TRACK_STOP:param4 corresponding to structure NET_PTZ_CONTROL_SET_TRACK_CONTROL,dwStop set as FALSE,param1、param2、param3 is invalid /// failed return false, successful return true 失败返回false 成功返回true [DllImport(LibDhNetSDK)] public static extern bool CLIENT_DHPTZControlEx2(IntPtr lLoginID, int nChannelID, uint dwPTZCommand, int lParam1, int lParam2, int lParam3, bool dwStop, IntPtr param4); /// /// start real-time monitor.support 32bit and 64bit /// 开始实时监视.支持32位和64位 /// /// user LoginID:Login's returns value 登陆ID,Login返回值 /// real time monitor channel NO.(from 0). 通道号 /// display window handle. When value is 0(IntPtr.Zero), data are not decoded or displayed 显示窗口句柄 /// realplay type 监视类型 /// failed return 0, successful return the real time monitorID(real time monitor handle),as parameter of related function. 失败返回0,成功返回大于0的值 [DllImport(LibDhNetSDK)] public static extern IntPtr CLIENT_RealPlayEx(IntPtr lLoginID, int nChannelID, IntPtr hWnd, EM_RealPlayType rType); /// /// stop real time monitoring /// 关闭实时监视 /// /// monitor handle StartRealPlay returns value 监视ID StartRealPlay返回值 /// failed return false, successful return true 失败返回false 成功返回true [DllImport(LibDhNetSDK)] public static extern bool CLIENT_StopRealPlayEx(IntPtr lRealHandle); #endregion Common Method }