From 4f26bd71769f6fc0e1e0da17b22d43eaebedbed8 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 16 八月 2023 16:39:44 +0800
Subject: [PATCH] 优化级联语音对讲释放逻辑

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
index 75fbea3..a00a99c 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
@@ -72,7 +72,7 @@
 	private IVideoManagerStorage storager;
 
 	@Autowired
-	private ZLMServerFactory ZLMServerFactory;
+	private ZLMServerFactory zlmServerFactory;
 
 	@Autowired
 	private SSRCFactory ssrcFactory;
@@ -114,18 +114,19 @@
 		SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
 
 		if (sendRtpItem != null){
-			logger.info("[鏀跺埌bye] 鏉ヨ嚜骞冲彴{}锛� 鍋滄閫氶亾锛歿}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId());
+			logger.info("[鏀跺埌bye] 鏉ヨ嚜{}锛屽仠姝㈤�氶亾锛歿}, 绫诲瀷锛� {}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), sendRtpItem.getPlayType());
+
 			String streamId = sendRtpItem.getStream();
 			Map<String, Object> param = new HashMap<>();
 			param.put("vhost","__defaultVhost__");
 			param.put("app",sendRtpItem.getApp());
 			param.put("stream",streamId);
 			param.put("ssrc",sendRtpItem.getSsrc());
-			logger.info("[鏀跺埌bye] 鍋滄鍚戜笂绾ф帹娴侊細{}", streamId);
+			logger.info("[鏀跺埌bye] 鍋滄鎺ㄦ祦锛歿}", streamId);
 			MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
 			redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(),
 					callIdHeader.getCallId(), null);
-			ZLMServerFactory.stopSendRtpStream(mediaInfo, param);
+			zlmServerFactory.stopSendRtpStream(mediaInfo, param);
 			if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) {
 				ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
 				if (platform != null) {
@@ -137,9 +138,17 @@
 				}else {
 					logger.info("[涓婄骇骞冲彴鍋滄瑙傜湅] 鏈壘鍒板钩鍙皗}鐨勪俊鎭紝鍙戦�乺edis娑堟伅澶辫触", sendRtpItem.getPlatformId());
 				}
+			}else if (sendRtpItem.getPlayType().equals(InviteStreamType.BROADCAST)
+					|| sendRtpItem.getPlayType().equals(InviteStreamType.TALK)) {
+				AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+				if (audioBroadcastCatch != null) {
+					// 鏉ヨ嚜涓婄骇骞冲彴鐨勫仠姝㈠璁�
+					logger.info("[鍋滄瀵硅] 鏉ヨ嚜涓婄骇锛屽钩鍙帮細{}, 閫氶亾锛歿}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+					audioBroadcastManager.del(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+				}
 			}
 
-			int totalReaderCount = ZLMServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
+			int totalReaderCount = zlmServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
 			if (totalReaderCount <= 0) {
 				logger.info("[鏀跺埌bye] {} 鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦", streamId);
 				if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
@@ -148,7 +157,7 @@
 						logger.info("[鏀跺埌bye] {} 閫氱煡璁惧鍋滄鎺ㄦ祦鏃舵湭鎵惧埌璁惧淇℃伅", streamId);
 					}
 					try {
-						logger.warn("[鍋滄鐐规挱] {}/{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+						logger.info("[鍋滄鐐规挱] {}/{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
 						cmder.streamByeCmd(device, sendRtpItem.getChannelId(), streamId, null);
 					} catch (InvalidArgumentException | ParseException | SipException |
 							 SsrcTransactionNotFoundException e) {

--
Gitblit v1.8.0