From d881c982247d66139f5a941d7021743ad0c6b43c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期六, 10 十月 2020 17:33:02 +0800
Subject: [PATCH] web页面集成

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java |   82 +++++++++++++++++++++++++----------------
 1 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index 25f000b..2d6b8e7 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -1,7 +1,14 @@
 package com.genersoft.iot.vmp.media.zlm;
 
 import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.genersoft.iot.vmp.conf.MediaServerConfig;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.utils.IpUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,9 +23,11 @@
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 
+import javax.servlet.http.HttpServletRequest;
+
 /**    
  * @Description:閽堝 ZLMediaServer鐨刪ook浜嬩欢鐩戝惉
- * @author: songww
+ * @author: swwheihei
  * @date:   2020骞�5鏈�8鏃� 涓婂崍10:46:48     
  */
 @RestController
@@ -29,6 +38,9 @@
 	
 	@Autowired
 	private SIPCommander cmder;
+
+	@Autowired
+	private IVideoManagerStorager storager;
 	
 	/**
 	 * 娴侀噺缁熻浜嬩欢锛屾挱鏀惧櫒鎴栨帹娴佸櫒鏂紑鏃跺苟涓旇�楃敤娴侀噺瓒呰繃鐗瑰畾闃堝�兼椂浼氳Е鍙戞浜嬩欢锛岄槇鍊奸�氳繃閰嶇疆鏂囦欢general.flowThreshold閰嶇疆锛涙浜嬩欢瀵瑰洖澶嶄笉鏁忔劅銆�
@@ -45,8 +57,8 @@
 		
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
+		ret.put("code", 0);
+		ret.put("msg", "success");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -64,10 +76,10 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("err", "");
-		json.put("path", "");
-		json.put("second", 600);
+		ret.put("code", 0);
+		ret.put("err", "");
+		ret.put("path", "");
+		ret.put("second", 600);
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -85,8 +97,8 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
+		ret.put("code", 0);
+		ret.put("msg", "success");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -104,11 +116,11 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
-		json.put("enableHls", true);
-		json.put("enableMP4", false);
-		json.put("enableRtxp", true);
+		ret.put("code", 0);
+		ret.put("msg", "success");
+		ret.put("enableHls", true);
+		ret.put("enableMP4", false);
+		ret.put("enableRtxp", true);
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -126,8 +138,8 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
+		ret.put("code", 0);
+		ret.put("msg", "success");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -145,8 +157,8 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("realm", "");
+		ret.put("code", 0);
+		ret.put("realm", "");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -165,9 +177,9 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("encrypted", false);
-		json.put("passwd", "test");
+		ret.put("code", 0);
+		ret.put("encrypted", false);
+		ret.put("passwd", "test");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -185,8 +197,8 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
+		ret.put("code", 0);
+		ret.put("msg", "success");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -204,8 +216,8 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
+		ret.put("code", 0);
+		ret.put("msg", "success");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -228,8 +240,8 @@
 		cmder.streamByeCmd(ssrc);
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("close", true);
+		ret.put("code", 0);
+		ret.put("close", true);
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -247,8 +259,8 @@
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
+		ret.put("code", 0);
+		ret.put("msg", "success");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 	
@@ -258,16 +270,22 @@
 	 */
 	@ResponseBody
 	@PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8")
-	public ResponseEntity<String> onServerStarted(@RequestBody JSONObject json){
+	public ResponseEntity<String> onServerStarted(HttpServletRequest request, @RequestBody JSONObject json){
 		
 		if (logger.isDebugEnabled()) {
 			logger.debug("ZLM HOOK on_server_started API璋冪敤锛屽弬鏁帮細" + json.toString());
 		}
+
+//		String data = json.getString("data");
+//		List<MediaServerConfig> mediaServerConfigs = JSON.parseArray(JSON.toJSONString(json), MediaServerConfig.class);
+//		MediaServerConfig mediaServerConfig = mediaServerConfigs.get(0);
+		MediaServerConfig mediaServerConfig = JSON.toJavaObject(json, MediaServerConfig.class);
+		storager.updateMediaInfo(mediaServerConfig);
 		// TODO Auto-generated method stub
 		
 		JSONObject ret = new JSONObject();
-		json.put("code", 0);
-		json.put("msg", "success");
+		ret.put("code", 0);
+		ret.put("msg", "success");
 		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
 	}
 }

--
Gitblit v1.8.0