Merge remote-tracking branch 'origin/master'
| | |
| | | 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; |
| | |
| | | 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() { |
| | | //初始化加载sdk库文件 |
| | | hikClientService.loadHCNetSDKLib(); |
| | | //登录所有相机 |
| | | hikClientService.loginAll(); |
| | | public void initSDK() { |
| | | cameraSdkService.initSDK(); |
| | | } |
| | | |
| | | @RequestMapping("/preview") |
| | |
| | | @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("在线状态") |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.pTZControlWithSpeed(cmd)); |
| | | return toAjax(cameraSdkService.pTZControl(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("调用预置点") |
| | |
| | | public @ResponseBody |
| | | AjaxResult gotoPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.gotoPreset(cmd)); |
| | | return toAjax(cameraSdkService.gotoPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置预置点") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setPreset(cmd)); |
| | | return toAjax(cameraSdkService.setPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("获取聚焦值") |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult setFocusPos(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setFocusPos(cmd)); |
| | | return toAjax(cameraSdkService.setFocusPos(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("获取PTZ") |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setPtz(cmd)); |
| | | return toAjax(cameraSdkService.setPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("指向目标") |
| | |
| | | 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("设置锁定") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.controlLock(cmd)); |
| | | return AjaxResult.success(cameraSdkService.controlLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置解锁") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.controlUnLock(cmd)); |
| | | return AjaxResult.success(cameraSdkService.controlUnLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("获取云台锁定信息") |
| | |
| | | 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("云台锁定状态:解锁"); |
| | | } else if (byWorkMode == 1) { |
| | |
| | | public @ResponseBody |
| | | AjaxResult defogcfg(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlDefogcfg(cmd)); |
| | | return toAjax(cameraSdkService.controlDefogcfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("红外开关") |
| | |
| | | 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自动") |
| | |
| | | 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自动") |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult heateRpwron(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlPTHeateRpwron(cmd)); |
| | | return toAjax(cameraSdkService.controlPTHeateRpwron(cmd)); |
| | | } |
| | | |
| | | |
| | |
| | | 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("相机抓图") |
| | |
| | | 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); |
| | | } |
| | | } |
| 对比新文件 |
| | |
| | | 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); |
| | | |
| | | //配置解锁 |
| | | 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); |
| | | |
| | | //停止录像-不上传minio |
| | | void recordStopNotToMinio(CameraCmd cmd); |
| | | |
| | | //获取相机通道信息 |
| | | public List<ArdChannel> getCameraChannelList(ArdCameras camera); |
| | | |
| | | //获取GIS信息数据 |
| | | public Map<String, Object> getGisInfo(CameraCmd cmd); |
| | | } |
| 对比新文件 |
| | |
| | | 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() { |
| | | //初始化加载sdk库文件 |
| | | 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; |
| | | } |
| | | //设置解锁 |
| | | @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("设置解锁异常:" + 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; |
| | | } |
| | | //停止录像并存入minio |
| | | @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; |
| | | } |
| | | } |
| | |
| | | @Resource
|
| | | private IDhClientService sdk;
|
| | |
|
| | | /**
|
| | | * @描述 初始加载大华库文件
|
| | | * @参数 []
|
| | | * @返回值 void
|
| | | * @创建人 刘苏义
|
| | | * @创建时间 2023/1/17 16:13
|
| | | * @修改人和其它信息 if (Platform.isLinux())
|
| | | */
|
| | | @PostConstruct
|
| | | public void initDHSDK() {
|
| | | //初始化加载sdk库文件
|
| | | 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-光圈缩小 ")
|
| | |
| | | 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);
|
| | | }
|
| | | } |
| 对比新文件 |
| | |
| | | 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、remote、timer 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); |
| | | } |
| | | } |
| | |
| | | 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:
|
| | |
| | | **/
|
| | | public class ConfigModule {
|
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
|
| | | public static NetSDKLib configsdk = NetSDKLib.CONFIG_INSTANCE;
|
| | | /**
|
| | | * 查询设备状态
|
| | | */
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | 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(); |
| | |
| | | * 主要有 :八个方向控制、变倍、变焦、光圈功能 |
| | | */ |
| | | 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); |
| | | } |
| | | } |
| 对比新文件 |
| | |
| | | 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内存由SDK内部申请释放) |
| | | */ |
| | | 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" + "码流类型为yuv数据"); |
| | | break; |
| | | case 3: |
| | | //pcm 音频数据 |
| | | System.out.println("码流大小为" + dwBufSize + "\n" + "码流类型为音频数据"); |
| | | break; |
| | | case 4: |
| | | //原始音频数据 |
| | | System.out.println("码流大小为" + dwBufSize + "\n" + "码流类型为原始音频数据"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | |
|
| | | //设置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);
|
| | | }
|
| | |
| | | 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;
|
| | |
| | | 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
|
| | |
| | | private IArdCamerasService ardCamerasService;
|
| | | @Resource
|
| | | private IArdChannelService ardChannelService;
|
| | | @Value("${minio.endpoint}")
|
| | | private String minioEndPoint;
|
| | |
|
| | | private Vector<String> chnlist = new Vector<String>();
|
| | | // 设备断线通知回调
|
| | |
| | | // 网络连接恢复
|
| | | private static HaveReConnect haveReConnect = new HaveReConnect();
|
| | |
|
| | |
|
| | | /**
|
| | | * 登录所有相机
|
| | | * 刘苏义
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public void loginAll() {
|
| | | try {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 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) {
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 注销
|
| | | * 刘苏义
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public Boolean logout(String cameraId) {
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | |
| | | return LoginModule.logout(loginId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否在线检测
|
| | | * 刘苏义
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public boolean isOnLine(CameraCmd cmd) {
|
| | | try {
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 云台控制
|
| | | * 刘苏义
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public boolean pTZControl(CameraCmd cmd) {
|
| | | String cameraId = cmd.getCameraId();
|
| | |
| | | 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;
|
| | |
| | | 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<>();
|
| | |
| | | }
|
| | | return ptzMap;
|
| | | }
|
| | |
|
| | | /**
|
| | | * @描述 设置ptz信息
|
| | | * @参数 [userId, channelNum]
|
| | |
| | | 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());
|
| | | }
|
| | |
| | | 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());
|
| | |
| | | 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 设置该回调函数,当设备出现断线时,SDK会调用该函数
|
| | | /**
|
| | | * @描述 短时录像
|
| | | * @参数 [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;
|
| | | }
|
| | | }
|
| | |
|
| | | // 设备断线回调: 当设备出现断线时,SDK会调用该函数
|
| | | 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 设置该回调函数,当已断线的设备重连成功时,SDK会调用该函数
|
| | | // 网络连接恢复回调:设备重连成功回调,当已断线的设备重连成功时,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);
|
| | | //存储到minio
|
| | | 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());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } |
| 文件名从 ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java 修改 |
| | |
| | | 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() {
|
| | | //初始化加载sdk库文件
|
| | | 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("设置解锁")
|
| | | @PostMapping("/setPTZUnLock")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
|
| | | @Log(title = "设置解锁", 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("云台锁定状态:解锁");
|
| | | } 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("设置解锁") |
| | | @PostMapping("/setPTZUnLock") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"}) |
| | | @Log(title = "设置解锁", 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("云台锁定状态:解锁"); |
| | | } 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)); |
| | | } |
| | | } |
| | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName: sdkClinet |
| | | * @ClassName: IHikClientService |
| | | * @Description: 海康操作客户端接口类 |
| | | * @Author: Administrator |
| | | * @Date: 2023年01月17日 15:59 |
| | | * @Version: 1.0 |
| | | **/ |
| | | public interface IHikClientService { |
| | | void loadHCNetSDKLib(); |
| | | //sdk初始化 |
| | | boolean init(); |
| | | |
| | | //同步登录 |
| | | void syncLogin(ArdCameras cameras); |
| | |
| | | boolean guideTargetPosition(CameraCmd cmd); |
| | | |
| | | //开始录像 |
| | | void recordStart(CameraCmd cmd); |
| | | boolean recordStart(CameraCmd cmd); |
| | | |
| | | //停止录像-上传minio-返回录像url |
| | | String recordStopToMinio(CameraCmd cmd); |
| | |
| | | private static HCNetSDK hCNetSDK;
|
| | |
|
| | | @Override
|
| | | public void loadHCNetSDKLib() {
|
| | | public boolean init() {
|
| | | try {
|
| | | log.debug("开始加载sdk库文件路径");
|
| | | if (Platform.isWindows()) {
|
| | |
| | | ptrByteArraySsl.write();
|
| | | hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArraySsl.getPointer());
|
| | | }
|
| | | return true;
|
| | | } catch (Exception ex) {
|
| | | log.error("加载库文件异常:" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | 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);
|
| | |
|
| | |
| | | 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));
|
| | |
| | | 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) {
|
| | |
| | | }
|
| | |
|
| | | @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帧结构体对象
|
| | |
| | | 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;
|
| | | }
|
| | | }
|
| | |
|