From f525b5572988326c4b73da9f68e7ee7e292a2e46 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 12 七月 2023 15:13:53 +0800
Subject: [PATCH] 修复发流复盖的为问题
---
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