From bb22908cf7cf698853a06d51593a22eaa64e789d Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 24 三月 2021 15:39:47 +0800
Subject: [PATCH] Merge pull request #67 from lawrencehj/wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java |   34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index ba1a6f1..51f61ef 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -133,8 +133,6 @@
 		if (logger.isDebugEnabled()) {
 			logger.debug("ZLM HOOK on_publish API璋冪敤锛屽弬鏁帮細" + json.toString());
 		}
-		// String app = json.getString("app");
-		// String streamId = json.getString("id");
 
 		ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
 		if (subscribe != null) subscribe.response(json);
@@ -212,6 +210,13 @@
 		if (logger.isDebugEnabled()) {
 			logger.debug("ZLM HOOK on_shell_login API璋冪敤锛屽弬鏁帮細" + json.toString());
 		}
+		// TODO 濡傛灉鏄甫鏈塺tpstream鍒欏紑鍚寜闇�鎷夋祦
+		// String app = json.getString("app");
+		// String stream = json.getString("stream");
+
+		ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
+		if (subscribe != null) subscribe.response(json);
+
 		JSONObject ret = new JSONObject();
 		ret.put("code", 0);
 		ret.put("msg", "success");
@@ -262,20 +267,25 @@
 		}
 		
 		String streamId = json.getString("stream");
-
-		cmder.streamByeCmd(streamId);
 		StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
-		if (streamInfo!=null){
-			redisCatchStorage.stopPlay(streamInfo);
-			storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
-		}else{
-			streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
-			redisCatchStorage.stopPlayback(streamInfo);
-		}
-		
+
 		JSONObject ret = new JSONObject();
 		ret.put("code", 0);
 		ret.put("close", true);
+
+		if (streamInfo != null) {
+			if (redisCatchStorage.isChannelSendingRTP(streamInfo.getChannelId())) {
+				ret.put("close", false);
+			} else {
+				cmder.streamByeCmd(streamId);
+				redisCatchStorage.stopPlay(streamInfo);
+				storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
+			}
+		}else{
+			cmder.streamByeCmd(streamId);
+			streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
+			redisCatchStorage.stopPlayback(streamInfo);
+		}
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	

--
Gitblit v1.8.0