From ccc0a99d6894844d83d751b924cfebe74da7826c Mon Sep 17 00:00:00 2001
From: ‘sxh’ <1632740646@qq.com>
Date: 星期四, 15 六月 2023 11:20:43 +0800
Subject: [PATCH] 同步主线的代码,保持一致性

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java |   60 ++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
index 3d5c294..5677c95 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
@@ -1,6 +1,5 @@
 package com.genersoft.iot.vmp.gb28181.transmit.callback;
 
-import com.alibaba.fastjson2.JSON;
 import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
@@ -40,17 +39,21 @@
 
 	public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD";
 
+	public static final String CALLBACK_CMD_PROXY = "CALLBACK_PROXY";
+
 	public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP";
 
 	public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL";
 
-	public static final String CALLBACK_CMD_MOBILEPOSITION = "CALLBACK_MOBILEPOSITION";
+	public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION";
 
 	public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY";
 
 	public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM";
 
 	public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST";
+
+	public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP";
 
 	private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();
 
@@ -130,23 +133,52 @@
 		if (deferredResultMap == null) {
 			return;
 		}
-		Set<String> ids = deferredResultMap.keySet();
-		for (String id : ids) {
-			DeferredResultEx result = deferredResultMap.get(id);
-			if (result == null) {
+		synchronized (this) {
+			deferredResultMap = map.get(msg.getKey());
+			if (deferredResultMap == null) {
 				return;
 			}
-			if (result.getFilter() != null) {
-				Object handler = result.getFilter().handler(msg.getData());
-				System.out.println(JSON.toJSONString(handler));
-				result.getDeferredResult().setResult(handler);
-			}else {
-				result.getDeferredResult().setResult(msg.getData());
-			}
+			Set<String> ids = deferredResultMap.keySet();
+			for (String id : ids) {
+				DeferredResultEx result = deferredResultMap.get(id);
+				if (result == null) {
+					return;
+				}
+				if (result.getFilter() != null) {
+					Object handler = result.getFilter().handler(msg.getData());
+					result.getDeferredResult().setResult(handler);
+				}else {
+					result.getDeferredResult().setResult(msg.getData());
+				}
 
+			}
+			map.remove(msg.getKey());
 		}
-		map.remove(msg.getKey());
 	}
 
+	/*============================璁惧涓诲瓙鐮佹祦閫昏緫START========================*/
+	public static String getPlayKey(String deviceId,String channelId,boolean deviceSwitchSubStream,boolean isSubStream){
+		String key = null;
+		if(deviceSwitchSubStream){
+			key = CALLBACK_CMD_PLAY + isSubStream + deviceId + channelId;
+		}else {
+			key = CALLBACK_CMD_PLAY +deviceId + channelId;
+		}
+		return key;
+	}
+
+	public static String getSnapKey(String deviceId,String channelId,boolean deviceSwitchSubStream,boolean isSubStream){
+		String key = null;
+		if(deviceSwitchSubStream){
+			key = CALLBACK_CMD_SNAP + isSubStream + deviceId + channelId;
+		}else {
+			key = CALLBACK_CMD_SNAP +deviceId + channelId;
+		}
+		return key;
+	}
+
+
+	/*============================璁惧涓诲瓙鐮佹祦閫昏緫END========================*/
+
 
 }

--
Gitblit v1.8.0