From 5777a8e93ca92f12370f7c4af8e28c295934bb25 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 6 Dec 2024 17:11:22 +0800 Subject: [PATCH 001/128] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 ------- .../vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java | 4 +--- .../vmp/gb28181/service/impl/DeviceChannelServiceImpl.java | 2 -- .../iot/vmp/gb28181/service/impl/DeviceServiceImpl.java | 2 -- .../vmp/gb28181/service/impl/InviteStreamServiceImpl.java | 2 -- .../gb28181/service/impl/PlatformChannelServiceImpl.java | 3 --- .../iot/vmp/gb28181/service/impl/PlatformServiceImpl.java | 2 -- .../iot/vmp/gb28181/service/impl/PlayServiceImpl.java | 2 -- .../iot/vmp/media/service/impl/MediaServerServiceImpl.java | 2 -- .../iot/vmp/service/impl/CloudRecordServiceImpl.java | 2 -- .../com/genersoft/iot/vmp/service/impl/RoleServerImpl.java | 2 -- .../iot/vmp/service/impl/UserApiKeyServiceImpl.java | 2 -- .../genersoft/iot/vmp/service/impl/UserServiceImpl.java | 2 -- .../service/impl/StreamProxyPlayServiceImpl.java | 2 -- .../streamProxy/service/impl/StreamProxyServiceImpl.java | 2 -- .../streamPush/service/impl/StreamPushPlayServiceImpl.java | 2 -- .../vmp/streamPush/service/impl/StreamPushServiceImpl.java | 2 -- src/main/resources/application.yml | 2 +- 18 files changed, 2 insertions(+), 42 deletions(-) diff --git a/pom.xml b/pom.xml index e13d5975c..19d3e8396 100644 --- a/pom.xml +++ b/pom.xml @@ -199,13 +199,6 @@ springdoc-openapi-security 1.6.10 - - - com.baomidou - dynamic-datasource-spring-boot-starter - 3.6.1 - - diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java index a08111af1..9dd6e6410 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java @@ -1,9 +1,8 @@ package com.genersoft.iot.vmp.gb28181.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService; import com.genersoft.iot.vmp.gb28181.dao.DeviceAlarmMapper; +import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; @@ -12,7 +11,6 @@ import org.springframework.stereotype.Service; import java.util.List; @Service -@DS("master") public class DeviceAlarmServiceImpl implements IDeviceAlarmService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 654648feb..4536c1ec8 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.alibaba.fastjson2.JSONObject; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.InviteInfo; import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.conf.UserSetting; @@ -43,7 +42,6 @@ import java.util.*; */ @Slf4j @Service -@DS("master") public class DeviceChannelServiceImpl implements IDeviceChannelService { @Autowired 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 c5be6386b..c3ede305a 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 @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.alibaba.fastjson2.JSON; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; @@ -47,7 +46,6 @@ import java.util.concurrent.TimeUnit; */ @Slf4j @Service -@DS("master") public class DeviceServiceImpl implements IDeviceService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java index 4338bbfe5..c3c768072 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.alibaba.fastjson2.JSON; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.*; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.Device; @@ -28,7 +27,6 @@ import java.util.concurrent.CopyOnWriteArrayList; @Slf4j @Service -@DS("master") public class InviteStreamServiceImpl implements IInviteStreamService { private final Map>> inviteErrorCallbackMap = new ConcurrentHashMap<>(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 71ca0988e..62125e7c5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -1,13 +1,11 @@ package com.genersoft.iot.vmp.gb28181.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.jt1078.proc.request.Re; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -26,7 +24,6 @@ import java.util.*; */ @Slf4j @Service -@DS("master") public class PlatformChannelServiceImpl implements IPlatformChannelService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java index 4232bc5f0..1269dc16e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.InviteInfo; import com.genersoft.iot.vmp.common.*; import com.genersoft.iot.vmp.conf.DynamicTask; @@ -53,7 +52,6 @@ import java.util.Vector; */ @Slf4j @Service -@DS("master") public class PlatformServiceImpl implements IPlatformService { private final static String REGISTER_KEY_PREFIX = "platform_register_"; 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 645a4b949..2c9b777b8 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 @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.InviteInfo; import com.genersoft.iot.vmp.common.*; import com.genersoft.iot.vmp.conf.DynamicTask; @@ -65,7 +64,6 @@ import java.util.Vector; @SuppressWarnings(value = {"rawtypes", "unchecked"}) @Slf4j @Service -@DS("master") public class PlayServiceImpl implements IPlayService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java index c6c597b07..f755c5f52 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.media.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.VideoManagerConstants; @@ -50,7 +49,6 @@ import java.util.*; */ @Slf4j @Service -@DS("master") public class MediaServerServiceImpl implements IMediaServerService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java index 725115fcd..0ef58621c 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.service.impl; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.service.ICloudRecordService; import com.genersoft.iot.vmp.media.bean.MediaServer; @@ -36,7 +35,6 @@ import java.util.Set; @Slf4j @Service -@DS("share") public class CloudRecordServiceImpl implements ICloudRecordService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RoleServerImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RoleServerImpl.java index f12c3cb8f..d31bbcefb 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RoleServerImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RoleServerImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.service.IRoleService; import com.genersoft.iot.vmp.storager.dao.RoleMapper; import com.genersoft.iot.vmp.storager.dao.dto.Role; @@ -10,7 +9,6 @@ import org.springframework.stereotype.Service; import java.util.List; @Service -@DS("master") public class RoleServerImpl implements IRoleService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/UserApiKeyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/UserApiKeyServiceImpl.java index 85ee4f0f5..8c552b10f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/UserApiKeyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/UserApiKeyServiceImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.service.IUserApiKeyService; import com.genersoft.iot.vmp.storager.dao.UserApiKeyMapper; import com.genersoft.iot.vmp.storager.dao.dto.UserApiKey; @@ -15,7 +14,6 @@ import org.springframework.stereotype.Service; import java.util.List; @Service -@DS("master") public class UserApiKeyServiceImpl implements IUserApiKeyService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java index fb97db939..cf0bea20f 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.service.IUserService; import com.genersoft.iot.vmp.storager.dao.UserMapper; import com.genersoft.iot.vmp.storager.dao.dto.User; @@ -13,7 +12,6 @@ import org.springframework.util.DigestUtils; import java.util.List; @Service -@DS("master") public class UserServiceImpl implements IUserService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java index 170ed6fdc..a0c628c6f 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.streamProxy.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.media.bean.MediaServer; @@ -20,7 +19,6 @@ import org.springframework.util.ObjectUtils; */ @Slf4j @Service -@DS("master") public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java index cf1818d9a..54e286335 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.streamProxy.service.impl; import com.alibaba.fastjson2.JSONObject; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; @@ -47,7 +46,6 @@ import java.util.Map; */ @Slf4j @Service -@DS("master") public class StreamProxyServiceImpl implements IStreamProxyService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushPlayServiceImpl.java index 7268b28c1..6fa3d65d0 100644 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushPlayServiceImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.streamPush.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; @@ -25,7 +24,6 @@ import java.util.UUID; @Service @Slf4j -@DS("master") public class StreamPushPlayServiceImpl implements IStreamPushPlayService { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java index 0c252efc2..35daca30d 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.streamPush.service.impl; import com.alibaba.fastjson2.JSONObject; -import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; @@ -41,7 +40,6 @@ import java.util.*; @Service @Slf4j -@DS("master") public class StreamPushServiceImpl implements IStreamPushService { @Autowired diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 80de5efb4..95ae11414 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,4 +2,4 @@ spring: application: name: wvp profiles: - active: dev \ No newline at end of file + active: 273数据库统合 \ No newline at end of file From 045150163e834b9eb168b458671b3883d8225aba Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 9 Dec 2024 10:30:56 +0800 Subject: [PATCH 002/128] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6f2621deb..bbe1975ee 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git # 功能特性 - [X] 集成web界面 - [X] 兼容性良好 -- [X] 支持电子地图,支持接入WGS84和GCJ02两种坐标系,并且自动转化为合适的坐标系进行展示和分发 - [X] 接入设备 - [X] 视频预览 - [X] 支持主码流子码流切换 @@ -68,6 +67,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 支持播放H264和H265 - [X] 报警信息处理,支持向前端推送报警信息 - [X] 语音对讲 + - [X] 支持业务分组和行政区划树自定义展示以及级联推送 - [X] 支持订阅与通知方法 - [X] 移动位置订阅 - [X] 移动位置通知处理 @@ -84,6 +84,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 注册 - [X] 心跳保活 - [X] 通道选择 + - [X] 支持通道编号自定义, 支持每个平台使用不同的通道编号 - [X] 通道推送 - [X] 点播 - [X] 云台控制 @@ -95,6 +96,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 录像查看与播放 - [X] GPS订阅与通知(直播推流) - [X] 语音对讲 + - [X] 支持同时级联到多个上级平台 - [X] 支持自动配置ZLM媒体服务, 减少因配置问题所出现的问题; - [X] 多流媒体节点,自动选择负载最低的节点使用。 - [X] 支持启用udp多端口模式, 提高udp模式下媒体传输性能; @@ -108,8 +110,8 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 支持打包可执行jar和war - [X] 支持跨域请求,支持前后端分离部署 - [X] 支持Mysql,Postgresql,金仓等数据库 -- [X] 支持Onvif(目前在onvif分支,需要安装onvif服务,服务请在知识星球获取) - +- [X] 支持Onvif, 目前付费提供, 永久免费试用包在知识星球获取 +- [X] 支持国标28181-2022协议, 目前付费提供, 永久免费试用包在知识星球获取 # 非开源的内容 From e62d106a1f4a9c5906a943d265bb0b85f86fe5da Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 11 Dec 2024 09:56:09 +0800 Subject: [PATCH 003/128] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/Device.java | 3 ++ .../gb28181/controller/PlayController.java | 3 ++ .../iot/vmp/gb28181/dao/DeviceMapper.java | 39 +++++++++++++++++++ .../vmp/gb28181/service/IDeviceService.java | 2 +- .../service/impl/DeviceServiceImpl.java | 4 +- .../iot/vmp/gb28181/task/SipRunner.java | 9 ++++- .../impl/RegisterRequestProcessor.java | 2 +- 7 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java index 1e783e867..8d673dbc6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java @@ -195,4 +195,7 @@ public class Device { @Schema(description = "控制语音对讲流程,释放收到ACK后发流") private boolean broadcastPushAfterAck; + + @Schema(description = "所属服务Id") + private String serverId; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index e7a8b1c87..003478f90 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -88,9 +88,12 @@ public class PlayController { Assert.notNull(channelId, "通道国标编号不可为NULL"); // 获取可用的zlm Device device = deviceService.getDeviceByDeviceId(deviceId); + Assert.notNull(deviceId, "设备不存在"); DeviceChannel channel = deviceChannelService.getOne(deviceId, channelId); Assert.notNull(channel, "通道不存在"); + + MediaServer newMediaServerItem = playService.getNewMediaServerItem(device); RequestMessage requestMessage = new RequestMessage(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java index abac64bb5..07b186763 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java @@ -78,6 +78,7 @@ public interface DeviceMapper { "as_message_channel,"+ "broadcast_push_after_ack,"+ "geo_coord_sys,"+ + "server_id,"+ "on_line"+ ") VALUES (" + "#{deviceId}," + @@ -108,6 +109,7 @@ public interface DeviceMapper { "#{asMessageChannel}," + "#{broadcastPushAfterAck}," + "#{geoCoordSys}," + + "#{serverId}," + "#{onLine}" + ")") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -130,6 +132,7 @@ public interface DeviceMapper { ", keepalive_time=#{keepaliveTime}" + ", keepalive_interval_time=#{keepaliveIntervalTime}" + ", expires=#{expires}" + + ", server_id=#{serverId}" + "WHERE device_id=#{deviceId}"+ " "}) int update(Device device); @@ -207,9 +210,43 @@ public interface DeviceMapper { "as_message_channel,"+ "broadcast_push_after_ack,"+ "geo_coord_sys,"+ + "server_id,"+ "on_line"+ " FROM wvp_device WHERE on_line = true") List getOnlineDevices(); + @Select("SELECT " + + "id, " + + "device_id, " + + "coalesce(custom_name, name) as name, " + + "password, " + + "manufacturer, " + + "model, " + + "firmware, " + + "transport," + + "stream_mode," + + "ip," + + "sdp_ip,"+ + "local_ip,"+ + "port,"+ + "host_address,"+ + "expires,"+ + "register_time,"+ + "keepalive_time,"+ + "create_time,"+ + "update_time,"+ + "charset,"+ + "subscribe_cycle_for_catalog,"+ + "subscribe_cycle_for_mobile_position,"+ + "mobile_position_submission_interval,"+ + "subscribe_cycle_for_alarm,"+ + "ssrc_check,"+ + "as_message_channel,"+ + "broadcast_push_after_ack,"+ + "geo_coord_sys,"+ + "server_id,"+ + "on_line"+ + " FROM wvp_device WHERE on_line = true and server_id = #{serverId}") + List getOnlineDevicesByServerId(@Param("serverId") String serverId); @Select("SELECT " + "id,"+ @@ -269,6 +306,7 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "stream_mode," + + "server_id," + "media_server_id"+ ") VALUES (" + "#{deviceId}," + @@ -284,6 +322,7 @@ public interface DeviceMapper { "#{geoCoordSys}," + "#{onLine}," + "#{streamMode}," + + "#{serverId}," + "#{mediaServerId}" + ")") void addCustomDevice(Device device); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java index 0812f8cfa..a8f48a476 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java @@ -86,7 +86,7 @@ public interface IDeviceService { * 获取所有在线设备 * @return 设备列表 */ - List getAllOnlineDevice(); + List getAllOnlineDevice(String serverId); List getAllByStatus(Boolean status); 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 c3ede305a..4773b9fda 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 @@ -353,8 +353,8 @@ public class DeviceServiceImpl implements IDeviceService { } @Override - public List getAllOnlineDevice() { - return deviceMapper.getOnlineDevices(); + public List getAllOnlineDevice(String serverId) { + return deviceMapper.getOnlineDevicesByServerId(serverId); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java index 102f9d0c9..56a649bc5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.task; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Platform; @@ -60,9 +61,12 @@ public class SipRunner implements CommandLineRunner { @Autowired private ISendRtpServerService sendRtpServerService; + @Autowired + private UserSetting userSetting; + @Override public void run(String... args) throws Exception { - List deviceList = deviceService.getAllOnlineDevice(); + List deviceList = deviceService.getAllOnlineDevice(userSetting.getServerId()); for (Device device : deviceList) { if (deviceService.expire(device)){ @@ -86,7 +90,8 @@ public class SipRunner implements CommandLineRunner { deviceMapInDb.put(device.getDeviceId(), device); }); devicesInRedis.parallelStream().forEach(device -> { - if (deviceMapInDb.get(device.getDeviceId()) == null) { + if (deviceMapInDb.get(device.getDeviceId()) == null + && userSetting.getServerId().equals(device.getServerId())) { redisCatchStorage.removeDevice(device.getDeviceId()); } }); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index 44a3eb1ed..8ad37f1ed 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -183,7 +183,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen device.setGeoCoordSys("WGS84"); } } - + device.setServerId(userSetting.getServerId()); device.setIp(remoteAddressInfo.getIp()); device.setPort(remoteAddressInfo.getPort()); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); From 5d26e3776d873023b37c1008229fa40e687d014a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 11 Dec 2024 16:59:48 +0800 Subject: [PATCH 004/128] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=82=B9=E6=92=AD?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E4=B8=AAredis=E4=B8=8B=E7=9A=84=E5=85=B6?= =?UTF-8?q?=E4=BB=96wvp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/controller/PlayController.java | 27 +++++----- .../service/IGbChannelRpcPlayService.java | 8 +++ .../iot/vmp/gb28181/service/IPlayService.java | 3 ++ .../gb28181/service/impl/PlayRpcService.java | 54 +++++++++++++++++++ .../gb28181/service/impl/PlayServiceImpl.java | 11 +++- .../redisMsg/control/RedisRpcController.java | 47 +++++++++++++++- 6 files changed, 136 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelRpcPlayService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayRpcService.java diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index 003478f90..d9f7e7317 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -10,15 +10,13 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService; -import com.genersoft.iot.vmp.gb28181.service.IPlayService; +import com.genersoft.iot.vmp.gb28181.service.*; import com.genersoft.iot.vmp.gb28181.session.SipInviteSessionManager; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; @@ -64,6 +62,9 @@ public class PlayController { @Autowired private IPlayService playService; + @Autowired + private IGbChannelRpcPlayService playRpcService; + @Autowired private IMediaServerService mediaServerService; @@ -88,14 +89,10 @@ public class PlayController { Assert.notNull(channelId, "通道国标编号不可为NULL"); // 获取可用的zlm Device device = deviceService.getDeviceByDeviceId(deviceId); - Assert.notNull(deviceId, "设备不存在"); DeviceChannel channel = deviceChannelService.getOne(deviceId, channelId); Assert.notNull(channel, "通道不存在"); - - MediaServer newMediaServerItem = playService.getNewMediaServerItem(device); - RequestMessage requestMessage = new RequestMessage(); String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; requestMessage.setKey(key); @@ -118,7 +115,7 @@ public class PlayController { // 录像查询以channelId作为deviceId查询 resultHolder.put(key, uuid, result); - playService.play(newMediaServerItem, deviceId, channelId, null, (code, msg, streamInfo) -> { + ErrorCallback callback = (code, msg, streamInfo) -> { WVPResult wvpResult = new WVPResult<>(); if (code == InviteErrorCode.SUCCESS.getCode()) { wvpResult.setCode(ErrorCode.SUCCESS.getCode()); @@ -136,8 +133,8 @@ public class PlayController { } streamInfo.channgeStreamIp(host); } - if (!ObjectUtils.isEmpty(newMediaServerItem.getTranscodeSuffix()) && !"null".equalsIgnoreCase(newMediaServerItem.getTranscodeSuffix())) { - streamInfo.setStream(streamInfo.getStream() + "_" + newMediaServerItem.getTranscodeSuffix()); + if (!ObjectUtils.isEmpty(streamInfo.getMediaServer().getTranscodeSuffix()) && !"null".equalsIgnoreCase(streamInfo.getMediaServer().getTranscodeSuffix())) { + streamInfo.setStream(streamInfo.getStream() + "_" + streamInfo.getMediaServer().getTranscodeSuffix()); } wvpResult.setData(new StreamContent(streamInfo)); }else { @@ -151,7 +148,13 @@ public class PlayController { requestMessage.setData(wvpResult); // 此处必须释放所有请求 resultHolder.invokeAllResult(requestMessage); - }); + }; + // 判断设备是否属于当前平台, 如果不属于则发起自动调用 + if (userSetting.getServerId().equals(device.getServerId())) { + playRpcService.play(device.getServerId(), channel.getId(), callback); + }else { + playService.play(device, channel, callback); + } return result; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelRpcPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelRpcPlayService.java new file mode 100644 index 000000000..1847e4307 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelRpcPlayService.java @@ -0,0 +1,8 @@ +package com.genersoft.iot.vmp.gb28181.service; + +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; + +public interface IGbChannelRpcPlayService { + void play(String serverId, Integer channelId, ErrorCallback callback); +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java index aa2ca3ab6..4a1403a04 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java @@ -25,6 +25,8 @@ public interface IPlayService { SSRCInfo play(MediaServer mediaServerItem, String deviceId, String channelId, String ssrc, ErrorCallback callback); + void play(Device device, DeviceChannel channel, ErrorCallback callback); + StreamInfo onPublishHandlerForPlay(MediaServer mediaServerItem, MediaInfo mediaInfo, Device device, DeviceChannel channel); MediaServer getNewMediaServerItem(Device device); @@ -70,4 +72,5 @@ public interface IPlayService { void download(CommonGBChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, ErrorCallback callback); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayRpcService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayRpcService.java new file mode 100644 index 000000000..96eb3ced6 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayRpcService.java @@ -0,0 +1,54 @@ +package com.genersoft.iot.vmp.gb28181.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelRpcPlayService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; +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.message.Response; + +@Slf4j +@Service("playRpcService") +public class PlayRpcService implements IGbChannelRpcPlayService { + + @Autowired + private RedisRpcConfig redisRpcConfig; + + @Autowired + private UserSetting userSetting; + + + private RedisRpcRequest buildRequest(String uri, Object param) { + RedisRpcRequest request = new RedisRpcRequest(); + request.setFromId(userSetting.getServerId()); + request.setParam(param); + request.setUri(uri); + return request; + } + + @Override + public void play(String serverId, Integer channelId, ErrorCallback callback) { + log.info("[点播其他WVP的设备] 通道Id:{}", channelId); + RedisRpcRequest request = buildRequest("playChannel", channelId); + request.setToId(serverId); + RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout()); + if (response == null) { + callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null); + }else { + if (response.getStatusCode() == Response.OK) { + StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class); + callback.run(response.getStatusCode(), "success", streamInfo); + }else { + callback.run(response.getStatusCode(), response.getBody().toString(), null); + } + } + } +} 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 2c9b777b8..8b3d9f067 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 @@ -63,7 +63,7 @@ import java.util.Vector; @SuppressWarnings(value = {"rawtypes", "unchecked"}) @Slf4j -@Service +@Service("playService") public class PlayServiceImpl implements IPlayService { @Autowired @@ -285,6 +285,15 @@ public class PlayServiceImpl implements IPlayService { } } + @Override + public void play(Device device, DeviceChannel channel, ErrorCallback callback) { + MediaServer mediaServerItem = getNewMediaServerItem(device); + if (mediaServerItem == null) { + log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); + } + play(mediaServerItem, device, channel, null, callback); + } @Override public SSRCInfo play(MediaServer mediaServerItem, String deviceId, String channelId, String ssrc, ErrorCallback callback) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java index b74df842f..946178bdf 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java @@ -8,7 +8,10 @@ import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; import com.genersoft.iot.vmp.media.bean.MediaInfo; import com.genersoft.iot.vmp.media.bean.MediaServer; @@ -17,6 +20,7 @@ import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; import com.genersoft.iot.vmp.media.event.hook.HookType; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.ISendRtpServerService; +import com.genersoft.iot.vmp.service.bean.InviteErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import lombok.extern.slf4j.Slf4j; @@ -24,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; +import javax.sip.message.Response; + /** * 其他wvp发起的rpc调用,这里的方法被 RedisRpcConfig 通过反射寻找对应的方法名称调用 */ @@ -49,6 +55,12 @@ public class RedisRpcController { @Autowired private RedisTemplate redisTemplate; + @Autowired + private IGbChannelService channelService; + + @Autowired + private IGbChannelPlayService channelPlayService; + /** * 获取发流的信息 @@ -255,7 +267,7 @@ public class RedisRpcController { String callId = request.getParam().toString(); SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); + response.setStatusCode(Response.OK); if (sendRtpItem == null) { log.info("[redis-rpc] 停止推流, 未找到redis中的发流信息, key:{}", callId); WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); @@ -290,4 +302,37 @@ public class RedisRpcController { message.setResponse(response); redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message); } + + /** + * 点播国标设备 + */ + public RedisRpcResponse playChannel(RedisRpcRequest request) { + int channelId = Integer.parseInt(request.getParam().toString()); + RedisRpcResponse response = request.getResponse(); + + if (channelId <= 0) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + // 获取对应的设备和通道信息 + CommonGBChannel channel = channelService.getOne(channelId); + if (channel == null) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + + channelPlayService.play(channel, null, (code, msg, data) ->{ + if (code == InviteErrorCode.SUCCESS.getCode()) { + response.setStatusCode(Response.OK); + response.setBody(data); + }else { + response.setStatusCode(code); + } + // 手动发送结果 + sendResponse(response); + }); + return null; + } } From 8d6a97897862c2b5de9fa91421a8ee049990f990 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 11 Dec 2024 18:26:18 +0800 Subject: [PATCH 005/128] =?UTF-8?q?[redis=E4=B8=8B=E7=9A=84=E5=A4=9Awvp]?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=9C=8D=E5=8A=A1=E9=97=B4=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/conf/redis/RedisRpcConfig.java | 61 ++++-- .../conf/redis/bean/RedisRpcClassHandler.java | 17 ++ .../gb28181/controller/PlayController.java | 10 +- .../iot/vmp/media/MediaServerConfig.java | 5 + .../iot/vmp/media/bean/MediaServer.java | 11 + .../service/impl/MediaServerServiceImpl.java | 22 +- .../media/zlm/ZLMMediaNodeServerService.java | 1 + .../redisMsg/IRedisRpcPlayService.java} | 6 +- .../service/redisMsg/IRedisRpcService.java | 1 + .../control/RedisRpcSendRtpController.java | 177 +++++++++++++++++ ...java => RedisRpcStreamPushController.java} | 188 ++---------------- .../redisMsg/dto/RedisRpcController.java | 16 ++ .../service/redisMsg/dto/RedisRpcMapping.java | 13 ++ .../service/RedisRpcPlayServiceImpl.java} | 11 +- .../redisMsg/service/RedisRpcServiceImpl.java | 16 +- .../vmp/storager/dao/MediaServerMapper.java | 34 ++-- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 2 + .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 2 + 18 files changed, 354 insertions(+), 239 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/redis/bean/RedisRpcClassHandler.java rename src/main/java/com/genersoft/iot/vmp/{gb28181/service/IGbChannelRpcPlayService.java => service/redisMsg/IRedisRpcPlayService.java} (68%) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java rename src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/{RedisRpcController.java => RedisRpcStreamPushController.java} (51%) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcController.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcMapping.java rename src/main/java/com/genersoft/iot/vmp/{gb28181/service/impl/PlayRpcService.java => service/redisMsg/service/RedisRpcPlayServiceImpl.java} (86%) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java index b762838c6..6607acecd 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisRpcConfig.java @@ -3,10 +3,13 @@ package com.genersoft.iot.vmp.conf.redis; import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcClassHandler; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; -import com.genersoft.iot.vmp.service.redisMsg.control.RedisRpcController; +import com.genersoft.iot.vmp.jt1078.util.ClassUtil; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -16,8 +19,11 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -36,9 +42,6 @@ public class RedisRpcConfig implements MessageListener { @Autowired private UserSetting userSetting; - @Autowired - private RedisRpcController redisRpcController; - @Autowired private RedisTemplate redisTemplate; @@ -48,6 +51,37 @@ public class RedisRpcConfig implements MessageListener { @Autowired private ThreadPoolTaskExecutor taskExecutor; + private final static Map protocolHash = new HashMap<>(); + + // 启动时执行 + @PostConstruct + public void init(){ + List> classList = ClassUtil.getClassList("com.genersoft.iot.vmp.service.redisMsg.control", RedisRpcController.class); + for (Class handlerClass : classList) { + String controllerPath = handlerClass.getAnnotation(RedisRpcController.class).value(); + // 扫描其下的方法 + Method[] methods = handlerClass.getDeclaredMethods(); + for (Method method : methods) { + RedisRpcMapping annotation = method.getAnnotation(RedisRpcMapping.class); + if (annotation != null) { + String methodPath = annotation.value(); + if (methodPath != null) { + protocolHash.put(controllerPath + "/" + methodPath, new RedisRpcClassHandler(handlerClass, method)); + } + } + + } + + } + for (String s : protocolHash.keySet()) { + System.out.println(s); + } + if (log.isDebugEnabled()) { + log.debug("消息ID缓存表 protocolHash:{}", protocolHash); + } + } + + @Override public void onMessage(Message message, byte[] pattern) { boolean isEmpty = taskQueue.isEmpty(); @@ -87,7 +121,9 @@ public class RedisRpcConfig implements MessageListener { return; } log.info("[redis-rpc] << {}", request); - Method method = getMethod(request.getUri()); + RedisRpcClassHandler redisRpcClassHandler = protocolHash.get(request.getUri()); + Class objectClass = redisRpcClassHandler.getObjectClass(); + Method method = redisRpcClassHandler.getMethod(); // 没有携带目标ID的可以理解为哪个wvp有结果就哪个回复,携带目标ID,但是如果是不存在的uri则直接回复404 if (userSetting.getServerId().equals(request.getToId())) { if (method == null) { @@ -97,7 +133,7 @@ public class RedisRpcConfig implements MessageListener { sendResponse(response); return; } - RedisRpcResponse response = (RedisRpcResponse)method.invoke(redisRpcController, request); + RedisRpcResponse response = (RedisRpcResponse)method.invoke(objectClass, request); if(response != null) { sendResponse(response); } @@ -105,7 +141,7 @@ public class RedisRpcConfig implements MessageListener { if (method == null) { return; } - RedisRpcResponse response = (RedisRpcResponse)method.invoke(redisRpcController, request); + RedisRpcResponse response = (RedisRpcResponse)method.invoke(objectClass, request); if (response != null) { sendResponse(response); } @@ -116,17 +152,6 @@ public class RedisRpcConfig implements MessageListener { } - private Method getMethod(String name) { - // 启动后扫描所有的路径注解 - Method[] methods = redisRpcController.getClass().getMethods(); - for (Method method : methods) { - if (method.getName().equals(name)) { - return method; - } - } - return null; - } - private void sendResponse(RedisRpcResponse response){ log.info("[redis-rpc] >> {}", response); response.setToId(userSetting.getServerId()); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/redis/bean/RedisRpcClassHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/redis/bean/RedisRpcClassHandler.java new file mode 100644 index 000000000..8c49a79f1 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/redis/bean/RedisRpcClassHandler.java @@ -0,0 +1,17 @@ +package com.genersoft.iot.vmp.conf.redis.bean; + +import lombok.Data; + +import java.lang.reflect.Method; + +@Data +public class RedisRpcClassHandler { + + private Class objectClass; + private Method method; + + public RedisRpcClassHandler(Class objectClass, Method method) { + this.objectClass = objectClass; + this.method = method; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index d9f7e7317..e5087cbaa 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -10,7 +10,10 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.gb28181.service.*; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; +import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService; +import com.genersoft.iot.vmp.gb28181.service.IPlayService; import com.genersoft.iot.vmp.gb28181.session.SipInviteSessionManager; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; @@ -18,6 +21,7 @@ import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; +import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; @@ -63,7 +67,7 @@ public class PlayController { private IPlayService playService; @Autowired - private IGbChannelRpcPlayService playRpcService; + private IRedisRpcPlayService redisRpcPlayService; @Autowired private IMediaServerService mediaServerService; @@ -151,7 +155,7 @@ public class PlayController { }; // 判断设备是否属于当前平台, 如果不属于则发起自动调用 if (userSetting.getServerId().equals(device.getServerId())) { - playRpcService.play(device.getServerId(), channel.getId(), callback); + redisRpcPlayService.play(device.getServerId(), channel.getId(), callback); }else { playService.play(device, channel, callback); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/MediaServerConfig.java b/src/main/java/com/genersoft/iot/vmp/media/MediaServerConfig.java index b9f7c08ef..ba27fb350 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/MediaServerConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/media/MediaServerConfig.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.media; import com.genersoft.iot.vmp.conf.MediaConfig; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerChangeEvent; import com.genersoft.iot.vmp.media.service.IMediaServerService; @@ -30,6 +31,9 @@ public class MediaServerConfig implements CommandLineRunner { @Autowired private MediaConfig mediaConfig; + @Autowired + private UserSetting userSetting; + @Override public void run(String... strings) throws Exception { @@ -37,6 +41,7 @@ public class MediaServerConfig implements CommandLineRunner { mediaServerService.clearMediaServerForOnline(); MediaServer defaultMediaServer = mediaServerService.getDefaultMediaServer(); MediaServer mediaSerItemInConfig = mediaConfig.getMediaSerItem(); + mediaSerItemInConfig.setServerId(userSetting.getServerId()); if (defaultMediaServer != null && mediaSerItemInConfig.getId().equals(defaultMediaServer.getId())) { mediaServerService.update(mediaSerItemInConfig); }else { diff --git a/src/main/java/com/genersoft/iot/vmp/media/bean/MediaServer.java b/src/main/java/com/genersoft/iot/vmp/media/bean/MediaServer.java index e6faac364..2660cb6a9 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/bean/MediaServer.java +++ b/src/main/java/com/genersoft/iot/vmp/media/bean/MediaServer.java @@ -103,6 +103,9 @@ public class MediaServer { @Schema(description = "转码的前缀") private String transcodeSuffix; + @Schema(description = "服务Id") + private String serverId; + public MediaServer() { } @@ -388,4 +391,12 @@ public class MediaServer { public void setTranscodeSuffix(String transcodeSuffix) { this.transcodeSuffix = transcodeSuffix; } + + public String getServerId() { + return serverId; + } + + public void setServerId(String serverId) { + this.serverId = serverId; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java index f755c5f52..3c38035e8 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java @@ -303,7 +303,7 @@ public class MediaServerServiceImpl implements IMediaServerService { mediaServerMapper.update(mediaSerItem); MediaServer mediaServerInRedis = getOne(mediaSerItem.getId()); // 获取完整数据 - MediaServer mediaServerInDataBase = mediaServerMapper.queryOne(mediaSerItem.getId()); + MediaServer mediaServerInDataBase = mediaServerMapper.queryOne(mediaSerItem.getId(), userSetting.getServerId()); if (mediaServerInDataBase == null) { return; } @@ -350,7 +350,7 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public List getAll() { - List mediaServerList = mediaServerMapper.queryAll(); + List mediaServerList = mediaServerMapper.queryAll(userSetting.getServerId()); if (mediaServerList.isEmpty()) { return new ArrayList<>(); } @@ -366,7 +366,7 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public List getAllFromDatabase() { - return mediaServerMapper.queryAll(); + return mediaServerMapper.queryAll(userSetting.getServerId()); } @Override @@ -403,7 +403,7 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public MediaServer getDefaultMediaServer() { - return mediaServerMapper.queryDefault(); + return mediaServerMapper.queryDefault(userSetting.getServerId()); } @Override @@ -423,7 +423,7 @@ public class MediaServerServiceImpl implements IMediaServerService { log.info("[添加媒体节点] 失败, mediaServer的类型:为空"); return; } - if (mediaServerMapper.queryOne(mediaServer.getId()) != null) { + if (mediaServerMapper.queryOne(mediaServer.getId(), userSetting.getServerId()) != null) { log.info("[添加媒体节点] 失败, 媒体服务ID已存在,请修改媒体服务器配置, {}", mediaServer.getId()); throw new ControllerException(ErrorCode.ERROR100.getCode(),"保存失败,媒体服务ID [ " + mediaServer.getId() + " ] 已存在,请修改媒体服务器配置"); } @@ -521,7 +521,7 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public MediaServer checkMediaServer(String ip, int port, String secret, String type) { - if (mediaServerMapper.queryOneByHostAndPort(ip, port) != null) { + if (mediaServerMapper.queryOneByHostAndPort(ip, port, userSetting.getServerId()) != null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "此连接已存在"); } @@ -532,7 +532,7 @@ public class MediaServerServiceImpl implements IMediaServerService { } MediaServer mediaServer = mediaNodeServerService.checkMediaServer(ip, port, secret); if (mediaServer != null) { - if (mediaServerMapper.queryOne(mediaServer.getId()) != null) { + if (mediaServerMapper.queryOne(mediaServer.getId(), userSetting.getServerId()) != null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "媒体服务ID [" + mediaServer.getId() + " ] 已存在,请修改媒体服务器配置"); } } @@ -560,7 +560,7 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public void delete(MediaServer mediaServer) { - mediaServerMapper.delOne(mediaServer.getId()); + mediaServerMapper.delOne(mediaServer.getId(), userSetting.getServerId()); redisTemplate.opsForZSet().remove(VideoManagerConstants.ONLINE_MEDIA_SERVERS_PREFIX + userSetting.getServerId(), mediaServer.getId()); String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + ":" + mediaServer.getId(); redisTemplate.delete(key); @@ -572,13 +572,13 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public MediaServer getOneFromDatabase(String mediaServerId) { - return mediaServerMapper.queryOne(mediaServerId); + return mediaServerMapper.queryOne(mediaServerId, userSetting.getServerId()); } @Override public void syncCatchFromDatabase() { List allInCatch = getAllOnlineList(); - List allInDatabase = mediaServerMapper.queryAll(); + List allInDatabase = mediaServerMapper.queryAll(userSetting.getServerId()); Map mediaServerMap = new HashMap<>(); for (MediaServer mediaServer : allInDatabase) { @@ -606,7 +606,7 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public List getAllWithAssistPort() { - return mediaServerMapper.queryAllWithAssistPort(); + return mediaServerMapper.queryAllWithAssistPort(userSetting.getServerId()); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java index 802b7eb6e..da44d23da 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java @@ -89,6 +89,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService { @Override public MediaServer checkMediaServer(String ip, int port, String secret) { MediaServer mediaServer = new MediaServer(); + mediaServer.setServerId(userSetting.getServerId()); mediaServer.setIp(ip); mediaServer.setHttpPort(port); mediaServer.setFlvPort(port); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelRpcPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java similarity index 68% rename from src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelRpcPlayService.java rename to src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java index 1847e4307..1ae1268ce 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelRpcPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java @@ -1,8 +1,10 @@ -package com.genersoft.iot.vmp.gb28181.service; +package com.genersoft.iot.vmp.service.redisMsg; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.service.bean.ErrorCallback; -public interface IGbChannelRpcPlayService { +public interface IRedisRpcPlayService { + + void play(String serverId, Integer channelId, ErrorCallback callback); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java index 7e23e2767..6dcfb5fb8 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java @@ -23,4 +23,5 @@ public interface IRedisRpcService { long onStreamOnlineEvent(String app, String stream, CommonCallback callback); void unPushStreamOnlineEvent(String app, String stream); + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java new file mode 100644 index 000000000..1077f5782 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcSendRtpController.java @@ -0,0 +1,177 @@ +package com.genersoft.iot.vmp.service.redisMsg.control; + +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; +import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; +import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; +import com.genersoft.iot.vmp.media.bean.MediaInfo; +import com.genersoft.iot.vmp.media.bean.MediaServer; +import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; +import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.service.ISendRtpServerService; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; + +import javax.sip.message.Response; + +@Slf4j +@RedisRpcController("sendRtp") +public class RedisRpcSendRtpController { + + @Autowired + private SSRCFactory ssrcFactory; + + @Autowired + private IMediaServerService mediaServerService; + + @Autowired + private ISendRtpServerService sendRtpServerService; + + @Autowired + private UserSetting userSetting; + + @Autowired + private HookSubscribe hookSubscribe; + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private IGbChannelService channelService; + + @Autowired + private IGbChannelPlayService channelPlayService; + + /** + * 获取发流的信息 + */ + @RedisRpcMapping("getSendRtpItem") + public RedisRpcResponse getSendRtpItem(RedisRpcRequest request) { + String callId = request.getParam().toString(); + SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); + if (sendRtpItem == null) { + log.info("[redis-rpc] 获取发流的信息, 未找到redis中的发流信息, callId:{}", callId); + RedisRpcResponse response = request.getResponse(); + response.setStatusCode(200); + return response; + } + log.info("[redis-rpc] 获取发流的信息: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + // 查询本级是否有这个流 + MediaServer mediaServerItem = mediaServerService.getMediaServerByAppAndStream(sendRtpItem.getApp(), sendRtpItem.getStream()); + if (mediaServerItem == null) { + RedisRpcResponse response = request.getResponse(); + response.setStatusCode(200); + } + // 自平台内容 + int localPort = sendRtpServerService.getNextPort(mediaServerItem); + if (localPort == 0) { + log.info("[redis-rpc] getSendRtpItem->服务器端口资源不足" ); + RedisRpcResponse response = request.getResponse(); + response.setStatusCode(200); + } + // 写入redis, 超时时回复 + sendRtpItem.setStatus(1); + sendRtpItem.setServerId(userSetting.getServerId()); + sendRtpItem.setLocalIp(mediaServerItem.getSdpIp()); + if (sendRtpItem.getSsrc() == null) { + // 上级平台点播时不使用上级平台指定的ssrc,使用自定义的ssrc,参考国标文档-点播外域设备媒体流SSRC处理方式 + String ssrc = "Play".equalsIgnoreCase(sendRtpItem.getSessionName()) ? ssrcFactory.getPlaySsrc(mediaServerItem.getId()) : ssrcFactory.getPlayBackSsrc(mediaServerItem.getId()); + sendRtpItem.setSsrc(ssrc); + } + sendRtpServerService.update(sendRtpItem); + RedisRpcResponse response = request.getResponse(); + response.setStatusCode(200); + response.setBody(callId); + return response; + } + + /** + * 开始发流 + */ + @RedisRpcMapping("startSendRtp") + public RedisRpcResponse startSendRtp(RedisRpcRequest request) { + String callId = request.getParam().toString(); + SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); + RedisRpcResponse response = request.getResponse(); + response.setStatusCode(200); + if (sendRtpItem == null) { + log.info("[redis-rpc] 开始发流, 未找到redis中的发流信息, callId:{}", callId); + WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); + response.setBody(wvpResult); + return response; + } + log.info("[redis-rpc] 开始发流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); + if (mediaServer == null) { + log.info("[redis-rpc] startSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); + WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到MediaServer"); + response.setBody(wvpResult); + return response; + } + MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream()); + if (mediaInfo == null) { + log.info("[redis-rpc] startSendRtp->流不在线: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream() ); + WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "流不在线"); + response.setBody(wvpResult); + return response; + } + try { + mediaServerService.startSendRtp(mediaServer, sendRtpItem); + }catch (ControllerException exception) { + log.info("[redis-rpc] 发流失败: {}/{}, 目标地址: {}:{}, {}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), exception.getMsg()); + WVPResult wvpResult = WVPResult.fail(exception.getCode(), exception.getMsg()); + response.setBody(wvpResult); + return response; + } + log.info("[redis-rpc] 发流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); + WVPResult wvpResult = WVPResult.success(); + response.setBody(wvpResult); + return response; + } + + /** + * 停止发流 + */ + @RedisRpcMapping("stopSendRtp") + public RedisRpcResponse stopSendRtp(RedisRpcRequest request) { + String callId = request.getParam().toString(); + SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); + RedisRpcResponse response = request.getResponse(); + response.setStatusCode(Response.OK); + if (sendRtpItem == null) { + log.info("[redis-rpc] 停止推流, 未找到redis中的发流信息, key:{}", callId); + WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); + response.setBody(wvpResult); + return response; + } + log.info("[redis-rpc] 停止推流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); + MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); + if (mediaServer == null) { + log.info("[redis-rpc] stopSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); + WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到MediaServer"); + response.setBody(wvpResult); + return response; + } + try { + mediaServerService.stopSendRtp(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getSsrc()); + }catch (ControllerException exception) { + log.info("[redis-rpc] 停止推流失败: {}/{}, 目标地址: {}:{}, code: {}, msg: {}", sendRtpItem.getApp(), + sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), exception.getCode(), exception.getMsg() ); + response.setBody(WVPResult.fail(exception.getCode(), exception.getMsg())); + return response; + } + log.info("[redis-rpc] 停止推流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); + response.setBody(WVPResult.success()); + return response; + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcStreamPushController.java similarity index 51% rename from src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java rename to src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcStreamPushController.java index 946178bdf..3465bdc8e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcStreamPushController.java @@ -3,39 +3,29 @@ package com.genersoft.iot.vmp.service.redisMsg.control; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; -import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo; import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; -import com.genersoft.iot.vmp.media.bean.MediaInfo; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.event.hook.Hook; import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; import com.genersoft.iot.vmp.media.event.hook.HookType; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.ISendRtpServerService; -import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; -import javax.sip.message.Response; - -/** - * 其他wvp发起的rpc调用,这里的方法被 RedisRpcConfig 通过反射寻找对应的方法名称调用 - */ @Slf4j -@Component -public class RedisRpcController { +@RedisRpcController("streamPush") +public class RedisRpcStreamPushController { @Autowired private SSRCFactory ssrcFactory; @@ -61,52 +51,18 @@ public class RedisRpcController { @Autowired private IGbChannelPlayService channelPlayService; - - /** - * 获取发流的信息 - */ - public RedisRpcResponse getSendRtpItem(RedisRpcRequest request) { - String callId = request.getParam().toString(); - SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); - if (sendRtpItem == null) { - log.info("[redis-rpc] 获取发流的信息, 未找到redis中的发流信息, callId:{}", callId); - RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); - return response; - } - log.info("[redis-rpc] 获取发流的信息: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); - // 查询本级是否有这个流 - MediaServer mediaServerItem = mediaServerService.getMediaServerByAppAndStream(sendRtpItem.getApp(), sendRtpItem.getStream()); - if (mediaServerItem == null) { - RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); - } - // 自平台内容 - int localPort = sendRtpServerService.getNextPort(mediaServerItem); - if (localPort == 0) { - log.info("[redis-rpc] getSendRtpItem->服务器端口资源不足" ); - RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); - } - // 写入redis, 超时时回复 - sendRtpItem.setStatus(1); - sendRtpItem.setServerId(userSetting.getServerId()); - sendRtpItem.setLocalIp(mediaServerItem.getSdpIp()); - if (sendRtpItem.getSsrc() == null) { - // 上级平台点播时不使用上级平台指定的ssrc,使用自定义的ssrc,参考国标文档-点播外域设备媒体流SSRC处理方式 - String ssrc = "Play".equalsIgnoreCase(sendRtpItem.getSessionName()) ? ssrcFactory.getPlaySsrc(mediaServerItem.getId()) : ssrcFactory.getPlayBackSsrc(mediaServerItem.getId()); - sendRtpItem.setSsrc(ssrc); - } - sendRtpServerService.update(sendRtpItem); - RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); - response.setBody(callId); - return response; + private void sendResponse(RedisRpcResponse response){ + log.info("[redis-rpc] >> {}", response); + response.setToId(userSetting.getServerId()); + RedisRpcMessage message = new RedisRpcMessage(); + message.setResponse(response); + redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message); } /** * 监听流上线 */ + @RedisRpcMapping("waitePushStreamOnline") public RedisRpcResponse waitePushStreamOnline(RedisRpcRequest request) { SendRtpInfo sendRtpItem = JSONObject.parseObject(request.getParam().toString(), SendRtpInfo.class); log.info("[redis-rpc] 监听流上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); @@ -158,6 +114,7 @@ public class RedisRpcController { /** * 监听流上线 */ + @RedisRpcMapping("onStreamOnlineEvent") public RedisRpcResponse onStreamOnlineEvent(RedisRpcRequest request) { StreamInfo streamInfo = JSONObject.parseObject(request.getParam().toString(), StreamInfo.class); log.info("[redis-rpc] 监听流信息,等待流上线: {}/{}", streamInfo.getApp(), streamInfo.getStream()); @@ -191,6 +148,7 @@ public class RedisRpcController { /** * 停止监听流上线 */ + @RedisRpcMapping("stopWaitePushStreamOnline") public RedisRpcResponse stopWaitePushStreamOnline(RedisRpcRequest request) { SendRtpInfo sendRtpItem = JSONObject.parseObject(request.getParam().toString(), SendRtpInfo.class); log.info("[redis-rpc] 停止监听流上线: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); @@ -205,6 +163,7 @@ public class RedisRpcController { /** * 停止监听流上线 */ + @RedisRpcMapping("unPushStreamOnlineEvent") public RedisRpcResponse unPushStreamOnlineEvent(RedisRpcRequest request) { StreamInfo streamInfo = JSONObject.parseObject(request.getParam().toString(), StreamInfo.class); log.info("[redis-rpc] 停止监听流上线: {}/{}", streamInfo.getApp(), streamInfo.getStream()); @@ -216,123 +175,4 @@ public class RedisRpcController { return response; } - - /** - * 开始发流 - */ - public RedisRpcResponse startSendRtp(RedisRpcRequest request) { - String callId = request.getParam().toString(); - SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); - RedisRpcResponse response = request.getResponse(); - response.setStatusCode(200); - if (sendRtpItem == null) { - log.info("[redis-rpc] 开始发流, 未找到redis中的发流信息, callId:{}", callId); - WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); - response.setBody(wvpResult); - return response; - } - log.info("[redis-rpc] 开始发流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); - MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - if (mediaServer == null) { - log.info("[redis-rpc] startSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); - WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到MediaServer"); - response.setBody(wvpResult); - return response; - } - MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream()); - if (mediaInfo == null) { - log.info("[redis-rpc] startSendRtp->流不在线: {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream() ); - WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "流不在线"); - response.setBody(wvpResult); - return response; - } - try { - mediaServerService.startSendRtp(mediaServer, sendRtpItem); - }catch (ControllerException exception) { - log.info("[redis-rpc] 发流失败: {}/{}, 目标地址: {}:{}, {}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), exception.getMsg()); - WVPResult wvpResult = WVPResult.fail(exception.getCode(), exception.getMsg()); - response.setBody(wvpResult); - return response; - } - log.info("[redis-rpc] 发流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort()); - WVPResult wvpResult = WVPResult.success(); - response.setBody(wvpResult); - return response; - } - - /** - * 停止发流 - */ - public RedisRpcResponse stopSendRtp(RedisRpcRequest request) { - String callId = request.getParam().toString(); - SendRtpInfo sendRtpItem = sendRtpServerService.queryByCallId(callId); - RedisRpcResponse response = request.getResponse(); - response.setStatusCode(Response.OK); - if (sendRtpItem == null) { - log.info("[redis-rpc] 停止推流, 未找到redis中的发流信息, key:{}", callId); - WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到redis中的发流信息"); - response.setBody(wvpResult); - return response; - } - log.info("[redis-rpc] 停止推流: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); - MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - if (mediaServer == null) { - log.info("[redis-rpc] stopSendRtp->未找到MediaServer: {}", sendRtpItem.getMediaServerId() ); - WVPResult wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到MediaServer"); - response.setBody(wvpResult); - return response; - } - try { - mediaServerService.stopSendRtp(mediaServer, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getSsrc()); - }catch (ControllerException exception) { - log.info("[redis-rpc] 停止推流失败: {}/{}, 目标地址: {}:{}, code: {}, msg: {}", sendRtpItem.getApp(), - sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), exception.getCode(), exception.getMsg() ); - response.setBody(WVPResult.fail(exception.getCode(), exception.getMsg())); - return response; - } - log.info("[redis-rpc] 停止推流成功: {}/{}, 目标地址: {}:{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() ); - response.setBody(WVPResult.success()); - return response; - } - - private void sendResponse(RedisRpcResponse response){ - log.info("[redis-rpc] >> {}", response); - response.setToId(userSetting.getServerId()); - RedisRpcMessage message = new RedisRpcMessage(); - message.setResponse(response); - redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message); - } - - /** - * 点播国标设备 - */ - public RedisRpcResponse playChannel(RedisRpcRequest request) { - int channelId = Integer.parseInt(request.getParam().toString()); - RedisRpcResponse response = request.getResponse(); - - if (channelId <= 0) { - response.setStatusCode(Response.BAD_REQUEST); - response.setBody("param error"); - return response; - } - // 获取对应的设备和通道信息 - CommonGBChannel channel = channelService.getOne(channelId); - if (channel == null) { - response.setStatusCode(Response.BAD_REQUEST); - response.setBody("param error"); - return response; - } - - channelPlayService.play(channel, null, (code, msg, data) ->{ - if (code == InviteErrorCode.SUCCESS.getCode()) { - response.setStatusCode(Response.OK); - response.setBody(data); - }else { - response.setStatusCode(code); - } - // 手动发送结果 - sendResponse(response); - }); - return null; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcController.java new file mode 100644 index 000000000..79cdcb370 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcController.java @@ -0,0 +1,16 @@ +package com.genersoft.iot.vmp.service.redisMsg.dto; + +import org.springframework.stereotype.Component; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Component +public @interface RedisRpcController { + /** + * 请求路径 + */ + String value() default ""; +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcMapping.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcMapping.java new file mode 100644 index 000000000..61f51bb68 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/dto/RedisRpcMapping.java @@ -0,0 +1,13 @@ +package com.genersoft.iot.vmp.service.redisMsg.dto; + +import java.lang.annotation.*; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RedisRpcMapping { + /** + * 请求路径 + */ + String value() default ""; +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayRpcService.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java similarity index 86% rename from src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayRpcService.java rename to src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java index 96eb3ced6..93f218a6c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayRpcService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java @@ -1,4 +1,4 @@ -package com.genersoft.iot.vmp.gb28181.service.impl; +package com.genersoft.iot.vmp.service.redisMsg.service; import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.common.StreamInfo; @@ -6,8 +6,8 @@ import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; -import com.genersoft.iot.vmp.gb28181.service.IGbChannelRpcPlayService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -16,8 +16,9 @@ import org.springframework.stereotype.Service; import javax.sip.message.Response; @Slf4j -@Service("playRpcService") -public class PlayRpcService implements IGbChannelRpcPlayService { +@Service +public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { + @Autowired private RedisRpcConfig redisRpcConfig; @@ -36,7 +37,6 @@ public class PlayRpcService implements IGbChannelRpcPlayService { @Override public void play(String serverId, Integer channelId, ErrorCallback callback) { - log.info("[点播其他WVP的设备] 通道Id:{}", channelId); RedisRpcRequest request = buildRequest("playChannel", channelId); request.setToId(serverId); RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout()); @@ -52,3 +52,4 @@ public class PlayRpcService implements IGbChannelRpcPlayService { } } } + diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java index 861821353..939dcb05e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java @@ -58,7 +58,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { @Override public SendRtpInfo getSendRtpItem(String callId) { - RedisRpcRequest request = buildRequest("getSendRtpItem", callId); + RedisRpcRequest request = buildRequest("sendRtp/getSendRtpItem", callId); RedisRpcResponse response = redisRpcConfig.request(request, 10); if (response.getBody() == null) { return null; @@ -69,7 +69,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { @Override public WVPResult startSendRtp(String callId, SendRtpInfo sendRtpItem) { log.info("[请求其他WVP] 开始推流,wvp:{}, {}/{}", sendRtpItem.getServerId(), sendRtpItem.getApp(), sendRtpItem.getStream()); - RedisRpcRequest request = buildRequest("startSendRtp", callId); + RedisRpcRequest request = buildRequest("sendRtp/startSendRtp", callId); request.setToId(sendRtpItem.getServerId()); RedisRpcResponse response = redisRpcConfig.request(request, 10); return JSON.parseObject(response.getBody().toString(), WVPResult.class); @@ -83,7 +83,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { return WVPResult.fail(ErrorCode.ERROR100.getCode(), "未找到发流信息"); } log.info("[请求其他WVP] 停止推流,wvp:{}, {}/{}", sendRtpItem.getServerId(), sendRtpItem.getApp(), sendRtpItem.getStream()); - RedisRpcRequest request = buildRequest("stopSendRtp", callId); + RedisRpcRequest request = buildRequest("sendRtp/stopSendRtp", callId); request.setToId(sendRtpItem.getServerId()); RedisRpcResponse response = redisRpcConfig.request(request, 10); return JSON.parseObject(response.getBody().toString(), WVPResult.class); @@ -94,7 +94,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { log.info("[请求所有WVP监听流上线] {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); // 监听流上线。 流上线直接发送sendRtpItem消息给实际的信令处理者 Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null); - RedisRpcRequest request = buildRequest("waitePushStreamOnline", sendRtpItem); + RedisRpcRequest request = buildRequest("streamPush/waitePushStreamOnline", sendRtpItem); request.setToId(sendRtpItem.getServerId()); hookSubscribe.addSubscribe(hook, (hookData) -> { @@ -135,7 +135,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { log.info("[停止WVP监听流上线] {}/{}", sendRtpItem.getApp(), sendRtpItem.getStream()); Hook hook = Hook.getInstance(HookType.on_media_arrival, sendRtpItem.getApp(), sendRtpItem.getStream(), null); hookSubscribe.removeSubscribe(hook); - RedisRpcRequest request = buildRequest("stopWaitePushStreamOnline", sendRtpItem); + RedisRpcRequest request = buildRequest("streamPush/stopWaitePushStreamOnline", sendRtpItem); request.setToId(sendRtpItem.getServerId()); redisRpcConfig.request(request, 10); } @@ -147,7 +147,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { log.info("[停止WVP监听流上线] 未找到redis中的发流信息, key:{}", callId); return; } - RedisRpcRequest request = buildRequest("rtpSendStopped", callId); + RedisRpcRequest request = buildRequest("streamPush/rtpSendStopped", callId); request.setToId(sendRtpItem.getServerId()); redisRpcConfig.request(request, 10); } @@ -166,7 +166,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { StreamInfo streamInfoParam = new StreamInfo(); streamInfoParam.setApp(app); streamInfoParam.setStream(stream); - RedisRpcRequest request = buildRequest("onStreamOnlineEvent", streamInfoParam); + RedisRpcRequest request = buildRequest("streamPush/onStreamOnlineEvent", streamInfoParam); hookSubscribe.addSubscribe(hook, (hookData) -> { log.info("[请求所有WVP监听流上线] 监听流上线 {}/{}", app, stream); if (callback != null) { @@ -198,7 +198,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { StreamInfo streamInfoParam = new StreamInfo(); streamInfoParam.setApp(app); streamInfoParam.setStream(stream); - RedisRpcRequest request = buildRequest("unPushStreamOnlineEvent", streamInfoParam); + RedisRpcRequest request = buildRequest("streamPush/unPushStreamOnlineEvent", streamInfoParam); redisRpcConfig.request(request, 10); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java index 2f2bfb6d7..8682461fe 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java @@ -42,6 +42,7 @@ public interface MediaServerMapper { "create_time,"+ "update_time,"+ "transcode_suffix,"+ + "server_id,"+ "hook_alive_interval"+ ") VALUES " + "(" + @@ -74,6 +75,7 @@ public interface MediaServerMapper { "#{createTime}, " + "#{updateTime}, " + "#{transcodeSuffix}, " + + "#{serverId}, " + "#{hookAliveInterval})") int add(MediaServer mediaServerItem); @@ -105,6 +107,7 @@ public interface MediaServerMapper { ", record_day=#{recordDay}" + ", record_path=#{recordPath}" + ", transcode_suffix=#{transcodeSuffix}" + + ", server_id=#{serverId}" + ", type=#{type}" + "WHERE id=#{id}"+ " "}) @@ -138,32 +141,27 @@ public interface MediaServerMapper { ", type=#{type}" + ", transcode_suffix=#{transcodeSuffix}" + ", hook_alive_interval=#{hookAliveInterval}" + + ", server_id=#{serverId}" + "WHERE ip=#{ip} and http_port=#{httpPort}"+ " "}) int updateByHostAndPort(MediaServer mediaServerItem); - @Select("SELECT * FROM wvp_media_server WHERE id=#{id}") - MediaServer queryOne(String id); + @Select("SELECT * FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}") + MediaServer queryOne(@Param("id") String id, @Param("serverId") String serverId); - @Select("SELECT * FROM wvp_media_server") - List queryAll(); + @Select("SELECT * FROM wvp_media_server where server_id = #{serverId}") + List queryAll(@Param("serverId") String serverId); - @Delete("DELETE FROM wvp_media_server WHERE id=#{id}") - void delOne(String id); + @Delete("DELETE FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}") + void delOne(String id, @Param("serverId") String serverId); - @Select("DELETE FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}") - void delOneByIPAndPort(@Param("host") String host, @Param("port") int port); + @Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port} and server_id = #{serverId}") + MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port, @Param("serverId") String serverId); - @Delete("DELETE FROM wvp_media_server WHERE default_server=true") - int delDefault(); + @Select("SELECT * FROM wvp_media_server WHERE default_server=true and server_id = #{serverId}") + MediaServer queryDefault(@Param("serverId") String serverId); - @Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}") - MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port); - - @Select("SELECT * FROM wvp_media_server WHERE default_server=true") - MediaServer queryDefault(); - - @Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0") - List queryAllWithAssistPort(); + @Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0 and server_id = #{serverId}") + List queryAllWithAssistPort(@Param("serverId") String serverId); } diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index e12677da5..5ffb722c6 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -29,6 +29,7 @@ create table wvp_device custom_name character varying(255), sdp_ip character varying(50), local_ip character varying(50), + server_id character varying(50), password character varying(255), as_message_channel bool default false, keepalive_interval_time integer, @@ -190,6 +191,7 @@ create table wvp_media_server record_path character varying(255), record_day integer default 7, transcode_suffix character varying(255), + server_id character varying(50), constraint uk_media_server_unique_ip_http_port unique (ip, http_port) ); diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index c632f9a83..9789b4632 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -29,6 +29,7 @@ create table wvp_device custom_name character varying(255), sdp_ip character varying(50), local_ip character varying(50), + server_id character varying(50), password character varying(255), as_message_channel bool default false, keepalive_interval_time integer, @@ -207,6 +208,7 @@ create table wvp_media_server record_path character varying(255), record_day integer default 7, transcode_suffix character varying(255), + server_id character varying(50), constraint uk_media_server_unique_ip_http_port unique (ip, http_port) ); From ca9b5c20546a3aeba2e76e649ea8671f1537dc5b Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:29:49 +0800 Subject: [PATCH 006/128] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=A1=A8=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 2 +- 数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 5ffb722c6..f294e62e0 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -192,7 +192,7 @@ create table wvp_media_server record_day integer default 7, transcode_suffix character varying(255), server_id character varying(50), - constraint uk_media_server_unique_ip_http_port unique (ip, http_port) + constraint uk_media_server_unique_ip_http_port unique (ip, http_port, server_id) ); create table wvp_platform diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 9789b4632..67fb1445f 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -209,7 +209,7 @@ create table wvp_media_server record_day integer default 7, transcode_suffix character varying(255), server_id character varying(50), - constraint uk_media_server_unique_ip_http_port unique (ip, http_port) + constraint uk_media_server_unique_ip_http_port unique (ip, http_port, server_id) ); create table wvp_platform From 541726a43c9f86efa9ca0cbe20393afe6851c962 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:37:12 +0800 Subject: [PATCH 007/128] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E7=82=B9=E6=92=ADRPC=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RedisRpcChannelPlayController.java | 101 ++++++++++++++++++ .../service/RedisRpcPlayServiceImpl.java | 2 +- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 1 + .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 1 + 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java new file mode 100644 index 000000000..adeda445a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -0,0 +1,101 @@ +package com.genersoft.iot.vmp.service.redisMsg.control; + +import com.alibaba.fastjson2.JSONObject; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; +import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; +import com.genersoft.iot.vmp.media.bean.MediaServer; +import com.genersoft.iot.vmp.media.event.hook.Hook; +import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; +import com.genersoft.iot.vmp.media.event.hook.HookType; +import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.service.ISendRtpServerService; +import com.genersoft.iot.vmp.service.bean.InviteErrorCode; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; + +import javax.sip.message.Response; + +@Slf4j +@RedisRpcController("chanel") +public class RedisRpcChannelPlayController { + + @Autowired + private SSRCFactory ssrcFactory; + + @Autowired + private IMediaServerService mediaServerService; + + @Autowired + private ISendRtpServerService sendRtpServerService; + + @Autowired + private UserSetting userSetting; + + @Autowired + private HookSubscribe hookSubscribe; + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private IGbChannelService channelService; + + @Autowired + private IGbChannelPlayService channelPlayService; + + private void sendResponse(RedisRpcResponse response){ + log.info("[redis-rpc] >> {}", response); + response.setToId(userSetting.getServerId()); + RedisRpcMessage message = new RedisRpcMessage(); + message.setResponse(response); + redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message); + } + + + /** + * 点播国标设备 + */ + @RedisRpcMapping("play") + public RedisRpcResponse playChannel(RedisRpcRequest request) { + int channelId = Integer.parseInt(request.getParam().toString()); + RedisRpcResponse response = request.getResponse(); + + if (channelId <= 0) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + // 获取对应的设备和通道信息 + CommonGBChannel channel = channelService.getOne(channelId); + if (channel == null) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + + channelPlayService.play(channel, null, (code, msg, data) ->{ + if (code == InviteErrorCode.SUCCESS.getCode()) { + response.setStatusCode(Response.OK); + response.setBody(data); + }else { + response.setStatusCode(code); + } + // 手动发送结果 + sendResponse(response); + }); + return null; + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java index 93f218a6c..0e1c0b1ee 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java @@ -37,7 +37,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { @Override public void play(String serverId, Integer channelId, ErrorCallback callback) { - RedisRpcRequest request = buildRequest("playChannel", channelId); + RedisRpcRequest request = buildRequest("channel/play", channelId); request.setToId(serverId); RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout()); if (response == null) { diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index f294e62e0..81658c3d0 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -34,6 +34,7 @@ create table wvp_device as_message_channel bool default false, keepalive_interval_time integer, broadcast_push_after_ack bool default false, + server_id character varying(50), constraint uk_device_device unique (device_id) ); diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 67fb1445f..d7c4c1f0a 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -34,6 +34,7 @@ create table wvp_device as_message_channel bool default false, keepalive_interval_time integer, broadcast_push_after_ack bool default false, + server_id character varying(50), constraint uk_device_device unique (device_id) ); From 9159f4a7a1f6b7f2a522fb1d884bbcff216a7a60 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:43:24 +0800 Subject: [PATCH 008/128] =?UTF-8?q?=E4=BF=AE=E6=94=B9RedisRpcChannelPlayCo?= =?UTF-8?q?ntroller=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/RedisRpcChannelPlayController.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java index adeda445a..d6f3a5af2 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -28,24 +28,12 @@ import org.springframework.data.redis.core.RedisTemplate; import javax.sip.message.Response; @Slf4j -@RedisRpcController("chanel") +@RedisRpcController("channel") public class RedisRpcChannelPlayController { - @Autowired - private SSRCFactory ssrcFactory; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private ISendRtpServerService sendRtpServerService; - @Autowired private UserSetting userSetting; - @Autowired - private HookSubscribe hookSubscribe; - @Autowired private RedisTemplate redisTemplate; From 9d966586968fab556429be9c987808e1d9ed4931 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 10:15:04 +0800 Subject: [PATCH 009/128] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9B=BD=E6=A0=87?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E7=82=B9=E6=92=AD=E5=85=B6=E4=BB=96wvp?= =?UTF-8?q?=E7=9A=84=E5=9B=BD=E6=A0=87=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/controller/PlayController.java | 11 +------- .../iot/vmp/gb28181/dao/DeviceMapper.java | 1 + .../gb28181/service/impl/PlayServiceImpl.java | 27 ++++++++++-------- web_src/src/components/DeviceList.vue | 28 +++++++++---------- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index e5087cbaa..b99a00bf6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -21,7 +21,6 @@ import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; @@ -66,9 +65,6 @@ public class PlayController { @Autowired private IPlayService playService; - @Autowired - private IRedisRpcPlayService redisRpcPlayService; - @Autowired private IMediaServerService mediaServerService; @@ -153,12 +149,7 @@ public class PlayController { // 此处必须释放所有请求 resultHolder.invokeAllResult(requestMessage); }; - // 判断设备是否属于当前平台, 如果不属于则发起自动调用 - if (userSetting.getServerId().equals(device.getServerId())) { - redisRpcPlayService.play(device.getServerId(), channel.getId(), callback); - }else { - playService.play(device, channel, callback); - } + playService.play(device, channel, callback); return result; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java index 07b186763..b33f906b5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java @@ -365,6 +365,7 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "media_server_id,"+ + "server_id,"+ "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.device_db_id= de.id) as channel_count " + " FROM wvp_device de" + " where 1 = 1 "+ 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 8b3d9f067..e631a6cdc 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 @@ -31,6 +31,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.service.IReceiveRtpServerService; import com.genersoft.iot.vmp.service.ISendRtpServerService; import com.genersoft.iot.vmp.service.bean.*; +import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.utils.CloudRecordUtils; import com.genersoft.iot.vmp.utils.DateUtil; @@ -123,6 +124,9 @@ public class PlayServiceImpl implements IPlayService { @Autowired private ICloudRecordService cloudRecordService; + @Autowired + private IRedisRpcPlayService redisRpcPlayService; + /** * 流到来的处理 */ @@ -287,12 +291,18 @@ public class PlayServiceImpl implements IPlayService { @Override public void play(Device device, DeviceChannel channel, ErrorCallback callback) { - MediaServer mediaServerItem = getNewMediaServerItem(device); - if (mediaServerItem == null) { - log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); + + // 判断设备是否属于当前平台, 如果不属于则发起自动调用 + if (userSetting.getServerId().equals(device.getServerId())) { + redisRpcPlayService.play(device.getServerId(), channel.getId(), callback); + }else { + MediaServer mediaServerItem = getNewMediaServerItem(device); + if (mediaServerItem == null) { + log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); + } + play(mediaServerItem, device, channel, null, callback); } - play(mediaServerItem, device, channel, null, callback); } @Override @@ -1660,13 +1670,8 @@ public class PlayServiceImpl implements IPlayService { log.warn("[点播] 未找到通道{}的设备信息", channel); throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); } - MediaServer mediaServer = getNewMediaServerItem(device); - if (mediaServer == null) { - log.warn("[点播] 未找到可用媒体节点"); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); - } DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); - play(mediaServer, device, deviceChannel, null, callback); + play(device, deviceChannel, callback); } @Override diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue index 7525def58..f9240f64d 100755 --- a/web_src/src/components/DeviceList.vue +++ b/web_src/src/components/DeviceList.vue @@ -15,7 +15,7 @@ 添加设备 - 平台信息 + 平台信息 @@ -53,7 +53,8 @@ @@ -62,11 +63,6 @@ - - - - - + + + + diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue new file mode 100644 index 000000000..3b54b1b6d --- /dev/null +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -0,0 +1,98 @@ + + + From c7e33f655efea9d7f564c87b67f6b5b226307217 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 20 Nov 2024 18:37:39 +0800 Subject: [PATCH 021/128] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BD=95=E5=88=B6=E8=AE=A1=E5=88=92=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/provider/ChannelProvider.java | 6 +- .../recordPlan/RecordPlanController.java | 27 ++++++- web_src/src/components/RecordPLan.vue | 2 +- .../src/components/dialog/editRecordPlan.vue | 79 ++++++++++++++++--- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 2 +- .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 2 +- 6 files changed, 99 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 3c481cdcb..8a941d3c5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -17,7 +17,7 @@ public class ChannelProvider { " stream_proxy_id,\n" + " create_time,\n" + " update_time,\n" + - " record_plan,\n" + + " record_plan_id,\n" + " coalesce(gb_device_id, device_id) as gb_device_id,\n" + " coalesce(gb_name, name) as gb_name,\n" + " coalesce(gb_manufacturer, manufacturer) as gb_manufacturer,\n" + @@ -198,8 +198,8 @@ public class ChannelProvider { if (params.get("online") != null && !(Boolean)params.get("online")) { sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'"); } - if (params.get("hasRecordPlan") != null && !(Boolean)params.get("hasRecordPlan")) { - sqlBuild.append(" AND record_plan == 0"); + if (params.get("hasRecordPlan") != null && (Boolean)params.get("hasRecordPlan")) { + sqlBuild.append(" AND record_plan_id > 0"); } if (params.get("channelType") != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java index 9c8b4687b..2a2698364 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -1,9 +1,17 @@ package com.genersoft.iot.vmp.vmanager.recordPlan; +import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; @Tag(name = "录制计划") @Slf4j @@ -11,5 +19,20 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/api/record/plan") public class RecordPlanController { + @ResponseBody + @PostMapping("/add") + @Operation(summary = "添加录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "channelId", description = "通道ID", required = true) + @Parameter(name = "deviceDbId", description = "国标设备ID", required = true) + @Parameter(name = "planList", description = "录制计划, 为空则清空计划", required = false) + public void openRtpServer(@RequestParam(required = false) Integer channelId, @RequestParam(required = false) Integer deviceDbId, @RequestParam(required = false) List planList + ) { + if (channelId == null && deviceDbId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); + } + + + + } } diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index a31917ce9..bba30ea4f 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -76,7 +76,7 @@ diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue index 3b54b1b6d..7f12794f3 100644 --- a/web_src/src/components/dialog/editRecordPlan.vue +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -11,9 +11,9 @@ >
- + -
+
保存 取消
@@ -36,7 +36,6 @@ export default { }, data() { return { - value:"", options: [], loading: false, showDialog: false, @@ -44,6 +43,7 @@ export default { deviceDbId: "", endCallback: "", byteTime: "", + planList: [], }; }, methods: { @@ -52,15 +52,22 @@ export default { this.deviceDbId = deviceDbId; this.endCallback = endCallback; this.showDialog = true; + this.byteTime= ""; + if (channel.recordPlanId) { + // 请求plan信息 + + } }, onSubmit: function () { + let planList = this.byteTime2PlanList(); + console.log(planList) this.$axios({ method: 'post', - url: "/api/user/add", + url: "/api/record/plan/add", params: { - username: this.username, - password: this.password, - roleId: this.roleId + channelId: this.channel?this.channel.id:null, + deviceDbId: this.deviceDbId, + planList: planList } }).then((res) => { if (res.data.code === 0) { @@ -68,11 +75,9 @@ export default { showClose: true, message: '添加成功', type: 'success', - }); this.showDialog = false; - this.listChangeCallback() - + this.endCallback() } else { this.$message({ showClose: true, @@ -85,7 +90,6 @@ export default { }); }, close: function () { - console.log(this.byteTime) this.channel = ""; this.deviceDbId = ""; this.showDialog = false; @@ -93,6 +97,59 @@ export default { this.endCallback(); } }, + byteTime2PlanList() { + this.planList = [] + if (this.byteTime.length === 0) { + return; + } + const DayTimes = 24 * 2; + let planList = [] + let week = 1; + // 把 336长度的 list 分成 7 组,每组 48 个 + for (let i = 0; i < this.byteTime.length; i += DayTimes) { + let planArray = this.byteTime2Plan(this.byteTime.slice(i, i + DayTimes)); + console.log(planArray) + if(!planArray || planArray.length === 0) { + week ++; + continue + } + for (let j = 0; j < planArray.length; j++) { + console.log(planArray[j]) + planList.push({ + startTime: planArray[j].startTime, + stopTime: planArray[j].stopTime, + weekDay: week + }) + } + week ++; + } + return planList + }, + byteTime2Plan(weekItem){ + let startTime = 0; + let endTime = 0; + let result = [] + + for (let i = 0; i < weekItem.length; i++) { + let item = weekItem[i] + if (item === '1') { + endTime = 30*i + if (startTime === 0 ) { + startTime = 30*i + } + } else { + if (endTime !== 0){ + result.push({ + startTime: startTime * 60 * 1000, + stopTime: endTime * 60 * 1000, + }) + startTime = 0 + endTime = 0 + } + } + } + return result; + } }, }; diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 0d9322a59..705eb301d 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -147,7 +147,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, - record_plan integer, + record_plan_id integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 223d80aba..f589329e1 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -163,7 +163,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, - record_plan integer, + record_plan_id integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), From 988845f246cfc90ff9cfdcda50b018a125dd42ef Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 20 Nov 2024 22:33:21 +0800 Subject: [PATCH 022/128] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=93=E6=9E=84=E4=BB=A5=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/dao/DeviceChannelMapper.java | 3 + .../service/IDeviceChannelService.java | 3 + .../impl/DeviceChannelServiceImpl.java | 10 ++ .../cmd/BroadcastResponseMessageHandler.java | 2 + .../iot/vmp/service/IRecordPlanService.java | 23 +++++ .../iot/vmp/service/bean/RecordPlan.java | 25 +++-- .../iot/vmp/service/bean/RecordPlanItem.java | 25 +++++ .../service/impl/RecordPlanServiceImpl.java | 79 ++++++++++++++++ .../vmp/storager/dao/RecordPlanMapper.java | 40 ++++++++ .../recordPlan/RecordPlanController.java | 93 +++++++++++++++++-- .../recordPlan/bean/RecordPlanParam.java | 22 +++++ src/main/resources/index.html | 10 ++ 数据库/2.7.3/初始化-mysql-2.7.3.sql | 20 ++++ .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 20 ++++ 14 files changed, 356 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java create mode 100644 src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java create mode 100644 src/main/resources/index.html diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index a52632354..75131ca60 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -93,6 +93,9 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}") + List queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index 81d9f9aff..4f0ee8e13 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -122,4 +122,7 @@ public interface IDeviceChannelService { DeviceChannel getOneBySourceId(int deviceDbId, String channelId); + List queryChaneListByDeviceDbId(Integer deviceDbId); + + List queryChaneIdListByDeviceDbId(Integer deviceDbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 4536c1ec8..8fecc7f41 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -348,6 +348,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { return channelMapper.queryChannelsByDeviceDbId(device.getId()); } + @Override + public List queryChaneListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChannelsByDeviceDbId(deviceDbId); + } + + @Override + public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + } + @Override public void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition) { if (userSetting.getSavePositionHistory()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java index 977482224..2567b7628 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java @@ -94,4 +94,6 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i public void handForPlatform(RequestEvent evt, Platform parentPlatform, Element element) { } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java new file mode 100644 index 000000000..641ddb180 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -0,0 +1,23 @@ +package com.genersoft.iot.vmp.service; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import com.github.pagehelper.PageInfo; + +import java.util.List; + +public interface IRecordPlanService { + + + RecordPlan get(Integer planId); + + void update(RecordPlan plan); + + void delete(Integer planId); + + PageInfo query(Integer page, Integer count, String query); + + void add(RecordPlan plan); + + void linke(List channelIds, Integer planId); +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java index 0ed21513e..5333b2c3e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.service.bean; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; + @Data @Schema(description = "录制计划") public class RecordPlan { @@ -10,18 +12,21 @@ public class RecordPlan { @Schema(description = "计划数据库ID") private int id; - @Schema(description = "计划关联的通道ID") - private Integer channelId; + @Schema(description = "计划名称") + private String name; - @Schema(description = "计划开始时间") - private Long startTime; - - @Schema(description = "计划结束时间") - private Long stopTime; - - @Schema(description = "计划周几执行") - private Integer weekDay; + @Schema(description = "计划关联通道数量") + private int channelCount; @Schema(description = "是否开启定时截图") private Boolean snap; + + @Schema(description = "创建时间") + private String createTime; + + @Schema(description = "更新时间") + private String updateTime; + + @Schema(description = "计划内容") + private List planItemList; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java new file mode 100644 index 000000000..14383cb15 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java @@ -0,0 +1,25 @@ +package com.genersoft.iot.vmp.service.bean; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "录制计划项") +public class RecordPlanItem { + + @Schema(description = "计划项数据库ID") + private int id; + + @Schema(description = "计划开始时间") + private Long startTime; + + @Schema(description = "计划结束时间") + private Long stopTime; + + @Schema(description = "计划周几执行") + private Integer weekDay; + + @Schema(description = "所属计划ID") + private Integer planId; + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java new file mode 100644 index 000000000..661bea1bc --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -0,0 +1,79 @@ +package com.genersoft.iot.vmp.service.impl; + +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; +import com.genersoft.iot.vmp.service.IRecordPlanService; +import com.genersoft.iot.vmp.service.bean.CloudRecordItem; +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import com.genersoft.iot.vmp.storager.dao.RecordPlanMapper; +import com.genersoft.iot.vmp.utils.DateUtil; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Slf4j +public class RecordPlanServiceImpl implements IRecordPlanService { + + @Autowired + private RecordPlanMapper recordPlanMapper; + + @Autowired + private CommonGBChannelMapper channelMapper; + + @Override + @Transactional + public void add(RecordPlan plan) { + plan.setCreateTime(DateUtil.getNow()); + plan.setUpdateTime(DateUtil.getNow()); + recordPlanMapper.add(plan); + if (plan.getId() > 0) { + recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); + } + } + + @Override + public RecordPlan get(Integer planId) { + return recordPlanMapper.get(planId); + } + + @Override + public void update(RecordPlan plan) { + plan.setUpdateTime(DateUtil.getNow()); + recordPlanMapper.update(plan); + } + + @Override + public void delete(Integer planId) { + recordPlanMapper.delete(planId); + } + + @Override + public PageInfo query(Integer page, Integer count, String query) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = recordPlanMapper.query(query); + return new PageInfo<>(all); + } + + @Override + public void linke(List channelIds, Integer planId) { + if (planId == null) { + log.info("[录制计划] 移除通道关联的计划"); + channelMapper.removeRecordPlan(channelIds); + }else { + channelMapper.addRecordPlan(channelIds, planId); + } + + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java new file mode 100644 index 000000000..cd4f3173d --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -0,0 +1,40 @@ +package com.genersoft.iot.vmp.storager.dao; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; + +import java.util.List; + +@Mapper +public interface RecordPlanMapper { + + @Insert(" ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void add(RecordPlan plan); + + RecordPlan get(Integer planId); + + List query(String query); + + void update(RecordPlan plan); + + void delete(Integer planId); + + + void batchAddItem(int planId, List planItemList); + +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java index 2a2698364..6f3fdfa37 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -2,15 +2,22 @@ package com.genersoft.iot.vmp.vmanager.recordPlan; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.RecordPlan; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.recordPlan.bean.RecordPlanParam; +import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; @Tag(name = "录制计划") @@ -19,20 +26,88 @@ import java.util.List; @RequestMapping("/api/record/plan") public class RecordPlanController { + @Autowired + private IRecordPlanService recordPlanService; + + @Autowired + private IDeviceChannelService deviceChannelService; + + @ResponseBody @PostMapping("/add") @Operation(summary = "添加录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) - @Parameter(name = "channelId", description = "通道ID", required = true) - @Parameter(name = "deviceDbId", description = "国标设备ID", required = true) - @Parameter(name = "planList", description = "录制计划, 为空则清空计划", required = false) - public void openRtpServer(@RequestParam(required = false) Integer channelId, @RequestParam(required = false) Integer deviceDbId, @RequestParam(required = false) List planList + @Parameter(name = "plan", description = "计划", required = true) + public void add(@RequestBody RecordPlan plan) { + if (plan.getPlanItemList() == null || plan.getPlanItemList().isEmpty()) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "添加录制计划时,录制计划不可为空"); + } + recordPlanService.add(plan); + } - ) { - if (channelId == null && deviceDbId == null) { + @ResponseBody + @PostMapping("/linke") + @Operation(summary = "通道关联录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "param", description = "通道关联录制计划", required = false) + public void linke(@RequestBody RecordPlanParam param) { + if (param.getChannelId() == null && param.getDeviceDbId() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); } - - - + List channelIds = new ArrayList<>(); + if (param.getChannelId() != null) { + channelIds.add(param.getChannelId()); + }else { + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbId(param.getDeviceDbId()); + if (chanelIdList == null || chanelIdList.isEmpty()) { + channelIds = chanelIdList; + } + } + recordPlanService.linke(channelIds, param.getPlanId()); } + + @ResponseBody + @GetMapping("/get") + @Operation(summary = "查询录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "planId", description = "计划ID", required = true) + public RecordPlan get(Integer planId) { + if (planId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "计划ID不可为NULL"); + } + return recordPlanService.get(planId); + } + + @ResponseBody + @GetMapping("/query") + @Operation(summary = "查询录制计划列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "query", description = "检索内容", required = false) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页查询数量", required = true) + public PageInfo query(@RequestParam(required = false) String query, @RequestParam Integer page, @RequestParam Integer count) { + if (query != null && ObjectUtils.isEmpty(query.trim())) { + query = null; + } + return recordPlanService.query(page, count, query); + } + + @ResponseBody + @PostMapping("/edit") + @Operation(summary = "编辑录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "plan", description = "计划", required = true) + public void edit(@RequestBody RecordPlan plan) { + if (plan == null || plan.getId() == 0) { + throw new ControllerException(ErrorCode.ERROR400); + } + recordPlanService.update(plan); + } + + @ResponseBody + @DeleteMapping("/delete") + @Operation(summary = "删除录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "planId", description = "计划ID", required = true) + public void delete(Integer planId) { + if (planId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "计划IDID不可为NULL"); + } + recordPlanService.delete(planId); + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java new file mode 100644 index 000000000..11cc1a0ab --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -0,0 +1,22 @@ +package com.genersoft.iot.vmp.vmanager.recordPlan.bean; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "录制计划-添加/编辑参数") +public class RecordPlanParam { + + @Schema(description = "关联的通道ID") + private Integer channelId; + + @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") + private Integer deviceDbId; + + @Schema(description = "录制计划ID, ID为空是删除关联的计划") + private Integer planId; +} diff --git a/src/main/resources/index.html b/src/main/resources/index.html new file mode 100644 index 000000000..9d2fdca2a --- /dev/null +++ b/src/main/resources/index.html @@ -0,0 +1,10 @@ + + + + + Title + + +111 + + \ No newline at end of file diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 705eb301d..faada9cd4 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -428,3 +428,23 @@ CREATE TABLE wvp_common_region constraint uk_common_region_device_id unique (device_id) ); +create table wvp_record_plan +( + id serial primary key, + snap bool default false, + name varchar(255) NOT NULL, + create_time character varying(50), + update_time character varying(50) +); + +create table wvp_record_plan_item +( + id serial primary key, + start_time bigint, + stop_time bigint, + week_day int, + plan_id int, + create_time character varying(50), + update_time character varying(50) +); + diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index f589329e1..9ef3e926b 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -445,3 +445,23 @@ CREATE TABLE wvp_common_region constraint uk_common_region_device_id unique (device_id) ); +create table wvp_record_plan +( + id serial primary key, + snap bool default false, + name varchar(255) NOT NULL, + create_time character varying(50), + update_time character varying(50) +); + +create table wvp_record_plan_item +( + id serial primary key, + start_time int8, + stop_time int8, + week_day int, + plan_id int, + create_time character varying(50), + update_time character varying(50) +); + From 0ad1aceeb58f7bdd95439e48748c54788c76577e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 21 Nov 2024 20:50:22 +0800 Subject: [PATCH 023/128] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RecordPlanServiceImpl.java | 10 +++++- .../vmp/storager/dao/RecordPlanMapper.java | 34 ++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index 661bea1bc..aa6d922d3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -40,7 +40,15 @@ public class RecordPlanServiceImpl implements IRecordPlanService { @Override public RecordPlan get(Integer planId) { - return recordPlanMapper.get(planId); + RecordPlan recordPlan = recordPlanMapper.get(planId); + if (recordPlan == null) { + return null; + } + List recordPlanItemList = recordPlanMapper.getItemList(planId); + if (!recordPlanItemList.isEmpty()) { + recordPlan.setPlanItemList(recordPlanItemList); + } + return recordPlan; } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java index cd4f3173d..9fb4d588b 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -2,9 +2,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.service.bean.RecordPlan; import com.genersoft.iot.vmp.service.bean.RecordPlanItem; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.*; import java.util.List; @@ -26,15 +24,35 @@ public interface RecordPlanMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void add(RecordPlan plan); - RecordPlan get(Integer planId); + @Insert(" ") + void batchAddItem(@Param("planId") int planId, List planItemList); - List query(String query); + @Select("select * from wvp_record_plan where id = #{planId}") + RecordPlan get(@Param("planId") Integer planId); + @Select(" ") + List query(@Param("query") String query); + + @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}") void update(RecordPlan plan); - void delete(Integer planId); + @Delete("DELETE FROM wvp_record_plan WHERE id=#{id}") + void delete(@Param("planId") Integer planId); - void batchAddItem(int planId, List planItemList); - + List getItemList(Integer planId); } From a35c1193f2bffe845585f05a4dcbac40063c0e40 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 21 Nov 2024 23:20:56 +0800 Subject: [PATCH 024/128] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=9A=E9=81=93?= =?UTF-8?q?=E5=85=B3=E8=81=94=E4=BB=A5=E5=8F=8A=E5=BD=95=E5=88=B6=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=8E=A5=E5=8F=A3=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/CommonGBChannelMapper.java | 89 ++++ .../vmp/gb28181/dao/DeviceChannelMapper.java | 5 +- .../service/IDeviceChannelService.java | 2 +- .../impl/DeviceChannelServiceImpl.java | 4 +- .../impl/PlatformChannelServiceImpl.java | 5 + .../iot/vmp/service/IRecordPlanService.java | 11 +- .../service/impl/RecordPlanServiceImpl.java | 49 +- .../vmp/storager/dao/RecordPlanMapper.java | 21 +- .../recordPlan/RecordPlanController.java | 56 +- .../recordPlan/bean/RecordPlanParam.java | 7 +- web_src/src/components/RecordPLan.vue | 157 +++--- .../src/components/dialog/editRecordPlan.vue | 152 ++++-- .../components/dialog/linkChannelRecord.vue | 500 ++++++++++++++++++ 13 files changed, 899 insertions(+), 159 deletions(-) create mode 100755 web_src/src/components/dialog/linkChannelRecord.vue diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 99aff9730..2f636a4d5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -459,4 +459,93 @@ public interface CommonGBChannelMapper { @SelectProvider(type = ChannelProvider.class, method = "queryList") List queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("channelType") Integer channelType); + + @Update(value = {" "}) + void removeRecordPlan(List channelIds); + + @Update(value = {" "}) + void addRecordPlan(List channelIds, @Param("planId") Integer planId); + + @Update(value = {" "}) + void addRecordPlanForAll(@Param("planId") Integer planId); + + @Update(value = {" "}) + void removeRecordPlanByPlanId( @Param("planId") Integer planId); + + + @Select("") + List queryForRecordPlanForWebList(@Param("planId") Integer planId, @Param("query") String query, + @Param("channelType") Integer channelType, @Param("online") Boolean online, + @Param("hasLink") Boolean hasLink); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 75131ca60..13f1976a8 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -93,8 +93,9 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); - @Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}") - List queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select("select id from wvp_device_channel where device_db_id in " + + " #{item} ") + List queryChaneIdListByDeviceDbIds(List deviceDbIds); @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index 4f0ee8e13..bb21e3214 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -124,5 +124,5 @@ public interface IDeviceChannelService { List queryChaneListByDeviceDbId(Integer deviceDbId); - List queryChaneIdListByDeviceDbId(Integer deviceDbId); + List queryChaneIdListByDeviceDbIds(List deviceDbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 8fecc7f41..c18510c3f 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -354,8 +354,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } @Override - public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { - return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + public List queryChaneIdListByDeviceDbIds(List deviceDbIds) { + return channelMapper.queryChaneIdListByDeviceDbIds(deviceDbIds); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 62125e7c5..6b51054b5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -52,6 +52,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Override public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer platformId, Boolean hasShare) { PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } List all = platformChannelMapper.queryForPlatformForWebList(platformId, query, channelType, online, hasShare); return new PageInfo<>(all); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java index 641ddb180..359e0072a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -1,7 +1,8 @@ package com.genersoft.iot.vmp.service; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.service.bean.RecordPlan; -import com.genersoft.iot.vmp.service.bean.RecordPlanItem; import com.github.pagehelper.PageInfo; import java.util.List; @@ -19,5 +20,11 @@ public interface IRecordPlanService { void add(RecordPlan plan); - void linke(List channelIds, Integer planId); + void link(List channelIds, Integer planId); + + PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink); + + void linkAll(Integer planId); + + void cleanAll(Integer planId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index aa6d922d3..f8f7e9c35 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -1,6 +1,8 @@ package com.genersoft.iot.vmp.service.impl; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.CloudRecordItem; @@ -8,6 +10,7 @@ import com.genersoft.iot.vmp.service.bean.RecordPlan; import com.genersoft.iot.vmp.service.bean.RecordPlanItem; import com.genersoft.iot.vmp.storager.dao.RecordPlanMapper; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -33,9 +36,13 @@ public class RecordPlanServiceImpl implements IRecordPlanService { plan.setCreateTime(DateUtil.getNow()); plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.add(plan); - if (plan.getId() > 0) { + if (plan.getId() > 0 && !plan.getPlanItemList().isEmpty()) { + for (RecordPlanItem recordPlanItem : plan.getPlanItemList()) { + recordPlanItem.setPlanId(plan.getId()); + } recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); } + // TODO 更新录像队列 } @Override @@ -52,14 +59,30 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override + @Transactional public void update(RecordPlan plan) { plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.update(plan); + recordPlanMapper.cleanItems(plan.getId()); + if (plan.getPlanItemList() != null){ + recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); + } + // TODO 更新录像队列 + } @Override + @Transactional public void delete(Integer planId) { + RecordPlan recordPlan = recordPlanMapper.get(planId); + if (recordPlan == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "录制计划不存在"); + } + // 清理关联的通道 + channelMapper.removeRecordPlanByPlanId(recordPlan.getId()); + recordPlanMapper.cleanItems(planId); recordPlanMapper.delete(planId); + // TODO 更新录像队列 } @Override @@ -75,13 +98,35 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override - public void linke(List channelIds, Integer planId) { + public void link(List channelIds, Integer planId) { if (planId == null) { log.info("[录制计划] 移除通道关联的计划"); channelMapper.removeRecordPlan(channelIds); }else { channelMapper.addRecordPlan(channelIds, planId); } + // TODO 更新录像队列 + } + @Override + public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = channelMapper.queryForRecordPlanForWebList(planId, query, channelType, online, hasLink); + return new PageInfo<>(all); + } + + @Override + public void linkAll(Integer planId) { + channelMapper.addRecordPlanForAll(planId); + } + + @Override + public void cleanAll(Integer planId) { + channelMapper.removeRecordPlanByPlanId(planId); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java index 9fb4d588b..705e59aae 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -10,7 +10,7 @@ import java.util.List; public interface RecordPlanMapper { @Insert(" ") void batchAddItem(@Param("planId") int planId, List planItemList); @@ -42,7 +41,8 @@ public interface RecordPlanMapper { RecordPlan get(@Param("planId") Integer planId); @Select(" ") List query(@Param("query") String query); @@ -50,9 +50,12 @@ public interface RecordPlanMapper { @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}") void update(RecordPlan plan); - @Delete("DELETE FROM wvp_record_plan WHERE id=#{id}") + @Delete("DELETE FROM wvp_record_plan WHERE id=#{planId}") void delete(@Param("planId") Integer planId); + @Select("select * from wvp_record_plan_item where plan_id = #{planId}") + List getItemList(@Param("planId") Integer planId); - List getItemList(Integer planId); + @Delete("DELETE FROM wvp_record_plan_item WHERE plan_id = #{planId}") + void cleanItems(@Param("planId") Integer planId); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java index 6f3fdfa37..3675acbb8 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.vmanager.recordPlan; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.RecordPlan; @@ -15,6 +17,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -45,23 +48,31 @@ public class RecordPlanController { } @ResponseBody - @PostMapping("/linke") + @PostMapping("/link") @Operation(summary = "通道关联录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "param", description = "通道关联录制计划", required = false) - public void linke(@RequestBody RecordPlanParam param) { - if (param.getChannelId() == null && param.getDeviceDbId() == null) { + public void link(@RequestBody RecordPlanParam param) { + if (param.getChannelIds() == null && param.getDeviceDbIds() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); } + if (param.getAll() != null) { + if (param.getAll()) { + recordPlanService.linkAll(param.getPlanId()); + }else { + recordPlanService.cleanAll(param.getPlanId()); + } + return; + } List channelIds = new ArrayList<>(); - if (param.getChannelId() != null) { - channelIds.add(param.getChannelId()); + if (param.getChannelIds() != null) { + channelIds.addAll(param.getChannelIds()); }else { - List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbId(param.getDeviceDbId()); + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbIds(param.getDeviceDbIds()); if (chanelIdList == null || chanelIdList.isEmpty()) { channelIds = chanelIdList; } } - recordPlanService.linke(channelIds, param.getPlanId()); + recordPlanService.link(channelIds, param.getPlanId()); } @ResponseBody @@ -88,11 +99,36 @@ public class RecordPlanController { return recordPlanService.query(page, count, query); } + @Operation(summary = "分页查询级联平台的所有所有通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页条数", required = true) + @Parameter(name = "planId", description = "录制计划ID") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") + @Parameter(name = "query", description = "查询内容") + @Parameter(name = "online", description = "是否在线") + @Parameter(name = "hasLink", description = "是否已经关联") + @GetMapping("/channel/list") @ResponseBody - @PostMapping("/edit") - @Operation(summary = "编辑录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + public PageInfo queryChannelList(int page, int count, + @RequestParam(required = false) Integer planId, + @RequestParam(required = false) String query, + @RequestParam(required = false) Integer channelType, + @RequestParam(required = false) Boolean online, + @RequestParam(required = false) Boolean hasLink) { + + Assert.notNull(planId, "录制计划ID不可为NULL"); + if (org.springframework.util.ObjectUtils.isEmpty(query)) { + query = null; + } + + return recordPlanService.queryChannelList(page, count, query, channelType, online, planId, hasLink); + } + + @ResponseBody + @PostMapping("/update") + @Operation(summary = "更新录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "plan", description = "计划", required = true) - public void edit(@RequestBody RecordPlan plan) { + public void update(@RequestBody RecordPlan plan) { if (plan == null || plan.getId() == 0) { throw new ControllerException(ErrorCode.ERROR400); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java index 11cc1a0ab..e74314098 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -12,10 +12,13 @@ import java.util.List; public class RecordPlanParam { @Schema(description = "关联的通道ID") - private Integer channelId; + private List channelIds; @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") - private Integer deviceDbId; + private List deviceDbIds; + + @Schema(description = "全部关联/全部取消关联") + private Boolean all; @Schema(description = "录制计划ID, ID为空是删除关联的计划") private Integer planId; diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index bba30ea4f..4e649fa55 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -9,82 +9,30 @@ 搜索: - - 在线状态: - - - - - - 录制计划: - - - - - - 类型: - - - - - - - 按国标设备添加 + 添加 - - 按国标设备移除 - - +
- - + - + - + - - + + + - - - - - - - - - @@ -99,37 +47,31 @@ :total="total"> + diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue index 7f12794f3..3772c4909 100644 --- a/web_src/src/components/dialog/editRecordPlan.vue +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -10,8 +10,13 @@ @close="close()" >
- + + + + + +
保存 @@ -38,67 +43,111 @@ export default { return { options: [], loading: false, + edit: false, + planName: null, + id: null, showDialog: false, - channel: "", - deviceDbId: "", endCallback: "", byteTime: "", - planList: [], }; }, methods: { - openDialog: function (channel, deviceDbId, endCallback) { - this.channel = channel; - this.deviceDbId = deviceDbId; + openDialog: function (recordPlan, endCallback) { + console.log(recordPlan); this.endCallback = endCallback; this.showDialog = true; this.byteTime= ""; - if (channel.recordPlanId) { - // 请求plan信息 + if (recordPlan) { + this.edit = true + this.planName = recordPlan.name + this.id = recordPlan.id + this.$axios({ + method: 'get', + url: "/api/record/plan/get", + params: { + planId: recordPlan.id, + } + }).then((res) => { + if (res.data.code === 0) { + this.byteTime = this.plan2Byte(res.data.data.planItemList) + } + }).catch((error) => { + console.error(error) + }); } }, onSubmit: function () { let planList = this.byteTime2PlanList(); - console.log(planList) - this.$axios({ - method: 'post', - url: "/api/record/plan/add", - params: { - channelId: this.channel?this.channel.id:null, - deviceDbId: this.deviceDbId, - planList: planList - } - }).then((res) => { - if (res.data.code === 0) { - this.$message({ - showClose: true, - message: '添加成功', - type: 'success', - }); - this.showDialog = false; - this.endCallback() - } else { - this.$message({ - showClose: true, - message: res.data.msg, - type: 'error' - }); - } - }).catch((error) => { - console.error(error) - }); + if (!this.edit) { + this.$axios({ + method: 'post', + url: "/api/record/plan/add", + data: { + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '添加成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + }else { + this.$axios({ + method: 'post', + url: "/api/record/plan/update", + data: { + id: this.id, + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '更新成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + } + }, close: function () { - this.channel = ""; - this.deviceDbId = ""; this.showDialog = false; + this.id = null + this.planName = null + this.byteTime = "" + this.endCallback = "" if(this.endCallback) { this.endCallback(); } }, byteTime2PlanList() { - this.planList = [] if (this.byteTime.length === 0) { return; } @@ -114,8 +163,8 @@ export default { continue } for (let j = 0; j < planArray.length; j++) { - console.log(planArray[j]) planList.push({ + id: this.id, startTime: planArray[j].startTime, stopTime: planArray[j].stopTime, weekDay: week @@ -149,6 +198,27 @@ export default { } } return result; + }, + plan2Byte(planList) { + console.log(planList); + let byte = "" + let indexArray = {} + for (let i = 0; i < planList.length; i++) { + let index = planList[i].startTime/1000/60/30 + let endIndex = planList[i].stopTime/1000/60/30 + for (let j = index; j <= endIndex; j++) { + indexArray[j + (planList[i].weekDay - 1 )*48] = j + i*48 + } + } + console.log(indexArray) + for (let i = 0; i < 336; i++) { + if (indexArray[i]){ + byte += "1" + }else { + byte += "0" + } + } + return byte } }, }; diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue new file mode 100755 index 000000000..173b5008b --- /dev/null +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -0,0 +1,500 @@ + + + + + From c2ad767d89505695912af352657d5c88e480459f Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sat, 23 Nov 2024 14:51:13 +0800 Subject: [PATCH 025/128] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/dialog/linkChannelRecord.vue | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue index 173b5008b..6f2a299a3 100755 --- a/web_src/src/components/dialog/linkChannelRecord.vue +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -1,6 +1,6 @@ - - +
+
+ 未找到通道,可在国标设备/通道中选择编辑按钮, 选择{{dataType === 'civilCode'?'行政区划':'父节点编码'}} +
+ + +
+
diff --git a/web_src/src/components/dialog/groupEdit.vue b/web_src/src/components/dialog/groupEdit.vue index 72795cb4d..1c77bc841 100755 --- a/web_src/src/components/dialog/groupEdit.vue +++ b/web_src/src/components/dialog/groupEdit.vue @@ -22,7 +22,7 @@
- 生成 + 选择 @@ -37,17 +37,17 @@
- + "}) int update(Device device); @@ -207,9 +210,43 @@ public interface DeviceMapper { "as_message_channel,"+ "broadcast_push_after_ack,"+ "geo_coord_sys,"+ + "server_id,"+ "on_line"+ " FROM wvp_device WHERE on_line = true") List getOnlineDevices(); + @Select("SELECT " + + "id, " + + "device_id, " + + "coalesce(custom_name, name) as name, " + + "password, " + + "manufacturer, " + + "model, " + + "firmware, " + + "transport," + + "stream_mode," + + "ip," + + "sdp_ip,"+ + "local_ip,"+ + "port,"+ + "host_address,"+ + "expires,"+ + "register_time,"+ + "keepalive_time,"+ + "create_time,"+ + "update_time,"+ + "charset,"+ + "subscribe_cycle_for_catalog,"+ + "subscribe_cycle_for_mobile_position,"+ + "mobile_position_submission_interval,"+ + "subscribe_cycle_for_alarm,"+ + "ssrc_check,"+ + "as_message_channel,"+ + "broadcast_push_after_ack,"+ + "geo_coord_sys,"+ + "server_id,"+ + "on_line"+ + " FROM wvp_device WHERE on_line = true and server_id = #{serverId}") + List getOnlineDevicesByServerId(@Param("serverId") String serverId); @Select("SELECT " + "id,"+ @@ -269,6 +306,7 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "stream_mode," + + "server_id," + "media_server_id"+ ") VALUES (" + "#{deviceId}," + @@ -284,6 +322,7 @@ public interface DeviceMapper { "#{geoCoordSys}," + "#{onLine}," + "#{streamMode}," + + "#{serverId}," + "#{mediaServerId}" + ")") void addCustomDevice(Device device); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java index 0812f8cfa..a8f48a476 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java @@ -86,7 +86,7 @@ public interface IDeviceService { * 获取所有在线设备 * @return 设备列表 */ - List getAllOnlineDevice(); + List getAllOnlineDevice(String serverId); List getAllByStatus(Boolean status); 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 c3ede305a..4773b9fda 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 @@ -353,8 +353,8 @@ public class DeviceServiceImpl implements IDeviceService { } @Override - public List getAllOnlineDevice() { - return deviceMapper.getOnlineDevices(); + public List getAllOnlineDevice(String serverId) { + return deviceMapper.getOnlineDevicesByServerId(serverId); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java index 102f9d0c9..56a649bc5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.task; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Platform; @@ -60,9 +61,12 @@ public class SipRunner implements CommandLineRunner { @Autowired private ISendRtpServerService sendRtpServerService; + @Autowired + private UserSetting userSetting; + @Override public void run(String... args) throws Exception { - List deviceList = deviceService.getAllOnlineDevice(); + List deviceList = deviceService.getAllOnlineDevice(userSetting.getServerId()); for (Device device : deviceList) { if (deviceService.expire(device)){ @@ -86,7 +90,8 @@ public class SipRunner implements CommandLineRunner { deviceMapInDb.put(device.getDeviceId(), device); }); devicesInRedis.parallelStream().forEach(device -> { - if (deviceMapInDb.get(device.getDeviceId()) == null) { + if (deviceMapInDb.get(device.getDeviceId()) == null + && userSetting.getServerId().equals(device.getServerId())) { redisCatchStorage.removeDevice(device.getDeviceId()); } }); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index 44a3eb1ed..8ad37f1ed 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -183,7 +183,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen device.setGeoCoordSys("WGS84"); } } - + device.setServerId(userSetting.getServerId()); device.setIp(remoteAddressInfo.getIp()); device.setPort(remoteAddressInfo.getPort()); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); From 6258bf69692407fa484160cff5826bdcd4546900 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 11 Dec 2024 11:43:41 +0800 Subject: [PATCH 038/128] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=AD=90=E7=A0=81=E6=B5=81=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java | 4 ++++ .../vmp/gb28181/service/impl/DeviceChannelServiceImpl.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 99bb6e36f..068eb4b79 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -413,6 +413,10 @@ public interface DeviceChannelMapper { "") void updateChannelStreamIdentification(DeviceChannel channel); + @Update("") + void updateAllChannelStreamIdentification(@Param("streamIdentification") String streamIdentification); @Update({""}) @@ -138,32 +141,27 @@ public interface MediaServerMapper { ", type=#{type}" + ", transcode_suffix=#{transcodeSuffix}" + ", hook_alive_interval=#{hookAliveInterval}" + + ", server_id=#{serverId}" + "WHERE ip=#{ip} and http_port=#{httpPort}"+ " "}) int updateByHostAndPort(MediaServer mediaServerItem); - @Select("SELECT * FROM wvp_media_server WHERE id=#{id}") - MediaServer queryOne(String id); + @Select("SELECT * FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}") + MediaServer queryOne(@Param("id") String id, @Param("serverId") String serverId); - @Select("SELECT * FROM wvp_media_server") - List queryAll(); + @Select("SELECT * FROM wvp_media_server where server_id = #{serverId}") + List queryAll(@Param("serverId") String serverId); - @Delete("DELETE FROM wvp_media_server WHERE id=#{id}") - void delOne(String id); + @Delete("DELETE FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}") + void delOne(String id, @Param("serverId") String serverId); - @Select("DELETE FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}") - void delOneByIPAndPort(@Param("host") String host, @Param("port") int port); + @Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port} and server_id = #{serverId}") + MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port, @Param("serverId") String serverId); - @Delete("DELETE FROM wvp_media_server WHERE default_server=true") - int delDefault(); + @Select("SELECT * FROM wvp_media_server WHERE default_server=true and server_id = #{serverId}") + MediaServer queryDefault(@Param("serverId") String serverId); - @Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}") - MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port); - - @Select("SELECT * FROM wvp_media_server WHERE default_server=true") - MediaServer queryDefault(); - - @Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0") - List queryAllWithAssistPort(); + @Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0 and server_id = #{serverId}") + List queryAllWithAssistPort(@Param("serverId") String serverId); } diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index e12677da5..5ffb722c6 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -29,6 +29,7 @@ create table wvp_device custom_name character varying(255), sdp_ip character varying(50), local_ip character varying(50), + server_id character varying(50), password character varying(255), as_message_channel bool default false, keepalive_interval_time integer, @@ -190,6 +191,7 @@ create table wvp_media_server record_path character varying(255), record_day integer default 7, transcode_suffix character varying(255), + server_id character varying(50), constraint uk_media_server_unique_ip_http_port unique (ip, http_port) ); diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index c632f9a83..9789b4632 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -29,6 +29,7 @@ create table wvp_device custom_name character varying(255), sdp_ip character varying(50), local_ip character varying(50), + server_id character varying(50), password character varying(255), as_message_channel bool default false, keepalive_interval_time integer, @@ -207,6 +208,7 @@ create table wvp_media_server record_path character varying(255), record_day integer default 7, transcode_suffix character varying(255), + server_id character varying(50), constraint uk_media_server_unique_ip_http_port unique (ip, http_port) ); From 8372bfec6884b4078721b8239d7d67e381d28f69 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:29:49 +0800 Subject: [PATCH 043/128] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=A1=A8=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 2 +- 数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 5ffb722c6..f294e62e0 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -192,7 +192,7 @@ create table wvp_media_server record_day integer default 7, transcode_suffix character varying(255), server_id character varying(50), - constraint uk_media_server_unique_ip_http_port unique (ip, http_port) + constraint uk_media_server_unique_ip_http_port unique (ip, http_port, server_id) ); create table wvp_platform diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 9789b4632..67fb1445f 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -209,7 +209,7 @@ create table wvp_media_server record_day integer default 7, transcode_suffix character varying(255), server_id character varying(50), - constraint uk_media_server_unique_ip_http_port unique (ip, http_port) + constraint uk_media_server_unique_ip_http_port unique (ip, http_port, server_id) ); create table wvp_platform From c4025d7a073bf0a47ec8680ef0916159011345ce Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:37:12 +0800 Subject: [PATCH 044/128] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E7=82=B9=E6=92=ADRPC=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RedisRpcChannelPlayController.java | 101 ++++++++++++++++++ .../service/RedisRpcPlayServiceImpl.java | 2 +- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 1 + .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 1 + 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java new file mode 100644 index 000000000..adeda445a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -0,0 +1,101 @@ +package com.genersoft.iot.vmp.service.redisMsg.control; + +import com.alibaba.fastjson2.JSONObject; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; +import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; +import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; +import com.genersoft.iot.vmp.media.bean.MediaServer; +import com.genersoft.iot.vmp.media.event.hook.Hook; +import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; +import com.genersoft.iot.vmp.media.event.hook.HookType; +import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.service.ISendRtpServerService; +import com.genersoft.iot.vmp.service.bean.InviteErrorCode; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController; +import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; + +import javax.sip.message.Response; + +@Slf4j +@RedisRpcController("chanel") +public class RedisRpcChannelPlayController { + + @Autowired + private SSRCFactory ssrcFactory; + + @Autowired + private IMediaServerService mediaServerService; + + @Autowired + private ISendRtpServerService sendRtpServerService; + + @Autowired + private UserSetting userSetting; + + @Autowired + private HookSubscribe hookSubscribe; + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private IGbChannelService channelService; + + @Autowired + private IGbChannelPlayService channelPlayService; + + private void sendResponse(RedisRpcResponse response){ + log.info("[redis-rpc] >> {}", response); + response.setToId(userSetting.getServerId()); + RedisRpcMessage message = new RedisRpcMessage(); + message.setResponse(response); + redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message); + } + + + /** + * 点播国标设备 + */ + @RedisRpcMapping("play") + public RedisRpcResponse playChannel(RedisRpcRequest request) { + int channelId = Integer.parseInt(request.getParam().toString()); + RedisRpcResponse response = request.getResponse(); + + if (channelId <= 0) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + // 获取对应的设备和通道信息 + CommonGBChannel channel = channelService.getOne(channelId); + if (channel == null) { + response.setStatusCode(Response.BAD_REQUEST); + response.setBody("param error"); + return response; + } + + channelPlayService.play(channel, null, (code, msg, data) ->{ + if (code == InviteErrorCode.SUCCESS.getCode()) { + response.setStatusCode(Response.OK); + response.setBody(data); + }else { + response.setStatusCode(code); + } + // 手动发送结果 + sendResponse(response); + }); + return null; + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java index 93f218a6c..0e1c0b1ee 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java @@ -37,7 +37,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { @Override public void play(String serverId, Integer channelId, ErrorCallback callback) { - RedisRpcRequest request = buildRequest("playChannel", channelId); + RedisRpcRequest request = buildRequest("channel/play", channelId); request.setToId(serverId); RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout()); if (response == null) { diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index f294e62e0..81658c3d0 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -34,6 +34,7 @@ create table wvp_device as_message_channel bool default false, keepalive_interval_time integer, broadcast_push_after_ack bool default false, + server_id character varying(50), constraint uk_device_device unique (device_id) ); diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 67fb1445f..d7c4c1f0a 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -34,6 +34,7 @@ create table wvp_device as_message_channel bool default false, keepalive_interval_time integer, broadcast_push_after_ack bool default false, + server_id character varying(50), constraint uk_device_device unique (device_id) ); From 1c2709163d97833276c56e2403c0168ef3df2a05 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 09:43:24 +0800 Subject: [PATCH 045/128] =?UTF-8?q?=E4=BF=AE=E6=94=B9RedisRpcChannelPlayCo?= =?UTF-8?q?ntroller=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control/RedisRpcChannelPlayController.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java index adeda445a..d6f3a5af2 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -28,24 +28,12 @@ import org.springframework.data.redis.core.RedisTemplate; import javax.sip.message.Response; @Slf4j -@RedisRpcController("chanel") +@RedisRpcController("channel") public class RedisRpcChannelPlayController { - @Autowired - private SSRCFactory ssrcFactory; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private ISendRtpServerService sendRtpServerService; - @Autowired private UserSetting userSetting; - @Autowired - private HookSubscribe hookSubscribe; - @Autowired private RedisTemplate redisTemplate; From fe341036a8f38f58563b3d6bbc8b2d39827e9acf Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 Dec 2024 10:15:04 +0800 Subject: [PATCH 046/128] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9B=BD=E6=A0=87?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E7=82=B9=E6=92=AD=E5=85=B6=E4=BB=96wvp?= =?UTF-8?q?=E7=9A=84=E5=9B=BD=E6=A0=87=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/controller/PlayController.java | 11 +------- .../iot/vmp/gb28181/dao/DeviceMapper.java | 1 + .../gb28181/service/impl/PlayServiceImpl.java | 27 ++++++++++-------- web_src/src/components/DeviceList.vue | 28 +++++++++---------- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index e5087cbaa..b99a00bf6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -21,7 +21,6 @@ import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; @@ -66,9 +65,6 @@ public class PlayController { @Autowired private IPlayService playService; - @Autowired - private IRedisRpcPlayService redisRpcPlayService; - @Autowired private IMediaServerService mediaServerService; @@ -153,12 +149,7 @@ public class PlayController { // 此处必须释放所有请求 resultHolder.invokeAllResult(requestMessage); }; - // 判断设备是否属于当前平台, 如果不属于则发起自动调用 - if (userSetting.getServerId().equals(device.getServerId())) { - redisRpcPlayService.play(device.getServerId(), channel.getId(), callback); - }else { - playService.play(device, channel, callback); - } + playService.play(device, channel, callback); return result; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java index 07b186763..b33f906b5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java @@ -365,6 +365,7 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "media_server_id,"+ + "server_id,"+ "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.device_db_id= de.id) as channel_count " + " FROM wvp_device de" + " where 1 = 1 "+ 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 8b3d9f067..e631a6cdc 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 @@ -31,6 +31,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.service.IReceiveRtpServerService; import com.genersoft.iot.vmp.service.ISendRtpServerService; import com.genersoft.iot.vmp.service.bean.*; +import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.utils.CloudRecordUtils; import com.genersoft.iot.vmp.utils.DateUtil; @@ -123,6 +124,9 @@ public class PlayServiceImpl implements IPlayService { @Autowired private ICloudRecordService cloudRecordService; + @Autowired + private IRedisRpcPlayService redisRpcPlayService; + /** * 流到来的处理 */ @@ -287,12 +291,18 @@ public class PlayServiceImpl implements IPlayService { @Override public void play(Device device, DeviceChannel channel, ErrorCallback callback) { - MediaServer mediaServerItem = getNewMediaServerItem(device); - if (mediaServerItem == null) { - log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); + + // 判断设备是否属于当前平台, 如果不属于则发起自动调用 + if (userSetting.getServerId().equals(device.getServerId())) { + redisRpcPlayService.play(device.getServerId(), channel.getId(), callback); + }else { + MediaServer mediaServerItem = getNewMediaServerItem(device); + if (mediaServerItem == null) { + log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); + } + play(mediaServerItem, device, channel, null, callback); } - play(mediaServerItem, device, channel, null, callback); } @Override @@ -1660,13 +1670,8 @@ public class PlayServiceImpl implements IPlayService { log.warn("[点播] 未找到通道{}的设备信息", channel); throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); } - MediaServer mediaServer = getNewMediaServerItem(device); - if (mediaServer == null) { - log.warn("[点播] 未找到可用媒体节点"); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); - } DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); - play(mediaServer, device, deviceChannel, null, callback); + play(device, deviceChannel, callback); } @Override diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue index 7525def58..f9240f64d 100755 --- a/web_src/src/components/DeviceList.vue +++ b/web_src/src/components/DeviceList.vue @@ -15,7 +15,7 @@ 添加设备 - 平台信息 + 平台信息 @@ -53,7 +53,8 @@ @@ -62,11 +63,6 @@ - - - - -