瀏覽代碼

优化发流端口分配

648540858 2 年之前
父節點
當前提交
5c49627012
共有 1 個文件被更改,包括 7 次插入6 次删除
  1. 7 6
      src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java

+ 7 - 6
src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java

@@ -36,6 +36,13 @@ public class SendRtpPortManager {
     }
 
     public int getNextPort(String mediaServerId) {
+        String sendIndexKey = KEY + userSetting.getServerId() + "_" +  mediaServerId;
+        MediaSendRtpPortInfo mediaSendRtpPortInfo = (MediaSendRtpPortInfo)redisTemplate.opsForValue().get(sendIndexKey);
+        if (mediaSendRtpPortInfo == null) {
+            logger.warn("[发送端口管理] 获取{}的发送端口时未找到端口信息", mediaSendRtpPortInfo);
+            return 0;
+        }
+
         String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
                 + userSetting.getServerId() + "_*";
         List<Object> queryResult = RedisUtil.scan(redisTemplate, key);
@@ -48,12 +55,6 @@ public class SendRtpPortManager {
             }
         }
 
-        String sendIndexKey = KEY + userSetting.getServerId() + "_" +  mediaServerId;
-        MediaSendRtpPortInfo mediaSendRtpPortInfo = (MediaSendRtpPortInfo)redisTemplate.opsForValue().get(sendIndexKey);
-        if (mediaSendRtpPortInfo == null) {
-            logger.warn("[发送端口管理] 获取{}的发送端口时未找到端口信息", mediaSendRtpPortInfo);
-            return 0;
-        }
         int port = getPort(mediaSendRtpPortInfo.getCurrent(),
                 mediaSendRtpPortInfo.getStart(),
                 mediaSendRtpPortInfo.getEnd(), checkPort -> sendRtpItemMap.get(checkPort) == null);