From acd767b47a4f78e905a3cbe89a4c82ffe88d73d9 Mon Sep 17 00:00:00 2001
From: hotcoffie <35990065+hotcoffie@users.noreply.github.com>
Date: 星期四, 21 四月 2022 10:04:50 +0800
Subject: [PATCH] Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
index e991a29..b7992e4 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
@@ -1,5 +1,13 @@
package com.genersoft.iot.vmp.gb28181.event.offline;
+import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
+import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
+import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
+import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
+import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
+import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
+import com.genersoft.iot.vmp.service.IMediaServerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -7,12 +15,14 @@
import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
+import java.util.List;
+
/**
- * @Description: 绂荤嚎浜嬩欢鐩戝惉鍣紝鐩戝惉鍒扮绾垮悗锛屼慨鏀硅澶囩鍦ㄧ嚎鐘舵�併�� 璁惧绂荤嚎鏈変袱涓潵婧愶細
- * 1銆佽澶囦富鍔ㄦ敞閿�锛屽彂閫佹敞閿�鎸囦护锛寋@link com.genersoft.iot.vmp.gb28181.transmit.request.impl.RegisterRequestProcessor}
+ * @description: 绂荤嚎浜嬩欢鐩戝惉鍣紝鐩戝惉鍒扮绾垮悗锛屼慨鏀硅澶囩鍦ㄧ嚎鐘舵�併�� 璁惧绂荤嚎鏈変袱涓潵婧愶細
+ * 1銆佽澶囦富鍔ㄦ敞閿�锛屽彂閫佹敞閿�鎸囦护锛寋@link com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.RegisterRequestProcessor}
* 2銆佽澶囨湭鐭ュ師鍥犵绾匡紝蹇冭烦瓒呮椂,{@link com.genersoft.iot.vmp.gb28181.event.offline.OfflineEventListener}
* @author: swwheihei
* @date: 2020骞�5鏈�6鏃� 涓嬪崍1:51:23
@@ -23,10 +33,27 @@
private final static Logger logger = LoggerFactory.getLogger(OfflineEventListener.class);
@Autowired
- private IVideoManagerStorager storager;
+ private IVideoManagerStorage storager;
+
+ @Autowired
+ private VideoStreamSessionManager streamSession;
@Autowired
private RedisUtil redis;
+
+ @Autowired
+ private UserSetting userSetting;
+
+ @Autowired
+ private EventPublisher eventPublisher;
+
+
+ @Autowired
+ private IMediaServerService mediaServerService;
+
+
+ @Autowired
+ private ZLMRTPServerFactory zlmrtpServerFactory;
@Override
public void onApplicationEvent(OfflineEvent event) {
@@ -35,7 +62,7 @@
logger.debug("璁惧绂荤嚎浜嬩欢瑙﹀彂锛宒eviceId锛�" + event.getDeviceId() + ",from:" + event.getFrom());
}
- String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + event.getDeviceId();
+ String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDeviceId();
switch (event.getFrom()) {
// 蹇冭烦瓒呮椂瑙﹀彂鐨勭绾夸簨浠讹紝璇存槑redis涓凡鍒犻櫎锛屾棤闇�澶勭悊
@@ -52,9 +79,22 @@
}
}
+ List<DeviceChannel> deviceChannelList = storager.queryOnlineChannelsByDeviceId(event.getDeviceId());
+ eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.OFF);
// 澶勭悊绂荤嚎鐩戝惉
storager.outline(event.getDeviceId());
- //
+ // TODO 绂荤嚎鍙栨秷璁㈤槄
+
+ // 绂荤嚎閲婃斁鎵�鏈塻src
+ List<SsrcTransaction> ssrcTransactions = streamSession.getSsrcTransactionForAll(event.getDeviceId(), null, null, null);
+ if (ssrcTransactions != null && ssrcTransactions.size() > 0) {
+ for (SsrcTransaction ssrcTransaction : ssrcTransactions) {
+ mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
+ mediaServerService.closeRTPServer(event.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
+ streamSession.remove(event.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
+ }
+ }
+
}
}
--
Gitblit v1.8.0