From 7e48d847402d2ea4da85af582529de676f30dc38 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 08 五月 2023 17:56:56 +0800
Subject: [PATCH] Merge pull request #844 from xiaoQQya/wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java | 51 ++++++++++++++++++++++++++++++++-------------------
1 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
index d7d9f6c..63999b7 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
@@ -4,6 +4,7 @@
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
+import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
@@ -52,6 +53,9 @@
@Autowired
private IRedisCatchStorage redisCatchStorage;
+
+ @Autowired
+ private SSRCFactory ssrcFactory;
@Autowired
private IMediaServerService mediaServerService;
@@ -123,8 +127,10 @@
@Override
public boolean update(ParentPlatform parentPlatform) {
+ logger.info("[鍥芥爣绾ц仈]鏇存柊骞冲彴 {}", parentPlatform.getDeviceGBId());
parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
ParentPlatform parentPlatformOld = platformMapper.getParentPlatById(parentPlatform.getId());
+ ParentPlatformCatch parentPlatformCatchOld = redisCatchStorage.queryPlatformCatchInfo(parentPlatformOld.getServerGBId());
parentPlatform.setUpdateTime(DateUtil.getNow());
if (!parentPlatformOld.getTreeType().equals(parentPlatform.getTreeType())) {
// 鐩綍缁撴瀯鍙戠敓鍙樺寲锛屾竻绌轰箣鍓嶇殑鍏宠仈鍏崇郴
@@ -134,6 +140,7 @@
platformGbStreamMapper.delByPlatformId(parentPlatformOld.getServerGBId());
}
+
// 鍋滄蹇冭烦瀹氭椂
final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatformOld.getServerGBId();
dynamicTask.stop(keepaliveTaskKey);
@@ -142,9 +149,13 @@
dynamicTask.stop(registerTaskKey);
// 娉ㄩ攢鏃х殑
try {
- commanderForPlatform.unregister(parentPlatformOld, null, eventResult -> {
- logger.info("[鍥芥爣绾ц仈] 娉ㄩ攢鎴愬姛锛� 骞冲彴锛歿}", parentPlatformOld.getServerGBId());
- });
+ if (parentPlatformOld.isStatus()) {
+ logger.info("淇濆瓨骞冲彴{}鏃跺彂鐜版晳骞冲彴鍦ㄧ嚎锛屽彂閫佹敞閿�鍛戒护", parentPlatformOld.getServerGBId());
+ commanderForPlatform.unregister(parentPlatformOld, parentPlatformCatchOld.getSipTransactionInfo(), null, eventResult -> {
+ logger.info("[鍥芥爣绾ц仈] 娉ㄩ攢鎴愬姛锛� 骞冲彴锛歿}", parentPlatformOld.getServerGBId());
+ });
+ }
+
} catch (InvalidArgumentException | ParseException | SipException e) {
logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 娉ㄩ攢: {}", e.getMessage());
}
@@ -169,6 +180,7 @@
// 淇濆瓨鏃跺惎鐢ㄥ氨鍙戦�佹敞鍐�
// 娉ㄥ唽鎴愬姛鏃剁敱绋嬪簭鐩存帴璋冪敤浜唎nline鏂规硶
try {
+ logger.info("[鍥芥爣绾ц仈] 骞冲彴娉ㄥ唽 {}", parentPlatform.getDeviceGBId());
commanderForPlatform.register(parentPlatform, eventResult -> {
logger.info("[鍥芥爣绾ц仈] {},娣诲姞鍚戜笂绾ф敞鍐屽け璐ワ紝璇风‘瀹氫笂绾у钩鍙板彲鐢ㄦ椂閲嶆柊淇濆瓨", parentPlatform.getServerGBId());
}, null);
@@ -185,36 +197,36 @@
@Override
- public void online(ParentPlatform parentPlatform) {
- logger.info("[鍥芥爣绾ц仈]锛歿}, 骞冲彴涓婄嚎/鏇存柊娉ㄥ唽", parentPlatform.getServerGBId());
+ public void online(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo) {
+ logger.info("[鍥芥爣绾ц仈]锛歿}, 骞冲彴涓婄嚎", parentPlatform.getServerGBId());
platformMapper.updateParentPlatformStatus(parentPlatform.getServerGBId(), true);
ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
- if (parentPlatformCatch != null) {
- parentPlatformCatch.getParentPlatform().setStatus(true);
- redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
- }else {
+ if (parentPlatformCatch == null) {
parentPlatformCatch = new ParentPlatformCatch();
parentPlatformCatch.setParentPlatform(parentPlatform);
parentPlatformCatch.setId(parentPlatform.getServerGBId());
parentPlatform.setStatus(true);
parentPlatformCatch.setParentPlatform(parentPlatform);
- redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
}
+
+ parentPlatformCatch.getParentPlatform().setStatus(true);
+ parentPlatformCatch.setSipTransactionInfo(sipTransactionInfo);
+ redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId();
if (!dynamicTask.isAlive(registerTaskKey)) {
+ logger.info("[鍥芥爣绾ц仈]锛歿}, 娣诲姞瀹氭椂娉ㄥ唽浠诲姟", parentPlatform.getServerGBId());
// 娣诲姞娉ㄥ唽浠诲姟
dynamicTask.startCron(registerTaskKey,
// 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
- ()-> {
- registerTask(parentPlatform);
- },
- (parentPlatform.getExpires()) *1000);
+ ()-> registerTask(parentPlatform, sipTransactionInfo),
+ parentPlatform.getExpires() * 1000);
}
final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId();
if (!dynamicTask.contains(keepaliveTaskKey)) {
+ logger.info("[鍥芥爣绾ц仈]锛歿}, 娣诲姞瀹氭椂蹇冭烦浠诲姟", parentPlatform.getServerGBId());
// 娣诲姞蹇冭烦浠诲姟
dynamicTask.startCron(keepaliveTaskKey,
()-> {
@@ -246,7 +258,7 @@
// 蹇冭烦鎴愬姛
// 娓呯┖涔嬪墠鐨勫績璺宠秴鏃惰鏁�
ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
- if (platformCatch.getKeepAliveReply() > 0) {
+ if (platformCatch != null && platformCatch.getKeepAliveReply() > 0) {
platformCatch.setKeepAliveReply(0);
redisCatchStorage.updatePlatformCatchInfo(platformCatch);
}
@@ -259,7 +271,7 @@
}
}
- private void registerTask(ParentPlatform parentPlatform){
+ private void registerTask(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo){
try {
// 璁剧疆瓒呮椂閲嶅彂锛� 鍚庣画浠庡簳灞傛敮鎸佹秷鎭噸鍙�
String key = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId() + "_timeout";
@@ -267,10 +279,10 @@
return;
}
dynamicTask.startDelay(key, ()->{
- registerTask(parentPlatform);
+ registerTask(parentPlatform, sipTransactionInfo);
}, 1000);
- logger.info("[鍥芥爣绾ц仈] 骞冲彴锛歿}娉ㄥ唽鍗冲皢鍒版湡锛岄噸鏂版敞鍐�", parentPlatform.getServerGBId());
- commanderForPlatform.register(parentPlatform, eventResult -> {
+ logger.info("[鍥芥爣绾ц仈] 骞冲彴锛歿}娉ㄥ唽鍗冲皢鍒版湡锛屽紑濮嬬画璁�", parentPlatform.getServerGBId());
+ commanderForPlatform.register(parentPlatform, sipTransactionInfo, eventResult -> {
dynamicTask.stop(key);
offline(parentPlatform, false);
},eventResult -> {
@@ -320,6 +332,7 @@
List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServer(platformId);
if (sendRtpItems != null && sendRtpItems.size() > 0) {
for (SendRtpItem sendRtpItem : sendRtpItems) {
+ ssrcFactory.releaseSsrc(sendRtpItem.getMediaServerId(), sendRtpItem.getSsrc());
redisCatchStorage.deleteSendRTPServer(platformId, sendRtpItem.getChannelId(), null, null);
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
Map<String, Object> param = new HashMap<>(3);
--
Gitblit v1.8.0