From a39ac45bcc7fbddbb578e0ab39fd109e30d214a4 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 20 七月 2023 17:18:11 +0800
Subject: [PATCH] 扩展兼容接口,支持HTTPS接口

---
 src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

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 94ed200..789974b 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
@@ -11,10 +11,7 @@
 import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
-import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils;
-import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
-import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
-import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
+import com.genersoft.iot.vmp.media.zlm.*;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
 import com.genersoft.iot.vmp.service.IMediaServerService;
@@ -70,6 +67,10 @@
     private UserSetting userSetting;
 
     @Autowired
+    private SendRtpPortManager sendRtpPortManager;
+
+
+    @Autowired
     private AssistRESTfulUtils assistRESTfulUtils;
 
     @Autowired
@@ -115,13 +116,40 @@
             if (ssrcFactory.hasMediaServerSSRC(mediaServerItem.getId())) {
                 ssrcFactory.initMediaServerSSRC(mediaServerItem.getId(), null);
             }
+            if (userSetting.getGbSendStreamStrict()) {
+                int startPort = 50000;
+                int endPort = 60000;
+                String sendRtpPortRange = mediaServerItem.getSendRtpPortRange();
+                if (sendRtpPortRange == null) {
+                    logger.warn("[zlm] ] 鏈厤缃彂娴佺鍙h寖鍥达紝榛樿浣跨敤50000鍒�60000");
+                }else {
+                    String[] sendRtpPortRangeArray = sendRtpPortRange.trim().split(",");
+                    if (sendRtpPortRangeArray.length != 2) {
+                        logger.warn("[zlm] ] 鍙戞祦绔彛鑼冨洿閿欒锛岄粯璁や娇鐢�50000鍒�60000");
+                    }else {
+                        try {
+                            startPort = Integer.parseInt(sendRtpPortRangeArray[0]);
+                            endPort = Integer.parseInt(sendRtpPortRangeArray[1]);
+                            if (endPort <= startPort) {
+                                logger.warn("[zlm] ] 鍙戞祦绔彛鑼冨洿閿欒锛岀粨鏉熺鍙e簲澶т簬寮�濮嬬鍙�,浣跨敤榛樿绔彛");
+                                startPort = 50000;
+                                endPort = 60000;
+                            }
+
+                        }catch (NumberFormatException e) {
+                            logger.warn("[zlm] ] 鍙戞祦绔彛鑼冨洿閿欒锛岄粯璁や娇鐢�50000鍒�60000");
+                        }
+                    }
+                }
+                logger.info("[[zlm] ] 閰嶇疆鍙戞祦绔彛鑼冨洿锛寋}-{}", startPort, endPort);
+                sendRtpPortManager.initServerPort(mediaServerItem.getId(), startPort, endPort);
+            }
             // 鏌ヨredis鏄惁瀛樺湪姝ediaServer
             String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId();
             Boolean hasKey = redisTemplate.hasKey(key);
             if (hasKey != null && ! hasKey) {
                 redisTemplate.opsForValue().set(key, mediaServerItem);
             }
-
         }
     }
 
@@ -409,7 +437,7 @@
         }
         final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + serverItem.getId();
         dynamicTask.stop(zlmKeepaliveKey);
-        dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(serverItem), (Math.getExponent(serverItem.getHookAliveInterval()) + 5) * 1000);
+        dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(serverItem), (serverItem.getHookAliveInterval().intValue() + 5) * 1000);
         publisher.zlmOnlineEventPublish(serverItem.getId());
 
         logger.info("[ZLM] 杩炴帴鎴愬姛 {} - {}:{} ",

--
Gitblit v1.8.0