From 9ff1613d3b39475a72b1f5ed10db525bb9f5db6e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 30 May 2023 10:54:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dweb=E7=AB=AF=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E8=8A=82=E7=82=B9=E8=B4=9F=E8=BD=BD=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=9B=BD=E6=A0=87=E6=94=B6=E6=B5=81=20#871?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/IInviteStreamService.java | 5 +++++ .../service/impl/InviteStreamServiceImpl.java | 19 +++++++++++++++++++ .../service/impl/MediaServerServiceImpl.java | 7 ++++++- .../iot/vmp/storager/IRedisCatchStorage.java | 2 -- .../storager/impl/RedisCatchStorageImpl.java | 9 --------- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java b/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java index fd388393..852a4089 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java @@ -65,4 +65,9 @@ public interface IInviteStreamService { * 清空一个设备的所有invite信息 */ void clearInviteInfo(String deviceId); + + /** + * 统计同一个zlm下的国标收流个数 + */ + int getStreamInfoCount(String mediaServerId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java index 19e82d49..2fb68164 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java @@ -179,4 +179,23 @@ public class InviteStreamServiceImpl implements IInviteStreamService { public void clearInviteInfo(String deviceId) { removeInviteInfo(null, deviceId, null, null); } + + @Override + public int getStreamInfoCount(String mediaServerId) { + int count = 0; + String key = VideoManagerConstants.INVITE_PREFIX + "_*_*_*_*"; + List scanResult = RedisUtil.scan(redisTemplate, key); + if (scanResult.size() == 0) { + return 0; + }else { + for (Object keyObj : scanResult) { + String keyStr = (String) keyObj; + InviteInfo inviteInfo = (InviteInfo) redisTemplate.opsForValue().get(keyStr); + if (inviteInfo != null && inviteInfo.getStreamInfo() != null && inviteInfo.getStreamInfo().getMediaServerId().equals(mediaServerId)) { + count++; + } + } + } + return count; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 230ce277..d997a43b 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -17,6 +17,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; +import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.service.bean.SSRCInfo; @@ -97,6 +98,9 @@ public class MediaServerServiceImpl implements IMediaServerService { @Autowired private IRedisCatchStorage redisCatchStorage; + @Autowired + private IInviteStreamService inviteStreamService; + @Autowired private RedisTemplate redisTemplate; @@ -735,7 +739,8 @@ public class MediaServerServiceImpl implements IMediaServerService { result.setId(mediaServerItem.getId()); result.setPush(redisCatchStorage.getPushStreamCount(mediaServerItem.getId())); result.setProxy(redisCatchStorage.getProxyStreamCount(mediaServerItem.getId())); - result.setGbReceive(redisCatchStorage.getGbReceiveCount(mediaServerItem.getId())); + + result.setGbReceive(inviteStreamService.getStreamInfoCount(mediaServerItem.getId())); result.setGbSend(redisCatchStorage.getGbSendCount(mediaServerItem.getId())); return result; } 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 ec93e78a..5e6c16b3 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -191,8 +191,6 @@ public interface IRedisCatchStorage { int getProxyStreamCount(String id); - int getGbReceiveCount(String id); - int getGbSendCount(String id); void addDiskInfo(List> diskInfo); 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 e9dbd3b2..75e91982 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 @@ -586,15 +586,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { return RedisUtil.scan(redisTemplate, key).size(); } - @Override - public int getGbReceiveCount(String id) { - String playKey = VideoManagerConstants.PLAYER_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*"; - String playBackKey = VideoManagerConstants.PLAY_BLACK_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*"; - String downloadKey = VideoManagerConstants.DOWNLOAD_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*"; - - return RedisUtil.scan(redisTemplate, playKey).size() + RedisUtil.scan(redisTemplate, playBackKey).size() + RedisUtil.scan(redisTemplate, downloadKey).size(); - } - @Override public int getGbSendCount(String id) { String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX