25694 2 anos atrás
pai
commit
059499c4cd

+ 25 - 6
src/main/java/com/persagy/cameractl/controller/Test2Controller.java

@@ -1,5 +1,8 @@
 package com.persagy.cameractl.controller;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -13,6 +16,7 @@ import com.persagy.cameractl.utils.Camera;
 import com.persagy.cameractl.utils.ResultClass;
 import com.sun.jna.Structure;
 import com.sun.jna.Union;
+import com.sun.jna.ptr.IntByReference;
 
 /**
  * 测试类
@@ -57,16 +61,31 @@ public class Test2Controller {
 			return returnResult;
         }
         
-        NET_DVR_STREAM_SRC_CFG net_dvr_stream_src_cfg = new NET_DVR_STREAM_SRC_CFG();
-		boolean deviceConfig = hCNetSDK.NET_DVR_GetDeviceConfig(lUserID, 9105, 0xffffffff, null, 0, null, net_dvr_stream_src_cfg.getPointer(), net_dvr_stream_src_cfg.size());
-		hCNetSDK.NET_DVR_GetDeviceConfig(lUserID, 6024, lUserID, null, lUserID, null, null, lUserID);
+        HCNetSDK.NET_DVR_STREAM_INFO struStreamID = new HCNetSDK.NET_DVR_STREAM_INFO();
+        struStreamID.dwSize = struStreamID.size();
+        struStreamID.byID = "18083116593134708100".getBytes();
+        struStreamID.write();
+        
+        NET_DVR_STREAM_SRC_INFO_V40 NET_DVR_STREAM_SRC_INFO_V40 = new NET_DVR_STREAM_SRC_INFO_V40();
+        
+        IntByReference lpBytesReturned = new IntByReference(0);
+		boolean deviceConfig = hCNetSDK.NET_DVR_GetDeviceConfig(lUserID, 6024, 1, struStreamID.getPointer(), struStreamID.size(),
+				lpBytesReturned.getPointer(), NET_DVR_STREAM_SRC_INFO_V40.getPointer(), NET_DVR_STREAM_SRC_INFO_V40.size());
 		if (!deviceConfig) {
-        	returnResult.reason = "获取设备流配置失败,错误码: " + hCNetSDK.NET_DVR_GetLastError();
+        	returnResult.reason = "获取流来源信息失败,错误码: " + hCNetSDK.NET_DVR_GetLastError();
 			return returnResult;
 		}
-		net_dvr_stream_src_cfg.read();
+		NET_DVR_STREAM_SRC_INFO_V40.read();
 		returnResult.name = true;
-		returnResult.resultData = net_dvr_stream_src_cfg.toString();
+		
+		Map<String, Object> temp = new HashMap<String, Object>();
+		temp.put("ip", new String(NET_DVR_STREAM_SRC_INFO_V40.uGetStream.struChanInfo.byAddress));
+		temp.put("username", new String(NET_DVR_STREAM_SRC_INFO_V40.uGetStream.struChanInfo.sUserName));
+		temp.put("password", new String(NET_DVR_STREAM_SRC_INFO_V40.uGetStream.struChanInfo.sPassword));
+		temp.put("port", NET_DVR_STREAM_SRC_INFO_V40.uGetStream.struChanInfo.wDVRPort);
+		temp.put("channel", NET_DVR_STREAM_SRC_INFO_V40.uGetStream.struChanInfo.dwChannel);
+		temp.put("protocol", NET_DVR_STREAM_SRC_INFO_V40.uGetStream.struChanInfo.byTransProtocol);
+		returnResult.resultData = temp;
 		
 		//退出程序时调用,每一台设备分别注销
         if (hCNetSDK.NET_DVR_Logout(lUserID)) {