//#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 }