|
@@ -12,7 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.persagy.cameractl.cvr.HCNetSDK;
|
|
|
import com.persagy.cameractl.cvr.HCNetSDK.NET_DVR_USER_LOGIN_INFO;
|
|
|
-import com.persagy.cameractl.init.SDKInit;
|
|
|
+import com.persagy.cameractl.init.DevInfoCallBack;
|
|
|
+import com.persagy.cameractl.init.SystemInit;
|
|
|
import com.persagy.cameractl.utils.Camera;
|
|
|
import com.persagy.cameractl.utils.ResultClass;
|
|
|
import com.sun.jna.Structure;
|
|
@@ -46,7 +47,7 @@ public class Test2Controller {
|
|
|
returnResult.name = false;
|
|
|
|
|
|
// SDK初始化
|
|
|
- boolean init = SDKInit.init();
|
|
|
+ boolean init = SystemInit.init();
|
|
|
if (!init) {
|
|
|
returnResult.reason = "SDK初始化失败";
|
|
|
return returnResult;
|
|
@@ -54,18 +55,18 @@ public class Test2Controller {
|
|
|
|
|
|
HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
|
|
|
//NET_DVR_USER_LOGIN_INFO m_strLoginInfo = this.getLoginObject(cameraApiConfig.getDecodeDeviceUserName(), cameraApiConfig.getDecodeDevicePassword(), cameraApiConfig.getDecodeDeviceIp(), (short)cameraApiConfig.getDecodeDevicePort());
|
|
|
- NET_DVR_USER_LOGIN_INFO m_strLoginInfo = SDKInit.getLoginObject(camera.userName, camera.password, camera.cameraIp, (short)camera.cameraPort);
|
|
|
- int lUserID = SDKInit.hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
|
|
|
+ NET_DVR_USER_LOGIN_INFO m_strLoginInfo = SystemInit.getLoginObject(camera.userName, camera.password, camera.cameraIp, (short)camera.cameraPort);
|
|
|
+ int lUserID = SystemInit.hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
|
|
|
if (lUserID == -1) {
|
|
|
- int errCode = SDKInit.hCNetSDK.NET_DVR_GetLastError();
|
|
|
+ int errCode = SystemInit.hCNetSDK.NET_DVR_GetLastError();
|
|
|
returnResult.reason = "设备注册失败,错误码: " + errCode;
|
|
|
return returnResult;
|
|
|
}
|
|
|
|
|
|
DevInfoCallBack fDevInfoCallBack = new DevInfoCallBack(strStreamInfo);
|
|
|
- int startRemoteHandle = SDKInit.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_STREAM_INFO, null, 0, fDevInfoCallBack, null);
|
|
|
+ int startRemoteHandle = SystemInit.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_STREAM_INFO, null, 0, fDevInfoCallBack, null);
|
|
|
if (startRemoteHandle == -1) {
|
|
|
- returnResult.reason = "启动远程配置失败,错误码: " + SDKInit.hCNetSDK.NET_DVR_GetLastError();
|
|
|
+ returnResult.reason = "启动远程配置失败,错误码: " + SystemInit.hCNetSDK.NET_DVR_GetLastError();
|
|
|
return returnResult;
|
|
|
}
|
|
|
|
|
@@ -78,114 +79,21 @@ public class Test2Controller {
|
|
|
returnResult.resultData = STREAM_ID_2_CHANNEL;
|
|
|
|
|
|
// 关闭资源
|
|
|
- boolean remoteConfig = SDKInit.hCNetSDK.NET_DVR_StopRemoteConfig(startRemoteHandle);
|
|
|
+ boolean remoteConfig = SystemInit.hCNetSDK.NET_DVR_StopRemoteConfig(startRemoteHandle);
|
|
|
if (!remoteConfig) {
|
|
|
- logger.warn("NET_DVR_StopRemoteConfig failure, errorCode: " + SDKInit.hCNetSDK.NET_DVR_GetLastError());
|
|
|
- returnResult.reason = "关闭长连接配置接口所创建的句柄,释放资源失败,错误码: " + SDKInit.hCNetSDK.NET_DVR_GetLastError();
|
|
|
+ logger.warn("NET_DVR_StopRemoteConfig failure, errorCode: " + SystemInit.hCNetSDK.NET_DVR_GetLastError());
|
|
|
+ returnResult.reason = "关闭长连接配置接口所创建的句柄,释放资源失败,错误码: " + SystemInit.hCNetSDK.NET_DVR_GetLastError();
|
|
|
return returnResult;
|
|
|
}
|
|
|
|
|
|
//退出程序时调用,每一台设备分别注销
|
|
|
- if (SDKInit.hCNetSDK.NET_DVR_Logout(lUserID)) {
|
|
|
+ if (SystemInit.hCNetSDK.NET_DVR_Logout(lUserID)) {
|
|
|
logger.info("logout success");
|
|
|
}
|
|
|
|
|
|
returnResult.name = true;
|
|
|
return returnResult;
|
|
|
}
|
|
|
-
|
|
|
- public static class NET_DVR_STREAM_SRC_INFO_V40 extends Structure {
|
|
|
- public int dwSize;
|
|
|
- public byte byGetStreamType;
|
|
|
- public byte[] byRes1 = new byte[3];
|
|
|
- public NET_DVR_STREAM_TYPE_V40_UNION uGetStream = new NET_DVR_STREAM_TYPE_V40_UNION();
|
|
|
- public byte[] byRes = new byte[512];
|
|
|
- }
|
|
|
-
|
|
|
- public static class NET_DVR_STREAM_TYPE_V40_UNION extends Union {
|
|
|
- public NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40 struChanInfo = new NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40();
|
|
|
- public NET_DVR_PU_STREAM_URL struPuStreamUrl = new NET_DVR_PU_STREAM_URL();
|
|
|
- public NET_DVR_PU_STREAM_URL_CFG_V40 struStreamUrlCfg = new NET_DVR_PU_STREAM_URL_CFG_V40();
|
|
|
- public NET_DVR_RTSP_PROTOCAL_CFG struRtspCfg = new NET_DVR_RTSP_PROTOCAL_CFG();
|
|
|
- public NET_DVR_STREAM_URL_V40 struStreamUrlV40 = new NET_DVR_STREAM_URL_V40();
|
|
|
- }
|
|
|
-
|
|
|
- public static class NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40 extends Structure {
|
|
|
- public byte byEnable;
|
|
|
- public byte byProType;
|
|
|
- public byte byZeroChan;
|
|
|
- public byte byRes1;
|
|
|
- public byte[] sUserName = new byte[32];
|
|
|
- public byte[] sPassword = new byte[16];
|
|
|
- public byte[] byAddress = new byte[64];
|
|
|
- public short wDVRPort;
|
|
|
- public byte byStreamType;
|
|
|
- public byte byOnline;
|
|
|
- public int dwChannel;
|
|
|
- public byte byTransProtocol;
|
|
|
- public byte byLocalBackUp;
|
|
|
- public byte[] byRes2 = new byte[2];
|
|
|
- public byte[] byVAGChanNo = new byte[32];
|
|
|
- public byte[] byRes = new byte[340];
|
|
|
- }
|
|
|
-
|
|
|
- public static class NET_DVR_PU_STREAM_URL extends Structure {
|
|
|
- public byte byEnable;//是否启用:0- 禁用,1- 启用
|
|
|
- public byte[] strURL = new byte[240];//取流URL路径
|
|
|
- public byte byTransPortocol;//传输协议类型:0-TCP,1-UDP
|
|
|
- public short wIPID;//设备ID号,wIPID = iDevInfoIndex + iGroupNO*64 +1
|
|
|
- public byte byChannel;//设备通道号
|
|
|
- public byte[] byRes = new byte[7];//保留,置为0
|
|
|
- }
|
|
|
-
|
|
|
- public static class NET_DVR_PU_STREAM_URL_CFG_V40 extends Structure {
|
|
|
- public byte byEnable;
|
|
|
- public byte[] byRes = new byte[3];
|
|
|
- public byte[] byStreamMediaIP = new byte[64];
|
|
|
- public short wStreamMediaPort;
|
|
|
- public byte byTransmitType;
|
|
|
- public byte byRes1;
|
|
|
- public byte[] byDevIP = new byte[64];
|
|
|
- public short wDevPort;
|
|
|
- public byte byChannel;
|
|
|
- public byte byTransMode;
|
|
|
- public byte byProType;
|
|
|
- public byte byTransProtocol;
|
|
|
- public byte[] byRes3 = new byte[2];
|
|
|
- public byte[] sUserName = new byte[32];
|
|
|
- public byte[] sPassWord = new byte[16];
|
|
|
- public byte[] byRes2 = new byte[308];
|
|
|
- }
|
|
|
-
|
|
|
- public static class NET_DVR_RTSP_PROTOCAL_CFG extends Structure {
|
|
|
- public byte byEnable;
|
|
|
- public byte byLocalBackUp;
|
|
|
- public byte[] byRes = new byte[2];
|
|
|
- public byte[] strURL = new byte[256];
|
|
|
- public int dwProtocalType;
|
|
|
- public byte[] sUserName = new byte[32];
|
|
|
- public byte[] sPassWord = new byte[16];
|
|
|
- public byte[] byAddress = new byte[64];
|
|
|
- public short wPort;
|
|
|
- public byte[] byRes1 = new byte[122];
|
|
|
- }
|
|
|
-
|
|
|
- public static class NET_DVR_STREAM_URL_V40 extends Structure {
|
|
|
- public byte byEnable;
|
|
|
- public byte byStreamType;
|
|
|
- public byte byLocalBackUp;
|
|
|
- public byte byRes;
|
|
|
- public byte[] strURL = new byte[256];
|
|
|
- public int dwProtocalType;
|
|
|
- public byte[] sUserName = new byte[32];
|
|
|
- public byte[] sPassWord = new byte[16];
|
|
|
- public byte[] byAddress = new byte[64];
|
|
|
- public short wIPPort;
|
|
|
- public short wChanNo;
|
|
|
- public byte[] byVAGChanNo = new byte[32];
|
|
|
- public byte[] byRes1 = new byte[88];
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
public static class NET_DVR_STREAM_SRC_CFG extends Structure {
|
|
|
public int dwSize;
|