From 221f99c764b51c3cd284c6e5a41492c26c5c7ffc Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 09 九月 2022 17:06:19 +0800
Subject: [PATCH] 优化sip消息

---
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java
index e9b9ef7..33c02ad 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java
@@ -3,20 +3,18 @@
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
-import com.genersoft.iot.vmp.service.IMediaServerService;
+import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.service.IPlayService;
 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
+import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -29,6 +27,9 @@
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.springframework.web.context.request.async.DeferredResult;
 
+/**
+ * @author lin
+ */
 @Tag(name = "瑙嗛鍥炴斁")
 @CrossOrigin
 @RestController
@@ -58,18 +59,24 @@
 	@Parameter(name = "startTime", description = "寮�濮嬫椂闂�", required = true)
 	@Parameter(name = "endTime", description = "缁撴潫鏃堕棿", required = true)
 	@GetMapping("/start/{deviceId}/{channelId}")
-	public DeferredResult<String> play(@PathVariable String deviceId, @PathVariable String channelId,
-													   String startTime,String endTime) {
+	public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId, @PathVariable String channelId,
+										  String startTime, String endTime) {
 
 		if (logger.isDebugEnabled()) {
 			logger.debug(String.format("璁惧鍥炴斁 API璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s", deviceId, channelId));
 		}
 
-		DeferredResult<String> result = playService.playBack(deviceId, channelId, startTime, endTime, null, wvpResult->{
-			resultHolder.invokeResult(wvpResult.getData());
-		});
 
-		return result;
+		return playService.playBack(deviceId, channelId, startTime, endTime, null,
+				playBackResult->{
+					if (playBackResult.getCode() != ErrorCode.SUCCESS.getCode()) {
+						RequestMessage data = playBackResult.getData();
+						data.setData(WVPResult.fail(playBackResult.getCode(), playBackResult.getMsg()));
+						resultHolder.invokeResult(data);
+					}else {
+						resultHolder.invokeResult(playBackResult.getData());
+					}
+				});
 	}
 
 
@@ -109,10 +116,8 @@
 	@GetMapping("/resume/{streamId}")
 	public void playResume(@PathVariable String streamId) {
 		logger.info("playResume: "+streamId);
-		JSONObject json = new JSONObject();
 		StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
 		if (null == streamInfo) {
-			json.put("msg", "streamId涓嶅瓨鍦�");
 			logger.warn("streamId涓嶅瓨鍦�!");
 			throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId涓嶅瓨鍦�");
 		}

--
Gitblit v1.8.0