From 67e40600538fddea05fed1c7baa1ce3909a09969 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 30 Nov 2023 18:09:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A8=E6=B5=81=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=93=E5=B1=9Eredis=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/common/VideoManagerConstants.java | 1 + .../iot/vmp/conf/SystemInfoTimerTask.java | 2 ++ .../iot/vmp/gb28181/task/SipRunner.java | 2 ++ .../iot/vmp/media/zlm/ZLMHttpHookListener.java | 7 +++++++ .../vmp/service/impl/StreamPushServiceImpl.java | 5 +++++ .../iot/vmp/storager/IRedisCatchStorage.java | 4 ++++ .../vmp/storager/impl/RedisCatchStorageImpl.java | 16 ++++++++++++++++ 7 files changed, 37 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java index 0842174d..4f3732e8 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java +++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java @@ -70,6 +70,7 @@ public class VideoManagerConstants { public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_"; public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_"; + public static final String PUSH_STREAM_LIST = "VMP_PUSH_STREAM_LIST_"; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java b/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java index 9bc86261..40803cd1 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java @@ -39,4 +39,6 @@ public class SystemInfoTimerTask { } } + + } 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 73cb9eaa..83418be0 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 @@ -129,4 +129,6 @@ public class SipRunner implements CommandLineRunner { } } } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 885126c1..bb15414f 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -392,6 +392,9 @@ public class ZLMHttpHookListener { || param.getOriginType() == OriginType.RTC_PUSH.ordinal()) { param.setSeverId(userSetting.getServerId()); zlmMediaListManager.addPush(param); + + // 冗余数据,自己系统中自用 + redisCatchStorage.addPushListItem(param.getApp(), param.getStream(), param); } } else { // 兼容流注销时类型从redis记录获取 @@ -400,6 +403,10 @@ public class ZLMHttpHookListener { if (onStreamChangedHookParam != null) { type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType(); redisCatchStorage.removeStream(mediaInfo.getId(), type, param.getApp(), param.getStream()); + if ("PUSH".equalsIgnoreCase(type)) { + // 冗余数据,自己系统中自用 + redisCatchStorage.removePushListItem(param.getApp(), param.getStream(), param.getMediaServerId()); + } } GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); if (gbStream != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index 32e9bdbe..25be5135 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -282,6 +282,8 @@ public class StreamPushServiceImpl implements IStreamPushService { redisCatchStorage.sendStreamChangeMsg(type, jsonObject); // 移除redis内流的信息 redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream()); + // 冗余数据,自己系统中自用 + redisCatchStorage.removePushListItem(offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream(), mediaServerItem.getId()); } } @@ -319,6 +321,9 @@ public class StreamPushServiceImpl implements IStreamPushService { jsonObject.put("register", false); jsonObject.put("mediaServerId", mediaServerId); redisCatchStorage.sendStreamChangeMsg(type, jsonObject); + + // 冗余数据,自己系统中自用 + redisCatchStorage.removePushListItem(onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream(), mediaServerId); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index a97e454c..b663c5c6 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -208,4 +208,8 @@ public interface IRedisCatchStorage { void sendPlatformStartPlayMsg(MessageForPushChannel messageForPushChannel); void sendPlatformStopPlayMsg(MessageForPushChannel messageForPushChannel); + + void addPushListItem(String app, String stream, OnStreamChangedHookParam param); + + void removePushListItem(String app, String stream, String mediaServerId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 0f1509f7..2871d695 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -650,4 +650,20 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { logger.info("[redis发送通知] 发送 上级平台停止观看 {}: {}/{}->{}", key, msg.getApp(), msg.getStream(), msg.getPlatFormId()); redisTemplate.convertAndSend(key, JSON.toJSON(msg)); } + + @Override + public void addPushListItem(String app, String stream, OnStreamChangedHookParam param) { + String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream; + redisTemplate.opsForValue().set(key, param); + } + + @Override + public void removePushListItem(String app, String stream, String mediaServerId) { + String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream; + OnStreamChangedHookParam param = (OnStreamChangedHookParam)redisTemplate.opsForValue().get(key); + if (param != null && param.getMediaServerId().equalsIgnoreCase(mediaServerId)) { + redisTemplate.delete(key); + } + + } }