Browse Source

IPC IP参数支持 rtsp地址

ZhangWenTao 2 years ago
parent
commit
777bff99c5

+ 42 - 33
src/main/java/com/persagy/cameractl/controller/HelloController.java

@@ -1,44 +1,24 @@
 package com.persagy.cameractl.controller;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.alibaba.fastjson.JSONObject;
 import com.persagy.cameractl.cache.SceneConfigCache;
 import com.persagy.cameractl.model.NvrSceneRelation;
 import com.persagy.cameractl.model.SceneConfig;
 import com.persagy.cameractl.service.PtzMain;
 import com.persagy.cameractl.service.windows.Nvr9CameraExecuteApi;
-import com.persagy.cameractl.utils.Camera;
-import com.persagy.cameractl.utils.OtherTools;
-import com.persagy.cameractl.utils.ResultClass;
-import com.persagy.cameractl.utils.ResultTools;
-import com.persagy.cameractl.utils.StringTools;
-
+import com.persagy.cameractl.utils.*;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.util.*;
+import java.util.Map.Entry;
 
 @Slf4j
 @CrossOrigin
@@ -67,6 +47,35 @@ public class HelloController {
 	 */
 	@RequestMapping(value = "/sdk/{opertype}", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
 	public String ptzOperation(@PathVariable("opertype") String operType, @RequestBody Camera _camera) {
+
+		// 拆分rtsp://(Admin:123@)0.0.0.0(:0)(/xxx/xxxxxx)(?xxx=xxxx) 中的ip地址
+		if (StringUtils.isNotEmpty(_camera.ipcIp) && _camera.ipcIp.startsWith("rtsp://")) {
+			String val = _camera.ipcIp.substring(7);
+
+			int idx = val.indexOf('@');
+			if (idx > -1) {
+				val = val.substring(idx + 1);
+			}
+
+			idx = val.indexOf('/');
+			if (idx > -1) {
+				val = val.substring(0, idx);
+			}
+
+			idx = val.indexOf(':');
+			if (idx > -1) {
+				val = val.substring(0, idx);
+			}
+
+			idx = val.indexOf('?');
+			if (idx > -1) {
+				val = val.substring(0, idx);
+			}
+
+			_camera.ipcIp = val;
+		}
+
+
 		ResultClass result = ptzMain.ptzOper(_camera, operType);
 		switch (String.valueOf(result.name)) {
 			// 调用成功
@@ -113,7 +122,7 @@ public class HelloController {
 	/**
 	 * 获取场景
 	 * 
-	 * @param request
+	 * @param oper
 	 * @return
 	 * @date 2021年11月4日 下午12:11:52
 	 */

+ 1 - 1
src/main/java/com/persagy/cameractl/utils/Camera.java

@@ -22,7 +22,7 @@ public class Camera {
 	@Max(256)
 	public int channel = 1;
 
-	// 码流类型 0:主码流 1:子码流 2:第三码流 参数不填,默认为主码流
+	// 码流类型 0:主码流 1:子码流 参数不填,默认为主码流
 	public int streamType = 0;
 
 	/**