From f3ea07bdcd722d667e16b7a880f41a30b9374732 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 14 六月 2024 17:03:55 +0800
Subject: [PATCH] 调整转码后的流的输出位置

---
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java |   53 +++++++++--------------------------------------------
 1 files changed, 9 insertions(+), 44 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 4324175..8e1207a 100755
--- 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
@@ -37,6 +37,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.context.request.async.DeferredResult;
 
@@ -147,14 +148,21 @@
 						}
 						streamInfo.channgeStreamIp(host);
 					}
+					if (!ObjectUtils.isEmpty(newMediaServerItem.getTranscodeSuffix()) && !"null".equalsIgnoreCase(newMediaServerItem.getTranscodeSuffix())) {
+						streamInfo.setStream(streamInfo.getStream() + "_" + newMediaServerItem.getTranscodeSuffix());
+					}
 					wvpResult.setData(new StreamContent(streamInfo));
+				}else {
+					wvpResult.setCode(code);
+					wvpResult.setMsg(msg);
 				}
 			}else {
 				wvpResult.setCode(code);
 				wvpResult.setMsg(msg);
 			}
 			requestMessage.setData(wvpResult);
-			resultHolder.invokeResult(requestMessage);
+			// 姝ゅ蹇呴』閲婃斁鎵�鏈夎姹�
+			resultHolder.invokeAllResult(requestMessage);
 		});
 		return result;
 	}
@@ -198,49 +206,6 @@
 		json.put("channelId", channelId);
 		json.put("isSubStream", isSubStream);
 		return json;
-	}
-
-	/**
-	 * 灏嗕笉鏄痟264鐨勮棰戦�氳繃ffmpeg 杞爜涓篽264 + aac
-	 * @param streamId 娴両D
-	 */
-	@Operation(summary = "灏嗕笉鏄痟264鐨勮棰戦�氳繃ffmpeg 杞爜涓篽264 + aac", security = @SecurityRequirement(name = JwtUtils.HEADER))
-	@Parameter(name = "streamId", description = "瑙嗛娴両D", required = true)
-	@PostMapping("/convert/{streamId}")
-	public JSONObject playConvert(@PathVariable String streamId) {
-//		StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
-
-		InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, streamId);
-		if (inviteInfo == null || inviteInfo.getStreamInfo() == null) {
-			logger.warn("瑙嗛杞爜API璋冪敤澶辫触锛�, 瑙嗛娴佸凡缁忓仠姝�!");
-			throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏈壘鍒拌棰戞祦淇℃伅, 瑙嗛娴佸彲鑳藉凡缁忓仠姝�");
-		}
-		MediaServerItem mediaInfo = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId());
-		JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
-		if (!rtpInfo.getBoolean("exist")) {
-			logger.warn("瑙嗛杞爜API璋冪敤澶辫触锛�, 瑙嗛娴佸凡鍋滄鎺ㄦ祦!");
-			throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏈壘鍒拌棰戞祦淇℃伅, 瑙嗛娴佸彲鑳藉凡鍋滄鎺ㄦ祦");
-		} else {
-			String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(),
-					streamId );
-			String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId);
-			JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(mediaInfo, srcUrl, dstUrl, "1000000", true, false, null);
-			logger.info(jsonObject.toJSONString());
-			if (jsonObject != null && jsonObject.getInteger("code") == 0) {
-				JSONObject data = jsonObject.getJSONObject("data");
-				if (data != null) {
-					JSONObject result = new JSONObject();
-					result.put("key", data.getString("key"));
-					StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false);
-					result.put("StreamInfo", streamInfoResult);
-					return result;
-				}else {
-					throw new ControllerException(ErrorCode.ERROR100.getCode(), "杞爜澶辫触");
-				}
-			}else {
-				throw new ControllerException(ErrorCode.ERROR100.getCode(), "杞爜澶辫触");
-			}
-		}
 	}
 
 	/**

--
Gitblit v1.8.0