From 5c2b4f386b09f9cbfc92c7457c5a56250b3271c8 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 8 Nov 2024 17:40:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=92=AD=E6=94=BE=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E9=A2=84=E7=BD=AE=E4=BD=8D=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/Preset.java | 12 ++++ .../vmp/gb28181/bean/PresetQuerySipReq.java | 28 --------- .../vmp/gb28181/controller/PtzController.java | 42 ++++++++++++- .../iot/vmp/gb28181/service/IPTZService.java | 21 +++++++ .../service/impl/DeviceServiceImpl.java | 5 -- .../gb28181/service/impl/PTZServiceImpl.java | 62 +++++++++++++++++++ .../gb28181/service/impl/PlayServiceImpl.java | 3 +- .../PresetQueryResponseMessageHandler.java | 6 +- .../vmp/media/zlm/ZLMHttpHookListener.java | 2 +- .../vmp/web/gb28181/ApiDeviceController.java | 6 +- .../src/components/dialog/devicePlayer.vue | 37 ++++++++++- 11 files changed, 177 insertions(+), 47 deletions(-) create mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/bean/Preset.java delete mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java create mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Preset.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Preset.java new file mode 100755 index 00000000..0bb8eec3 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Preset.java @@ -0,0 +1,12 @@ +package com.genersoft.iot.vmp.gb28181.bean; + + +import lombok.Data; + +@Data +public class Preset { + + private String presetId; + + private String presetName; +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java deleted file mode 100755 index d1971a2e..00000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - - -/** - * @author chenjialing - */ -public class PresetQuerySipReq { - - private String presetId; - - private String presetName; - - public String getPresetId() { - return presetId; - } - - public void setPresetId(String presetId) { - this.presetId = presetId; - } - - public String getPresetName() { - return presetName; - } - - public void setPresetName(String presetName) { - this.presetName = presetName; - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java index d2773918..a2319447 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java @@ -119,7 +119,7 @@ public class PtzController { @Parameter(name = "parameter1", description = "数据一", required = true) @Parameter(name = "parameter2", description = "数据二", required = true) @Parameter(name = "combindCode2", description = "组合码二", required = true) - @PostMapping("/front_end_command/{deviceId}/{channelId}") + @PostMapping("/fi/{deviceId}/{channelId}") public void frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){ if (log.isDebugEnabled()) { @@ -136,11 +136,11 @@ public class PtzController { } - @Operation(summary = "预置位查询", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "查询预置位", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true) @GetMapping("/preset/query/{deviceId}/{channelId}") - public DeferredResult presetQueryApi(@PathVariable String deviceId, @PathVariable String channelId) { + public DeferredResult queryPreset(@PathVariable String deviceId, @PathVariable String channelId) { if (log.isDebugEnabled()) { log.debug("设备预置位查询API调用"); } @@ -175,4 +175,40 @@ public class PtzController { } return result; } + + @Operation(summary = "新增预置位", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "presetId", description = "预置位编号", required = true) + @GetMapping("/preset/add/{deviceId}/{channelId}") + public void addPreset(@PathVariable String deviceId, @PathVariable String channelId, Integer presetId) { + if (presetId == null || presetId < 1 || presetId > 255) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "预置位编号必须为1-255之间的数字"); + } + frontEndCommand(deviceId, channelId, 0x81, 1, presetId, 0); + } + + @Operation(summary = "调用预置位", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "presetId", description = "预置位编号", required = true) + @GetMapping("/preset/call/{deviceId}/{channelId}") + public void callPreset(@PathVariable String deviceId, @PathVariable String channelId, Integer presetId) { + if (presetId == null || presetId < 1 || presetId > 255) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "预置位编号必须为1-255之间的数字"); + } + frontEndCommand(deviceId, channelId, 0x82, 1, presetId, 0); + } + + @Operation(summary = "删除预置位", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "presetId", description = "预置位编号", required = true) + @GetMapping("/preset/delete/{deviceId}/{channelId}") + public void deletePreset(@PathVariable String deviceId, @PathVariable String channelId, Integer presetId) { + if (presetId == null || presetId < 1 || presetId > 255) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "预置位编号必须为1-255之间的数字"); + } + frontEndCommand(deviceId, channelId, 0x83, 1, presetId, 0); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java new file mode 100755 index 00000000..d7c46805 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java @@ -0,0 +1,21 @@ +package com.genersoft.iot.vmp.gb28181.service; + + +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.Preset; + +import java.util.List; + +public interface IPTZService { + + + List queryPresetList(String deviceId, String channelDeviceId); + + void addPreset(Preset preset); + + void deletePreset(Integer qq); + + void ptz(Device device, String channelId, int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed); + + void frontEndCommand(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combindCode2); +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java index f731ce70..d37af47a 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java @@ -19,7 +19,6 @@ import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; @@ -34,7 +33,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ObjectUtils; import javax.sip.InvalidArgumentException; import javax.sip.SipException; @@ -51,9 +49,6 @@ import java.util.concurrent.TimeUnit; @DS("master") public class DeviceServiceImpl implements IDeviceService { - @Autowired - private SIPCommander cmder; - @Autowired private DynamicTask dynamicTask; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java new file mode 100644 index 00000000..36f60510 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java @@ -0,0 +1,62 @@ +package com.genersoft.iot.vmp.gb28181.service.impl; + +import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.Preset; +import com.genersoft.iot.vmp.gb28181.service.IPTZService; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.sip.InvalidArgumentException; +import javax.sip.SipException; +import java.text.ParseException; +import java.util.Collections; +import java.util.List; + +@Slf4j +@Service +public class PTZServiceImpl implements IPTZService { + + + @Autowired + private SIPCommander cmder; + + + @Override + public void ptz(Device device, String channelId, int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed) { + try { + cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] 云台控制: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } + + @Override + public void frontEndCommand(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combindCode2) { + try { + cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] 前端控制: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } + + @Override + public List queryPresetList(String deviceId, String channelDeviceId) { + return Collections.emptyList(); + } + + @Override + public void addPreset(Preset preset) { + + } + + @Override + public void deletePreset(Integer qq) { + + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index fcc5db8f..68fba96e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -488,8 +488,7 @@ public class PlayServiceImpl implements IPlayService { log.info("[语音对讲]开始 获取发流端口失败 deviceId: {}, channelId: {},", device.getDeviceId(), channel.getDeviceId()); return; } - - + sendRtpInfo.setOnlyAudio(true); sendRtpInfo.setPt(8); sendRtpInfo.setStatus(1); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java index 119b0c7f..21626d8b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java @@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respon import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Platform; -import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; +import com.genersoft.iot.vmp.gb28181.bean.Preset; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; @@ -79,11 +79,11 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent return; } int sumNum = Integer.parseInt(presetListNumElement.attributeValue("Num")); - List presetQuerySipReqList = new ArrayList<>(); + List presetQuerySipReqList = new ArrayList<>(); if (sumNum > 0) { for (Iterator presetIterator = presetListNumElement.elementIterator(); presetIterator.hasNext(); ) { Element itemListElement = presetIterator.next(); - PresetQuerySipReq presetQuerySipReq = new PresetQuerySipReq(); + Preset presetQuerySipReq = new Preset(); for (Iterator itemListIterator = itemListElement.elementIterator(); itemListIterator.hasNext(); ) { // 遍历item Element itemOne = itemListIterator.next(); diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 114e4c72..6b1c1d13 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -299,7 +299,7 @@ public class ZLMHttpHookListener { @ResponseBody @PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8") public HookResult onRecordMp4(HttpServletRequest request, @RequestBody OnRecordMp4HookParam param) { - log.info("[ZLM HOOK] 录像完成事件:{}->{}", param.getMediaServerId(), param.getFile_path()); + log.info("[ZLM HOOK] 录像完成:时长: {}, {}->{}",param.getTime_len(), param.getMediaServerId(), param.getFile_path()); try { MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index 359d3814..c8d04952 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; +import com.genersoft.iot.vmp.gb28181.bean.Preset; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; @@ -215,13 +215,13 @@ public class ApiDeviceController { } deferredResultEx.setFilter(filterResult->{ - List presetQuerySipReqList = (List)filterResult; + List presetQuerySipReqList = (List)filterResult; HashMap resultMap = new HashMap<>(); resultMap.put("DeviceID", code); resultMap.put("Result", "OK"); resultMap.put("SumNum", presetQuerySipReqList.size()); ArrayList> presetItemList = new ArrayList<>(presetQuerySipReqList.size()); - for (PresetQuerySipReq presetQuerySipReq : presetQuerySipReqList) { + for (Preset presetQuerySipReq : presetQuerySipReqList) { Map item = new HashMap<>(); item.put("PresetID", presetQuerySipReq.getPresetId()); item.put("PresetName", presetQuerySipReq.getPresetName()); diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue index 0eaec92f..cb01e06a 100755 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -26,6 +26,7 @@
+
@@ -154,7 +155,7 @@ -
+
@@ -180,11 +181,39 @@ style="font-size: 1.875rem;">
+ class="el-icon-zoom-out control-zoom-btn">
+
+ + + + + + + + +
+ 111 +
+
+ 111 +
+
+ 111 +
+
+
+ + +
+
@@ -327,11 +356,13 @@ import rtcPlayer from '../dialog/rtcPlayer.vue' import LivePlayer from '@liveqing/liveplayer' import crypto from 'crypto' import jessibucaPlayer from '../common/jessibuca.vue' +import PtzPreset from "../common/ptzPreset.vue"; export default { name: 'devicePlayer', props: {}, components: { + PtzPreset, LivePlayer, jessibucaPlayer, rtcPlayer, }, computed: { @@ -363,6 +394,8 @@ export default { }, showVideoDialog: false, streamId: '', + ptzMethod: 'preset', + ptzPresetId: '', app: '', mediaServerId: '', convertKey: '',