From ea08969bfcff38b8195282c77495eb1f8bd8eb07 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 15 三月 2022 15:37:22 +0800
Subject: [PATCH] 使用zlm原生的rtp随机端口配置

---
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java |   48 ++++++++++++++++++++++--------------------------
 1 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
index 2346ab3..930bb33 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
@@ -88,7 +88,7 @@
 		// 鑾峰彇鍙敤鐨剒lm
 		Device device = storager.queryVideoDevice(deviceId);
 		MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
-		PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null);
+		PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null);
 
 		return playResult.getResult();
 	}
@@ -109,27 +109,24 @@
 		// 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ
 		String key = DeferredResultHolder.CALLBACK_CMD_STOP + deviceId + channelId;
 		resultHolder.put(key, uuid, result);
-		Device device = storager.queryVideoDevice(deviceId);
-		cmder.streamByeCmd(deviceId, channelId, (event) -> {
-			StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
-			if (streamInfo == null) {
-				RequestMessage msg = new RequestMessage();
-				msg.setId(uuid);
-				msg.setKey(key);
-				msg.setData("鐐规挱鏈壘鍒�");
-				resultHolder.invokeAllResult(msg);
-				storager.stopPlay(deviceId, channelId);
-			}else {
-				redisCatchStorage.stopPlay(streamInfo);
-				storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
-				RequestMessage msg = new RequestMessage();
-				msg.setId(uuid);
-				msg.setKey(key);
-				//Response response = event.getResponse();
-				msg.setData(String.format("success"));
-				resultHolder.invokeAllResult(msg);
-			}
-			mediaServerService.closeRTPServer(device, channelId);
+		StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
+		if (streamInfo == null) {
+			RequestMessage msg = new RequestMessage();
+			msg.setId(uuid);
+			msg.setKey(key);
+			msg.setData("鐐规挱鏈壘鍒�");
+			resultHolder.invokeAllResult(msg);
+			storager.stopPlay(deviceId, channelId);
+			return result;
+		}
+		cmder.streamByeCmd(deviceId, channelId, streamInfo.getStream(), null, eventResult -> {
+			redisCatchStorage.stopPlay(streamInfo);
+			storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
+			RequestMessage msgForSuccess = new RequestMessage();
+			msgForSuccess.setId(uuid);
+			msgForSuccess.setKey(key);
+			msgForSuccess.setData(String.format("success"));
+			resultHolder.invokeAllResult(msgForSuccess);
 		});
 
 		if (deviceId != null || channelId != null) {
@@ -175,7 +172,7 @@
 	public ResponseEntity<String> playConvert(@PathVariable String streamId) {
 		StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
 		if (streamInfo == null) {
-			streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
+			streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
 		}
 		if (streamInfo == null) {
 			logger.warn("瑙嗛杞爜API璋冪敤澶辫触锛�, 瑙嗛娴佸凡缁忓仠姝�!");
@@ -287,7 +284,6 @@
 			return result;
 		}
 		cmder.audioBroadcastCmd(device, (event) -> {
-			Response response = event.getResponse();
 			RequestMessage msg = new RequestMessage();
 			msg.setKey(key);
 			msg.setId(uuid);
@@ -295,7 +291,7 @@
 			json.put("DeviceID", deviceId);
 			json.put("CmdType", "Broadcast");
 			json.put("Result", "Failed");
-			json.put("Description", String.format("璇煶骞挎挱鎿嶄綔澶辫触锛岄敊璇爜锛� %s, %s", response.getStatusCode(), response.getReasonPhrase()));
+			json.put("Description", String.format("璇煶骞挎挱鎿嶄綔澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg));
 			msg.setData(json);
 			resultHolder.invokeResult(msg);
 		});
@@ -330,7 +326,7 @@
 			jsonObject.put("deviceId", transaction.getDeviceId());
 			jsonObject.put("channelId", transaction.getChannelId());
 			jsonObject.put("ssrc", transaction.getSsrc());
-			jsonObject.put("streamId", transaction.getStreamId());
+			jsonObject.put("streamId", transaction.getStream());
 			objects.add(jsonObject);
 		}
 

--
Gitblit v1.8.0