From 07cac52e0b64a78361ce4a353604c94bd1186a6c Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期四, 07 九月 2023 10:50:00 +0800
Subject: [PATCH] 更新webrtc-streamer版本 为了避免通道数和通道号混淆修改sdk请求参数channelNum为chanNo sdk接口增加聚焦值获取
---
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java | 181 ++++++++++++++++++++++++++++++---------------
1 files changed, 120 insertions(+), 61 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
index 4ed6415..12c8cc8 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java
@@ -9,11 +9,11 @@
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.hiksdk.common.GlobalVariable;
import com.ruoyi.device.camera.domain.ArdCameras;
-import com.ruoyi.device.hiksdk.util.hikSdkUtil.GisUtil;
-import com.ruoyi.device.hiksdk.util.hikSdkUtil.HCNetSDK;
+import com.ruoyi.utils.gis.GisUtil;
+import com.ruoyi.device.hiksdk.sdk.HCNetSDK;
import com.ruoyi.device.hiksdk.service.IHikClientService;
-import com.ruoyi.device.hiksdk.util.hikSdkUtil.LoginResultCallBack;
-import com.ruoyi.storage.minio.utils.MinioUtils;
+import com.ruoyi.device.hiksdk.sdk.LoginResultCallBack;
+import com.ruoyi.utils.minio.MinioUtil;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
@@ -29,10 +29,9 @@
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
import java.util.*;
-import static com.ruoyi.device.hiksdk.util.hikSdkUtil.HCNetSDK.*;
+import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.*;
/**
* @ClassName: hikClientServiceImpl
@@ -49,8 +48,6 @@
private static String endpoint;
@Resource
private IArdCamerasService ardCamerasService;
- @Resource
- private MinioUtils minioUtil;
private static HCNetSDK hCNetSDK;
@@ -265,7 +262,7 @@
public boolean pTZControlWithSpeed(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
Integer speed = cmd.getSpeed();
Integer code = cmd.getCode();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
@@ -351,23 +348,31 @@
@SdkOperate
public boolean setFocusPos(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
Integer dwFocusPos = cmd.getDwFocusPos();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
+ // 鑾峰彇鍙傛暟
Integer userId = GlobalVariable.loginMap.get(cameraId);
-
- NET_DVR_FOCUSMODE_CFG focusmodeCfg = new NET_DVR_FOCUSMODE_CFG();
- Pointer point = focusmodeCfg.getPointer();
- IntByReference ibrBytesReturned = new IntByReference(0);
- focusmodeCfg.dwFocusPos = dwFocusPos;
- boolean bool = hCNetSDK.NET_DVR_GetDVRConfig(userId, NET_DVR_GET_FOCUSMODECFG, channelNum, point, focusmodeCfg.size(), ibrBytesReturned);
+ HCNetSDK.NET_DVR_STD_CONFIG struStdCfg = new HCNetSDK.NET_DVR_STD_CONFIG();
+ HCNetSDK.NET_DVR_GIS_INFO struGisInfo = new HCNetSDK.NET_DVR_GIS_INFO();
+ struGisInfo.struPtzPosEx.dwFocus=dwFocusPos;
+ struStdCfg.read();
+ IntByReference lchannel = new IntByReference(channelNum);
+ struStdCfg.lpInBuffer= struGisInfo.getPointer();
+ struStdCfg.lpCondBuffer = lchannel.getPointer();
+ struStdCfg.dwCondSize = 4;
+ struStdCfg.dwInSize = struGisInfo.size();
+ struStdCfg.write();//璁剧疆鍓嶄箣鍓嶈write()
+ boolean bool = hCNetSDK.NET_DVR_SetSTDConfig(userId, NET_DVR_GET_GISINFO, struStdCfg);
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("璁剧疆鑱氱劍鍊煎け璐�,璇风◢鍚庨噸璇�" + code);
+ log.error("璁剧疆GIS淇℃伅鏁版嵁澶辫触,璇风◢鍚庨噸璇�" + code);
+ return false;
+ } else {
+ return true;
}
- return bool;
}
/**
@@ -378,28 +383,31 @@
@Override
public Map<String, Object> getFocusPos(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
-
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return new HashMap<>();
}
+ // 鑾峰彇鍙傛暟
Integer userId = GlobalVariable.loginMap.get(cameraId);
-
- NET_DVR_FOCUSMODE_CFG focusmodeCfg = new NET_DVR_FOCUSMODE_CFG();
- Pointer point = focusmodeCfg.getPointer();
- IntByReference ibrBytesReturned = new IntByReference(0);
- boolean bool = hCNetSDK.NET_DVR_GetDVRConfig(userId, NET_DVR_GET_FOCUSMODECFG, channelNum, point, focusmodeCfg.size(), ibrBytesReturned);
- if (bool) {
- focusmodeCfg.read();
- Map<String, Object> map = new HashMap<>();
- map.put("dwFocusPos", focusmodeCfg.dwFocusPos);
- map.put("byFocusDefinitionDisplay ", focusmodeCfg.byFocusDefinitionDisplay);
- map.put("dwRelativeFocusPos", focusmodeCfg.dwRelativeFocusPos);
- return map;
- } else {
+ HCNetSDK.NET_DVR_STD_CONFIG struStdCfg = new HCNetSDK.NET_DVR_STD_CONFIG();
+ HCNetSDK.NET_DVR_GIS_INFO struGisInfo = new HCNetSDK.NET_DVR_GIS_INFO();
+ struStdCfg.read();
+ IntByReference lchannel = new IntByReference(channelNum);
+ struStdCfg.lpCondBuffer = lchannel.getPointer();
+ struStdCfg.dwCondSize = 4;
+ struStdCfg.lpOutBuffer = struGisInfo.getPointer();
+ struStdCfg.dwOutSize = struGisInfo.size();
+ struStdCfg.write();//璁剧疆鍓嶄箣鍓嶈write()
+ boolean bool = hCNetSDK.NET_DVR_GetSTDConfig(userId, NET_DVR_GET_GISINFO, struStdCfg);
+ if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
- log.debug("鑾峰彇鑱氱劍鍊煎け璐�,璇风◢鍚庨噸璇�" + code);
+ log.error("鑾峰彇GIS淇℃伅鏁版嵁澶辫触,璇风◢鍚庨噸璇�" + code);
return new HashMap<>();
+ } else {
+ struGisInfo.read();
+ Map<String, Object> map = new HashMap<>();
+ map.put("dwFocus",struGisInfo.struPtzPosEx.dwFocus);
+ return map;
}
}
@@ -412,7 +420,7 @@
@SdkOperate
public boolean setPreset(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
Integer PresetIndex = cmd.getPresetIndex();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
@@ -435,7 +443,7 @@
@SdkOperate
public boolean gotoPreset(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
Integer PresetIndex = cmd.getPresetIndex();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
@@ -460,7 +468,7 @@
@Override
public String getVideoResolution(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return " ";
}
@@ -565,7 +573,7 @@
@Override
public Map<String, Object> getPtz(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return null;
}
@@ -616,7 +624,7 @@
@SdkOperate
public boolean setPtz(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
Map<String, Double> ptz = cmd.getPtzMap();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
@@ -649,7 +657,7 @@
@SdkOperate
public boolean guideTargetPosition(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
@@ -736,7 +744,7 @@
@Override
public int getPTZLockInfo(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return -1;
}
@@ -768,7 +776,7 @@
@SdkOperate
public boolean setZeroPtz(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
@@ -800,7 +808,7 @@
@Override
public Map<String, Object> getPtzScope(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return new HashMap<>();
}
@@ -849,7 +857,7 @@
public boolean controlDefogcfg(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
@@ -895,7 +903,7 @@
public boolean controlInfrarecfg(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
@@ -943,7 +951,7 @@
public boolean controlFocusMode(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
@@ -976,9 +984,17 @@
return bool;
}
+ /**
+ * @鎻忚堪 鑾峰彇鑱氱劍妯″紡
+ * @鍙傛暟 [userId, channelNum]
+ * @杩斿洖鍊� boolean
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/1/18 13:07
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
public String getFocusMode(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return "";
}
@@ -1008,7 +1024,7 @@
public boolean controlPTHeateRpwron(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
@@ -1041,7 +1057,7 @@
public boolean controlCameraDeicing(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
@@ -1078,7 +1094,7 @@
*/
public String captureJPEGPicture(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return "";
}
@@ -1121,7 +1137,7 @@
@SdkOperate
public String picCutCate(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return "";
}
@@ -1155,9 +1171,9 @@
InputStream input = new ByteArrayInputStream(array);
String url = "";
try {
- boolean b = minioUtil.uploadObject(BucketName, ObjectName, input, input.available(), MimeTypeUtils.IMAGE_JPEG);
+ boolean b = MinioUtil.uploadObject(BucketName, ObjectName, input, input.available(), MimeTypeUtils.IMAGE_JPEG);
if (b) {
- url = minioUtil.getBucketObjectUrl(BucketName, ObjectName);
+ url = MinioUtil.getBucketObjectUrl(BucketName, ObjectName);
log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
}
} catch (IOException ex) {
@@ -1183,7 +1199,7 @@
public String record(CameraCmd cmd) {
try {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
boolean enable = cmd.isEnable();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
@@ -1245,7 +1261,7 @@
public void recordStart(CameraCmd cmd) {
try {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return;
@@ -1300,7 +1316,7 @@
String url = "";
try {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return "";
@@ -1336,11 +1352,11 @@
log.debug("褰曞儚鍋滄");
//瀛樺叆minio
String BucketName = cmd.getRecordBucketName();
- String ObjectName = cmd.getRecordObjectName()+".mp4";
+ String ObjectName = cmd.getRecordObjectName() + ".mp4";
FileInputStream stream = new FileInputStream(path);
- boolean b = minioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4");
+ boolean b = MinioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4");
if (b) {
- url = minioUtil.getBucketObjectUrl(BucketName, ObjectName);
+ url = MinioUtil.getBucketObjectUrl(BucketName, ObjectName);
log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
}
return url;
@@ -1354,7 +1370,7 @@
public void recordStopNotToMinio(CameraCmd cmd) {
try {
String cameraId = cmd.getCameraId();
- Integer channelNum = cmd.getChannelNum();
+ Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return;
}
@@ -1402,7 +1418,7 @@
// 鑾峰彇閫氶亾鍙�
for (int iChannum = 0; iChannum < chanNum; iChannum++) {
ArdChannel ardChannel = new ArdChannel();
- int channum = iChannum + startDChan+1;
+ int channum = iChannum + startDChan + 1;
HCNetSDK.NET_DVR_PICCFG_V40 strPicCfg = new HCNetSDK.NET_DVR_PICCFG_V40();
strPicCfg.dwSize = strPicCfg.size();
strPicCfg.write();
@@ -1426,4 +1442,47 @@
}
return channelList;
}
+
+ /**
+ * @鎻忚堪 鑾峰彇GIS淇℃伅鏁版嵁
+ * @鍙傛暟 [userId, channelNum]
+ * @杩斿洖鍊� boolean
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/1/17 16:36
+ * @淇敼浜哄拰鍏跺畠淇℃伅 0-瑙i攣 1-閿佸畾
+ */
+ @Override
+ public Map<String, Object> getGisInfo(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();
+ Integer channelNum = cmd.getChanNo();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return new HashMap<>();
+ }
+ // 鑾峰彇鍙傛暟
+ Integer userId = GlobalVariable.loginMap.get(cameraId);
+ HCNetSDK.NET_DVR_STD_CONFIG struStdCfg = new HCNetSDK.NET_DVR_STD_CONFIG();
+ HCNetSDK.NET_DVR_GIS_INFO struGisInfo = new HCNetSDK.NET_DVR_GIS_INFO();
+ struStdCfg.read();
+ IntByReference lchannel = new IntByReference(channelNum);
+ struStdCfg.lpCondBuffer = lchannel.getPointer();
+ struStdCfg.dwCondSize = 4;
+ struStdCfg.lpOutBuffer = struGisInfo.getPointer();
+ struStdCfg.dwOutSize = struGisInfo.size();
+ struStdCfg.write();//璁剧疆鍓嶄箣鍓嶈write()
+ boolean bool = hCNetSDK.NET_DVR_GetSTDConfig(userId, NET_DVR_GET_GISINFO, struStdCfg);
+ if (!bool) {
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("鑾峰彇GIS淇℃伅鏁版嵁澶辫触,璇风◢鍚庨噸璇�" + code);
+ return new HashMap<>();
+ } else {
+ struGisInfo.read();
+ Map<String, Object> map = new HashMap<>();
+ map.put("p", struGisInfo.struPtzPos.fPanPos);
+ map.put("t", struGisInfo.struPtzPos.fTiltPos<0?struGisInfo.struPtzPos.fTiltPos+360:struGisInfo.struPtzPos.fTiltPos);
+ map.put("z", struGisInfo.struPtzPos.fZoomPos);
+ map.put("fHorFieldAngle", struGisInfo.fHorizontalValue);// 姘村钩瑙嗗満瑙�
+ map.put("fVerFieldAngle", struGisInfo.fVerticalValue);// 鍨傜洿瑙嗗満瑙�
+ return map;
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3