You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1512 lines
42 KiB

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