From 14699711028f0d157eddfb0432e26ab91f1b4493 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 22 十一月 2022 15:02:25 +0800
Subject: [PATCH] 支持配置设备上线时自动更新查询通道,修复通道刷新进度展示

---
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java |   53 +++++++++++++++++++++++++++--------------------------
 1 files changed, 27 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 87e203a..9fed0c5 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
@@ -83,20 +83,6 @@
 	public DeferredResult<WVPResult<StreamInfo>> play(HttpServletRequest request, @PathVariable String deviceId,
 													  @PathVariable String channelId) {
 
-		String localAddr = request.getLocalAddr();
-		String localName = request.getLocalName();
-		String remoteHost = request.getRemoteHost();
-		String remoteAddr = request.getRemoteAddr();
-		String remoteUser = request.getRemoteUser();
-		String requestURI = request.getRequestURI();
-		System.out.println(3333333);
-		System.out.println(localAddr);
-		System.out.println(localName);
-		System.out.println(remoteHost);
-		System.out.println(remoteAddr);
-		System.out.println(remoteUser);
-		System.out.println(requestURI);
-		System.out.println(4444444);
 		// 鑾峰彇鍙敤鐨剒lm
 		Device device = storager.queryVideoDevice(deviceId);
 		MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
@@ -110,17 +96,34 @@
 		DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
 		DeferredResultEx<WVPResult<StreamInfo>> deferredResultEx = new DeferredResultEx<>(result);
 
-		deferredResultEx.setFilter(result1 -> {
-			System.out.println(1111);
-			System.out.println(request.getLocalName());
-			WVPResult<StreamInfo> wvpResult = (WVPResult<StreamInfo>)result1;
-			if (wvpResult.getCode() == ErrorCode.SUCCESS.getCode()) {
-				StreamInfo data = wvpResult.getData();
-				data.channgeStreamIp(request.getLocalName());
-				((WVPResult<StreamInfo>)result1).setData(data);
-			}
-			return result1;
+		result.onTimeout(()->{
+			logger.info("鐐规挱鎺ュ彛绛夊緟瓒呮椂");
+			// 閲婃斁rtpserver
+			WVPResult<StreamInfo> wvpResult = new WVPResult<>();
+			wvpResult.setCode(ErrorCode.ERROR100.getCode());
+			wvpResult.setMsg("鐐规挱瓒呮椂");
+			msg.setData(wvpResult);
+			resultHolder.invokeResult(msg);
 		});
+
+		if (userSetting.getUseSourceIpAsStreamIp()) {
+			// TODO 鍦ㄧ偣鎾湭鎴愬姛鐨勬儏鍐典笅鍦ㄦ璋冪敤鎺ュ彛鐐规挱浼氬鑷磋繑鍥炵殑娴佸湴鍧�ip閿欒
+			deferredResultEx.setFilter(result1 -> {
+				WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1;
+				WVPResult<StreamInfo> clone = null;
+				try {
+					clone = (WVPResult<StreamInfo>)wvpResult1.clone();
+				} catch (CloneNotSupportedException e) {
+					throw new RuntimeException(e);
+				}
+				if (clone.getCode() == ErrorCode.SUCCESS.getCode()) {
+					StreamInfo data = clone.getData().clone();
+					data.channgeStreamIp(request.getLocalName());
+					clone.setData(data);
+				}
+				return clone;
+			});
+		}
 
 		// 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ
 		resultHolder.put(key, uuid, deferredResultEx);
@@ -130,7 +133,6 @@
 		}
 		return result;
 	}
-
 
 	@Operation(summary = "鍋滄鐐规挱")
 	@Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
@@ -168,7 +170,6 @@
 		json.put("deviceId", deviceId);
 		json.put("channelId", channelId);
 		return json;
-
 	}
 
 	/**

--
Gitblit v1.8.0