From 5f7c53823a38ef8a840dff57a01cad70d645dc88 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 17 Nov 2022 18:21:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E8=BF=87=E6=9C=9F=E7=9A=84?= =?UTF-8?q?=E6=8E=A8=E6=B5=81=E9=89=B4=E6=9D=83=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/service/impl/StreamPushServiceImpl.java | 15 +++++++++++++++ .../iot/vmp/storager/IRedisCatchStorage.java | 2 ++ .../vmp/storager/impl/RedisCatchStorageImpl.java | 12 ++++++++++++ 3 files changed, 29 insertions(+) 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 ffbcb42b..45166de5 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -221,6 +221,12 @@ public class StreamPushServiceImpl implements IStreamPushService { streamInfoPushItemMap.put(onStreamChangedHookParam.getApp() + onStreamChangedHookParam.getStream(), onStreamChangedHookParam); } } + // 获取所有推流鉴权信息,清理过期的 + List allStreamAuthorityInfo = redisCatchStorage.getAllStreamAuthorityInfo(); + Map streamAuthorityInfoInfoMap = new HashMap<>(); + for (StreamAuthorityInfo streamAuthorityInfo : allStreamAuthorityInfo) { + streamAuthorityInfoInfoMap.put(streamAuthorityInfo.getApp() + streamAuthorityInfo.getStream(), streamAuthorityInfo); + } zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ if (mediaList == null) { return; @@ -239,6 +245,7 @@ public class StreamPushServiceImpl implements IStreamPushService { for (StreamPushItem streamPushItem : streamPushItems) { pushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); streamInfoPushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); + streamAuthorityInfoInfoMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); } } List offlinePushItems = new ArrayList<>(pushItemMap.values()); @@ -274,6 +281,14 @@ public class StreamPushServiceImpl implements IStreamPushService { redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream()); } } + + Collection streamAuthorityInfos = streamAuthorityInfoInfoMap.values(); + if (streamAuthorityInfos.size() > 0) { + for (StreamAuthorityInfo streamAuthorityInfo : streamAuthorityInfos) { + // 移除redis内流的信息 + redisCatchStorage.removeStreamAuthorityInfo(streamAuthorityInfo.getApp(), streamAuthorityInfo.getStream()); + } + } })); } 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 f9a223c7..15b6d807 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -233,6 +233,8 @@ public interface IRedisCatchStorage { */ StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream); + List getAllStreamAuthorityInfo(); + /** * 发送redis消息 查询所有推流设备的状态 */ 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 ca2e348c..8cf5293b 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -714,6 +714,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } + @Override + public List getAllStreamAuthorityInfo() { + String scanKey = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_*_*" ; + List result = new ArrayList<>(); + List keys = RedisUtil.scan(scanKey); + for (Object o : keys) { + String key = (String) o; + result.add((StreamAuthorityInfo) RedisUtil.get(key)); + } + return result; + } + @Override public OnStreamChangedHookParam getStreamInfo(String app, String streamId, String mediaServerId) {