From 1dcdbc3742835ccab28a8983ae002d2bbdba87eb Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 02 三月 2022 12:52:37 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0' into wvp-pro-record

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 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 c97b55a..9b6e727 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
@@ -28,15 +28,14 @@
 import java.util.HashMap;
 import java.util.Map;
 
-/**    
- * @description: BYE璇锋眰澶勭悊鍣�
- * @author: lawrencehj
- * @date:   2021骞�3鏈�9鏃�     
+/**
+ * SIP鍛戒护绫诲瀷锛� BYE璇锋眰
  */
 @Component
 public class ByeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
 
-	private Logger logger = LoggerFactory.getLogger(ByeRequestProcessor.class);
+	private final Logger logger = LoggerFactory.getLogger(ByeRequestProcessor.class);
+	private final String method = "BYE";
 
 	@Autowired
 	private ISIPCommander cmder;
@@ -52,8 +51,6 @@
 
 	@Autowired
 	private IMediaServerService mediaServerService;
-
-	private String method = "BYE";
 
 	@Autowired
 	private SIPProcessorObserver sipProcessorObserver;
@@ -90,18 +87,29 @@
 					MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
 					zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
 					redisCatchStorage.deleteSendRTPServer(platformGbId, channelId);
-					if (zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId) == 0) {
+					int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
+					if (totalReaderCount == 0) {
 						logger.info(streamId + "鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦");
 						cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId);
+					}else if (totalReaderCount == -1){
+						logger.warn(streamId + " 鏌ユ壘鍏跺畠瑙傜湅鑰呭け璐�");
 					}
 				}
 				// 鍙兘鏄澶囦富鍔ㄥ仠姝�
 				Device device = storager.queryVideoDeviceByChannelId(platformGbId);
 				if (device != null) {
-					StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
-					if (streamInfo != null) {
-						redisCatchStorage.stopPlay(streamInfo);
+					if (sendRtpItem.isPlay()) {
+						StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
+						if (streamInfo != null) {
+							redisCatchStorage.stopPlay(streamInfo);
+						}
+					}else {
+						StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(device.getDeviceId(), channelId);
+						if (streamInfo != null) {
+							redisCatchStorage.stopPlayback(streamInfo);
+						}
 					}
+
 					storager.stopPlay(device.getDeviceId(), channelId);
 					mediaServerService.closeRTPServer(device, channelId);
 				}

--
Gitblit v1.8.0