From bc249b678693fe6be61ff4a529d85652e0288567 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Thu, 6 Mar 2025 16:30:42 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=9B=BD=E6=A0=87=E7=BA=A7=E8=81=94]=20?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=80=9A=E7=94=A8=E9=80=9A=E9=81=93=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=8E=A7=E5=88=B6=E5=A4=84=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/common/enums/ChannelDataType.java | 3 +- .../service/IGbChannelControlService.java | 4 + .../impl/GbChannelControlServiceImpl.java | 20 +++ .../cmd/DeviceControlQueryMessageHandler.java | 114 +++++++++++------- 4 files changed, 94 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java index fc1d7c2b..c2d2a11e 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java +++ b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java @@ -8,8 +8,7 @@ public enum ChannelDataType { GB28181(1,"国标28181"), STREAM_PUSH(2,"推流设备"), - STREAM_PROXY(3,"拉流代理"), - ONVIF(100,"ONVIF"); + STREAM_PROXY(3,"拉流代理"); public final int value; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java index 5e65ceed..c552c5b4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java @@ -8,5 +8,9 @@ public interface IGbChannelControlService { void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); + void fi(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); + void tour(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); + void scan(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); + void auxiliary(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java index c0eb500f..4751c2ef 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java @@ -20,4 +20,24 @@ public class GbChannelControlServiceImpl implements IGbChannelControlService { public void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { log.info("[通用通道] 预置位, 通道: {}", channel.getGbId()); } + + @Override + public void fi(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { + log.info("[通用通道] FI指令, 通道: {}", channel.getGbId()); + } + + @Override + public void tour(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { + + } + + @Override + public void scan(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { + + } + + @Override + public void auxiliary(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { + + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 71919cac..c4a8f268 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -149,56 +149,80 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent } })); }else { - if (channel.getDataType() == ChannelDataType.ONVIF.value) { // 这里可以处理其他协议接入的设备 - // 解析云台控制参数 - String cmdString = getText(rootElement, type.getVal()); - IFrontEndControlCode frontEndControlCode = FrontEndCode.decode(cmdString); - if (frontEndControlCode == null) { - log.info("[INFO 消息] 不支持的控制方式"); + // 解析云台控制参数 + String cmdString = getText(rootElement, type.getVal()); + IFrontEndControlCode frontEndControlCode = FrontEndCode.decode(cmdString); + if (frontEndControlCode == null) { + log.info("[INFO 消息] 不支持的控制方式"); + try { + responseAck(request, Response.FORBIDDEN, ""); + } catch (InvalidArgumentException | SipException | ParseException exception) { + log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + } + return; + } + switch (frontEndControlCode.getType()){ + case PTZ: + channelControlService.ptz(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { + try { + responseAck(request, code, msg); + } catch (InvalidArgumentException | SipException | ParseException exception) { + log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + } + })); + break; + case FI: + channelControlService.fi(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { + try { + responseAck(request, code, msg); + } catch (InvalidArgumentException | SipException | ParseException exception) { + log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + } + })); + break; + case PRESET: + channelControlService.preset(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { + try { + responseAck(request, code, msg); + } catch (InvalidArgumentException | SipException | ParseException exception) { + log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + } + })); + break; + case TOUR: + channelControlService.tour(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { + try { + responseAck(request, code, msg); + } catch (InvalidArgumentException | SipException | ParseException exception) { + log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + } + })); + break; + case SCAN: + channelControlService.scan(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { + try { + responseAck(request, code, msg); + } catch (InvalidArgumentException | SipException | ParseException exception) { + log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + } + })); + break; + case AUXILIARY: + channelControlService.auxiliary(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { + try { + responseAck(request, code, msg); + } catch (InvalidArgumentException | SipException | ParseException exception) { + log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + } + })); + break; + default: + log.info("[INFO 消息] 设备不支持的控制方式"); try { responseAck(request, Response.FORBIDDEN, ""); } catch (InvalidArgumentException | SipException | ParseException exception) { log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); } - return; - } - switch (frontEndControlCode.getType()){ - case PTZ: - channelControlService.ptz(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { - try { - responseAck(request, code, msg); - } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); - } - })); - break; - case PRESET: - channelControlService.preset(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { - try { - responseAck(request, code, msg); - } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); - } - })); - break; - default: - log.info("[INFO 消息] 设备不支持的控制方式"); - try { - responseAck(request, Response.FORBIDDEN, ""); - } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); - } - } - - - return; - } - // 只支持国标的云台控制 - log.warn("[INFO 消息] 只支持国标的云台控制, 通道ID: {}", channel.getGbId()); - try { - responseAck(request, Response.FORBIDDEN, ""); - } catch (SipException | InvalidArgumentException | ParseException e) { - log.error("[命令发送失败] 错误信息: {}", e.getMessage()); } } }