From e85cef434595073b777cea8338543b93d3956b93 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 17 Apr 2024 23:23:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9Awvp=E5=9B=BD?= =?UTF-8?q?=E6=A0=87=E7=BA=A7=E8=81=94=E6=8E=A8=E6=B5=81=E6=97=B6=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/impl/InviteRequestProcessor.java | 13 +++++---- .../iot/vmp/storager/IRedisCatchStorage.java | 4 +++ .../storager/impl/RedisCatchStorageImpl.java | 27 +++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 64538db4..51c5b697 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -54,10 +54,7 @@ import javax.sip.header.CallIdHeader; import javax.sip.message.Response; import java.text.ParseException; import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.Vector; +import java.util.*; /** * SIP命令类型: INVITE请求 @@ -589,7 +586,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements sendRtpItem.setOnlyAudio(false); sendRtpItem.setStatus(0); sendRtpItem.setSessionName(sessionName); - + // 清理可能存在的缓存避免用到旧的数据 + List sendRtpItemList = redisCatchStorage.querySendRTPServer(platform.getServerGBId(), channelId, gbStream.getStream()); + if (!sendRtpItemList.isEmpty()) { + for (SendRtpItem rtpItem : sendRtpItemList) { + redisCatchStorage.deleteSendRTPServer(rtpItem); + } + } if ("push".equals(gbStream.getStreamType())) { sendRtpItem.setPlayType(InviteStreamType.PUSH); if (streamPushItem != null) { 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 0cf6c39d..6ee859aa 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -40,6 +40,8 @@ public interface IRedisCatchStorage { void updateSendRTPSever(SendRtpItem sendRtpItem); + List querySendRTPServer(String platformGbId, String channelId, String streamId); + /** * 查询RTP推送信息缓存 * @param platformGbId @@ -192,6 +194,8 @@ public interface IRedisCatchStorage { void addDiskInfo(List> diskInfo); + void deleteSendRTPServer(SendRtpItem sendRtpItem); + List queryAllSendRTPServer(); List getAllDevices(); 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 d1e80523..97e45732 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 @@ -152,6 +152,25 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { redisTemplate.opsForValue().set(key, sendRtpItem); } + @Override + public List querySendRTPServer(String platformGbId, String channelId, String streamId) { + String scanKey = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_" + + platformGbId + "_" + + channelId + "_" + + streamId + "_" + + "*"; + List result = new ArrayList<>(); + List scan = RedisUtil.scan(redisTemplate, scanKey); + if (!scan.isEmpty()) { + for (Object o : scan) { + String key = (String) o; + result.add(JsonUtil.redisJsonToObject(redisTemplate, key, SendRtpItem.class)); + } + } + return result; + } + @Override public SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) { if (platformGbId == null) { @@ -268,6 +287,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } } + /** + * 删除RTP推送信息缓存 + */ + @Override + public void deleteSendRTPServer(SendRtpItem sendRtpItem) { + deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(),sendRtpItem.getCallId(), sendRtpItem.getServerId()); + } + @Override public List queryAllSendRTPServer() { String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX