fajiao
2 years ago
42 changed files with 2003 additions and 0 deletions
@ -0,0 +1,164 @@ |
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
/// <summary>
|
|||
/// 相机信息
|
|||
/// </summary>
|
|||
public class CameraInfo |
|||
{ |
|||
#region Attr
|
|||
|
|||
/// <summary>
|
|||
/// 相机类型
|
|||
/// </summary>
|
|||
public int Type { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// ip 地址
|
|||
/// </summary>
|
|||
public string Ip { get; set; } = string.Empty; |
|||
|
|||
/// <summary>
|
|||
/// 端口
|
|||
/// </summary>
|
|||
public int Port { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 账号
|
|||
/// </summary>
|
|||
public string UserName { get; set; } = string.Empty; |
|||
|
|||
/// <summary>
|
|||
/// 密码
|
|||
/// </summary>
|
|||
public string Password { get; set; } = string.Empty; |
|||
|
|||
#endregion Attr
|
|||
|
|||
public static CameraInfo New(int type, string ip, int port, string userName, string password) |
|||
{ |
|||
CameraInfo info = new() { Type = type, Ip = ip, Port = port, UserName = userName, Password = password }; |
|||
if (port <= 0) |
|||
throw new Exception("Camera type not support."); |
|||
return info; |
|||
} |
|||
|
|||
public static CameraInfo New(int type, string ip, string userName, string password) |
|||
{ |
|||
CameraInfo info = new() { Type = type, Ip = ip, UserName = userName, Password = password }; |
|||
int port = (CameraType)type switch |
|||
{ |
|||
CameraType.HiK => CameraPort.HiK, |
|||
CameraType.DaHua => CameraPort.DaHua, |
|||
CameraType.YuShi => CameraPort.YuShi, |
|||
_ => -1, |
|||
}; |
|||
info.Port = port; |
|||
if (port <= 0) |
|||
throw new Exception("Camera type not support."); |
|||
return info; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 相机类型
|
|||
/// </summary>
|
|||
public enum CameraType |
|||
{ |
|||
HiK = 0, |
|||
DaHua = 1, |
|||
YuShi = 2, |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 相机默认连接端口
|
|||
/// </summary>
|
|||
public class CameraPort |
|||
{ |
|||
public const int HiK = 8000; |
|||
public const int DaHua = 37777; |
|||
public const int YuShi = 8800; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Ptz 信息
|
|||
/// </summary>
|
|||
public class PtzInfo |
|||
{ |
|||
#region Attr
|
|||
|
|||
public double Pan { get; set; } |
|||
public double Tilt { get; set; } |
|||
public double Zoom { get; set; } |
|||
|
|||
#endregion Attr
|
|||
|
|||
public PtzInfo(double pan, double tilt, double zoom) |
|||
{ |
|||
Pan = pan; |
|||
Tilt = tilt; |
|||
Zoom = zoom; |
|||
} |
|||
|
|||
public static PtzInfo Default |
|||
{ |
|||
get { return new(0, 0, 0); } |
|||
} |
|||
|
|||
public static PtzInfo New(double pan, double tilt, double zoom) |
|||
{ |
|||
return new PtzInfo(pan, tilt, zoom); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 相机异常
|
|||
/// </summary>
|
|||
public class CameraException : Exception |
|||
{ |
|||
public CameraException() : base() |
|||
{ |
|||
} |
|||
|
|||
public CameraException(string? message) : base(message) |
|||
{ |
|||
} |
|||
|
|||
public CameraException(string? message, Exception? innerException) : base(message, innerException) |
|||
{ |
|||
} |
|||
|
|||
protected class CameraExceptionObj |
|||
{ |
|||
public CameraType Type { get; set; } |
|||
|
|||
public int ErrCode { get; set; } |
|||
|
|||
public string? ErrMsg { get; set; } |
|||
|
|||
public override string? ToString() |
|||
{ |
|||
return $"Type:{Type}, ErrCode:{ErrCode}, ErrMsg:{ErrMsg}"; |
|||
} |
|||
} |
|||
|
|||
public static CameraException New(CameraType type, int errCode) |
|||
{ |
|||
CameraExceptionObj obj = new() |
|||
{ |
|||
Type = type, |
|||
ErrCode = errCode |
|||
}; |
|||
return new CameraException(obj.ToString()); |
|||
} |
|||
|
|||
public static CameraException New(CameraType type, int errCode, string errMsg) |
|||
{ |
|||
CameraExceptionObj obj = new() |
|||
{ |
|||
Type = type, |
|||
ErrCode = errCode, |
|||
ErrMsg = errMsg |
|||
}; |
|||
return new CameraException(obj.ToString()); |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
public abstract class ICameraSDK |
|||
{ |
|||
#region Attr
|
|||
|
|||
protected CameraInfo CameraInfo { get; set; } |
|||
|
|||
#endregion Attr
|
|||
|
|||
public ICameraSDK(CameraInfo cameraInfo) |
|||
{ |
|||
CameraInfo = cameraInfo; |
|||
} |
|||
|
|||
#region Base Method
|
|||
|
|||
/// <summary>
|
|||
/// 初始化资源
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public abstract bool Init(); |
|||
|
|||
/// <summary>
|
|||
/// 释放资源
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public abstract bool Destory(); |
|||
|
|||
/// <summary>
|
|||
/// 连接是否成功
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public abstract bool ConnectSuccess(); |
|||
|
|||
/// <summary>
|
|||
/// 处理异常
|
|||
/// </summary>
|
|||
public abstract void BuildException(); |
|||
|
|||
#endregion Base Method
|
|||
|
|||
#region Main Method
|
|||
|
|||
/// <summary>
|
|||
/// 获取 ptz
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public abstract PtzInfo GetPtzInfo(); |
|||
|
|||
#endregion Main Method
|
|||
} |
@ -0,0 +1,848 @@ |
|||
//#define Linux32
|
|||
//#define Linux64
|
|||
//#define Win32
|
|||
//#define Win64
|
|||
|
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
public static class DaHuaOriSDK |
|||
{ |
|||
#region Lib Attr
|
|||
|
|||
#if (Linux32)
|
|||
private const string LibDhNetSDK = @"./libs/dahua/linux32/libdhnetsdk.so"; |
|||
#elif (Linux64)
|
|||
private const string LibDhNetSDK = @"./libs/dahua/linux64/libdhnetsdk.so"; |
|||
#elif (Win32)
|
|||
private const string LibDhNetSDK = @"./libs/dahua/win32/dhnetsdk.dll"; |
|||
#elif (Win64)
|
|||
private const string LibDhNetSDK = @"./libs/dahua/win64/dhnetsdk.dll"; |
|||
#endif
|
|||
|
|||
#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 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>
|
|||
/// 预置点状态枚举
|
|||
/// </summary>
|
|||
public enum EM_DH_PTZ_PRESET_STATUS |
|||
{ |
|||
UNKNOWN, // 未知
|
|||
REACH, // 预置点到达
|
|||
UNREACH, // 预置点未到达
|
|||
} |
|||
|
|||
#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); |
|||
|
|||
#endregion Common Method
|
|||
} |
@ -0,0 +1,111 @@ |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
public class DaHuaSDK : ICameraSDK |
|||
{ |
|||
#region Attr
|
|||
|
|||
private IntPtr LoginId { get; set; } = IntPtr.Zero; |
|||
|
|||
#endregion Attr
|
|||
|
|||
public DaHuaSDK(CameraInfo cameraInfo) : base(cameraInfo) |
|||
{ |
|||
} |
|||
|
|||
#region Base Method
|
|||
|
|||
public override bool Init() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (ret) return true; |
|||
|
|||
DaHuaOriSDK.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stuInParam = new(); |
|||
stuInParam.dwSize = (uint)Marshal.SizeOf(stuInParam); |
|||
stuInParam.szIP = CameraInfo.Ip; |
|||
stuInParam.nPort = CameraInfo.Port; |
|||
stuInParam.szUserName = CameraInfo.UserName; |
|||
stuInParam.szPassword = CameraInfo.Password; |
|||
stuInParam.emSpecCap = DaHuaOriSDK.EM_LOGIN_SPAC_CAP_TYPE.TCP; |
|||
stuInParam.pCapParam = IntPtr.Zero; |
|||
DaHuaOriSDK.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stuOutParam = new(); |
|||
stuOutParam.dwSize = (uint)Marshal.SizeOf(stuOutParam); |
|||
LoginId = DaHuaOriSDK.CLIENT_LoginWithHighLevelSecurity(ref stuInParam, ref stuOutParam); |
|||
ret = ConnectSuccess(); |
|||
if (ret) DaHuaOriSDK.CLIENT_SetAutoReconnect(delegate (IntPtr lLoginID, IntPtr pchDVRIP, int nDVRPort, IntPtr dwUser) |
|||
{ |
|||
LoginId = lLoginID; |
|||
}, IntPtr.Zero); |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
public override bool Destory() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (!ret) return true; |
|||
|
|||
ret = DaHuaOriSDK.CLIENT_Logout(LoginId); |
|||
if (ret) LoginId = IntPtr.Zero; |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
public override bool ConnectSuccess() |
|||
{ |
|||
return LoginId != IntPtr.Zero; |
|||
} |
|||
|
|||
public override void BuildException() |
|||
{ |
|||
uint errCode = (uint)DaHuaOriSDK.CLIENT_GetLastError(); |
|||
if (errCode == 0) return; |
|||
errCode -= 0x80000000; |
|||
throw CameraException.New(CameraType.DaHua, (int)errCode); |
|||
} |
|||
|
|||
#endregion Base Method
|
|||
|
|||
#region Main Method
|
|||
|
|||
private static class GPIParams |
|||
{ |
|||
public static int Size { get; private set; } |
|||
public static Type Type { get; private set; } |
|||
|
|||
static GPIParams() |
|||
{ |
|||
DaHuaOriSDK.DH_PTZ_LOCATION_INFO info = new(); |
|||
Size = Marshal.SizeOf(info); |
|||
Type = info.GetType(); |
|||
} |
|||
} |
|||
|
|||
public override PtzInfo GetPtzInfo() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (!ret) return PtzInfo.Default; |
|||
|
|||
DaHuaOriSDK.DH_PTZ_LOCATION_INFO entity = new(); |
|||
int nBufLen = GPIParams.Size; |
|||
int pRetLen = 0; |
|||
IntPtr ptrBuf = Marshal.AllocHGlobal(GPIParams.Size); |
|||
Marshal.StructureToPtr(entity, ptrBuf, true); |
|||
try |
|||
{ |
|||
ret = DaHuaOriSDK.CLIENT_QueryDevState(LoginId, (int)DaHuaOriSDK.EM_DEVICE_STATE.PTZ_LOCATION, ptrBuf, nBufLen, ref pRetLen, 3000); |
|||
if (!ret) { BuildException(); return PtzInfo.Default; } |
|||
object? objBuf = Marshal.PtrToStructure(ptrBuf, GPIParams.Type); |
|||
if (objBuf == null) return PtzInfo.Default; |
|||
entity = (DaHuaOriSDK.DH_PTZ_LOCATION_INFO)objBuf; |
|||
return PtzInfo.New(entity.nPTZPan, entity.nPTZTilt, entity.nPTZZoom); |
|||
} |
|||
finally |
|||
{ |
|||
Marshal.FreeHGlobal(ptrBuf); |
|||
} |
|||
} |
|||
|
|||
#endregion Main Method
|
|||
} |
@ -0,0 +1,226 @@ |
|||
//#define Linux32
|
|||
//#define Linux64
|
|||
//#define Win32
|
|||
//#define Win64
|
|||
|
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
public static class HiKOriSDK |
|||
{ |
|||
#region Lib Attr
|
|||
|
|||
#if (Linux32)
|
|||
public const string LibHcNetSDK = @"./libs/hik/linux32/libhcnetsdk.so"; |
|||
#elif (Linux64)
|
|||
public const string LibHcNetSDK = @"./libs/hik/linux64/libhcnetsdk.so"; |
|||
#elif (Win32)
|
|||
public const string LibHcNetSDK = @"./libs/hik/win32/HCNetSDK.dll"; |
|||
#elif (Win64)
|
|||
public const string LibHcNetSDK = @"./libs/hik/win64/HCNetSDK.dll"; |
|||
#endif
|
|||
|
|||
#endregion Lib Attr
|
|||
|
|||
static HiKOriSDK() |
|||
{ |
|||
GlobalInit(); |
|||
} |
|||
|
|||
#region Global
|
|||
|
|||
public static bool InitSuccess { get; private set; } |
|||
|
|||
public static bool GlobalInit() |
|||
{ |
|||
if (InitSuccess) return true; |
|||
bool ret = NET_DVR_Init(); |
|||
InitSuccess = ret; |
|||
if (!ret) throw new Exception("HiKOriSDK global init failure."); |
|||
return ret; |
|||
} |
|||
|
|||
public static bool GlobalDestory() |
|||
{ |
|||
if (!InitSuccess) return true; |
|||
bool ret = NET_DVR_Cleanup(); |
|||
if (ret) InitSuccess = false; |
|||
return ret; |
|||
} |
|||
|
|||
#endregion Global
|
|||
|
|||
#region SDK Const
|
|||
|
|||
public const int SERIALNO_LEN = 48; //序列号长度
|
|||
|
|||
#region 用于 NET_DVR_SetDVRConfig 和 NET_DVR_GetDVRConfig
|
|||
|
|||
public const int NET_DVR_SET_PTZPOS = 292; //云台设置PTZ位置
|
|||
public const int NET_DVR_GET_PTZPOS = 293; //云台获取PTZ位置
|
|||
public const int NET_DVR_GET_PTZSCOPE = 294; //云台获取PTZ范围
|
|||
|
|||
#endregion 用于 NET_DVR_SetDVRConfig 和 NET_DVR_GetDVRConfig
|
|||
|
|||
#endregion SDK Const
|
|||
|
|||
#region SDK Struct
|
|||
|
|||
//NET_DVR_Login()参数结构
|
|||
[StructLayoutAttribute(LayoutKind.Sequential)] |
|||
public struct NET_DVR_DEVICEINFO |
|||
{ |
|||
[MarshalAsAttribute( |
|||
UnmanagedType.ByValArray, |
|||
SizeConst = SERIALNO_LEN, |
|||
ArraySubType = UnmanagedType.I1 |
|||
)] |
|||
public byte[] sSerialNumber; //序列号
|
|||
|
|||
public byte byAlarmInPortNum; //DVR报警输入个数
|
|||
public byte byAlarmOutPortNum; //DVR报警输出个数
|
|||
public byte byDiskNum; //DVR硬盘个数
|
|||
public byte byDVRType; //DVR类型, 1:DVR 2:ATM DVR 3:DVS ......
|
|||
public byte byChanNum; //DVR 通道个数
|
|||
public byte byStartChan; //起始通道号,例如DVS-1,DVR - 1
|
|||
} |
|||
|
|||
//NET_DVR_Login_V30()参数结构
|
|||
[StructLayoutAttribute(LayoutKind.Sequential)] |
|||
public struct NET_DVR_DEVICEINFO_V30 |
|||
{ |
|||
[MarshalAsAttribute( |
|||
UnmanagedType.ByValArray, |
|||
SizeConst = SERIALNO_LEN, |
|||
ArraySubType = UnmanagedType.I1 |
|||
)] |
|||
public byte[] sSerialNumber; //序列号
|
|||
|
|||
public byte byAlarmInPortNum; //报警输入个数
|
|||
public byte byAlarmOutPortNum; //报警输出个数
|
|||
public byte byDiskNum; //硬盘个数
|
|||
public byte byDVRType; //设备类型, 1:DVR 2:ATM DVR 3:DVS ......
|
|||
public byte byChanNum; //模拟通道个数
|
|||
public byte byStartChan; //起始通道号,例如DVS-1,DVR - 1
|
|||
public byte byAudioChanNum; //语音通道数
|
|||
public byte byIPChanNum; //最大数字通道个数,低位
|
|||
public byte byZeroChanNum; //零通道编码个数 //2010-01-16
|
|||
public byte byMainProto; //主码流传输协议类型 0-private, 1-rtsp,2-同时支持private和rtsp
|
|||
public byte bySubProto; //子码流传输协议类型0-private, 1-rtsp,2-同时支持private和rtsp
|
|||
public byte bySupport; //能力,位与结果为0表示不支持,1表示支持,
|
|||
|
|||
//bySupport & 0x1, 表示是否支持智能搜索
|
|||
//bySupport & 0x2, 表示是否支持备份
|
|||
//bySupport & 0x4, 表示是否支持压缩参数能力获取
|
|||
//bySupport & 0x8, 表示是否支持多网卡
|
|||
//bySupport & 0x10, 表示支持远程SADP
|
|||
//bySupport & 0x20, 表示支持Raid卡功能
|
|||
//bySupport & 0x40, 表示支持IPSAN 目录查找
|
|||
//bySupport & 0x80, 表示支持rtp over rtsp
|
|||
public byte bySupport1; // 能力集扩充,位与结果为0表示不支持,1表示支持
|
|||
|
|||
//bySupport1 & 0x1, 表示是否支持snmp v30
|
|||
//bySupport1 & 0x2, 支持区分回放和下载
|
|||
//bySupport1 & 0x4, 是否支持布防优先级
|
|||
//bySupport1 & 0x8, 智能设备是否支持布防时间段扩展
|
|||
//bySupport1 & 0x10, 表示是否支持多磁盘数(超过33个)
|
|||
//bySupport1 & 0x20, 表示是否支持rtsp over http
|
|||
//bySupport1 & 0x80, 表示是否支持车牌新报警信息2012-9-28, 且还表示是否支持NET_DVR_IPPARACFG_V40结构体
|
|||
public byte bySupport2; /*能力,位与结果为0表示不支持,非0表示支持 |
|||
|
|||
bySupport2 & 0x1, 表示解码器是否支持通过URL取流解码 |
|||
bySupport2 & 0x2, 表示支持FTPV40 |
|||
bySupport2 & 0x4, 表示支持ANR |
|||
bySupport2 & 0x8, 表示支持CCD的通道参数配置 |
|||
bySupport2 & 0x10, 表示支持布防报警回传信息(仅支持抓拍机报警 新老报警结构) |
|||
bySupport2 & 0x20, 表示是否支持单独获取设备状态子项 |
|||
bySupport2 & 0x40, 表示是否是码流加密设备*/ |
|||
public ushort wDevType; //设备型号
|
|||
public byte bySupport3; //能力集扩展,位与结果为0表示不支持,1表示支持
|
|||
|
|||
//bySupport3 & 0x1, 表示是否多码流
|
|||
// bySupport3 & 0x4 表示支持按组配置, 具体包含 通道图像参数、报警输入参数、IP报警输入、输出接入参数、
|
|||
// 用户参数、设备工作状态、JPEG抓图、定时和时间抓图、硬盘盘组管理
|
|||
//bySupport3 & 0x8为1 表示支持使用TCP预览、UDP预览、多播预览中的"延时预览"字段来请求延时预览(后续都将使用这种方式请求延时预览)。而当bySupport3 & 0x8为0时,将使用 "私有延时预览"协议。
|
|||
//bySupport3 & 0x10 表示支持"获取报警主机主要状态(V40)"。
|
|||
//bySupport3 & 0x20 表示是否支持通过DDNS域名解析取流
|
|||
|
|||
public byte byMultiStreamProto; //是否支持多码流,按位表示,0-不支持,1-支持,bit1-码流3,bit2-码流4,bit7-主码流,bit-8子码流
|
|||
public byte byStartDChan; //起始数字通道号,0表示无效
|
|||
public byte byStartDTalkChan; //起始数字对讲通道号,区别于模拟对讲通道号,0表示无效
|
|||
public byte byHighDChanNum; //数字通道个数,高位
|
|||
public byte bySupport4; |
|||
public byte byLanguageType; // 支持语种能力,按位表示,每一位0-不支持,1-支持
|
|||
|
|||
// byLanguageType 等于0 表示 老设备
|
|||
// byLanguageType & 0x1表示支持中文
|
|||
// byLanguageType & 0x2表示支持英文
|
|||
[MarshalAsAttribute( |
|||
UnmanagedType.ByValArray, |
|||
SizeConst = 9, |
|||
ArraySubType = UnmanagedType.I1 |
|||
)] |
|||
public byte[] byRes2; //保留
|
|||
} |
|||
|
|||
//球机位置信息
|
|||
[StructLayoutAttribute(LayoutKind.Sequential)] |
|||
public struct NET_DVR_PTZPOS |
|||
{ |
|||
public ushort wAction; //获取时该字段无效
|
|||
public ushort wPanPos; //水平参数
|
|||
public ushort wTiltPos; //垂直参数
|
|||
public ushort wZoomPos; //变倍参数
|
|||
} |
|||
|
|||
//球机范围信息
|
|||
[StructLayoutAttribute(LayoutKind.Sequential)] |
|||
public struct NET_DVR_PTZSCOPE |
|||
{ |
|||
public ushort wPanPosMin; //水平参数min
|
|||
public ushort wPanPosMax; //水平参数max
|
|||
public ushort wTiltPosMin; //垂直参数min
|
|||
public ushort wTiltPosMax; //垂直参数max
|
|||
public ushort wZoomPosMin; //变倍参数min
|
|||
public ushort wZoomPosMax; //变倍参数max
|
|||
} |
|||
|
|||
#endregion SDK Struct
|
|||
|
|||
#region Common Method
|
|||
|
|||
[DllImport(LibHcNetSDK)] |
|||
public static extern bool NET_DVR_Init(); |
|||
|
|||
[DllImport(LibHcNetSDK)] |
|||
public static extern bool NET_DVR_Cleanup(); |
|||
|
|||
[DllImport(LibHcNetSDK)] |
|||
public static extern uint NET_DVR_GetLastError(); |
|||
|
|||
[DllImport(LibHcNetSDK)] |
|||
public static extern int NET_DVR_Login_V30( |
|||
string sDVRIP, |
|||
int wDVRPort, |
|||
string sUserName, |
|||
string sPassword, |
|||
ref NET_DVR_DEVICEINFO_V30 lpDeviceInfo |
|||
); |
|||
|
|||
[DllImport(LibHcNetSDK)] |
|||
public static extern bool NET_DVR_Logout(int iUserID); |
|||
|
|||
//参数配置 begin
|
|||
[DllImport(LibHcNetSDK)] |
|||
public static extern bool NET_DVR_GetDVRConfig( |
|||
int lUserID, |
|||
uint dwCommand, |
|||
int lChannel, |
|||
IntPtr lpOutBuffer, |
|||
uint dwOutBufferSize, |
|||
ref uint lpBytesReturned |
|||
); |
|||
|
|||
#endregion Common Method
|
|||
} |
@ -0,0 +1,97 @@ |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
public class HiKSDK : ICameraSDK |
|||
{ |
|||
#region Attr
|
|||
|
|||
private int LoginId { get; set; } = -1; |
|||
|
|||
#endregion Attr
|
|||
|
|||
public HiKSDK(CameraInfo cameraInfo) : base(cameraInfo) |
|||
{ |
|||
} |
|||
|
|||
#region Base Method
|
|||
|
|||
public override bool Init() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (ret) return true; |
|||
|
|||
HiKOriSDK.NET_DVR_DEVICEINFO_V30 deviceInfo = new(); |
|||
LoginId = HiKOriSDK.NET_DVR_Login_V30(CameraInfo.Ip, CameraInfo.Port, CameraInfo.UserName, CameraInfo.Password, ref deviceInfo); |
|||
ret = ConnectSuccess(); |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
public override bool Destory() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (!ret) return true; |
|||
|
|||
ret = HiKOriSDK.NET_DVR_Logout(LoginId); |
|||
if (ret) LoginId = -1; |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
public override bool ConnectSuccess() |
|||
{ |
|||
return LoginId >= 0; |
|||
} |
|||
|
|||
public override void BuildException() |
|||
{ |
|||
uint errCode = HiKOriSDK.NET_DVR_GetLastError(); |
|||
if (errCode == 0) return; |
|||
throw CameraException.New(CameraType.HiK, (int)errCode); |
|||
} |
|||
|
|||
#endregion Base Method
|
|||
|
|||
#region Main Method
|
|||
|
|||
private static class GPIParams |
|||
{ |
|||
public static int Size { get; private set; } |
|||
public static Type Type { get; private set; } |
|||
|
|||
static GPIParams() |
|||
{ |
|||
HiKOriSDK.NET_DVR_PTZPOS ptzPos = new(); |
|||
Size = Marshal.SizeOf(ptzPos); |
|||
Type = ptzPos.GetType(); |
|||
} |
|||
} |
|||
|
|||
public override PtzInfo GetPtzInfo() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (!ret) return PtzInfo.Default; |
|||
|
|||
HiKOriSDK.NET_DVR_PTZPOS entity = new(); |
|||
int dwSize = GPIParams.Size; |
|||
uint dwReturned = 0; |
|||
IntPtr ptrBuf = Marshal.AllocHGlobal(dwSize); |
|||
Marshal.StructureToPtr(entity, ptrBuf, true); |
|||
try |
|||
{ |
|||
ret = HiKOriSDK.NET_DVR_GetDVRConfig(LoginId, HiKOriSDK.NET_DVR_GET_PTZPOS, 0, ptrBuf, (uint)dwSize, ref dwReturned); |
|||
if (!ret) { BuildException(); return PtzInfo.Default; } |
|||
object? objBuf = Marshal.PtrToStructure(ptrBuf, GPIParams.Type); |
|||
if (objBuf == null) return PtzInfo.Default; |
|||
entity = (HiKOriSDK.NET_DVR_PTZPOS)objBuf; |
|||
return PtzInfo.New(entity.wPanPos, entity.wTiltPos, entity.wZoomPos); |
|||
} |
|||
finally |
|||
{ |
|||
Marshal.FreeHGlobal(ptrBuf); |
|||
} |
|||
} |
|||
|
|||
#endregion Main Method
|
|||
} |
@ -0,0 +1,150 @@ |
|||
//#define Linux32
|
|||
//#define Linux64
|
|||
//#define Win32
|
|||
//#define Win64
|
|||
|
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
public static class YuShiOriSDK |
|||
{ |
|||
#region Lib Attr
|
|||
|
|||
#if (Linux32)
|
|||
public const string LibYsNetSDK = @"./libs/yushi/linux64/libNetDEVSDK.so"; |
|||
#elif (Linux64)
|
|||
public const string LibYsNetSDK = @"./libs/yushi/linux64/libNetDEVSDK.so"; |
|||
#elif (Win32)
|
|||
public const string LibYsNetSDK = @"./libs/yushi/win32/NetDEVSDK.dll"; |
|||
#elif (Win64)
|
|||
public const string LibYsNetSDK = @"./libs/yushi/win64/NetDEVSDK.dll"; |
|||
#endif
|
|||
|
|||
#endregion Lib Attr
|
|||
|
|||
static YuShiOriSDK() |
|||
{ |
|||
GlobalInit(); |
|||
} |
|||
|
|||
#region Global
|
|||
|
|||
public static bool InitSuccess { get; private set; } |
|||
|
|||
public static bool GlobalInit() |
|||
{ |
|||
if (InitSuccess) return true; |
|||
bool ret = NETDEV_Init(); |
|||
InitSuccess = ret; |
|||
if (!ret) throw new Exception("YuShiOriSDK global init failure."); |
|||
return ret; |
|||
} |
|||
|
|||
public static bool GlobalDestory() |
|||
{ |
|||
if (!InitSuccess) return true; |
|||
bool ret = NETDEV_Cleanup(); |
|||
if (ret) InitSuccess = false; |
|||
return ret; |
|||
} |
|||
|
|||
#endregion Global
|
|||
|
|||
#region SDK Const
|
|||
|
|||
/* Common length */ |
|||
public const int NETDEV_LEN_64 = 64; |
|||
public const int NETDEV_LEN_128 = 128; |
|||
public const int NETDEV_LEN_132 = 132; |
|||
public const int NETDEV_LEN_260 = 260; |
|||
|
|||
#endregion SDK Const
|
|||
|
|||
#region SDK Struct
|
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct NETDEV_DEVICE_LOGIN_INFO_S |
|||
{ |
|||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NETDEV_LEN_260)] |
|||
public string szIPAddr; /* IP地址/域名 */ |
|||
|
|||
public Int32 dwPort; /* 端口号 */ |
|||
|
|||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NETDEV_LEN_132)] |
|||
public string szUserName; /* 用户名 */ |
|||
|
|||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NETDEV_LEN_128)] |
|||
public string szPassword; /* 密码 */ |
|||
|
|||
public Int32 dwLoginProto; /* 登录协议, 参见NETDEV_LOGIN_PROTO_E */ |
|||
public Int32 dwDeviceType; /* 设备类型, 参见NETDEV_DEVICE_TYPE_E */ |
|||
|
|||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] |
|||
public byte[] byRes; /* Reserved */ |
|||
}; |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct NETDEV_SELOG_INFO_S |
|||
{ |
|||
public Int32 dwSELogCount; |
|||
public Int32 dwSELogTime; |
|||
|
|||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] |
|||
public byte[] byRes; |
|||
}; |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct NETDEV_VIDEO_CHL_DETAIL_INFO_S |
|||
{ |
|||
public Int32 dwChannelID; |
|||
public Int32 bPtzSupported; /* Whether ptz is supported */ |
|||
public Int32 enStatus; /* Channel status */ |
|||
public Int32 dwStreamNum; /* Number of streams */ |
|||
|
|||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NETDEV_LEN_64)] |
|||
public string szChnName; /* Device serial number */ |
|||
|
|||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] |
|||
public byte[] szReserve; |
|||
} |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct NETDEV_PTZ_STATUS_S |
|||
{ |
|||
public float fPanTiltX; /* 绝对水平坐标 Absolute horizontal coordinates*/ |
|||
public float fPanTiltY; /* 绝对竖直坐标 Absolute vertical coordinates*/ |
|||
public float fZoomX; /* 绝对聚焦倍数 Absolute multiples*/ |
|||
public Int32 enPanTiltStatus;/* 云台状态 PTZ Status*/ |
|||
public Int32 enZoomStatus; /* 聚焦状态 Focus Status*/ |
|||
}; |
|||
|
|||
#endregion SDK Struct
|
|||
|
|||
#region Common Method
|
|||
|
|||
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern bool NETDEV_Init(); |
|||
|
|||
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern bool NETDEV_Cleanup(); |
|||
|
|||
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern int NETDEV_GetLastError(); |
|||
|
|||
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern IntPtr NETDEV_Login_V30(ref NETDEV_DEVICE_LOGIN_INFO_S pstDevLoginInfo, ref NETDEV_SELOG_INFO_S pstSELogInfo); |
|||
|
|||
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern bool NETDEV_Logout(IntPtr lpUserID); |
|||
|
|||
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern Int32 NETDEV_QueryVideoChlDetailList(IntPtr lpUserID, ref int pdwChlCount, IntPtr pstVideoChlList); |
|||
|
|||
[DllImport(LibYsNetSDK, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern bool NETDEV_PTZGetStatus(IntPtr lpUserID, int dwChannelID, ref NETDEV_PTZ_STATUS_S pstPTZStaus); |
|||
|
|||
//public boolean NETDEV_GetDevConfig(Pointer lpUserID, int dwChannelID, int dwCommand, Pointer lpOutBuffer, int dwOutBufferSize, IntByReference pdwBytesReturned);
|
|||
|
|||
#endregion Common Method
|
|||
} |
@ -0,0 +1,74 @@ |
|||
namespace EC.Helper.CameraSDK; |
|||
|
|||
public class YuShiSDK : ICameraSDK |
|||
{ |
|||
#region Attr
|
|||
|
|||
private IntPtr LoginId { get; set; } = IntPtr.Zero; |
|||
|
|||
#endregion Attr
|
|||
|
|||
public YuShiSDK(CameraInfo cameraInfo) : base(cameraInfo) |
|||
{ |
|||
} |
|||
|
|||
#region Base Method
|
|||
|
|||
public override bool Init() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (ret) return true; |
|||
|
|||
YuShiOriSDK.NETDEV_DEVICE_LOGIN_INFO_S loginInfo = new(); |
|||
loginInfo.szIPAddr = CameraInfo.Ip; |
|||
loginInfo.dwPort = CameraInfo.Port; |
|||
loginInfo.szUserName = CameraInfo.UserName; |
|||
loginInfo.szPassword = CameraInfo.Password; |
|||
YuShiOriSDK.NETDEV_SELOG_INFO_S logInfo = new(); |
|||
LoginId = YuShiOriSDK.NETDEV_Login_V30(ref loginInfo, ref logInfo); |
|||
ret = ConnectSuccess(); |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
public override bool Destory() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (!ret) return true; |
|||
|
|||
ret = YuShiOriSDK.NETDEV_Logout(LoginId); |
|||
if (ret) LoginId = IntPtr.Zero; |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
public override bool ConnectSuccess() |
|||
{ |
|||
return LoginId != IntPtr.Zero; |
|||
} |
|||
|
|||
public override void BuildException() |
|||
{ |
|||
int errCode = YuShiOriSDK.NETDEV_GetLastError(); |
|||
if (errCode == 0) return; |
|||
throw CameraException.New(CameraType.YuShi, (int)errCode); |
|||
} |
|||
|
|||
#endregion Base Method
|
|||
|
|||
#region Main Method
|
|||
|
|||
public override PtzInfo GetPtzInfo() |
|||
{ |
|||
bool ret = ConnectSuccess(); |
|||
if (!ret) return PtzInfo.Default; |
|||
|
|||
YuShiOriSDK.NETDEV_PTZ_STATUS_S entity = new(); |
|||
ret = YuShiOriSDK.NETDEV_PTZGetStatus(LoginId, 1, ref entity); |
|||
if (!ret) { BuildException(); return PtzInfo.Default; } |
|||
|
|||
return PtzInfo.New(entity.fPanTiltX, entity.fPanTiltY, entity.fZoomX); |
|||
} |
|||
|
|||
#endregion Main Method
|
|||
} |
@ -0,0 +1,151 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<DefineConstants>$(DefineConstants)TRACE;Win64</DefineConstants> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<DefineConstants>$(DefineConstants)TRACE;Win64</DefineConstants> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="libs\dahua\linux32\libdhnetsdk.so" /> |
|||
<None Remove="libs\dahua\linux64\libdhnetsdk.so" /> |
|||
<None Remove="libs\dahua\win32\dhnetsdk.dll" /> |
|||
<None Remove="libs\dahua\win64\dhnetsdk.dll" /> |
|||
<None Remove="libs\hik\linux32\HCNetSDKCom\libHCCoreDevCfg.so" /> |
|||
<None Remove="libs\hik\linux32\HCNetSDKCom\libHCPreview.so" /> |
|||
<None Remove="libs\hik\linux32\libcrypto.so.1.1" /> |
|||
<None Remove="libs\hik\linux32\libHCCore.so" /> |
|||
<None Remove="libs\hik\linux32\libhcnetsdk.so" /> |
|||
<None Remove="libs\hik\linux32\libssl.so.1.1" /> |
|||
<None Remove="libs\hik\linux64\HCNetSDKCom\libHCCoreDevCfg.so" /> |
|||
<None Remove="libs\hik\linux64\HCNetSDKCom\libHCPreview.so" /> |
|||
<None Remove="libs\hik\linux64\libcrypto.so.1.1" /> |
|||
<None Remove="libs\hik\linux64\libHCCore.so" /> |
|||
<None Remove="libs\hik\linux64\libhcnetsdk.so" /> |
|||
<None Remove="libs\hik\linux64\libssl.so.1.1" /> |
|||
<None Remove="libs\hik\win32\HCNetSDKCom\HCCoreDevCfg.dll" /> |
|||
<None Remove="libs\hik\win32\HCNetSDKCom\HCPreview.dll" /> |
|||
<None Remove="libs\hik\win32\HCCore.dll" /> |
|||
<None Remove="libs\hik\win32\HCNetSDK.dll" /> |
|||
<None Remove="libs\hik\win32\libcrypto-1_1.dll" /> |
|||
<None Remove="libs\hik\win32\libssl-1_1.dll" /> |
|||
<None Remove="libs\hik\win64\HCNetSDKCom\HCCoreDevCfg.dll" /> |
|||
<None Remove="libs\hik\win64\HCNetSDKCom\HCPreview.dll" /> |
|||
<None Remove="libs\hik\win64\HCCore.dll" /> |
|||
<None Remove="libs\hik\win64\HCNetSDK.dll" /> |
|||
<None Remove="libs\hik\win64\libcrypto-1_1-x64.dll" /> |
|||
<None Remove="libs\hik\win64\libssl-1_1-x64.dll" /> |
|||
<None Remove="libs\yushi\linux64\libNetDEVSDK.so" /> |
|||
<None Remove="libs\yushi\win32\NetDEVSDK.dll" /> |
|||
<None Remove="libs\yushi\win64\NetDEVSDK.dll" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Content Include="libs\dahua\linux32\libdhnetsdk.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\dahua\linux64\libdhnetsdk.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\dahua\win32\dhnetsdk.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\dahua\win64\dhnetsdk.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux32\HCNetSDKCom\libHCCoreDevCfg.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux32\HCNetSDKCom\libHCPreview.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux32\libcrypto.so.1.1"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux32\libHCCore.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux32\libhcnetsdk.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux32\libssl.so.1.1"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux64\HCNetSDKCom\libHCCoreDevCfg.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux64\HCNetSDKCom\libHCPreview.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux64\libcrypto.so.1.1"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux64\libHCCore.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux64\libhcnetsdk.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\linux64\libssl.so.1.1"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win32\HCNetSDKCom\HCCoreDevCfg.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win32\HCNetSDKCom\HCPreview.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win32\HCCore.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win32\HCNetSDK.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win32\libcrypto-1_1.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win32\libssl-1_1.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win64\HCNetSDKCom\HCCoreDevCfg.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win64\HCNetSDKCom\HCPreview.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win64\HCCore.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win64\HCNetSDK.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win64\libcrypto-1_1-x64.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\hik\win64\libssl-1_1-x64.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\yushi\linux64\libNetDEVSDK.so"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\yushi\win32\NetDEVSDK.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
<Content Include="libs\yushi\win64\NetDEVSDK.dll"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Folder Include="libs\yushi\linux32\" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -0,0 +1,124 @@ |
|||
using EC.Helper.CameraSDK; |
|||
|
|||
namespace EC.Helper.Test; |
|||
|
|||
public class CameraSDKTest |
|||
{ |
|||
public static void Test() |
|||
{ |
|||
//HiKTest();
|
|||
//DaHuaTest();
|
|||
//YuShiTest();
|
|||
} |
|||
|
|||
public static void HiKTest() |
|||
{ |
|||
Console.WriteLine("====HiK=========================="); |
|||
|
|||
try |
|||
{ |
|||
string ip = "192.168.1.65"; |
|||
string username = "admin"; |
|||
string password = "hk123456"; |
|||
int type = (int)CameraType.HiK; |
|||
CameraInfo cameraInfo = CameraInfo.New(type, ip, username, password); |
|||
ICameraSDK sdk = new HiKSDK(cameraInfo); |
|||
ICameraSDK sdk2 = new HiKSDK(cameraInfo); |
|||
sdk.Init(); |
|||
sdk2.Init(); |
|||
|
|||
PtzInfo ptzInfo = sdk.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
|
|||
sdk.Destory(); |
|||
|
|||
Thread.Sleep(1000); |
|||
|
|||
ptzInfo = sdk.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
|
|||
ptzInfo = sdk2.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Console.WriteLine(e.ToString()); |
|||
throw; |
|||
} |
|||
Console.WriteLine("================================="); |
|||
} |
|||
|
|||
public static void DaHuaTest() |
|||
{ |
|||
Console.WriteLine("====DaHua========================"); |
|||
|
|||
try |
|||
{ |
|||
string ip = "192.168.1.71"; |
|||
string username = "admin"; |
|||
string password = "hk123456"; |
|||
int type = (int)CameraType.DaHua; |
|||
CameraInfo cameraInfo = CameraInfo.New(type, ip, username, password); |
|||
ICameraSDK sdk = new DaHuaSDK(cameraInfo); |
|||
ICameraSDK sdk2 = new DaHuaSDK(cameraInfo); |
|||
sdk.Init(); |
|||
sdk2.Init(); |
|||
PtzInfo ptzInfo = sdk.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
|
|||
sdk.Destory(); |
|||
|
|||
Thread.Sleep(1000); |
|||
|
|||
ptzInfo = sdk.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
|
|||
ptzInfo = sdk2.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Console.WriteLine(e.ToString()); |
|||
throw; |
|||
} |
|||
|
|||
Console.WriteLine("================================="); |
|||
} |
|||
|
|||
public static void YuShiTest() |
|||
{ |
|||
Console.WriteLine("====YuShi========================"); |
|||
|
|||
try |
|||
{ |
|||
string ip = "192.168.1.109"; |
|||
string username = "admin"; |
|||
string password = "hk123456"; |
|||
int type = (int)CameraType.YuShi; |
|||
CameraInfo cameraInfo = CameraInfo.New(type, ip, username, password); |
|||
ICameraSDK sdk = new YuShiSDK(cameraInfo); |
|||
ICameraSDK sdk2 = new YuShiSDK(cameraInfo); |
|||
sdk.Init(); |
|||
sdk2.Init(); |
|||
PtzInfo ptzInfo = sdk.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
|
|||
sdk.Destory(); |
|||
|
|||
Thread.Sleep(1000); |
|||
|
|||
ptzInfo = sdk.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
|
|||
ptzInfo = sdk2.GetPtzInfo(); |
|||
Console.WriteLine($"{ptzInfo.Pan}, {ptzInfo.Tilt}, {ptzInfo.Zoom}"); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Console.WriteLine(e.ToString()); |
|||
throw; |
|||
} |
|||
|
|||
Console.WriteLine("================================="); |
|||
} |
|||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue