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