zhangqiankun 2 lat temu
rodzic
commit
11433f8437

+ 9 - 20
src/main/java/com/persagy/cameractl/cvr/PlayBackController.java

@@ -23,7 +23,7 @@ import com.persagy.cameractl.init.StreamInfoInit;
 import com.persagy.cameractl.init.SystemInit;
 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.sun.jna.Pointer;
 import com.sun.jna.ptr.IntByReference;
 
@@ -42,16 +42,12 @@ public class PlayBackController {
 	public static Logger logger = LoggerFactory.getLogger(PlayBackController.class);
 
 	@RequestMapping(value = "/playback/{operType}", method = RequestMethod.POST)
-	public ResultClass play(@RequestBody Camera camera, @PathVariable("operType") String operType) throws Exception {
-		ResultClass returnResult = new ResultClass();
-		returnResult.name = false;
-		
+	public Object play(@RequestBody Camera camera, @PathVariable("operType") String operType) throws Exception {
 		// 验证是否需要走配置
 		if (StrUtil.isBlank(camera.streamId)) {
 			CameraStream stream = StreamInfoInit.CAMERA_2_STREAM.get(camera.cameraIndexCode);
 			if (stream == null) {
-				returnResult.reason = "不存在此设备的配置信息";
-				return returnResult;
+				 return ResultTools.errorResult("不存在此设备的配置信息");
 			}
 			camera.cameraIp = stream.getCvrIp();
 			camera.cameraPort = stream.getCvrPort();
@@ -63,8 +59,7 @@ public class PlayBackController {
 		// SDK初始化
 		boolean init = SystemInit.init();
 		if (!init) {
-			returnResult.reason = "SDK初始化失败";
-			return returnResult;
+			return ResultTools.errorResult("SDK初始化失败");
 		}
         
         //登录设备,每一台设备分别登录; 登录句柄是唯一的,可以区分设备
@@ -73,8 +68,7 @@ public class PlayBackController {
         int lUserID = SystemInit.hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
         if (lUserID == -1) {
         	int errCode = SystemInit.hCNetSDK.NET_DVR_GetLastError();
-        	returnResult.reason = "设备注册失败,失败码: " + errCode;
-			return returnResult;
+        	return ResultTools.errorResult("设备注册失败,失败码: " + errCode);
         }
         
         logger.info(camera.cameraIp + ": login success! " + "device serial number: " + new String(m_strDeviceInfo.struDeviceV30.sSerialNumber).trim());
@@ -90,8 +84,7 @@ public class PlayBackController {
 		if ("stream".equals(operType)) {
 			result = this.playBackBytime(file, camera.startDateStr, camera.endDateStr, lUserID, camera.streamId);
 		} else {
-			returnResult.reason = "非法请求";
-			return returnResult;
+			return ResultTools.errorResult("非法请求");
 		}
         
         //退出程序时调用,每一台设备分别注销
@@ -103,16 +96,12 @@ public class PlayBackController {
         // hCNetSDK.NET_DVR_Cleanup();
 		
         if ("true".equals(result)) {
-        	returnResult.reason = "文件生成成功";
         	Map<String, String> data = new HashMap<String, String>(4);
-			data.put("url", OtherTools.playMp4RootUrl + OtherTools.getMp4NamePrefix(file.getName()));
-			returnResult.resultData = data;
-		} else {
-			returnResult.reason = result;
+			data.put("videoUrl", file.getName());
+			return ResultTools.dataResult(data);
 		}
         
-        returnResult.name = true;
-		return returnResult;
+		return ResultTools.errorResult(result);
 	}
 	
 	/**