From 49207386ea4a3d663628347eef443af9c7cc7f39 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期二, 17 十月 2023 17:20:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/device/dhsdk/service/IDhClientService.java | 19
ard-work/src/main/java/com/ruoyi/device/dhsdk/service/impl/DhClientServiceImpl.java | 375 ++++++++
ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java | 107 +-
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/IHikClientService.java | 7
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java | 584 +++++++++++++
ard-work/src/main/java/com/ruoyi/device/dhsdk/module/ConfigModule.java | 36
ard-work/src/main/java/com/ruoyi/device/dhsdk/module/LoginModule.java | 6
ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/HikSdkController.java | 659 +++++++--------
ard-work/src/main/java/com/ruoyi/device/dhsdk/module/RealPlayModule.java | 113 ++
ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java | 106 ++
ard-work/src/main/java/com/ruoyi/device/dhsdk/module/PtzControlModule.java | 309 +++---
ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java | 31
ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java | 106 ++
ard-work/src/main/java/com/ruoyi/device/dhsdk/controller/DhSdkController.java | 47
14 files changed, 1,914 insertions(+), 591 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java b/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java
index b7e6aef..81adfa8 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java
@@ -10,6 +10,7 @@
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.service.IArdCamerasService;
+import com.ruoyi.device.camera.service.ICameraSdkService;
import com.ruoyi.device.dhsdk.service.IDhClientService;
import com.ruoyi.device.hiksdk.service.IHikClientService;
import io.swagger.annotations.Api;
@@ -58,26 +59,20 @@
public class CameraSdkController extends BaseController {
@Resource
- private IHikClientService hikClientService;
- @Resource
- private IDhClientService dhClientService;
+ private ICameraSdkService cameraSdkService;
@Resource
private IArdCamerasService ardCamerasService;
/**
- * @鎻忚堪 鍒濆鍔犺浇娴峰悍搴撴枃浠�
- * @鍙傛暟 []
+ * @鎻忚堪 鍒濆鍔犺浇SDK搴撴枃浠�
* @杩斿洖鍊� void
* @鍒涘缓浜� 鍒樿嫃涔�
* @鍒涘缓鏃堕棿 2023/1/17 16:13
* @淇敼浜哄拰鍏跺畠淇℃伅 if (Platform.isLinux())
*/
@PostConstruct
- public void initHCNetSDK() {
- //鍒濆鍖栧姞杞絪dk搴撴枃浠�
- hikClientService.loadHCNetSDKLib();
- //鐧诲綍鎵�鏈夌浉鏈�
- hikClientService.loginAll();
+ public void initSDK() {
+ cameraSdkService.initSDK();
}
@RequestMapping("/preview")
@@ -103,7 +98,7 @@
@Log(title = "鑾峰彇鐮佹祦鍘嬬缉鍙傛暟", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) {
- return AjaxResult.success(hikClientService.getVideoCompressionCfg(cmd));
+ return AjaxResult.success(cameraSdkService.getVideoCompressionCfg(cmd));
}
@ApiOperation("鍦ㄧ嚎鐘舵��")
@@ -113,7 +108,7 @@
public @ResponseBody
AjaxResult getOnlineState(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- boolean onLine = hikClientService.isOnLine(cmd);
+ boolean onLine = cameraSdkService.isOnLine(cmd);
return AjaxResult.success(onLine);
}
@@ -125,7 +120,7 @@
public @ResponseBody
AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.pTZControlWithSpeed(cmd));
+ return toAjax(cameraSdkService.pTZControl(cmd));
}
@ApiOperation("璋冪敤棰勭疆鐐�")
@@ -135,7 +130,7 @@
public @ResponseBody
AjaxResult gotoPreset(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.gotoPreset(cmd));
+ return toAjax(cameraSdkService.gotoPreset(cmd));
}
@ApiOperation("璁剧疆棰勭疆鐐�")
@@ -145,7 +140,7 @@
public @ResponseBody
AjaxResult setPreset(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.setPreset(cmd));
+ return toAjax(cameraSdkService.setPreset(cmd));
}
@ApiOperation("鑾峰彇鑱氱劍鍊�")
@@ -155,7 +150,7 @@
public @ResponseBody
AjaxResult getFocusPos(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- Map<String, Object> Map = hikClientService.getFocusPos(cmd);
+ Map<String, Object> Map = cameraSdkService.getFocusPos(cmd);
return AjaxResult.success("鑾峰彇鑱氱劍鍊�", Map);
}
@@ -166,7 +161,7 @@
public @ResponseBody
AjaxResult setFocusPos(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.setFocusPos(cmd));
+ return toAjax(cameraSdkService.setFocusPos(cmd));
}
@ApiOperation("鑾峰彇PTZ")
@@ -176,7 +171,7 @@
public @ResponseBody
AjaxResult getPTZ(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- Map<String, Object> ptzMap = hikClientService.getPtz(cmd);
+ Map<String, Object> ptzMap = cameraSdkService.getPtz(cmd);
return AjaxResult.success("鑾峰彇ptz", ptzMap);
}
@@ -187,7 +182,7 @@
public @ResponseBody
AjaxResult getPTZScope(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- Map<String, Object> ptzMap = hikClientService.getPtzScope(cmd);
+ Map<String, Object> ptzMap = cameraSdkService.getPtzScope(cmd);
return AjaxResult.success("鑾峰彇ptz鑼冨洿", ptzMap);
}
@@ -198,7 +193,7 @@
public @ResponseBody
AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.setPtz(cmd));
+ return toAjax(cameraSdkService.setPtz(cmd));
}
@ApiOperation("鎸囧悜鐩爣")
@@ -208,18 +203,18 @@
public @ResponseBody
AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.guideTargetPosition(cmd));
+ return toAjax(cameraSdkService.guideTargetPosition(cmd));
}
@ApiOperation("璁剧疆闆舵柟浣嶈")
@PostMapping("/setZeroPTZ")
@Log(title = "璁剧疆闆舵柟浣嶈", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.cmd.chanNo"})
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
public @ResponseBody
AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.setZeroPtz(cmd));
+ return toAjax(cameraSdkService.setZeroPtz(cmd));
}
@ApiOperation("璁剧疆閿佸畾")
@@ -229,7 +224,7 @@
public @ResponseBody
AjaxResult setPTZLock(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return AjaxResult.success(hikClientService.controlLock(cmd));
+ return AjaxResult.success(cameraSdkService.controlLock(cmd));
}
@ApiOperation("璁剧疆瑙i攣")
@@ -239,7 +234,7 @@
public @ResponseBody
AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return AjaxResult.success(hikClientService.controlUnLock(cmd));
+ return AjaxResult.success(cameraSdkService.controlUnLock(cmd));
}
@ApiOperation("鑾峰彇浜戝彴閿佸畾淇℃伅")
@@ -249,7 +244,7 @@
public @ResponseBody
AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- int byWorkMode = hikClientService.getPTZLockInfo(cmd);
+ int byWorkMode = cameraSdkService.getPTZLockInfo(cmd);
if (byWorkMode == 0) {
return AjaxResult.success("浜戝彴閿佸畾鐘舵�侊細瑙i攣");
} else if (byWorkMode == 1) {
@@ -266,7 +261,7 @@
public @ResponseBody
AjaxResult defogcfg(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.controlDefogcfg(cmd));
+ return toAjax(cameraSdkService.controlDefogcfg(cmd));
}
@ApiOperation("绾㈠寮�鍏�")
@@ -276,7 +271,7 @@
public @ResponseBody
AjaxResult infrarecfg(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.controlInfrarecfg(cmd));
+ return toAjax(cameraSdkService.controlInfrarecfg(cmd));
}
@ApiOperation(value = "鎵嬪姩/鑷姩鑱氱劍", notes = "true鎵嬪姩flase鑷姩")
@@ -286,7 +281,7 @@
public @ResponseBody
AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.controlFocusMode(cmd));
+ return toAjax(cameraSdkService.controlFocusMode(cmd));
}
@ApiOperation(value = "鑾峰彇鑱氱劍妯″紡", notes = "1鎵嬪姩2鑷姩")
@@ -294,7 +289,7 @@
public @ResponseBody
AjaxResult getFocusMode(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- String focusMode = hikClientService.getFocusMode(cmd);
+ String focusMode = cameraSdkService.getFocusMode(cmd);
return AjaxResult.success(focusMode);
}
@@ -305,7 +300,7 @@
public @ResponseBody
AjaxResult heateRpwron(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.controlPTHeateRpwron(cmd));
+ return toAjax(cameraSdkService.controlPTHeateRpwron(cmd));
}
@@ -316,15 +311,7 @@
public @ResponseBody
AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(hikClientService.controlCameraDeicing(cmd));
- }
-
- @PostMapping("/captureJPEGPicture")
- public @ResponseBody
- AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- String base64Str = hikClientService.captureJPEGPicture(cmd);
- return toAjaxString(base64Str, "鐩告満鎶撳浘");
+ return toAjax(cameraSdkService.controlCameraDeicing(cmd));
}
@ApiOperation("鐩告満鎶撳浘")
@@ -334,28 +321,38 @@
public @ResponseBody
AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- String path = hikClientService.picCutCate(cmd);
+ String path = cameraSdkService.picCutCate(cmd);
return toAjaxString(path, "鐩告満鎶撳浘");
}
- @ApiOperation("鎵嬪姩褰曞儚")
- @PostMapping("/record")
- @Log(title = "鎵嬪姩褰曞儚", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult record(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- String path = hikClientService.record(cmd);
- return toAjaxString(path, "鎵嬪姩褰曞儚");
- }
-
@ApiOperation("鑾峰彇鐩告満鏋惰鍙傛暟")
- @PostMapping("/getCameraSetupCFG")
+ @PostMapping("/getGisInfo")
@Log(title = "鑾峰彇鐩告満鏋惰鍙傛暟", businessType = BusinessType.CONTROL)
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
public @ResponseBody
- AjaxResult getCameraSetupCFG(@RequestBody CameraCmd cmd) {
+ AjaxResult getGisInfo(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return AjaxResult.success(hikClientService.getGisInfo(cmd));
+ return AjaxResult.success(cameraSdkService.getGisInfo(cmd));
+ }
+
+ @ApiOperation("鎵嬪姩褰曞儚寮�濮�")
+ @PostMapping("/recordStart")
+ @Log(title = "鎵嬪姩褰曞儚寮�濮�", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ public @ResponseBody
+ AjaxResult recordStart(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ boolean b = cameraSdkService.recordStart(cmd);
+ return toAjax(b);
+ }
+ @ApiOperation("鎵嬪姩褰曞儚鍋滄")
+ @PostMapping("/recordStop")
+ @Log(title = "鎵嬪姩褰曞儚鍋滄", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.recordBucketName", "cmd.recordObjectName"})
+ public @ResponseBody
+ AjaxResult recordStop(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ String url = cameraSdkService.recordStopToMinio(cmd);
+ return AjaxResult.success(url);
}
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java
new file mode 100644
index 0000000..dc7f5cf
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java
@@ -0,0 +1,106 @@
+package com.ruoyi.device.camera.service;
+
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.channel.domain.ArdChannel;
+
+import java.util.List;
+import java.util.Map;
+
+public interface ICameraSdkService {
+ //sdk鍒濆鍖�
+ void initSDK();
+
+ //鍚屾鐧诲綍
+ void syncLogin(ArdCameras cameras);
+
+ //寮傛鐧诲綍
+ void asyncLogin(ArdCameras cameras);
+
+ //娉ㄩ攢
+ boolean logout(String cameraId);
+
+ //鍦ㄧ嚎鐘舵��
+ boolean isOnLine(CameraCmd cmd);
+
+ //浜戝彴鎺у埗
+ boolean pTZControl(CameraCmd cmd);
+
+ //璁剧疆鑱氱劍鍊�
+ boolean setFocusPos(CameraCmd cmd);
+
+ //鑾峰彇鑱氱劍鍊�
+ Map<String, Object> getFocusPos(CameraCmd cmd);
+
+ //璁剧疆棰勭疆浣�
+ boolean setPreset(CameraCmd cmd);
+
+ //璋冪敤棰勭疆浣�
+ boolean gotoPreset(CameraCmd cmd);
+
+ //鑾峰彇鐮佹祦鍘嬬缉鍙傛暟
+ Map<String, String> getVideoCompressionCfg(CameraCmd cmd);
+
+ //閫忛浘
+ boolean controlDefogcfg(CameraCmd cmd);
+
+ //绾㈠?
+ boolean controlInfrarecfg(CameraCmd cmd);
+
+ //鑱氱劍妯″紡
+ boolean controlFocusMode(CameraCmd cmd);
+
+ //鑾峰彇鑱氱劍妯″紡
+ String getFocusMode(CameraCmd cmd);
+
+ //浜戝彴鍔犵儹
+ boolean controlPTHeateRpwron(CameraCmd cmd);
+
+ //闀滃ご闄ゅ啺
+ boolean controlCameraDeicing(CameraCmd cmd);
+
+ //閰嶇疆閿佸畾
+ boolean controlLock(CameraCmd cmd);
+
+ //閰嶇疆瑙i攣
+ boolean controlUnLock(CameraCmd cmd);
+
+ //鑾峰彇浜戝彴閿佸畾淇℃伅
+ int getPTZLockInfo(CameraCmd cmd);
+
+ //鎶撳浘-杩旂粰鍓嶇浜岃繘鍒舵祦
+ String captureJPEGPicture(CameraCmd cmd);
+
+ //鎶撳浘
+ String picCutCate(CameraCmd cmd);
+
+ //ptz 涓夊潗鏍�
+ Map<String, Object> getPtz(CameraCmd cmd);
+
+ //鑾峰彇ptz鑼冨洿
+ Map<String, Object> getPtzScope(CameraCmd cmd);
+
+ boolean setPtz(CameraCmd cmd);
+
+ //璁剧疆闆舵柟浣嶈
+ boolean setZeroPtz(CameraCmd cmd);
+
+
+ //寮曞鐩爣浣嶇疆
+ boolean guideTargetPosition(CameraCmd cmd);
+
+ //鎵嬪姩寮�濮嬪綍鍍�
+ boolean recordStart(CameraCmd cmd);
+
+ //鎵嬪姩鍋滄褰曞儚-涓婁紶minio-杩斿洖褰曞儚url
+ String recordStopToMinio(CameraCmd cmd);
+
+ //鍋滄褰曞儚-涓嶄笂浼爉inio
+ void recordStopNotToMinio(CameraCmd cmd);
+
+ //鑾峰彇鐩告満閫氶亾淇℃伅
+ public List<ArdChannel> getCameraChannelList(ArdCameras camera);
+
+ //鑾峰彇GIS淇℃伅鏁版嵁
+ public Map<String, Object> getGisInfo(CameraCmd cmd);
+}
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
new file mode 100644
index 0000000..97591be
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
@@ -0,0 +1,584 @@
+package com.ruoyi.device.camera.service.impl;
+
+import com.ruoyi.common.constant.CacheConstants;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.service.ICameraSdkService;
+import com.ruoyi.device.channel.domain.ArdChannel;
+import com.ruoyi.device.dhsdk.service.IDhClientService;
+import com.ruoyi.device.hiksdk.common.GlobalVariable;
+import com.ruoyi.device.hiksdk.service.IHikClientService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.NET_DVR_CHECK_USER_STATUS;
+
+
+/**
+ * @Description: 鐩告満sdk涓氬姟
+ * @ClassName: CameraSdkServiceImpl
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�10鏈�16鏃�15:21:01
+ **/
+@Service
+@Slf4j(topic = "SDK")
+public class CameraSdkServiceImpl implements ICameraSdkService {
+ @Resource
+ IHikClientService hikClientService;
+ @Resource
+ IDhClientService dhClientService;
+ @Resource
+ RedisCache redisCache;
+
+ @Override
+ public void initSDK() {
+ //鍒濆鍖栧姞杞絪dk搴撴枃浠�
+ boolean initHIK = hikClientService.init();
+ if (initHIK) {
+ hikClientService.loginAll();//鐧诲綍鍏ㄩ儴娴峰悍鐩告満
+ }
+ Boolean initDH = dhClientService.init();
+ if (initDH) {
+ dhClientService.loginAll();//鐧诲綍鍏ㄩ儴澶у崕鐩告満
+ }
+ }
+ @Override
+ public void syncLogin(ArdCameras cameras) {
+
+ }
+
+ @Override
+ public void asyncLogin(ArdCameras cameras) {
+
+ }
+
+ @Override
+ public boolean logout(String cameraId) {
+ return false;
+ }
+ //鍦ㄧ嚎妫�娴�
+ @Override
+ public boolean isOnLine(CameraCmd cmd) {
+ try {
+ boolean onLine = false;
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ onLine = hikClientService.isOnLine(cmd);
+ } else if (factory.equals("2")) {
+ onLine = dhClientService.isOnLine(cmd);
+ }
+ }
+ return onLine;
+ } catch (Exception ex) {
+ log.error("妫�娴嬪湪绾垮紓甯革細" + ex.getMessage());
+ return false;
+ }
+ }
+ //浜戝彴鎺у埗
+ @Override
+ public boolean pTZControl(CameraCmd cmd) {
+ try {
+ boolean result = false;
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.pTZControlWithSpeed(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.pTZControl(cmd);
+ }
+ }
+ return result;
+ } catch (Exception ex) {
+ log.error("ptz鎺у埗寮傚父锛�" + ex.getMessage());
+ return false;
+ }
+ }
+ //璁剧疆鑱氱劍鍊�
+ @Override
+ public boolean setFocusPos(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setFocusPos(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆鑱氱劍鍊煎紓甯革細" + ex.getMessage());
+
+ }
+ return result;
+ }
+ //鑾峰彇鑱氱劍鍊�
+ @Override
+ public Map<String, Object> getFocusPos(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getFocusPos(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鑱氱劍鍊煎紓甯革細" + ex.getMessage());
+ }
+ return map;
+ }
+ //璁剧疆棰勭疆浣�
+ @Override
+ public boolean setPreset(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setPreset(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.setPreset(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆棰勭疆浣嶅紓甯革細" + ex.getMessage());
+ }
+ return result;
+ }
+ //璋冪敤棰勭疆浣�
+ @Override
+ public boolean gotoPreset(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.gotoPreset(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.gotoPreset(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璋冪敤棰勭疆浣嶅紓甯革細" + ex.getMessage());
+ }
+ return result;
+ }
+ //鑾峰彇鐮佹祦鍘嬬缉鍙傛暟
+ @Override
+ public Map<String, String> getVideoCompressionCfg(CameraCmd cmd) {
+ Map<String, String> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getVideoCompressionCfg(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鐮佹祦鍘嬬缉鍙傛暟寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+ //閫忛浘寮�鍏�
+ @Override
+ public boolean controlDefogcfg(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlDefogcfg(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶閫忛浘寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //绾㈠寮�鍏�
+ @Override
+ public boolean controlInfrarecfg(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlInfrarecfg(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶绾㈠寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //鎵嬪姩/鑷姩鑱氱劍
+ @Override
+ public boolean controlFocusMode(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlFocusMode(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.controlFocusMode(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶鑱氱劍妯″紡寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //鑾峰彇鑱氱劍妯″紡
+ @Override
+ public String getFocusMode(CameraCmd cmd) {
+ String result = "";
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.getFocusMode(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鑱氱劍妯″紡寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //浜戝彴鍔犵儹
+ @Override
+ public boolean controlPTHeateRpwron(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlPTHeateRpwron(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶浜戝彴鍔犵儹寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //闀滃ご鍔犵儹
+ @Override
+ public boolean controlCameraDeicing(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlCameraDeicing(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶浜戝彴鍔犵儹寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //鎿嶆帶閿佸畾
+ @Override
+ public boolean controlLock(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlLock(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶閿佸畾寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //璁剧疆瑙i攣
+ @Override
+ public boolean controlUnLock(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlUnLock(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆瑙i攣寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //鑾峰彇浜戝彴閿佸畾淇℃伅
+ @Override
+ public int getPTZLockInfo(CameraCmd cmd) {
+ int result = 99;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.getPTZLockInfo(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇浜戝彴閿佸畾淇℃伅寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public String captureJPEGPicture(CameraCmd cmd) {
+ return null;
+ }
+ //鎶撳浘
+ @Override
+ public String picCutCate(CameraCmd cmd) {
+ String url = "";
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ url = hikClientService.picCutCate(cmd);
+ } else if (factory.equals("2")) {
+ url = dhClientService.picCutCate(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎶撳浘寮傚父锛�" + ex.getMessage());
+ }
+ return url;
+ }
+ //鑾峰彇ptz
+ @Override
+ public Map<String, Object> getPtz(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getPtz(cmd);
+ } else if (factory.equals("2")) {
+ map = dhClientService.getPtz(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇ptz寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+ //鑾峰彇ptz鑼冨洿
+ @Override
+ public Map<String, Object> getPtzScope(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getPtzScope(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇ptz鑼冨洿寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+ //璁剧疆ptz
+ @Override
+ public boolean setPtz(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setPtz(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.setPtz(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆ptz寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //璁剧疆闆舵柟浣嶈
+ @Override
+ public boolean setZeroPtz(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setZeroPtz(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.setZeroPtz(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆闆舵柟浣嶈寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //寮曞鎸囧悜鐩爣
+ @Override
+ public boolean guideTargetPosition(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.guideTargetPosition(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.guideTargetPosition(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("寮曞鎸囧悜鐩爣寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+ //寮�濮嬪綍鍍�
+ @Override
+ public boolean recordStart(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.recordStart(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.recordStart(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("寮�濮嬪綍鍍忓紓甯革細" + ex.getMessage());
+ }
+ return result;
+ }
+ //鍋滄褰曞儚骞跺瓨鍏inio
+ @Override
+ public String recordStopToMinio(CameraCmd cmd) {
+ String url = "";
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ url = hikClientService.recordStopToMinio(cmd);
+ } else if (factory.equals("2")) {
+ url = dhClientService.recordStopToMinio(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鍋滄褰曞儚寮傚父锛�" + ex.getMessage());
+ }
+ return url;
+ }
+ //鍋滄褰曞儚骞朵笉瀛樺叆minio
+ @Override
+ public void recordStopNotToMinio(CameraCmd cmd) {
+
+ }
+
+ @Override
+ public List<ArdChannel> getCameraChannelList(ArdCameras camera) {
+ return null;
+ }
+
+ //鑾峰彇鐩告満鏋惰鍙傛暟
+ @Override
+ public Map<String, Object> getGisInfo(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getGisInfo(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鐩告満鏋惰鍙傛暟寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+}
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/controller/DhSdkController.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/controller/DhSdkController.java
index a2ac3b8..c0039e5 100644
--- a/ard-work/src/main/java/com/ruoyi/device/dhsdk/controller/DhSdkController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/controller/DhSdkController.java
@@ -37,23 +37,6 @@
@Resource
private IDhClientService sdk;
- /**
- * @鎻忚堪 鍒濆鍔犺浇澶у崕搴撴枃浠�
- * @鍙傛暟 []
- * @杩斿洖鍊� void
- * @鍒涘缓浜� 鍒樿嫃涔�
- * @鍒涘缓鏃堕棿 2023/1/17 16:13
- * @淇敼浜哄拰鍏跺畠淇℃伅 if (Platform.isLinux())
- */
- @PostConstruct
- public void initDHSDK() {
- //鍒濆鍖栧姞杞絪dk搴撴枃浠�
- if (sdk.init())
- {
- //鐧诲綍鎵�鏈夌浉鏈�
- sdk.loginAll();
- }
- }
@ApiOperation(value = "浜戝彴鎺у埗", notes = "Code:1-宸︿笂 2-涓� 3-鍙充笂 4-宸� 5-宸¤埅 6-鍙� 7-宸︿笅 8-涓� 9-鍙充笅 10-鐒﹁窛鍙樺ぇ 11-鐒﹁窛鍙樺皬\n" +
"12-鐒︾偣鍓嶈皟 13-鐒︾偣鍚庤皟 14-鍏夊湀鎵╁ぇ 15-鍏夊湀缂╁皬 ")
@@ -104,4 +87,34 @@
cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.setZeroPtz(cmd));
}
+ @ApiOperation("鐩告満鎶撳浘")
+ @PostMapping("/picCutCate")
+ @Log(title = "鐩告満鎶撳浘", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ public @ResponseBody
+ AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ String url = sdk.picCutCate(cmd);
+ return toAjaxString(url, "鐩告満鎶撳浘");
+ }
+ @ApiOperation("鎵嬪姩褰曞儚寮�濮�")
+ @PostMapping("/recordStart")
+ @Log(title = "鎵嬪姩褰曞儚寮�濮�", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ public @ResponseBody
+ AjaxResult recordStart(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ boolean b = sdk.recordStart(cmd);
+ return toAjax(b);
+ }
+ @ApiOperation("鎵嬪姩褰曞儚鍋滄")
+ @PostMapping("/recordStop")
+ @Log(title = "鎵嬪姩褰曞儚鍋滄", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.recordBucketName", "cmd.recordObjectName"})
+ public @ResponseBody
+ AjaxResult recordStop(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ String url = sdk.recordStopToMinio(cmd);
+ return AjaxResult.success(url);
+ }
}
\ No newline at end of file
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java
new file mode 100644
index 0000000..0b1c73d
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java
@@ -0,0 +1,106 @@
+package com.ruoyi.device.dhsdk.module;
+import com.ruoyi.device.dhsdk.lib.NetSDKLib;
+import com.ruoyi.device.dhsdk.lib.ToolKits;
+import com.sun.jna.ptr.IntByReference;
+
+/**
+ * \if ENGLISH_LANG
+ * Capture Picture Interface
+ * contains:local銆乺emote銆乼imer and stop capture picture
+ * \else
+ * 鎶撳浘鎺ュ彛瀹炵幇
+ * 鍖呭惈: 鏈湴銆佽繙绋嬨�佸畾鏃跺拰鍋滄鎶撳浘
+ * \endif
+ */
+public class CapturePictureModule {
+
+ public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
+
+ /**
+ * \if ENGLISH_LANG
+ * Local Capture Picture
+ * \else
+ * 鏈湴鎶撳浘
+ * \endif
+ */
+ public static boolean localCapturePicture(NetSDKLib.LLong hPlayHandle, String picFileName) {
+
+ if (!netsdk.CLIENT_CapturePictureEx(hPlayHandle, picFileName, NetSDKLib.NET_CAPTURE_FORMATS.NET_CAPTURE_JPEG)) {
+ System.err.printf("CLIENT_CapturePicture Failed!" + ToolKits.getErrorCodePrint());
+ return false;
+ } else {
+ System.out.println("CLIENT_CapturePicture success");
+ }
+ return true;
+ }
+
+ /**
+ * \if ENGLISH_LANG
+ * Remote Capture Picture
+ * \else
+ * 杩滅▼鎶撳浘
+ * \endif
+ */
+ public static boolean remoteCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) {
+ return snapPicture(m_hLoginHandle,chn, 0, 0);
+ }
+
+ /**
+ * \if ENGLISH_LANG
+ * Timer Capture Picture
+ * \else
+ * 瀹氭椂鎶撳浘
+ * \endif
+ */
+ public static boolean timerCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) {
+ return snapPicture(m_hLoginHandle,chn, 1, 2);
+ }
+
+ /**
+ * \if ENGLISH_LANG
+ * Stop Timer Capture Picture
+ * \else
+ * 鍋滄瀹氭椂鎶撳浘
+ * \endif
+ */
+ public static boolean stopCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) {
+ return snapPicture(m_hLoginHandle,chn, -1, 0);
+ }
+
+ /**
+ * \if ENGLISH_LANG
+ * Capture Picture (except local capture picture, others all call this interface)
+ * \else
+ * 鎶撳浘 (闄ゆ湰鍦版姄鍥惧, 鍏朵粬鍏ㄩ儴璋冪敤姝ゆ帴鍙�)
+ * \endif
+ */
+ private static boolean snapPicture(NetSDKLib.LLong m_hLoginHandle,int chn, int mode, int interval) {
+ // send caputre picture command to device
+ NetSDKLib.SNAP_PARAMS stuSnapParams = new NetSDKLib.SNAP_PARAMS();
+ stuSnapParams.Channel = chn; // channel
+ stuSnapParams.mode = mode; // capture picture mode
+ stuSnapParams.Quality = 3; // picture quality
+ stuSnapParams.InterSnap = interval; // timer capture picture time interval
+ stuSnapParams.CmdSerial = 0; // request serial
+
+ IntByReference reserved = new IntByReference(0);
+ if (!LoginModule.netsdk.CLIENT_SnapPictureEx(m_hLoginHandle, stuSnapParams, reserved)) {
+ System.err.printf("CLIENT_SnapPictureEx Failed!" + ToolKits.getErrorCodePrint());
+ return false;
+ } else {
+ System.out.println("CLIENT_SnapPictureEx success");
+ }
+ return true;
+ }
+
+ /**
+ * \if ENGLISH_LANG
+ * Set Capture Picture Callback
+ * \else
+ * 璁剧疆鎶撳浘鍥炶皟鍑芥暟
+ * \endif
+ */
+ public static void setSnapRevCallBack(NetSDKLib.fSnapRev cbSnapReceive){
+ LoginModule.netsdk.CLIENT_SetSnapRevCallBack(cbSnapReceive, null);
+ }
+}
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/ConfigModule.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/ConfigModule.java
index a435d75..bb99075 100644
--- a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/ConfigModule.java
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/ConfigModule.java
@@ -3,6 +3,7 @@
import com.ruoyi.device.dhsdk.lib.NetSDKLib;
import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
+import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint;
/**
* @Description:
@@ -12,6 +13,7 @@
**/
public class ConfigModule {
public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
+ public static NetSDKLib configsdk = NetSDKLib.CONFIG_INSTANCE;
/**
* 鏌ヨ璁惧鐘舵��
*/
@@ -19,10 +21,42 @@
IntByReference intRetLen = new IntByReference();
stuInfo.write();
- if (!LoginModule.netsdk.CLIENT_QueryDevState(hLoginHandle, nType, stuInfo.getPointer(), stuInfo.size(), intRetLen, 3000)) {
+ if (!netsdk.CLIENT_QueryDevState(hLoginHandle, nType, stuInfo.getPointer(), stuInfo.size(), intRetLen, 3000)) {
return false;
}
stuInfo.read();
return true;
}
+ /**
+ * 璁剧疆鍗曚釜閰嶇疆
+ * @param hLoginHandle 鐧婚檰鍙ユ焺
+ * @param nChn 閫氶亾鍙凤紝-1 琛ㄧず鍏ㄩ�氶亾
+ * @param strCmd 閰嶇疆鍚嶇О
+ * @param cmdObject 閰嶇疆瀵瑰簲鐨勭粨鏋勪綋瀵硅薄
+ * @return 鎴愬姛杩斿洖 true
+ */
+ public static boolean SetDevConfig(NetSDKLib.LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) {
+ boolean result = false;
+ int nBufferLen = 2*1024*1024;
+ byte szBuffer[] = new byte[nBufferLen];
+ for(int i=0; i<nBufferLen; i++)szBuffer[i]=0;
+ IntByReference error = new IntByReference(0);
+ IntByReference restart = new IntByReference(0);
+ cmdObject.write();
+ if (configsdk.CLIENT_PacketData(strCmd, cmdObject.getPointer(), cmdObject.size(), szBuffer, nBufferLen)) {
+ cmdObject.read();
+ if( configsdk.CLIENT_SetNewDevConfig(hLoginHandle, strCmd , nChn , szBuffer, nBufferLen, error, restart, 3000)) {
+ result = true;
+ } else {
+ System.err.printf("Set %s Config Failed! Last Error = %s\n" , strCmd , getErrorCodePrint());
+ result = false;
+ }
+ } else {
+ System.err.println("Packet " + strCmd + " Config Failed!" + getErrorCodePrint());
+ result = false;
+ }
+
+ return result;
+ }
+
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/LoginModule.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/LoginModule.java
index dff3f36..da42a76 100644
--- a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/LoginModule.java
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/LoginModule.java
@@ -4,13 +4,8 @@
import com.ruoyi.device.dhsdk.lib.NetSDKLib.LLong;
import com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY;
import com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY;
-import com.ruoyi.device.dhsdk.lib.ToolKits;
-import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import lombok.extern.slf4j.Slf4j;
-
-import java.io.File;
-
import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint;
/**
@@ -21,7 +16,6 @@
public class LoginModule {
public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
- public static NetSDKLib configsdk = NetSDKLib.CONFIG_INSTANCE;
// 璁惧淇℃伅
public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/PtzControlModule.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/PtzControlModule.java
index 5885eee..31ecfe6 100644
--- a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/PtzControlModule.java
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/PtzControlModule.java
@@ -7,200 +7,215 @@
* 涓昏鏈� 锛氬叓涓柟鍚戞帶鍒躲�佸彉鍊嶃�佸彉鐒︺�佸厜鍦堝姛鑳�
*/
public class PtzControlModule {
+ public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
- /**
- * 鍚戜笂
- */
- public static boolean ptzControlUpStart(NetSDKLib.LLong lLoginID,int nChannelID, int lParam1, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlUpEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
- 0, 0, 0, 1);
- }
-
- /**
- * 鍚戜笅
- */
- public static boolean ptzControlDownStart(int nChannelID, int lParam1, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlDownEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
- 0, 0, 0, 1);
- }
-
- /**
- * 鍚戝乏
- */
- public static boolean ptzControlLeftStart(int nChannelID, int lParam1, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlLeftEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
- 0, 0, 0, 1);
- }
-
- /**
- * 鍚戝彸
- */
- public static boolean ptzControlRightStart(int nChannelID, int lParam1,int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlRightEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
- 0, 0, 0, 1);
- }
-
- /**
- * 鍚戝乏涓�
- */
- public static boolean ptzControlLeftUpStart(int nChannelID, int lParam1, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlLeftUpEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
- 0, 0, 0, 1);
- }
-
- /**
- * 鍚戝彸涓�
- */
- public static boolean ptzControlRightUpStart(int nChannelID, int lParam1, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlRightUpEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
- 0, 0, 0, 1);
- }
+ /**
+ * 鍚戜笂
+ */
+ public static boolean ptzControlUpStart(NetSDKLib.LLong lLoginID, int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
+ lParam1, lParam2, 0, 0);
+ }
- /**
- * 鍚戝乏涓�
- */
- public static boolean ptzControlLeftDownStart(int nChannelID, int lParam1, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlLeftDownEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
- 0, 0, 0, 1);
- }
-
- /**
- * 鍚戝彸涓�
- */
- public static boolean ptzControlRightDownStart(int nChannelID, int lParam1, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
- lParam1, lParam2, 0, 0);
- }
- public static boolean ptzControlRightDownEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
- 0, 0, 0, 1);
- }
-
+ public static boolean ptzControlUpEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
+ 0, 0, 0, 1);
+ }
+
+ /**
+ * 鍚戜笅
+ */
+ public static boolean ptzControlDownStart(int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
+ lParam1, lParam2, 0, 0);
+ }
+
+ public static boolean ptzControlDownEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
+ 0, 0, 0, 1);
+ }
+
+ /**
+ * 鍚戝乏
+ */
+ public static boolean ptzControlLeftStart(int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
+ lParam1, lParam2, 0, 0);
+ }
+
+ public static boolean ptzControlLeftEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
+ 0, 0, 0, 1);
+ }
+
+ /**
+ * 鍚戝彸
+ */
+ public static boolean ptzControlRightStart(int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
+ lParam1, lParam2, 0, 0);
+ }
+
+ public static boolean ptzControlRightEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
+ 0, 0, 0, 1);
+ }
+
+ /**
+ * 鍚戝乏涓�
+ */
+ public static boolean ptzControlLeftUpStart(int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
+ lParam1, lParam2, 0, 0);
+ }
+
+ public static boolean ptzControlLeftUpEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
+ 0, 0, 0, 1);
+ }
+
+ /**
+ * 鍚戝彸涓�
+ */
+ public static boolean ptzControlRightUpStart(int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
+ lParam1, lParam2, 0, 0);
+ }
+
+ public static boolean ptzControlRightUpEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
+ 0, 0, 0, 1);
+ }
+
+ /**
+ * 鍚戝乏涓�
+ */
+ public static boolean ptzControlLeftDownStart(int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
+ lParam1, lParam2, 0, 0);
+ }
+
+ public static boolean ptzControlLeftDownEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
+ 0, 0, 0, 1);
+ }
+
+ /**
+ * 鍚戝彸涓�
+ */
+ public static boolean ptzControlRightDownStart(int nChannelID, int lParam1, int lParam2) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
+ lParam1, lParam2, 0, 0);
+ }
+
+ public static boolean ptzControlRightDownEnd(int nChannelID) {
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
+ 0, 0, 0, 1);
+ }
+
/**
* 鍙樺��+
*/
public static boolean ptzControlZoomAddStart(int nChannelID, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
- 0, lParam2, 0, 0);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
+ 0, lParam2, 0, 0);
}
+
public static boolean ptzControlZoomAddEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
- 0, 0, 0, 1);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
+ 0, 0, 0, 1);
}
/**
* 鍙樺��-
*/
public static boolean ptzControlZoomDecStart(int nChannelID, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
- 0, lParam2, 0, 0);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
+ 0, lParam2, 0, 0);
}
+
public static boolean ptzControlZoomDecEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
- 0, 0, 0, 1);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
+ 0, 0, 0, 1);
}
/**
* 鍙樼劍+
*/
public static boolean ptzControlFocusAddStart(int nChannelID, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
- 0, lParam2, 0, 0);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
+ 0, lParam2, 0, 0);
}
+
public static boolean ptzControlFocusAddEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
- 0, 0, 0, 1);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
+ 0, 0, 0, 1);
}
/**
* 鍙樼劍-
*/
public static boolean ptzControlFocusDecStart(int nChannelID, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
- 0, lParam2, 0, 0);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
+ 0, lParam2, 0, 0);
}
+
public static boolean ptzControlFocusDecEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
- 0, 0, 0, 1);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
+ 0, 0, 0, 1);
}
/**
* 鍏夊湀+
*/
public static boolean ptzControlIrisAddStart(int nChannelID, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
- 0, lParam2, 0, 0);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
+ 0, lParam2, 0, 0);
}
+
public static boolean ptzControlIrisAddEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
- 0, 0, 0, 1);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
+ 0, 0, 0, 1);
}
/**
* 鍏夊湀-
*/
public static boolean ptzControlIrisDecStart(int nChannelID, int lParam2) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
- 0, lParam2, 0, 0);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
+ 0, lParam2, 0, 0);
}
+
public static boolean ptzControlIrisDecEnd(int nChannelID) {
- return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
- NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
- 0, 0, 0, 1);
+ return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID,
+ NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
+ 0, 0, 0, 1);
}
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/RealPlayModule.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/RealPlayModule.java
new file mode 100644
index 0000000..a397132
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/RealPlayModule.java
@@ -0,0 +1,113 @@
+package com.ruoyi.device.dhsdk.module;
+
+import com.ruoyi.device.dhsdk.lib.NetSDKLib;
+import com.ruoyi.device.dhsdk.lib.ToolKits;
+import com.sun.jna.Pointer;
+
+import static com.ruoyi.device.dhsdk.module.LoginModule.netsdk;
+
+/**
+ * 瀹炴椂棰勮鎺ュ彛瀹炵幇
+ * 涓昏鏈� 锛氬紑濮嬫媺娴併�佸仠姝㈡媺娴佸姛鑳�
+ */
+public class RealPlayModule {
+ /**
+ * \if ENGLISH_LANG
+ * Start RealPlay
+ * \else
+ * 寮�濮嬮瑙�
+ * \endif
+ */
+ public static NetSDKLib.LLong startRealPlay(NetSDKLib.LLong m_hLoginHandle, int channel, int stream) {
+ NetSDKLib.LLong m_hPlayHandle = netsdk.CLIENT_RealPlayEx(m_hLoginHandle, channel, null, stream);
+ if (m_hPlayHandle.longValue() == 0) {
+ System.err.println("寮�濮嬪疄鏃堕瑙堝け璐ワ紝閿欒鐮�" + ToolKits.getErrorCodePrint());
+ } else {
+ System.out.println("Success to start realplay");
+ // netsdk.CLIENT_SetRealDataCallBackEx(m_hPlayHandle, CbfRealDataCallBackEx.getInstance(),null, 0x0000001f);
+ }
+ return m_hPlayHandle;
+ }
+
+ public static NetSDKLib.LLong startRealPlay1(NetSDKLib.LLong m_hLoginHandle, int channel, String path) {
+ NetSDKLib.NET_IN_REALPLAY_BY_DATA_TYPE net_in_realplay_by_data_type = new NetSDKLib.NET_IN_REALPLAY_BY_DATA_TYPE();
+ net_in_realplay_by_data_type.nChannelID = channel;
+ net_in_realplay_by_data_type.hWnd = null;
+ net_in_realplay_by_data_type.rType = 0;
+ net_in_realplay_by_data_type.emDataType = NetSDKLib.EM_REAL_DATA_TYPE.EM_REAL_DATA_TYPE_MP4;
+ net_in_realplay_by_data_type.szSaveFileName = path;
+ //net_in_realplay_by_data_type.cbRealData = CbfRealDataCallBackEx.getInstance();
+ NetSDKLib.NET_OUT_REALPLAY_BY_DATA_TYPE net_out_realplay_by_data_type = new NetSDKLib.NET_OUT_REALPLAY_BY_DATA_TYPE();
+ NetSDKLib.LLong m_hPlayHandle = netsdk.CLIENT_RealPlayByDataType(m_hLoginHandle, net_in_realplay_by_data_type, net_out_realplay_by_data_type, 5000);
+ if (m_hPlayHandle.longValue() == 0) {
+ System.err.println("寮�濮嬪疄鏃堕瑙堝け璐ワ紝閿欒鐮�" + ToolKits.getErrorCodePrint());
+ } else {
+ System.out.println("Success to start realplay");
+ }
+ return m_hPlayHandle;
+ }
+
+ /**
+ * \if ENGLISH_LANG
+ * Start RealPlay
+ * \else
+ * 鍋滄棰勮
+ * \endif
+ */
+ public static void stopRealPlay(NetSDKLib.LLong m_hPlayHandle) {
+ if (m_hPlayHandle.longValue() == 0) {
+ return;
+ }
+ boolean bRet = netsdk.CLIENT_StopRealPlayEx(m_hPlayHandle);
+ if (bRet) {
+ m_hPlayHandle.setValue(0);
+ }
+ }
+
+ /**
+ * 瀹炴椂棰勮鏁版嵁鍥炶皟鍑芥暟--鎵╁睍(pBuffer鍐呭瓨鐢盨DK鍐呴儴鐢宠閲婃斁)
+ */
+ private static class CbfRealDataCallBackEx implements NetSDKLib.fRealDataCallBackEx {
+ private CbfRealDataCallBackEx() {
+ }
+
+ private static class CallBackHolder {
+ private static CbfRealDataCallBackEx instance = new CbfRealDataCallBackEx();
+ }
+
+ public static CbfRealDataCallBackEx getInstance() {
+ return CallBackHolder.instance;
+ }
+
+ @Override
+ public void invoke(NetSDKLib.LLong lRealHandle, int dwDataType, Pointer pBuffer,
+ int dwBufSize, int param, Pointer dwUser) {
+ int bInput = 0;
+ if (0 != lRealHandle.longValue()) {
+ switch (dwDataType) {
+ case 0:
+ System.out.println("鐮佹祦澶у皬涓�" + dwBufSize + "\n" + "鐮佹祦绫诲瀷涓哄師濮嬮煶瑙嗛娣峰悎鏁版嵁");
+ break;
+ case 1:
+ //鏍囧噯瑙嗛鏁版嵁
+ System.out.println("鐮佹祦澶у皬涓�" + dwBufSize + "\n" + "鐮佹祦绫诲瀷涓烘爣鍑嗚棰戞暟鎹�");
+ break;
+ case 2:
+ //yuv 鏁版嵁
+ System.out.println("鐮佹祦澶у皬涓�" + dwBufSize + "\n" + "鐮佹祦绫诲瀷涓簓uv鏁版嵁");
+ break;
+ case 3:
+ //pcm 闊抽鏁版嵁
+ System.out.println("鐮佹祦澶у皬涓�" + dwBufSize + "\n" + "鐮佹祦绫诲瀷涓洪煶棰戞暟鎹�");
+ break;
+ case 4:
+ //鍘熷闊抽鏁版嵁
+ System.out.println("鐮佹祦澶у皬涓�" + dwBufSize + "\n" + "鐮佹祦绫诲瀷涓哄師濮嬮煶棰戞暟鎹�");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/IDhClientService.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/IDhClientService.java
index 7a1a435..32ad998 100644
--- a/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/IDhClientService.java
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/IDhClientService.java
@@ -40,6 +40,25 @@
//璁剧疆PTZ
boolean setPtz(CameraCmd cmd);
+
//璁剧疆闆舵柟浣嶈
boolean setZeroPtz(CameraCmd cmd);
+
+ //鎶撳浘
+ String picCutCate(CameraCmd cmd);
+
+ //鐭椂褰曞儚
+ String record(CameraCmd cmd);
+ boolean recordStart(CameraCmd cmd);
+ String recordStopToMinio(CameraCmd cmd);
+
+ //寮曞鐩爣浣嶇疆
+ boolean guideTargetPosition(CameraCmd cmd);
+
+ //璋冪敤棰勭疆浣�
+ boolean gotoPreset(CameraCmd cmd);
+ //璁剧疆棰勭疆浣�
+ boolean setPreset(CameraCmd cmd);
+ //鑱氱劍妯″紡
+ boolean controlFocusMode(CameraCmd cmd);
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/impl/DhClientServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/impl/DhClientServiceImpl.java
index b984262..b7aadfb 100644
--- a/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/impl/DhClientServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/service/impl/DhClientServiceImpl.java
@@ -1,6 +1,9 @@
package com.ruoyi.device.dhsdk.service.impl;
import com.ruoyi.common.annotation.SdkOperate;
+import com.ruoyi.common.utils.file.FileUtils;
+import com.ruoyi.common.utils.file.MimeTypeUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
@@ -10,27 +13,39 @@
import com.ruoyi.device.dhsdk.common.Res;
import com.ruoyi.device.dhsdk.lib.NetSDKLib;
import com.ruoyi.device.dhsdk.lib.NetSDKLib.LLong;
-import com.ruoyi.device.dhsdk.lib.ToolKits;
-import com.ruoyi.device.dhsdk.lib.enumeration.EM_NEW_QUERY_SYSTEM_INFO;
+import com.ruoyi.device.dhsdk.lib.structure.CFG_VIDEO_IN_FOCUS;
+import com.ruoyi.device.dhsdk.lib.structure.CFG_VIDEO_IN_FOCUS_UNIT;
+import com.ruoyi.device.dhsdk.module.CapturePictureModule;
import com.ruoyi.device.dhsdk.module.ConfigModule;
import com.ruoyi.device.dhsdk.module.LoginModule;
-import com.ruoyi.device.dhsdk.module.PtzControlModule;
+import com.ruoyi.device.dhsdk.module.RealPlayModule;
import com.ruoyi.device.dhsdk.service.IDhClientService;
import com.ruoyi.device.hiksdk.common.GlobalVariable;
import com.ruoyi.device.hiksdk.sdk.HCNetSDK;
+import com.ruoyi.utils.gis.GisUtil;
+import com.ruoyi.utils.minio.MinioUtil;
import com.sun.jna.Pointer;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.text.DecimalFormat;
import java.util.*;
import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_DEVSTATE_ONLINE;
import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_DEVSTATE_PTZ_LOCATION;
+import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_MOVE_CONTROL;
+import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_SET_CONTROL;
import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint;
-import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.*;
+import static com.ruoyi.device.dhsdk.module.LoginModule.netsdk;
+import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.NET_DVR_SET_PTZPOS;
+
/**
* @ClassName DhSdkServiceImpl
@@ -46,6 +61,8 @@
private IArdCamerasService ardCamerasService;
@Resource
private IArdChannelService ardChannelService;
+ @Value("${minio.endpoint}")
+ private String minioEndPoint;
private Vector<String> chnlist = new Vector<String>();
// 璁惧鏂嚎閫氱煡鍥炶皟
@@ -53,7 +70,11 @@
// 缃戠粶杩炴帴鎭㈠
private static HaveReConnect haveReConnect = new HaveReConnect();
-
+ /**
+ * 鐧诲綍鎵�鏈夌浉鏈�
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:28:13
+ */
@Override
public void loginAll() {
try {
@@ -70,11 +91,21 @@
}
}
+ /**
+ * sdk鍒濆鍖�
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:28:13
+ */
@Override
public Boolean init() {
return LoginModule.init(disConnect, haveReConnect); // 鎵撳紑宸ョ▼锛屽垵濮嬪寲
}
+ /**
+ * 鐧诲綍
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:28:13
+ */
@Override
@Async
public Boolean login(ArdCameras camera) {
@@ -114,6 +145,11 @@
return true;
}
+ /**
+ * 娉ㄩ攢
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:28:13
+ */
@Override
public Boolean logout(String cameraId) {
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
@@ -123,6 +159,11 @@
return LoginModule.logout(loginId);
}
+ /**
+ * 鏄惁鍦ㄧ嚎妫�娴�
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:28:13
+ */
@Override
public boolean isOnLine(CameraCmd cmd) {
try {
@@ -143,6 +184,11 @@
return true;
}
+ /**
+ * 浜戝彴鎺у埗
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:28:13
+ */
@Override
public boolean pTZControl(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
@@ -176,7 +222,7 @@
dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL;
break;
case 5:
- dwPTZCommand = HCNetSDK.RUN_SEQ;
+ dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_LOOP_CONTROL;
break;
case 6:
dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL;
@@ -211,14 +257,22 @@
case 15:
dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL;
break;
+ case 16:
+ dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LAMP_CONTROL;
+ break;
}
- boolean bool = LoginModule.netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, dwPTZCommand, speed, speed, 0, dwStop);
+ boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, dwPTZCommand, speed, speed, 0, dwStop);
if (!bool) {
log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
}
return bool;
}
+ /**
+ * 鑾峰彇PTZ鍊�
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:28:13
+ */
@Override
public Map<String, Object> getPtz(CameraCmd cmd) {
Map<String, Object> ptzMap = new HashMap<>();
@@ -240,6 +294,7 @@
}
return ptzMap;
}
+
/**
* @鎻忚堪 璁剧疆ptz淇℃伅
* @鍙傛暟 [userId, channelNum]
@@ -257,12 +312,15 @@
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
- LLong loginId = (LLong)GlobalVariable.loginMap.get(cameraId);
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
try {
- int p = (int)(ptz.get("p") * 10);
- int t = (int)(ptz.get("t") * 10);
+ int p = (int) (ptz.get("p") * 10);
+ int t = (int) (ptz.get("t") * 10);
int z = ptz.get("z").intValue();
- boolean bool = LoginModule.netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0 );
+ if (z == 0) {
+ z = 1;
+ }
+ boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0);
if (!bool) {
log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
}
@@ -289,7 +347,7 @@
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
return false;
}
- LLong loginId = (LLong)GlobalVariable.loginMap.get(cameraId);
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
boolean bool = NetSDKLib.NETSDK_INSTANCE.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RESETZERO, 0, 0, 0, 0);
if (!bool) {
log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
@@ -297,21 +355,308 @@
return bool;
}
+ /**
+ * @鎻忚堪 鎴浘 瀛樻湇鍔″櫒
+ * @鍙傛暟 [cameraId, channelNum]
+ * @杩斿洖鍊� java.lang.String
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/2/2 14:59
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+ @Override
+ @SdkOperate
+ public String picCutCate(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return "";
+ }
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
+ String bucketName = "pic";
+ String picUrl = "";
+ String bucketObject = "/capture/" + IdUtils.simpleUUID() + ".jpeg";
+ fCaptureReceiveCB m_CaptureReceiveCB = new fCaptureReceiveCB(minioEndPoint, bucketName, bucketObject);
+ CapturePictureModule.setSnapRevCallBack(m_CaptureReceiveCB);
+ boolean b = CapturePictureModule.remoteCapturePicture(loginId, chanNo - 1);
+ if (b) {
+ picUrl = minioEndPoint + "/" + bucketName + bucketObject;
+ }
+ return picUrl;
+ }
- // 璁惧鏂嚎鍥炶皟: 閫氳繃 CLIENT_Init 璁剧疆璇ュ洖璋冨嚱鏁帮紝褰撹澶囧嚭鐜版柇绾挎椂锛孲DK浼氳皟鐢ㄨ鍑芥暟
+ /**
+ * @鎻忚堪 鐭椂褰曞儚
+ * @鍙傛暟 [userId, channelNum, enable]
+ * @杩斿洖鍊� void
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/1/20 11:18
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+ @Override
+ public String record(CameraCmd cmd) {
+ try {
+ String url = "";
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
+ boolean enable = cmd.isEnable();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return "";
+ }
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
+
+ if (enable) {
+ LLong lRealHandle = new LLong(0);
+ if (!GlobalVariable.previewMap.containsKey(cameraId)) {
+ lRealHandle = RealPlayModule.startRealPlay(loginId, chanNo, 0);
+ if (lRealHandle.longValue() <= 0) {
+ log.error("鍙栨祦澶辫触" + getErrorCodePrint());
+ return "";
+ }
+ log.debug("鍙栨祦鎴愬姛");
+ GlobalVariable.previewMap.put(cameraId, lRealHandle.intValue());
+ }
+ if (!netsdk.CLIENT_SaveRealData(lRealHandle, path)) {
+ log.error("淇濆瓨瑙嗛鏂囦欢鍒颁复鏃舵枃浠跺す澶辫触 閿欒鐮佷负: " + getErrorCodePrint());
+ return "";
+ }
+ log.debug("褰曞儚寮�濮�");
+ } else {
+ if (GlobalVariable.previewMap.containsKey(cameraId)) {
+ LLong lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId));
+ boolean b = netsdk.CLIENT_StopSaveRealData(lRealHandle);
+ GlobalVariable.previewMap.remove(cameraId);
+ }
+ log.debug("褰曞儚鍋滄");
+ }
+ return url;
+ } catch (Exception ex) {
+ log.error("褰曞儚寮傚父" + ex.getMessage());
+ return "";
+ }
+ }
+
+ @Override
+ public boolean recordStart(CameraCmd cmd) {
+ try {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return false;
+ }
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
+ LLong lRealHandle;
+ if (GlobalVariable.previewMap.containsKey(cameraId)) {
+ lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId));
+ netsdk.CLIENT_StopRealPlayEx(lRealHandle);
+ GlobalVariable.previewMap.remove(cameraId);
+ log.debug("鍋滄褰撳墠褰曞儚");
+ }
+ lRealHandle = RealPlayModule.startRealPlay1(loginId, chanNo - 1, path);
+ if (lRealHandle.longValue() <= 0) {
+ log.error("鍙栨祦澶辫触" + getErrorCodePrint());
+ }
+ log.debug("鍙栨祦鎴愬姛");
+ GlobalVariable.previewMap.put(cameraId, lRealHandle.intValue());
+ GlobalVariable.threadMap.put(cameraId, Thread.currentThread().getName());
+ //if (!netsdk.CLIENT_SaveRealData(lRealHandle, path)) {
+ // log.error("淇濆瓨瑙嗛鏂囦欢鍒颁复鏃舵枃浠跺す澶辫触 閿欒鐮佷负: " +getErrorCodePrint());
+ // return false;
+ //}
+ log.debug("褰曞儚寮�濮�");
+ return true;
+ } catch (Exception ex) {
+ log.error("寮�濮嬪綍鍍忓紓甯�" + ex.getMessage());
+ return false;
+ }
+ }
+
+ @Override
+ public String recordStopToMinio(CameraCmd cmd) {
+ String url = "";
+ try {
+ String cameraId = cmd.getCameraId();
+ String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return "";
+ }
+ LLong lRealHandle;
+ if (GlobalVariable.previewMap.containsKey(cameraId)) {
+ lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId));
+ netsdk.CLIENT_StopRealPlayEx(lRealHandle);
+ GlobalVariable.previewMap.remove(cameraId);
+ log.debug("鍋滄褰撳墠褰曞儚");
+ }
+ //瀛樺叆minio
+ String BucketName = cmd.getRecordBucketName();
+ String ObjectName = cmd.getRecordObjectName() + ".mp4";
+ FileInputStream stream = new FileInputStream(path);
+ boolean b = MinioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4");
+ if (b) {
+ url = MinioUtil.getBucketObjectUrl(BucketName, ObjectName);
+ log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
+ }
+ return url;
+ } catch (Exception ex) {
+ log.error("褰曞儚寮傚父" + ex.getMessage());
+ return "";
+ }
+ }
+
+ /**
+ * 寮曞鐩爣浣嶇疆
+ * 鍒樿嫃涔�
+ * 2023/10/17 8:27:48
+ */
+ @Override
+ public boolean guideTargetPosition(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return false;
+ }
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
+ try {
+ ArdCameras cameras = ardCamerasService.selectArdCamerasById(cameraId);
+ double[] cameraPositon = new double[]{cameras.getLongitude(), cameras.getLatitude(), cameras.getAltitude()};
+ double[] targetPositions = cmd.getTargetPosition();
+ double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPositon, targetPositions, 20, 150);
+ int p = (int) (cameraPTZ[0] * 10);
+ int t = (int) (cameraPTZ[1] * 10);
+ int z = (int) (cameraPTZ[2]);
+ boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0);
+ if (!bool) {
+ log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
+ }
+ return bool;
+ } catch (Exception ex) {
+ log.error("寮曞寮傚父:" + ex.getMessage());
+ return false;
+ }
+ }
+
+ //杞嚦棰勭疆鐐�
+ @Override
+ public boolean gotoPreset(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ Integer PresetIndex = cmd.getPresetIndex();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return false;
+ }
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
+ try {
+
+ boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NET_PTZ_POINT_MOVE_CONTROL, 0, PresetIndex, 0, 0);
+ if (!bool) {
+ log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
+ }
+ return bool;
+ } catch (Exception ex) {
+ log.error("杞嚦棰勭疆鐐瑰紓甯�:" + ex.getMessage());
+ return false;
+ }
+ }
+
+ @Override
+ //璁剧疆棰勭疆浣�
+ public boolean setPreset(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ Integer PresetIndex = cmd.getPresetIndex();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return false;
+ }
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
+ try {
+
+ boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NET_PTZ_POINT_SET_CONTROL, 0, PresetIndex, 0, 0);
+ if (!bool) {
+ log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
+ }
+ return bool;
+ } catch (Exception ex) {
+ log.error("璁剧疆棰勭疆鐐瑰紓甯�:" + ex.getMessage());
+ return false;
+ }
+ }
+
+ //鍒囨崲鑱氱劍妯″紡
+ @Override
+ public boolean controlFocusMode(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ boolean enable = cmd.isEnable();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return false;
+ }
+ LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
+ try {
+ CFG_VIDEO_IN_FOCUS cfg_video_in_focus = new CFG_VIDEO_IN_FOCUS();
+ CFG_VIDEO_IN_FOCUS_UNIT[] stVideoInFocusUnit = new CFG_VIDEO_IN_FOCUS_UNIT[32];
+ if (enable) {
+ stVideoInFocusUnit[0].nMode = 4;//鎵嬪姩鑱氱劍
+ } else {
+ stVideoInFocusUnit[0].nMode = 2;//鎵嬪姩鑱氱劍
+ }
+ cfg_video_in_focus.nChannelIndex = chanNo - 1;
+ cfg_video_in_focus.stVideoInFocusUnit = stVideoInFocusUnit;
+ boolean bool = ConfigModule.SetDevConfig(loginId, chanNo - 1, NetSDKLib.CFG_CMD_VIDEOIN_FOCUS, cfg_video_in_focus);
+ if (!bool) {
+ log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
+ }
+ return bool;
+ } catch (Exception ex) {
+ log.error("鍒囨崲鑱氱劍妯″紡寮傚父:" + ex.getMessage());
+ return false;
+ }
+ }
+
+ // 璁惧鏂嚎鍥炶皟: 褰撹澶囧嚭鐜版柇绾挎椂锛孲DK浼氳皟鐢ㄨ鍑芥暟
private static class DisConnect implements NetSDKLib.fDisConnect {
public void invoke(LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
System.out.printf("Device[%s] Port[%d] DisConnect!\n", pchDVRIP, nDVRPort);
}
}
- // 缃戠粶杩炴帴鎭㈠锛岃澶囬噸杩炴垚鍔熷洖璋�
- // 閫氳繃 CLIENT_SetAutoReconnect 璁剧疆璇ュ洖璋冨嚱鏁帮紝褰撳凡鏂嚎鐨勮澶囬噸杩炴垚鍔熸椂锛孲DK浼氳皟鐢ㄨ鍑芥暟
+ // 缃戠粶杩炴帴鎭㈠鍥炶皟:璁惧閲嶈繛鎴愬姛鍥炶皟锛屽綋宸叉柇绾跨殑璁惧閲嶈繛鎴愬姛鏃讹紝SDK浼氳皟鐢ㄨ鍑芥暟
private static class HaveReConnect implements NetSDKLib.fHaveReConnect {
@Override
public void invoke(LLong lLoginID, String pchDVRIP, int nDVRPort, Pointer dwUser) {
System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort);
}
}
+
+ // 鎶撳浘鎺ユ敹鍥炶皟:褰撴姄鍥炬垚鍔燂紝sdk浼氳皟鐢ㄨ鍑芥暟
+ public static class fCaptureReceiveCB implements NetSDKLib.fSnapRev {
+ private String minioEndPoint;
+ private String ObjectName;
+ private String bucketName;
+
+ public fCaptureReceiveCB(String minioEndPoint, String bucketName, String ObjectName) {
+ this.minioEndPoint = minioEndPoint;
+ this.bucketName = bucketName;
+ this.ObjectName = ObjectName;
+ }
+
+ public void invoke(LLong lLoginID, Pointer pBuf, int RevLen, int EncodeType, int CmdSerial, Pointer dwUser) {
+ if (pBuf != null && RevLen > 0) {
+ byte[] buf = pBuf.getByteArray(0, RevLen);
+ //瀛樺偍鍒癿inio
+ InputStream input = new ByteArrayInputStream(buf);
+
+ try {
+ boolean b = MinioUtil.uploadObject(bucketName, ObjectName, input, input.available(), MimeTypeUtils.IMAGE_JPEG);
+ if (b) {
+ String url = minioEndPoint + "/" + bucketName + ObjectName;
+ log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
+ }
+ } catch (IOException ex) {
+ log.error("涓婁紶鏂囦欢寮傚父锛�" + ex.getMessage());
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/HikSdkController.java
similarity index 96%
rename from ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java
rename to ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/HikSdkController.java
index ea46ace..6f9fbcb 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/HikSdkController.java
@@ -1,338 +1,321 @@
-package com.ruoyi.device.hiksdk.controller;
-
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import com.ruoyi.common.annotation.Log;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.device.camera.domain.ArdCameras;
-import com.ruoyi.device.camera.domain.CameraCmd;
-import com.ruoyi.device.camera.service.IArdCamerasService;
-import com.ruoyi.device.dhsdk.service.IDhClientService;
-import com.ruoyi.device.hiksdk.service.IHikClientService;
-import com.ruoyi.common.annotation.Anonymous;
-import com.ruoyi.common.core.domain.AjaxResult;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @ClassName: sdkController
- * @Description:
- * @Author: Administrator
- * @Date: 2023骞�01鏈�17鏃� 12:04
- * @Version: 1.0
- **/
-@Api(tags = "娴峰悍SDK鎺ュ彛")
-@Controller
-@RequestMapping("/hik")
-@Anonymous
-public class SdkController extends BaseController {
-
- @Resource
- private IHikClientService sdk;
- @Resource
- private IDhClientService ClientService;
- @Resource
- private IArdCamerasService ardCamerasService;
-
- /**
- * @鎻忚堪 鍒濆鍔犺浇娴峰悍搴撴枃浠�
- * @鍙傛暟 []
- * @杩斿洖鍊� void
- * @鍒涘缓浜� 鍒樿嫃涔�
- * @鍒涘缓鏃堕棿 2023/1/17 16:13
- * @淇敼浜哄拰鍏跺畠淇℃伅 if (Platform.isLinux())
- */
- @PostConstruct
- public void initHCNetSDK() {
- //鍒濆鍖栧姞杞絪dk搴撴枃浠�
- sdk.loadHCNetSDKLib();
- //鐧诲綍鎵�鏈夌浉鏈�
- sdk.loginAll();
- }
-
- @RequestMapping("/preview")
- private String preview() {
- return "preview";
- }
- @RequestMapping("/index")
- private String index() {
- return "test";
- }
-
- @GetMapping("/list")
- public @ResponseBody
- AjaxResult list(ArdCameras ardCamera) {
- List<ArdCameras> list = ardCamerasService.selectArdCamerasListNoDataScope(ardCamera);
- return AjaxResult.success("鐩告満鍒楄〃锛�", list);
- }
-
- @ApiOperation("鑾峰彇鐮佹祦鍘嬬缉鍙傛暟")
- @PostMapping("/getVideoCompressionCfg")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
- @Log(title = "鑾峰彇鐮佹祦鍘嬬缉鍙傛暟", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) {
- return AjaxResult.success(sdk.getVideoCompressionCfg(cmd));
- }
-
- @ApiOperation("鍦ㄧ嚎鐘舵��")
- @PostMapping("/state")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
- @Log(title = "鍦ㄧ嚎鐘舵��", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult getOnlineState(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- boolean onLine = sdk.isOnLine(cmd);
- return AjaxResult.success(onLine);
- }
-
- @ApiOperation(value = "浜戝彴鎺у埗", notes = "Code:1-宸︿笂 2-涓� 3-鍙充笂 4-宸� 5-宸¤埅 6-鍙� 7-宸︿笅 8-涓� 9-鍙充笅 10-鐒﹁窛鍙樺ぇ 11-鐒﹁窛鍙樺皬\n" +
- "12-鐒︾偣鍓嶈皟 13-鐒︾偣鍚庤皟 14-鍏夊湀鎵╁ぇ 15-鍏夊湀缂╁皬 16-闆ㄥ埛寮�鍚�")
- @PostMapping("/PTZControlWithSpeed")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.speed", "cmd.enable", "cmd.code"})
- @Log(title = "浜戝彴鎺у埗", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.pTZControlWithSpeed(cmd));
- }
-
- @ApiOperation("璋冪敤棰勭疆鐐�")
- @PostMapping("/gotoPreset")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
- @Log(title = "璋冪敤棰勭疆鐐�", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult gotoPreset(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.gotoPreset(cmd));
- }
-
- @ApiOperation("璁剧疆棰勭疆鐐�")
- @PostMapping("/setPreset")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
- @Log(title = "璁剧疆棰勭疆鐐�", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult setPreset(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.setPreset(cmd));
- }
-
- @ApiOperation("鑾峰彇鑱氱劍鍊�")
- @PostMapping("/getFocusPos")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
- @Log(title = "鑾峰彇鑱氱劍鍊�", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult getFocusPos(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- Map<String, Object> Map = sdk.getFocusPos(cmd);
- return AjaxResult.success("鑾峰彇鑱氱劍鍊�", Map);
- }
-
- @ApiOperation("璁剧疆鑱氱劍鍊�")
- @PostMapping("/setFocusPos")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.dwFocusPos"})
- @Log(title = "璁剧疆鑱氱劍鍊�", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult setFocusPos(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.setFocusPos(cmd));
- }
-
- @ApiOperation("鑾峰彇PTZ")
- @PostMapping("/getPTZ")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
- @Log(title = "鑾峰彇PTZ", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult getPTZ(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- Map<String, Object> ptzMap = sdk.getPtz(cmd);
- return AjaxResult.success("鑾峰彇ptz", ptzMap);
- }
-
- @ApiOperation("鑾峰彇PTZ鑼冨洿")
- @PostMapping("/getPTZScope")
- @Log(title = "鑾峰彇PTZ鑼冨洿", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
- public @ResponseBody
- AjaxResult getPTZScope(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- Map<String, Object> ptzMap = sdk.getPtzScope(cmd);
- return AjaxResult.success("鑾峰彇ptz鑼冨洿", ptzMap);
- }
-
- @ApiOperation("璁剧疆PTZ")
- @PostMapping("/setPTZ")
- @Log(title = "璁剧疆PTZ", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.ptzMap"})
- public @ResponseBody
- AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.setPtz(cmd));
- }
-
- @ApiOperation("鎸囧悜鐩爣")
- @PostMapping("/setTargetPosition")
- @Log(title = "鎸囧悜鐩爣", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.targetPosition"})
- public @ResponseBody
- AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.guideTargetPosition(cmd));
- }
-
-
- @ApiOperation("璁剧疆闆舵柟浣嶈")
- @PostMapping("/setZeroPTZ")
- @Log(title = "璁剧疆闆舵柟浣嶈", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
- public @ResponseBody
- AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.setZeroPtz(cmd));
- }
-
- @ApiOperation("璁剧疆閿佸畾")
- @PostMapping("/setPTZLock")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.expired"})
- @Log(title = "璁剧疆閿佸畾", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult setPTZLock(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return AjaxResult.success(sdk.controlLock(cmd));
- }
-
- @ApiOperation("璁剧疆瑙i攣")
- @PostMapping("/setPTZUnLock")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
- @Log(title = "璁剧疆瑙i攣", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return AjaxResult.success(sdk.controlUnLock(cmd));
- }
-
- @ApiOperation("鑾峰彇浜戝彴閿佸畾淇℃伅")
- @PostMapping("/getPTZLockInfo")
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
- @Log(title = "鑾峰彇浜戝彴閿佸畾淇℃伅", businessType = BusinessType.CONTROL)
- public @ResponseBody
- AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- int byWorkMode = sdk.getPTZLockInfo(cmd);
- if (byWorkMode == 0) {
- return AjaxResult.success("浜戝彴閿佸畾鐘舵�侊細瑙i攣");
- } else if (byWorkMode == 1) {
- return AjaxResult.success("浜戝彴閿佸畾鐘舵�侊細閿佸畾");
- } else {
- return AjaxResult.error("浜戝彴閿佸畾鐘舵�侊細澶辫触");
- }
- }
-
- @ApiOperation("閫忛浘寮�鍏�")
- @PostMapping("/defogcfg")
- @Log(title = "閫忛浘寮�鍏�", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult defogcfg(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.controlDefogcfg(cmd));
- }
-
- @ApiOperation("绾㈠寮�鍏�")
- @PostMapping("/infrarecfg")
- @Log(title = "绾㈠寮�鍏�", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult infrarecfg(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.controlInfrarecfg(cmd));
- }
-
- @ApiOperation(value = "鎵嬪姩/鑷姩鑱氱劍", notes = "true鎵嬪姩flase鑷姩")
- @PostMapping("/focusMode")
- @Log(title = "鎵嬪姩/鑷姩鑱氱劍", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.controlFocusMode(cmd));
- }
-
- @ApiOperation(value = "鑾峰彇鑱氱劍妯″紡", notes = "1鎵嬪姩2鑷姩")
- @PostMapping("/getFocusMode")
- public @ResponseBody
- AjaxResult getFocusMode(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- String focusMode = sdk.getFocusMode(cmd);
- return AjaxResult.success(focusMode);
- }
-
- @ApiOperation("浜戝彴鍔犵儹")
- @PostMapping("/heateRpwron")
- @Log(title = "浜戝彴鍔犵儹", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult heateRpwron(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.controlPTHeateRpwron(cmd));
- }
-
-
- @ApiOperation("闀滃ご鍔犵儹")
- @PostMapping("/cameraDeicing")
- @Log(title = "闀滃ご鍔犵儹", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.controlCameraDeicing(cmd));
- }
-
- @PostMapping("/captureJPEGPicture")
- public @ResponseBody
- AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- String base64Str = sdk.captureJPEGPicture(cmd);
- return toAjaxString(base64Str, "鐩告満鎶撳浘");
- }
-
- @ApiOperation("鐩告満鎶撳浘")
- @PostMapping("/picCutCate")
- @Log(title = "鐩告満鎶撳浘", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
- public @ResponseBody
- AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- String path = sdk.picCutCate(cmd);
- return toAjaxString(path, "鐩告満鎶撳浘");
- }
-
- @ApiOperation("鎵嬪姩褰曞儚")
- @PostMapping("/record")
- @Log(title = "鎵嬪姩褰曞儚", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult record(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- String path = sdk.record(cmd);
- return toAjaxString(path, "鎵嬪姩褰曞儚");
- }
-
- @ApiOperation("鑾峰彇鐩告満鏋惰鍙傛暟")
- @PostMapping("/getCameraSetupCFG")
- @Log(title = "鑾峰彇鐩告満鏋惰鍙傛暟", businessType = BusinessType.CONTROL)
- @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
- public @ResponseBody
- AjaxResult getCameraSetupCFG(@RequestBody CameraCmd cmd) {
- cmd.setOperator(SecurityUtils.getUserId());
- return AjaxResult.success(sdk.getGisInfo(cmd));
- }
-}
+package com.ruoyi.device.hiksdk.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.service.IArdCamerasService;
+import com.ruoyi.device.dhsdk.service.IDhClientService;
+import com.ruoyi.device.hiksdk.service.IHikClientService;
+import com.ruoyi.common.annotation.Anonymous;
+import com.ruoyi.common.core.domain.AjaxResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName: sdkController
+ * @Description:
+ * @Author: Administrator
+ * @Date: 2023骞�01鏈�17鏃� 12:04
+ * @Version: 1.0
+ **/
+@Api(tags = "娴峰悍SDK鎺ュ彛")
+@Controller
+@RequestMapping("/hik")
+@Anonymous
+public class HikSdkController extends BaseController {
+
+ @Resource
+ private IHikClientService sdk;
+ @Resource
+ private IArdCamerasService ardCamerasService;
+
+
+ @RequestMapping("/preview")
+ private String preview() {
+ return "preview";
+ }
+ @RequestMapping("/index")
+ private String index() {
+ return "test";
+ }
+
+ @GetMapping("/list")
+ public @ResponseBody
+ AjaxResult list(ArdCameras ardCamera) {
+ List<ArdCameras> list = ardCamerasService.selectArdCamerasListNoDataScope(ardCamera);
+ return AjaxResult.success("鐩告満鍒楄〃锛�", list);
+ }
+
+ @ApiOperation("鑾峰彇鐮佹祦鍘嬬缉鍙傛暟")
+ @PostMapping("/getVideoCompressionCfg")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ @Log(title = "鑾峰彇鐮佹祦鍘嬬缉鍙傛暟", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) {
+ return AjaxResult.success(sdk.getVideoCompressionCfg(cmd));
+ }
+
+ @ApiOperation("鍦ㄧ嚎鐘舵��")
+ @PostMapping("/state")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
+ @Log(title = "鍦ㄧ嚎鐘舵��", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult getOnlineState(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ boolean onLine = sdk.isOnLine(cmd);
+ return AjaxResult.success(onLine);
+ }
+
+ @ApiOperation(value = "浜戝彴鎺у埗", notes = "Code:1-宸︿笂 2-涓� 3-鍙充笂 4-宸� 5-宸¤埅 6-鍙� 7-宸︿笅 8-涓� 9-鍙充笅 10-鐒﹁窛鍙樺ぇ 11-鐒﹁窛鍙樺皬\n" +
+ "12-鐒︾偣鍓嶈皟 13-鐒︾偣鍚庤皟 14-鍏夊湀鎵╁ぇ 15-鍏夊湀缂╁皬 16-闆ㄥ埛寮�鍚�")
+ @PostMapping("/PTZControlWithSpeed")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.speed", "cmd.enable", "cmd.code"})
+ @Log(title = "浜戝彴鎺у埗", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.pTZControlWithSpeed(cmd));
+ }
+
+ @ApiOperation("璋冪敤棰勭疆鐐�")
+ @PostMapping("/gotoPreset")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
+ @Log(title = "璋冪敤棰勭疆鐐�", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult gotoPreset(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.gotoPreset(cmd));
+ }
+
+ @ApiOperation("璁剧疆棰勭疆鐐�")
+ @PostMapping("/setPreset")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
+ @Log(title = "璁剧疆棰勭疆鐐�", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult setPreset(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.setPreset(cmd));
+ }
+
+ @ApiOperation("鑾峰彇鑱氱劍鍊�")
+ @PostMapping("/getFocusPos")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ @Log(title = "鑾峰彇鑱氱劍鍊�", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult getFocusPos(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ Map<String, Object> Map = sdk.getFocusPos(cmd);
+ return AjaxResult.success("鑾峰彇鑱氱劍鍊�", Map);
+ }
+
+ @ApiOperation("璁剧疆鑱氱劍鍊�")
+ @PostMapping("/setFocusPos")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.dwFocusPos"})
+ @Log(title = "璁剧疆鑱氱劍鍊�", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult setFocusPos(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.setFocusPos(cmd));
+ }
+
+ @ApiOperation("鑾峰彇PTZ")
+ @PostMapping("/getPTZ")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ @Log(title = "鑾峰彇PTZ", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult getPTZ(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ Map<String, Object> ptzMap = sdk.getPtz(cmd);
+ return AjaxResult.success("鑾峰彇ptz", ptzMap);
+ }
+
+ @ApiOperation("鑾峰彇PTZ鑼冨洿")
+ @PostMapping("/getPTZScope")
+ @Log(title = "鑾峰彇PTZ鑼冨洿", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ public @ResponseBody
+ AjaxResult getPTZScope(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ Map<String, Object> ptzMap = sdk.getPtzScope(cmd);
+ return AjaxResult.success("鑾峰彇ptz鑼冨洿", ptzMap);
+ }
+
+ @ApiOperation("璁剧疆PTZ")
+ @PostMapping("/setPTZ")
+ @Log(title = "璁剧疆PTZ", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.ptzMap"})
+ public @ResponseBody
+ AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.setPtz(cmd));
+ }
+
+ @ApiOperation("鎸囧悜鐩爣")
+ @PostMapping("/setTargetPosition")
+ @Log(title = "鎸囧悜鐩爣", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.targetPosition"})
+ public @ResponseBody
+ AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.guideTargetPosition(cmd));
+ }
+
+
+ @ApiOperation("璁剧疆闆舵柟浣嶈")
+ @PostMapping("/setZeroPTZ")
+ @Log(title = "璁剧疆闆舵柟浣嶈", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ public @ResponseBody
+ AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.setZeroPtz(cmd));
+ }
+
+ @ApiOperation("璁剧疆閿佸畾")
+ @PostMapping("/setPTZLock")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.expired"})
+ @Log(title = "璁剧疆閿佸畾", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult setPTZLock(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return AjaxResult.success(sdk.controlLock(cmd));
+ }
+
+ @ApiOperation("璁剧疆瑙i攣")
+ @PostMapping("/setPTZUnLock")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
+ @Log(title = "璁剧疆瑙i攣", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return AjaxResult.success(sdk.controlUnLock(cmd));
+ }
+
+ @ApiOperation("鑾峰彇浜戝彴閿佸畾淇℃伅")
+ @PostMapping("/getPTZLockInfo")
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ @Log(title = "鑾峰彇浜戝彴閿佸畾淇℃伅", businessType = BusinessType.CONTROL)
+ public @ResponseBody
+ AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ int byWorkMode = sdk.getPTZLockInfo(cmd);
+ if (byWorkMode == 0) {
+ return AjaxResult.success("浜戝彴閿佸畾鐘舵�侊細瑙i攣");
+ } else if (byWorkMode == 1) {
+ return AjaxResult.success("浜戝彴閿佸畾鐘舵�侊細閿佸畾");
+ } else {
+ return AjaxResult.error("浜戝彴閿佸畾鐘舵�侊細澶辫触");
+ }
+ }
+
+ @ApiOperation("閫忛浘寮�鍏�")
+ @PostMapping("/defogcfg")
+ @Log(title = "閫忛浘寮�鍏�", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
+ public @ResponseBody
+ AjaxResult defogcfg(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.controlDefogcfg(cmd));
+ }
+
+ @ApiOperation("绾㈠寮�鍏�")
+ @PostMapping("/infrarecfg")
+ @Log(title = "绾㈠寮�鍏�", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
+ public @ResponseBody
+ AjaxResult infrarecfg(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.controlInfrarecfg(cmd));
+ }
+
+ @ApiOperation(value = "鎵嬪姩/鑷姩鑱氱劍", notes = "true鎵嬪姩flase鑷姩")
+ @PostMapping("/focusMode")
+ @Log(title = "鎵嬪姩/鑷姩鑱氱劍", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
+ public @ResponseBody
+ AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.controlFocusMode(cmd));
+ }
+
+ @ApiOperation(value = "鑾峰彇鑱氱劍妯″紡", notes = "1鎵嬪姩2鑷姩")
+ @PostMapping("/getFocusMode")
+ public @ResponseBody
+ AjaxResult getFocusMode(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ String focusMode = sdk.getFocusMode(cmd);
+ return AjaxResult.success(focusMode);
+ }
+
+ @ApiOperation("浜戝彴鍔犵儹")
+ @PostMapping("/heateRpwron")
+ @Log(title = "浜戝彴鍔犵儹", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
+ public @ResponseBody
+ AjaxResult heateRpwron(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.controlPTHeateRpwron(cmd));
+ }
+
+
+ @ApiOperation("闀滃ご鍔犵儹")
+ @PostMapping("/cameraDeicing")
+ @Log(title = "闀滃ご鍔犵儹", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
+ public @ResponseBody
+ AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return toAjax(sdk.controlCameraDeicing(cmd));
+ }
+
+ @PostMapping("/captureJPEGPicture")
+ public @ResponseBody
+ AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ String base64Str = sdk.captureJPEGPicture(cmd);
+ return toAjaxString(base64Str, "鐩告満鎶撳浘");
+ }
+
+ @ApiOperation("鐩告満鎶撳浘")
+ @PostMapping("/picCutCate")
+ @Log(title = "鐩告満鎶撳浘", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
+ public @ResponseBody
+ AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ String path = sdk.picCutCate(cmd);
+ return toAjaxString(path, "鐩告満鎶撳浘");
+ }
+
+ @ApiOperation("鎵嬪姩褰曞儚")
+ @PostMapping("/record")
+ @Log(title = "鎵嬪姩褰曞儚", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
+ public @ResponseBody
+ AjaxResult record(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ String path = sdk.record(cmd);
+ return toAjaxString(path, "鎵嬪姩褰曞儚");
+ }
+
+ @ApiOperation("鑾峰彇鐩告満鏋惰鍙傛暟")
+ @PostMapping("/getCameraSetupCFG")
+ @Log(title = "鑾峰彇鐩告満鏋惰鍙傛暟", businessType = BusinessType.CONTROL)
+ @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
+ public @ResponseBody
+ AjaxResult getCameraSetupCFG(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
+ return AjaxResult.success(sdk.getGisInfo(cmd));
+ }
+}
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/IHikClientService.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/IHikClientService.java
index b71b6f6..b740fc8 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/IHikClientService.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/IHikClientService.java
@@ -8,14 +8,15 @@
import java.util.Map;
/**
- * @ClassName: sdkClinet
+ * @ClassName: IHikClientService
* @Description: 娴峰悍鎿嶄綔瀹㈡埛绔帴鍙g被
* @Author: Administrator
* @Date: 2023骞�01鏈�17鏃� 15:59
* @Version: 1.0
**/
public interface IHikClientService {
- void loadHCNetSDKLib();
+ //sdk鍒濆鍖�
+ boolean init();
//鍚屾鐧诲綍
void syncLogin(ArdCameras cameras);
@@ -102,7 +103,7 @@
boolean guideTargetPosition(CameraCmd cmd);
//寮�濮嬪綍鍍�
- void recordStart(CameraCmd cmd);
+ boolean recordStart(CameraCmd cmd);
//鍋滄褰曞儚-涓婁紶minio-杩斿洖褰曞儚url
String recordStopToMinio(CameraCmd cmd);
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 4fb1c27..126acde 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
@@ -61,7 +61,7 @@
private static HCNetSDK hCNetSDK;
@Override
- public void loadHCNetSDKLib() {
+ public boolean init() {
try {
log.debug("寮�濮嬪姞杞絪dk搴撴枃浠惰矾寰�");
if (Platform.isWindows()) {
@@ -96,8 +96,10 @@
ptrByteArraySsl.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArraySsl.getPointer());
}
+ return true;
} catch (Exception ex) {
log.error("鍔犺浇搴撴枃浠跺紓甯革細" + ex.getMessage());
+ return false;
}
}
@@ -794,7 +796,7 @@
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return null;
+ return new HashMap<>();
}
Integer userId = (Integer)GlobalVariable.loginMap.get(cameraId);
@@ -852,9 +854,9 @@
NET_DVR_PTZPOS m_ptzPosCurrent = new NET_DVR_PTZPOS();
m_ptzPosCurrent.wAction = 1;
try {
- String p = String.valueOf(ptz.get("p") * 10);
- String t = String.valueOf(ptz.get("t") * 10);
- String z = String.valueOf(ptz.get("z") * 10);
+ String p = String.valueOf((int)(ptz.get("p") * 10));
+ String t = String.valueOf((int)(ptz.get("t") * 10));
+ String z = String.valueOf((int)(ptz.get("z") * 10));
m_ptzPosCurrent.wPanPos = (short) (Integer.parseInt(p, 16));
m_ptzPosCurrent.wTiltPos = (short) (Integer.parseInt(t, 16));
m_ptzPosCurrent.wZoomPos = (short) (Integer.parseInt(z, 16));
@@ -1468,6 +1470,15 @@
GlobalVariable.previewMap.remove(cameraId);
}
log.debug("褰曞儚鍋滄");
+ //瀛樺叆minio
+ String BucketName = "record";
+ String ObjectName =IdUtils.simpleUUID() + ".mp4";
+ FileInputStream stream = new FileInputStream(path);
+ boolean b = MinioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4");
+ if (b) {
+ url = MinioUtil.getBucketObjectUrl(BucketName, ObjectName);
+ log.debug("涓婁紶鏂囦欢鎴愬姛!" + url);
+ }
}
return url;
} catch (Exception ex) {
@@ -1477,13 +1488,13 @@
}
@Override
- public void recordStart(CameraCmd cmd) {
+ public boolean recordStart(CameraCmd cmd) {
try {
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return;
+ return false;
}
Integer userId = (Integer)GlobalVariable.loginMap.get(cameraId);
//寮哄埗I甯х粨鏋勪綋瀵硅薄
@@ -1515,18 +1526,20 @@
int lRealHandle = hCNetSDK.NET_DVR_RealPlay_V40(userId, previewinfo, null, null);
if (lRealHandle == -1) {
log.error("鍙栨祦澶辫触" + hCNetSDK.NET_DVR_GetLastError());
- return;
+ return false;
}
log.debug("鍙栨祦鎴愬姛");
GlobalVariable.threadMap.put(cameraId, Thread.currentThread().getName());
GlobalVariable.previewMap.put(cameraId, lRealHandle);
if (!hCNetSDK.NET_DVR_SaveRealData_V30(GlobalVariable.previewMap.get(cameraId), 2, path)) {
log.error("淇濆瓨瑙嗛鏂囦欢鍒颁复鏃舵枃浠跺す澶辫触 閿欒鐮佷负: " + hCNetSDK.NET_DVR_GetLastError());
- return;
+ return false;
}
log.debug("褰曞儚寮�濮�");
+ return true;
} catch (Exception ex) {
log.error("寮�濮嬪綍鍍忓紓甯�" + ex.getMessage());
+ return false;
}
}
--
Gitblit v1.9.3