From 67bd75bdd209c9019e21e2cec39bcd43898c4671 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: 星期一, 06 五月 2024 15:32:51 +0800
Subject: [PATCH] 移除webrtc-streamer
---
ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java | 306 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 212 insertions(+), 94 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
index 3f8969b..5c9587f 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
@@ -32,9 +32,12 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.PriorityBlockingQueue;
@@ -77,7 +80,7 @@
try {
// 鍒濆鍖�
if (!hCNetSDK.NET_DVR_Init()) {
- log.error("SDK鍒濆鍖栧け璐�");
+ log.debug("SDK鍒濆鍖栧け璐�");
}
//鎵撳嵃娴峰悍sdk鏃ュ織
if (Platform.isWindows()) {
@@ -120,8 +123,8 @@
//鍒犻櫎绠$悊閫氶亾
ardChannelService.deleteArdChannelByDeviceId(camera.getId());
ardCamerasService.updateArdCameras(camera);
- log.error("璁惧[" + camera.getIp() + ":" + camera.getPort() + "]鐧诲綍澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
- return AjaxResult.error("璁惧鐧诲綍澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
+ log.debug("璁惧[" + camera.getIp() + ":" + camera.getPort() + "]鐧诲綍澶辫触: " + SdkErrorCodeEnum.getDescByCode(errorCode) + "(" + errorCode + ")");
+ return AjaxResult.warn("璁惧[" + camera.getIp() + ":" + camera.getPort() + "]鐧诲綍澶辫触: " + SdkErrorCodeEnum.getDescByCode(errorCode) + "(" + errorCode + ")");
}
log.debug("Login Success [ " + camera.getIp() + ":" + camera.getPort() + " ]");
@@ -188,7 +191,7 @@
// 鍒濆鍖�
if (!hCNetSDK.NET_DVR_Init()) {
log.error("SDK鍒濆鍖栧け璐�");
- return AjaxResult.error("SDK鍒濆鍖栧け璐�");
+ return AjaxResult.warn("SDK鍒濆鍖栧け璐�");
}
//鎵撳嵃娴峰悍sdk鏃ュ織
if (Platform.isWindows()) {
@@ -231,8 +234,8 @@
//鍒犻櫎绠$悊閫氶亾
ardChannelService.deleteArdChannelByDeviceId(camera.getId());
ardCamerasService.updateArdCameras(camera);
- log.error("璁惧[" + camera.getIp() + ":" + camera.getPort() + "]鐧诲綍澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
- return AjaxResult.error("璁惧鐧诲綍澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
+ log.error("璁惧[" + camera.getIp() + ":" + camera.getPort() + "]鐧诲綍澶辫触: " + SdkErrorCodeEnum.getDescByCode(errorCode) + "(" + errorCode + ")");
+ return AjaxResult.warn("璁惧[" + camera.getIp() + ":" + camera.getPort() + "]鐧诲綍澶辫触: " + SdkErrorCodeEnum.getDescByCode(errorCode) + "(" + errorCode + ")");
}
log.debug("Login Success 銆� " + camera.getIp() + ":" + camera.getPort() + " 銆�");
synchronized (_lock) {
@@ -284,16 +287,12 @@
//鍒涘缓寮曞闃熷垪
private void createGuideQueue(ArdCameras camera) {
- if (camera.getCamAlarmGuideEnable() != null) {
- if (camera.getCamAlarmGuideEnable() == 1) {
- if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
- Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
- PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
- GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
- //鍚姩闃熷垪澶勭悊鍣�
- queueHandler.process(camera.getId());
- }
- }
+ if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
+ Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
+ PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
+ GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue);
+ //鍚姩闃熷垪澶勭悊鍣�
+ queueHandler.process(camera.getId());
}
}
@@ -388,7 +387,7 @@
Integer speed = cmd.getSpeed();
Integer code = cmd.getCode();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
int dwStop;
@@ -457,7 +456,7 @@
if (!bool) {
int errorCode = hCNetSDK.NET_DVR_GetLastError();
log.error("鎺у埗澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
- return AjaxResult.error("鎺у埗澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
+ return AjaxResult.warn("鎺у埗澶辫触:" + SdkErrorCodeEnum.getDescByCode(errorCode) + "(" + errorCode + ")");
}
return AjaxResult.success("鎺у埗鎴愬姛");
}
@@ -473,7 +472,7 @@
Integer channelNum = cmd.getChanNo();
Integer dwFocusPos = cmd.getDwFocusPos();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
// 鑾峰彇鍙傛暟
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
@@ -491,7 +490,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("璁剧疆GIS淇℃伅鏁版嵁澶辫触,璇风◢鍚庨噸璇�" + code);
- return AjaxResult.error("璁剧疆GIS淇℃伅鏁版嵁澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璁剧疆GIS淇℃伅鏁版嵁澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
return AjaxResult.success("璁剧疆GIS淇℃伅鏁版嵁鎴愬姛");
}
@@ -523,7 +522,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇鑱氱劍鍊煎け璐�: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇鑱氱劍鍊煎け璐�: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇鑱氱劍鍊煎け璐�:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
struGisInfo.read();
int result = struGisInfo.struPtzPosEx.dwFocus;
@@ -548,7 +547,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("棰勭疆鐐硅缃け璐�: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("棰勭疆鐐硅缃け璐�: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("棰勭疆鐐硅缃け璐�:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
return AjaxResult.success("棰勭疆鐐硅缃垚鍔�");
}
@@ -571,7 +570,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("璋冪敤棰勭疆鐐瑰け璐�: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("璋冪敤棰勭疆鐐瑰け璐�: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璋冪敤棰勭疆鐐瑰け璐�:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
return AjaxResult.success("璋冪敤棰勭疆鐐规垚鍔�");
}
@@ -900,7 +899,7 @@
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
@@ -912,7 +911,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇ptz澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇ptz澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇ptz澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
m_ptzPosCurrent.read();
// DecimalFormat df = new DecimalFormat("0.0");//璁剧疆淇濈暀浣嶆暟
@@ -950,7 +949,7 @@
String cameraId = cmd.getCameraId();
Integer chanNo = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
IntByReference pchannel = new IntByReference(chanNo);
Pointer pChannelNum = pchannel.getPointer();
@@ -967,8 +966,8 @@
boolean res = hCNetSDK.NET_DVR_GetSTDConfig(lUserID, HCNetSDK.NET_DVR_GET_PTZABSOLUTEEX, lpConfigParam6696);
if (!res) {
int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("鑾峰彇楂樼簿搴TZ缁濆浣嶇疆閰嶇疆澶辫触: errorCde" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇楂樼簿搴TZ缁濆浣嶇疆閰嶇疆澶辫触: errorCde" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ log.error("鑾峰彇楂樼簿搴TZ澶辫触: errorCode" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇楂樼簿搴TZ澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
lpPTZAbsoluteEX_cfg.read();
//log.debug("P锛�" + lpPTZAbsoluteEX_cfg.struPTZCtrl.fPan + " T锛�" + lpPTZAbsoluteEX_cfg.struPTZCtrl.fTilt + " Z锛�" + lpPTZAbsoluteEX_cfg.struPTZCtrl.fZoom
@@ -1003,7 +1002,7 @@
Integer channelNum = cmd.getChanNo();
Map<String, Double> ptz = cmd.getPtzMap();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_PTZPOS m_ptzPosCurrent = new NET_DVR_PTZPOS();
@@ -1019,9 +1018,9 @@
m_ptzPosCurrent.write();
boolean bool = hCNetSDK.NET_DVR_SetDVRConfig(userId, NET_DVR_SET_PTZPOS, channelNum, point, m_ptzPosCurrent.size());
if (!bool) {
- int errorCode = hCNetSDK.NET_DVR_GetLastError();
- log.error("璁剧疆PTZ鍙傛暟澶辫触:" + errorCode);
- return AjaxResult.error("璁剧疆PTZ鍙傛暟澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("璁剧疆PTZ鍙傛暟澶辫触: errorCode" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璁剧疆PTZ鍙傛暟澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
return AjaxResult.success("璁剧疆PTZ鍙傛暟鎴愬姛");
} catch (Exception ex) {
@@ -1046,7 +1045,7 @@
Integer chanNo = cmd.getChanNo();
Map<String, Double> ptz = cmd.getPtzMap();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer lUserID = (Integer) GlobalVariable.loginMap.get(cameraId);
IntByReference pchannel = new IntByReference(chanNo);
@@ -1078,9 +1077,9 @@
lpConfigParam6697.write();
boolean bool = hCNetSDK.NET_DVR_SetSTDConfig(lUserID, NET_DVR_SET_PTZABSOLUTEEX, lpConfigParam6697);
if (!bool) {
- int errorCode = hCNetSDK.NET_DVR_GetLastError();
- log.error("璁剧疆楂樼簿搴TZ鍙傛暟澶辫触:" + errorCode);
- return AjaxResult.error("璁剧疆楂樼簿搴TZ鍙傛暟澶辫触: errorCode:" + errorCode + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("璁剧疆楂樼簿搴TZ澶辫触:" + code);
+ return AjaxResult.warn("璁剧疆楂樼簿搴TZ澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
return AjaxResult.success("璁剧疆楂樼簿搴TZ鍙傛暟鎴愬姛");
@@ -1096,7 +1095,7 @@
String cameraId = cmd.getCameraId();
Integer chanNo = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_PTZPOS m_ptzPosCurrent = new NET_DVR_PTZPOS();
@@ -1118,7 +1117,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("璁剧疆ptz澶辫触,璇风◢鍚庨噸璇�" + code);
- return AjaxResult.error("璁剧疆ptz澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璁剧疆ptz澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
return AjaxResult.success("寮曞鍧愭爣鎴愬姛");
} catch (Exception ex) {
@@ -1140,7 +1139,7 @@
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_PTZ_LOCKCFG netDvrPtzLockcfg = new NET_DVR_PTZ_LOCKCFG();
@@ -1150,8 +1149,8 @@
boolean bool = hCNetSDK.NET_DVR_GetDVRConfig(userId, NET_DVR_GET_PTZLOCKCFG, channelNum, point, netDvrPtzLockcfg.size(), ibrBytesReturned);
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("鑾峰彇ptz閿佸畾淇℃伅澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇ptz閿佸畾淇℃伅澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ log.error("鑾峰彇ptz閿佸畾澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇ptz閿佸畾澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
} else {
netDvrPtzLockcfg.read();
int byWorkMode = netDvrPtzLockcfg.byWorkMode;
@@ -1188,7 +1187,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("璁剧疆闆舵柟浣嶈澶辫触:" + code);
- return AjaxResult.error("璁剧疆闆舵柟浣嶈澶辫触: errorCode:" + code + "errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璁剧疆闆舵柟浣嶈澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
return AjaxResult.success();
}
@@ -1217,7 +1216,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇ptz鑼冨洿澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇ptz鑼冨洿澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇ptz鑼冨洿澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
} else {
m_ptzPosCurrent.read();
DecimalFormat df = new DecimalFormat("0.0");//璁剧疆淇濈暀浣嶆暟
@@ -1253,7 +1252,7 @@
boolean enable = cmd.isEnable();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_CAMERAPARAMCFG_EX struCameraParam = new NET_DVR_CAMERAPARAMCFG_EX();
@@ -1263,7 +1262,7 @@
if (!b_GetCameraParam) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇鍓嶇鍙傛暟澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
struCameraParam.read();
log.debug("鏄惁寮�鍚�忛浘锛�" + struCameraParam.struDefogCfg.byMode);
@@ -1281,7 +1280,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鍒囨崲閫忛浘澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鍒囨崲閫忛浘澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鍒囨崲閫忛浘澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
log.debug("鍒囨崲閫忛浘鎴愬姛");
return AjaxResult.success("鍒囨崲閫忛浘鎴愬姛");
@@ -1301,7 +1300,7 @@
boolean enable = cmd.isEnable();
Integer chanNo = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_CAMERAPARAMCFG_EX struDayNigh = new NET_DVR_CAMERAPARAMCFG_EX();
@@ -1311,7 +1310,7 @@
if (!b_GetCameraParam) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇鍓嶇鍙傛暟澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
struDayNigh.read();
String current = struDayNigh.struDayNight.byDayNightFilterType == 1 ? "寮�鍚�" : "鍏抽棴";
@@ -1331,7 +1330,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鍒囨崲绾㈠澶辫触 ErrorCode:{},ErrorInfo:{}", code, SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鍒囨崲绾㈠澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鍒囨崲绾㈠澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
log.debug("鍒囨崲绾㈠鎴愬姛");
return AjaxResult.success("鍒囨崲绾㈠鎴愬姛");
@@ -1351,7 +1350,7 @@
boolean enable = cmd.isEnable();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_FOCUSMODE_CFG struFocusMode = new NET_DVR_FOCUSMODE_CFG();
@@ -1361,7 +1360,7 @@
if (!b_GetCameraParam) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇鍓嶇鍙傛暟澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
struFocusMode.read();
log.debug("褰撳墠鑱氱劍妯″紡锛�" + struFocusMode.byFocusMode);
@@ -1379,7 +1378,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("璁剧疆鑱氱劍妯″紡澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("璁剧疆鑱氱劍妯″紡澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璁剧疆鑱氱劍妯″紡澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
log.debug("璁剧疆鑱氱劍妯″紡鎴愬姛");
return AjaxResult.success("璁剧疆鑱氱劍妯″紡鎴愬姛");
@@ -1397,7 +1396,7 @@
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_FOCUSMODE_CFG struFocusMode = new NET_DVR_FOCUSMODE_CFG();
@@ -1406,8 +1405,8 @@
boolean b_GetCameraParam = hCNetSDK.NET_DVR_GetDVRConfig(userId, NET_DVR_GET_FOCUSMODECFG, channelNum, point, struFocusMode.size(), ibrBytesReturned);
if (!b_GetCameraParam) {
int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ log.error("鑾峰彇鑱氱劍妯″紡澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇鑱氱劍妯″紡澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
struFocusMode.read();
log.debug("褰撳墠鑱氱劍妯″紡锛�" + struFocusMode.byFocusMode);
@@ -1428,7 +1427,7 @@
boolean enable = cmd.isEnable();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
int dwStop;
@@ -1441,7 +1440,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("璁剧疆浜戝彴鍔犵儹澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("璁剧疆浜戝彴鍔犵儹澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璁剧疆浜戝彴鍔犵儹澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
log.debug("璁剧疆浜戝彴鍔犵儹鎴愬姛");
return AjaxResult.success("璁剧疆浜戝彴鍔犵儹鎴愬姛");
@@ -1461,7 +1460,7 @@
boolean enable = cmd.isEnable();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_DEVSERVER_CFG struDeicing = new NET_DVR_DEVSERVER_CFG();
@@ -1471,7 +1470,7 @@
if (!b_GetCameraParam) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇鍓嶇鍙傛暟澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇鍓嶇鍙傛暟澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
struDeicing.read();
log.debug("鏄惁寮�鍚櫎鍐帮細" + struDeicing.byEnableDeicing);
@@ -1486,7 +1485,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("璁剧疆闀滃ご闄ゅ啺澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("璁剧疆闀滃ご闄ゅ啺澶辫触: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("璁剧疆闀滃ご闄ゅ啺澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
log.debug("璁剧疆闀滃ご闄ゅ啺鎴愬姛");
return AjaxResult.success("璁剧疆闀滃ご闄ゅ啺鎴愬姛");
@@ -1497,38 +1496,45 @@
*
* @param cmd 鐩告満鍛戒护
*/
- public AjaxResult captureJPEGPicture(CameraCmd cmd) {
- String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChanNo();
- if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ @Override
+ public AjaxResult localCapture(CameraCmd cmd) {
+ try {
+ String cameraId = cmd.getCameraId();
+ Integer channelNum = cmd.getChanNo();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return AjaxResult.warn("璁惧鏈櫥褰�");
+ }
+ Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
+ NET_DVR_WORKSTATE_V30 devwork = new NET_DVR_WORKSTATE_V30();
+ if (!hCNetSDK.NET_DVR_GetDVRWorkState_V30(userId, devwork)) {
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("鑾峰彇璁惧宸ヤ綔鐘舵�佸け璐�: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇璁惧宸ヤ綔鐘舵�佸け璐�:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
+ }
+ //鍥剧墖璐ㄩ噺
+ NET_DVR_JPEGPARA jpeg = new NET_DVR_JPEGPARA();
+ //璁剧疆鍥剧墖鍒嗚鲸鐜�
+ jpeg.wPicSize = 0;
+ //璁剧疆鍥剧墖璐ㄩ噺
+ jpeg.wPicQuality = 0;
+ IntByReference a = new IntByReference();
+ //璁剧疆鍥剧墖澶у皬
+ ByteBuffer jpegBuffer = ByteBuffer.allocate(1024 * 1024);
+ // 鎶撳浘鍒板唴瀛橈紝鍗曞抚鏁版嵁鎹曡幏骞朵繚瀛樻垚JPEG瀛樻斁鍦ㄦ寚瀹氱殑鍐呭瓨绌洪棿涓�
+ boolean is = hCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(userId, channelNum, jpeg, jpegBuffer, 1024 * 1024, a);
+ //log.debug("-----------杩欓噷寮�濮嬪浘鐗囧瓨鍏ュ唴瀛�----------" + is);
+ // OutputStream outputStream = response.getOutputStream();
+ //outputStream.write(jpegBuffer.array());
+ //Base64.Encoder decoder = Base64.getEncoder();
+ // BASE64Encoder encoder = new BASE64Encoder();
+ //String png_base64 = decoder.encodeToString(jpegBuffer.array());//杞崲鎴恇ase64涓�
+ // png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//鍒犻櫎 \r\n
+ //log.debug("-----------澶勭悊瀹屾垚鎴浘鏁版嵁----------");
+ return AjaxResult.success(jpegBuffer.array());
+ } catch (Exception ex) {
+ log.error("-----------鎴浘澶辫触----------");
+ return AjaxResult.error(ex.getMessage());
}
- Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
- NET_DVR_WORKSTATE_V30 devwork = new NET_DVR_WORKSTATE_V30();
- if (!hCNetSDK.NET_DVR_GetDVRWorkState_V30(userId, devwork)) {
- int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("鑾峰彇璁惧宸ヤ綔鐘舵�佸け璐�: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇璁惧宸ヤ綔鐘舵�佸け璐�: errorCode" + code + " errorInfo" + SdkErrorCodeEnum.getDescByCode(code));
- }
- //鍥剧墖璐ㄩ噺
- NET_DVR_JPEGPARA jpeg = new NET_DVR_JPEGPARA();
- //璁剧疆鍥剧墖鍒嗚鲸鐜�
- jpeg.wPicSize = 0;
- //璁剧疆鍥剧墖璐ㄩ噺
- jpeg.wPicQuality = 0;
- IntByReference a = new IntByReference();
- //璁剧疆鍥剧墖澶у皬
- ByteBuffer jpegBuffer = ByteBuffer.allocate(1024 * 1024);
- // 鎶撳浘鍒板唴瀛橈紝鍗曞抚鏁版嵁鎹曡幏骞朵繚瀛樻垚JPEG瀛樻斁鍦ㄦ寚瀹氱殑鍐呭瓨绌洪棿涓�
- boolean is = hCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(userId, channelNum, jpeg, jpegBuffer, 1024 * 1024, a);
- log.debug("-----------杩欓噷寮�濮嬪浘鐗囧瓨鍏ュ唴瀛�----------" + is);
-
- Base64.Encoder decoder = Base64.getEncoder();
- // BASE64Encoder encoder = new BASE64Encoder();
- String png_base64 = decoder.encodeToString(jpegBuffer.array());//杞崲鎴恇ase64涓�
- png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//鍒犻櫎 \r\n
- log.debug("-----------澶勭悊瀹屾垚鎴浘鏁版嵁----------");
- return AjaxResult.success(png_base64);
}
/**
@@ -1689,7 +1695,8 @@
netDvrIFrame.dwSize = netDvrIFrame.size();
netDvrIFrame.write();
if (!hCNetSDK.NET_DVR_RemoteControl(userId, 3402, netDvrIFrame.getPointer(), netDvrIFrame.dwSize)) {
- log.error("寮哄埗I甯� 閿欒鐮佷负: " + hCNetSDK.NET_DVR_GetLastError());
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("璁剧疆寮哄埗I甯ч敊璇�:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
//棰勮鍙傛暟
NET_DVR_PREVIEWINFO previewinfo = new NET_DVR_PREVIEWINFO();
@@ -1898,7 +1905,7 @@
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return AjaxResult.error("璁惧鏈櫥褰�");
+ return AjaxResult.warn("璁惧鏈櫥褰�");
}
// 鑾峰彇鍙傛暟
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
@@ -1915,7 +1922,7 @@
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
log.error("鑾峰彇GIS淇℃伅鏁版嵁澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
- return AjaxResult.error("鑾峰彇GIS淇℃伅鏁版嵁澶辫触: errorCode:" + code + " errorInfo:" + SdkErrorCodeEnum.getDescByCode(code));
+ return AjaxResult.warn("鑾峰彇GIS淇℃伅鏁版嵁澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
}
struGisInfo.read();
Map<String, Object> map = new HashMap<>();
@@ -1927,4 +1934,115 @@
return AjaxResult.success(map);
}
+
+ //鏈湴褰曞儚寮�濮�
+ @Override
+ public AjaxResult localRecordStart(CameraCmd cmd) {
+ try {
+ String cameraId = cmd.getCameraId();
+ Integer channelNum = cmd.getChanNo();
+ String path = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4");
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return AjaxResult.warn("璁惧鏈櫥褰�");
+ }
+ Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
+ //寮哄埗I甯х粨鏋勪綋瀵硅薄
+ HCNetSDK.NET_DVR_I_FRAME netDvrIFrame = new HCNetSDK.NET_DVR_I_FRAME(); //鏂板缓缁撴瀯浣撳璞�
+ netDvrIFrame.read();
+ netDvrIFrame.dwChannel = channelNum;//鍥犱负涓婃枃浠g爜涓缃簡閫氶亾鍙凤紝鎸夌収涓婃枃涓殑璁剧疆
+ netDvrIFrame.byStreamType = 0;
+ netDvrIFrame.dwSize = netDvrIFrame.size();
+ netDvrIFrame.write();
+ if (!hCNetSDK.NET_DVR_RemoteControl(userId, 3402, netDvrIFrame.getPointer(), netDvrIFrame.dwSize)) {
+ log.error("寮哄埗I甯� 閿欒鐮佷负: " + hCNetSDK.NET_DVR_GetLastError());
+ }
+ //棰勮鍙傛暟
+ NET_DVR_PREVIEWINFO previewinfo = new NET_DVR_PREVIEWINFO();
+ previewinfo.read();
+ previewinfo.lChannel = channelNum;
+ previewinfo.dwStreamType = 0;//鐮佹祦绫诲瀷锛�0-涓荤爜娴侊紝1-瀛愮爜娴侊紝2-涓夌爜娴侊紝3-铏氭嫙鐮佹祦锛屼互姝ょ被鎺�
+ previewinfo.dwLinkMode = 0;//杩炴帴鏂瑰紡锛�0-TCP鏂瑰紡锛�1-UDP鏂瑰紡锛�2-澶氭挱鏂瑰紡锛�3-RTP鏂瑰紡锛�4-RTP/RTSP锛�5-RTP/HTTP锛�6-HRUDP锛堝彲闈犱紶杈擄級锛�7-RTSP/HTTPS锛�8-NPQ
+ previewinfo.hPlayWnd = null;//鎾斁绐楀彛鐨勫彞鏌勶紝涓篘ULL琛ㄧず涓嶈В鐮佹樉绀恒��
+ previewinfo.bBlocked = 0;//0- 闈為樆濉炲彇娴侊紝1-闃诲鍙栨祦
+ previewinfo.byNPQMode = 0;//NPQ妯″紡锛�0-鐩磋繛妯″紡锛�1-杩囨祦濯掍綋妯″紡
+ previewinfo.write();
+ //if (GlobalVariable.previewMap.containsKey(cameraId)) {
+ // Integer lRealHandle = GlobalVariable.previewMap.get(cameraId);
+ // hCNetSDK.NET_DVR_StopRealPlay(lRealHandle);
+ // GlobalVariable.previewMap.remove(cameraId);
+ // log.debug("鍋滄褰撳墠褰曞儚");
+ //}
+ int lRealHandle = hCNetSDK.NET_DVR_RealPlay_V40(userId, previewinfo, null, null);
+ if (lRealHandle == -1) {
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("鏈湴褰曞儚鍙栨祦澶辫触" + hCNetSDK.NET_DVR_GetLastError());
+ return AjaxResult.warn("鏈湴褰曞儚鍙栨祦澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
+ }
+ log.debug("鏈湴褰曞儚鍙栨祦鎴愬姛");
+ //GlobalVariable.threadMap.put(cameraId, Thread.currentThread().getName());
+ //GlobalVariable.previewMap.put(cameraId, lRealHandle);
+ if (!hCNetSDK.NET_DVR_SaveRealData_V30(lRealHandle, 2, path)) {
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("淇濆瓨瑙嗛鏂囦欢鍒颁复鏃舵枃浠跺す澶辫触 閿欒鐮佷负: " + hCNetSDK.NET_DVR_GetLastError());
+ return AjaxResult.warn("鏈湴褰曞儚鍙栨祦澶辫触:" + SdkErrorCodeEnum.getDescByCode(code) + "(" + code + ")");
+ }
+ log.debug("鏈湴褰曞儚寮�濮�");
+ return AjaxResult.success("褰曞儚寮�濮�", lRealHandle);
+ } catch (Exception ex) {
+ log.error("鏈湴褰曞儚寮�濮嬪紓甯�" + ex.getMessage());
+ return AjaxResult.error("鏈湴褰曞儚寮�濮嬪紓甯�" + ex.getMessage());
+ }
+ }
+
+ //鏈湴褰曞儚鍋滄
+ @Override
+ public AjaxResult localRecordStop(CameraCmd cmd) {
+ try {
+ String cameraId = cmd.getCameraId();
+ Integer channelNum = cmd.getChanNo();
+ Integer lRealHandle = cmd.getRecordId().intValue();
+
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return AjaxResult.warn("璁惧鏈櫥褰�");
+ }
+ Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
+ //region 寮哄埗I甯�
+ HCNetSDK.NET_DVR_I_FRAME netDvrIFrame = new HCNetSDK.NET_DVR_I_FRAME(); //鏂板缓缁撴瀯浣撳璞�
+ netDvrIFrame.read();
+ netDvrIFrame.dwChannel = channelNum;//鍥犱负涓婃枃浠g爜涓缃簡閫氶亾鍙凤紝鎸夌収涓婃枃涓殑璁剧疆
+ netDvrIFrame.byStreamType = 0;
+ netDvrIFrame.dwSize = netDvrIFrame.size();
+ netDvrIFrame.write();
+ if (!hCNetSDK.NET_DVR_RemoteControl(userId, 3402, netDvrIFrame.getPointer(), netDvrIFrame.dwSize)) {
+ log.error("寮哄埗I甯� 閿欒鐮佷负: " + hCNetSDK.NET_DVR_GetLastError());
+ }
+ //endregion
+ //region 棰勮鍙傛暟
+ NET_DVR_PREVIEWINFO previewinfo = new NET_DVR_PREVIEWINFO();
+ previewinfo.read();
+ previewinfo.lChannel = channelNum;
+ previewinfo.dwStreamType = 0;//鐮佹祦绫诲瀷锛�0-涓荤爜娴侊紝1-瀛愮爜娴侊紝2-涓夌爜娴侊紝3-铏氭嫙鐮佹祦锛屼互姝ょ被鎺�
+ previewinfo.dwLinkMode = 0;//杩炴帴鏂瑰紡锛�0-TCP鏂瑰紡锛�1-UDP鏂瑰紡锛�2-澶氭挱鏂瑰紡锛�3-RTP鏂瑰紡锛�4-RTP/RTSP锛�5-RTP/HTTP锛�6-HRUDP锛堝彲闈犱紶杈擄級锛�7-RTSP/HTTPS锛�8-NPQ
+ previewinfo.hPlayWnd = null;//鎾斁绐楀彛鐨勫彞鏌勶紝涓篘ULL琛ㄧず涓嶈В鐮佹樉绀恒��
+ previewinfo.bBlocked = 0;//0- 闈為樆濉炲彇娴侊紝1-闃诲鍙栨祦
+ previewinfo.byNPQMode = 0;//NPQ妯″紡锛�0-鐩磋繛妯″紡锛�1-杩囨祦濯掍綋妯″紡
+ previewinfo.write();
+ //endregion
+ //if (GlobalVariable.previewMap.containsKey(cameraId)) {
+ // Integer lRealHandle = GlobalVariable.previewMap.get(cameraId);
+ // hCNetSDK.NET_DVR_StopRealPlay(lRealHandle);
+ // GlobalVariable.previewMap.remove(cameraId);
+ //}
+ hCNetSDK.NET_DVR_StopRealPlay(lRealHandle);
+ log.debug("鏈湴褰曞儚鍋滄");
+ String recordPath = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4");
+ byte[] recordBytes = Files.readAllBytes(Paths.get(recordPath));
+ //OutputStream outputStream = response.getOutputStream();
+ //outputStream.write(imageBytes);
+ return AjaxResult.success(recordBytes);
+ } catch (Exception ex) {
+ log.error("鏈湴褰曞儚鍋滄寮傚父" + ex.getMessage());
+ return AjaxResult.error("鏈湴褰曞儚鍋滄寮傚父" + ex.getMessage());
+ }
+ }
}
--
Gitblit v1.9.3