Commit 5c49627012996aedb802b81e64c4776f9874f0a7
1 parent
287d42c1
优化发流端口分配
Showing
1 changed file
with
7 additions
and
6 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java
| @@ -36,6 +36,13 @@ public class SendRtpPortManager { | @@ -36,6 +36,13 @@ public class SendRtpPortManager { | ||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public int getNextPort(String mediaServerId) { | 38 | public int getNextPort(String mediaServerId) { |
| 39 | + String sendIndexKey = KEY + userSetting.getServerId() + "_" + mediaServerId; | ||
| 40 | + MediaSendRtpPortInfo mediaSendRtpPortInfo = (MediaSendRtpPortInfo)redisTemplate.opsForValue().get(sendIndexKey); | ||
| 41 | + if (mediaSendRtpPortInfo == null) { | ||
| 42 | + logger.warn("[发送端口管理] 获取{}的发送端口时未找到端口信息", mediaSendRtpPortInfo); | ||
| 43 | + return 0; | ||
| 44 | + } | ||
| 45 | + | ||
| 39 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX | 46 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX |
| 40 | + userSetting.getServerId() + "_*"; | 47 | + userSetting.getServerId() + "_*"; |
| 41 | List<Object> queryResult = RedisUtil.scan(redisTemplate, key); | 48 | List<Object> queryResult = RedisUtil.scan(redisTemplate, key); |
| @@ -48,12 +55,6 @@ public class SendRtpPortManager { | @@ -48,12 +55,6 @@ public class SendRtpPortManager { | ||
| 48 | } | 55 | } |
| 49 | } | 56 | } |
| 50 | 57 | ||
| 51 | - String sendIndexKey = KEY + userSetting.getServerId() + "_" + mediaServerId; | ||
| 52 | - MediaSendRtpPortInfo mediaSendRtpPortInfo = (MediaSendRtpPortInfo)redisTemplate.opsForValue().get(sendIndexKey); | ||
| 53 | - if (mediaSendRtpPortInfo == null) { | ||
| 54 | - logger.warn("[发送端口管理] 获取{}的发送端口时未找到端口信息", mediaSendRtpPortInfo); | ||
| 55 | - return 0; | ||
| 56 | - } | ||
| 57 | int port = getPort(mediaSendRtpPortInfo.getCurrent(), | 58 | int port = getPort(mediaSendRtpPortInfo.getCurrent(), |
| 58 | mediaSendRtpPortInfo.getStart(), | 59 | mediaSendRtpPortInfo.getStart(), |
| 59 | mediaSendRtpPortInfo.getEnd(), checkPort -> sendRtpItemMap.get(checkPort) == null); | 60 | mediaSendRtpPortInfo.getEnd(), checkPort -> sendRtpItemMap.get(checkPort) == null); |