From 391fdf466014fa11a8dbb0b92d29d6d608dbc1b2 Mon Sep 17 00:00:00 2001
From: lin <648540858@qq.com>
Date: Tue, 23 Jun 2026 12:20:40 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9C=8B=E5=AE=88=E4=BD=8D?=
=?UTF-8?q?=E6=8E=A7=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../conf/CustomMessageProcessorFactory.java | 24 +++++
.../vmp/gb28181/conf/DefaultProperties.java | 2 +-
.../vmp/gb28181/controller/DeviceControl.java | 6 +-
.../service/impl/DeviceServiceImpl.java | 2 +-
.../transmit/cmd/impl/SIPCommander.java | 2 +-
.../stack/CustomNioTcpMessageProcessor.java | 34 ++++++
web/src/views/device/channel/ptzConfig.vue | 8 +-
.../views/device/common/ptzGuardConfig.vue | 102 ++++++++++++++++++
8 files changed, 173 insertions(+), 7 deletions(-)
create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/conf/CustomMessageProcessorFactory.java
create mode 100644 src/main/java/gov/nist/javax/sip/stack/CustomNioTcpMessageProcessor.java
create mode 100644 web/src/views/device/common/ptzGuardConfig.vue
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/conf/CustomMessageProcessorFactory.java b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/CustomMessageProcessorFactory.java
new file mode 100644
index 000000000..7b8818efe
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/CustomMessageProcessorFactory.java
@@ -0,0 +1,24 @@
+package com.genersoft.iot.vmp.gb28181.conf;
+
+import gov.nist.javax.sip.stack.CustomNioTcpMessageProcessor;
+import gov.nist.javax.sip.stack.MessageProcessor;
+import gov.nist.javax.sip.stack.NioMessageProcessorFactory;
+import gov.nist.javax.sip.stack.SIPTransactionStack;
+
+import javax.sip.ListeningPoint;
+import java.io.IOException;
+import java.net.InetAddress;
+
+public class CustomMessageProcessorFactory extends NioMessageProcessorFactory {
+
+ @Override
+ public MessageProcessor createMessageProcessor(
+ SIPTransactionStack sipStack, InetAddress ipAddress,
+ int port, String transport) throws IOException {
+ if (transport.equalsIgnoreCase(ListeningPoint.TCP)) {
+ return new CustomNioTcpMessageProcessor(ipAddress, sipStack, port);
+ }
+ return super.createMessageProcessor(sipStack, ipAddress, port, transport);
+ }
+
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java
index 73e271d18..95e85adf8 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java
@@ -51,7 +51,7 @@ public class DefaultProperties {
// 如果为 true(默认作),则堆栈将保持套接字打开,以便以牺牲线程和内存资源为代价来最大化性能 - 使自身容易受到 DOS 攻击。
properties.setProperty("gov.nist.javax.sip.CACHE_SERVER_CONNECTIONS", String.valueOf(sipCacheServerConnections));
- properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", "gov.nist.javax.sip.stack.NioMessageProcessorFactory");
+ properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", "com.genersoft.iot.vmp.gb28181.conf.CustomMessageProcessorFactory");
/**
* sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceControl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceControl.java
index 03c608bb4..10181f057 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceControl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceControl.java
@@ -134,7 +134,7 @@ public class DeviceControl {
deviceService.iFrame(device, channelId);
}
- @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)
@Parameter(name = "enabled", description = "是否开启看守位", required = true)
@@ -145,7 +145,7 @@ public class DeviceControl {
@RequestParam(required = false) Integer resetTime,
@RequestParam(required = false) Integer presetIndex) {
if (log.isDebugEnabled()) {
- log.debug("看守位控制API调用");
+ log.debug("看守位设置API调用");
}
Device device = deviceService.getDeviceByDeviceId(deviceId);
Assert.notNull(device, "设备不存在");
@@ -154,7 +154,7 @@ public class DeviceControl {
result.setResult(new WVPResult<>(code, msg, data));
});
result.onTimeout(() -> {
- log.warn("[看守位控制] 操作超时, 设备未返回应答指令, {}", deviceId);
+ log.warn("[看守位设置] 操作超时, 设备未返回应答指令, {}", deviceId);
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
});
return result;
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 7b1a8e694..a712bce17 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
@@ -1294,7 +1294,7 @@ public class DeviceServiceImpl implements IDeviceService {
try {
sipCommander.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, callback);
} catch (InvalidArgumentException | SipException | ParseException e) {
- log.error("[命令发送失败] 看守位控制: {}", e.getMessage());
+ log.error("[命令发送失败] 看守位设置: {}", e.getMessage());
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
index 7173d4601..b58352d0b 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
@@ -778,7 +778,7 @@ public class SIPCommander implements ISIPCommander {
}
/**
- * 看守位控制命令
+ * 看守位设置
*
* @param device 视频设备
* @param channelId 通道id,非通道则是设备本身
diff --git a/src/main/java/gov/nist/javax/sip/stack/CustomNioTcpMessageProcessor.java b/src/main/java/gov/nist/javax/sip/stack/CustomNioTcpMessageProcessor.java
new file mode 100644
index 000000000..838b93241
--- /dev/null
+++ b/src/main/java/gov/nist/javax/sip/stack/CustomNioTcpMessageProcessor.java
@@ -0,0 +1,34 @@
+package gov.nist.javax.sip.stack;
+
+import gov.nist.core.HostPort;
+
+import java.io.IOException;
+import java.net.InetAddress;
+
+public class CustomNioTcpMessageProcessor extends NioTcpMessageProcessor {
+
+ public CustomNioTcpMessageProcessor(InetAddress ipAddress,
+ SIPTransactionStack sipStack, int port) {
+ super(ipAddress, sipStack, port);
+ }
+
+ @Override
+ public MessageChannel createMessageChannel(HostPort targetHostPort) throws IOException {
+ MessageChannel retval = null;
+ try {
+ String key = MessageChannel.getKey(targetHostPort, transport);
+ retval = messageChannels.get(key);
+ //here we use double-checked locking trying to reduce contention
+ } finally {
+ }
+ return retval;
+ }
+
+ @Override
+ public MessageChannel createMessageChannel(InetAddress targetHost, int port) throws IOException {
+ String key = MessageChannel.getKey(targetHost, port, transport);
+ MessageChannel retval = messageChannels.get(key);
+ //here we use double-checked locking trying to reduce contention
+ return retval;
+ }
+}
diff --git a/web/src/views/device/channel/ptzConfig.vue b/web/src/views/device/channel/ptzConfig.vue
index bf5c09e5b..0a6b564ca 100644
--- a/web/src/views/device/channel/ptzConfig.vue
+++ b/web/src/views/device/channel/ptzConfig.vue
@@ -16,6 +16,10 @@
线性扫描
+
+
+ 看守位
+
辅助开关
@@ -30,6 +34,7 @@
+
@@ -43,10 +48,11 @@ import ptzPresetConfig from '../common/ptzPresetConfig.vue'
import ptzCruiseConfig from '../common/ptzCruiseConfig.vue'
import ptzScanConfig from '../common/ptzScanConfig.vue'
import ptzSwitchConfig from '../common/ptzSwitchConfig.vue'
+import ptzGuardConfig from '../common/ptzGuardConfig.vue'
export default {
name: 'PtzConfigPage',
- components: { playerPtzPanel, ptzPresetConfig, ptzCruiseConfig, ptzScanConfig, ptzSwitchConfig },
+ components: { playerPtzPanel, ptzPresetConfig, ptzCruiseConfig, ptzScanConfig, ptzSwitchConfig, ptzGuardConfig },
props: {
deviceId: { type: String, default: null },
channelDeviceId: { type: String, default: null }
diff --git a/web/src/views/device/common/ptzGuardConfig.vue b/web/src/views/device/common/ptzGuardConfig.vue
new file mode 100644
index 000000000..0912b333b
--- /dev/null
+++ b/web/src/views/device/common/ptzGuardConfig.vue
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 刷新
+ 保存
+
+
+
+
+
+
+
+
+