zhangqiankun 3 年之前
父节点
当前提交
4270903440
共有 55 个文件被更改,包括 490 次插入202 次删除
  1. 二进制
      resourcesFile/cameraDll/windows/AudioRender.dll
  2. 二进制
      resourcesFile/cameraDll/windows/EagleEyeRender.dll
  3. 二进制
      resourcesFile/cameraDll/windows/GdiPlus.dll
  4. 二进制
      resourcesFile/cameraDll/windows/HCCore.dll
  5. 二进制
      resourcesFile/cameraDll/windows/HCNetSDK.dll
  6. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/AnalyzeData.dll
  7. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/AudioIntercom.dll
  8. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/AudioRender.dll
  9. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCAlarm.dll
  10. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCAlarm.lib
  11. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCCoreDevCfg.dll
  12. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCDisplay.dll
  13. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCGeneralCfgMgr.dll
  14. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCGeneralCfgMgr.lib
  15. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCIndustry.dll
  16. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCPlayBack.dll
  17. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCPreview.dll
  18. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCPreview.lib
  19. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/HCVoiceTalk.dll
  20. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/OpenAL32.dll
  21. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/StreamTransClient.dll
  22. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/SystemTransform.dll
  23. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/libiconv2.dll
  24. 二进制
      resourcesFile/cameraDll/windows/HCNetSDKCom/msvcr90.dll
  25. 二进制
      resourcesFile/cameraDll/windows/HXVA.dll
  26. 二进制
      resourcesFile/cameraDll/windows/HmMerge.dll
  27. 二进制
      resourcesFile/cameraDll/windows/MP_Render.dll
  28. 二进制
      resourcesFile/cameraDll/windows/MP_VIE.dll
  29. 二进制
      resourcesFile/cameraDll/windows/NPQos.dll
  30. 二进制
      resourcesFile/cameraDll/windows/OpenAL32.dll
  31. 二进制
      resourcesFile/cameraDll/windows/PlayCtrl.dll
  32. 二进制
      resourcesFile/cameraDll/windows/SuperRender.dll
  33. 二进制
      resourcesFile/cameraDll/windows/YUVProcess.dll
  34. 二进制
      resourcesFile/cameraDll/windows/gdiplus.dll
  35. 二进制
      resourcesFile/cameraDll/windows/hlog.dll
  36. 二进制
      resourcesFile/cameraDll/windows/hpr.dll
  37. 二进制
      resourcesFile/cameraDll/windows/libcrypto-1_1.dll
  38. 二进制
      resourcesFile/cameraDll/windows/libeay32.dll
  39. 二进制
      resourcesFile/cameraDll/windows/libmmd.dll
  40. 二进制
      resourcesFile/cameraDll/windows/libssl-1_1.dll
  41. 二进制
      resourcesFile/cameraDll/windows/ssleay32.dll
  42. 二进制
      resourcesFile/cameraDll/windows/zlib1.dll
  43. 57 0
      src/main/java/com/persagy/cameractl/conf/AddressConfig.java
  44. 0 2
      src/main/java/com/persagy/cameractl/conf/AllStaticConfig.java
  45. 53 0
      src/main/java/com/persagy/cameractl/conf/CVRConfig.java
  46. 1 4
      src/main/java/com/persagy/cameractl/conf/CameraApiConfig.java
  47. 12 104
      src/main/java/com/persagy/cameractl/controller/Test2Controller.java
  48. 90 0
      src/main/java/com/persagy/cameractl/cvr/HCNetSDK.java
  49. 64 0
      src/main/java/com/persagy/cameractl/cvr/TestController.java
  50. 2 3
      src/main/java/com/persagy/cameractl/controller/DevInfoCallBack.java
  51. 0 69
      src/main/java/com/persagy/cameractl/init/SDKInit.java
  52. 152 2
      src/main/java/com/persagy/cameractl/init/StreamInfoInit.java
  53. 55 14
      src/main/java/com/persagy/cameractl/init/SystemInit.java
  54. 3 3
      src/main/java/com/persagy/cameractl/service/HkCameraExecuteApi.java
  55. 1 1
      src/main/resources/application.yml

二进制
resourcesFile/cameraDll/windows/AudioRender.dll


二进制
resourcesFile/cameraDll/windows/EagleEyeRender.dll


二进制
resourcesFile/cameraDll/windows/GdiPlus.dll


二进制
resourcesFile/cameraDll/windows/HCCore.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDK.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/AnalyzeData.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/AudioIntercom.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/AudioRender.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCAlarm.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCAlarm.lib


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCCoreDevCfg.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCDisplay.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCGeneralCfgMgr.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCGeneralCfgMgr.lib


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCIndustry.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCPlayBack.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCPreview.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCPreview.lib


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/HCVoiceTalk.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/OpenAL32.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/StreamTransClient.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/SystemTransform.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/libiconv2.dll


二进制
resourcesFile/cameraDll/windows/HCNetSDKCom/msvcr90.dll


二进制
resourcesFile/cameraDll/windows/HXVA.dll


二进制
resourcesFile/cameraDll/windows/HmMerge.dll


二进制
resourcesFile/cameraDll/windows/MP_Render.dll


二进制
resourcesFile/cameraDll/windows/MP_VIE.dll


二进制
resourcesFile/cameraDll/windows/NPQos.dll


二进制
resourcesFile/cameraDll/windows/OpenAL32.dll


二进制
resourcesFile/cameraDll/windows/PlayCtrl.dll


二进制
resourcesFile/cameraDll/windows/SuperRender.dll


二进制
resourcesFile/cameraDll/windows/YUVProcess.dll


二进制
resourcesFile/cameraDll/windows/gdiplus.dll


二进制
resourcesFile/cameraDll/windows/hlog.dll


二进制
resourcesFile/cameraDll/windows/hpr.dll


二进制
resourcesFile/cameraDll/windows/libcrypto-1_1.dll


二进制
resourcesFile/cameraDll/windows/libeay32.dll


二进制
resourcesFile/cameraDll/windows/libmmd.dll


二进制
resourcesFile/cameraDll/windows/libssl-1_1.dll


二进制
resourcesFile/cameraDll/windows/ssleay32.dll


二进制
resourcesFile/cameraDll/windows/zlib1.dll


+ 57 - 0
src/main/java/com/persagy/cameractl/conf/AddressConfig.java

@@ -0,0 +1,57 @@
+package com.persagy.cameractl.conf;
+
+/**
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2022年6月28日 下午5:40:46
+ */
+public class AddressConfig {
+
+	private String address;
+	
+	private int port;
+	
+	private String username;
+	
+	private String password;
+
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	public int getPort() {
+		return port;
+	}
+
+	public void setPort(int port) {
+		this.port = port;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	@Override
+	public String toString() {
+		return "CVRConfig [address=" + address + ", port=" + port + ", username=" + username + ", password=" + password + "]";
+	}
+	
+}

+ 0 - 2
src/main/java/com/persagy/cameractl/conf/AllStaticConfig.java

@@ -13,6 +13,4 @@ public class AllStaticConfig {
 	// 69解码器密码
 	public static String decodeDevicePassword;
 	
-	public static String recordLocation;
-	
 }

+ 53 - 0
src/main/java/com/persagy/cameractl/conf/CVRConfig.java

@@ -0,0 +1,53 @@
+package com.persagy.cameractl.conf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * CVR 配置
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2022年6月28日 下午5:03:11
+ */
+@Component
+@ConfigurationProperties(prefix = "hk-config")
+public class CVRConfig {
+
+	/** 是否开启SDK的对接方式 */
+	private boolean sdkEnable = false;
+
+	/** 当开启了SDK的对接方式后,回放是否采用流ID的播放方式 */
+	private boolean streamEnable = false;
+	
+	private List<AddressConfig> addressConfig = new ArrayList<AddressConfig>();
+	
+	public boolean isSdkEnable() {
+		return sdkEnable;
+	}
+
+	public void setSdkEnable(boolean sdkEnable) {
+		this.sdkEnable = sdkEnable;
+	}
+
+	public boolean isStreamEnable() {
+		return streamEnable;
+	}
+
+	public void setStreamEnable(boolean streamEnable) {
+		this.streamEnable = streamEnable;
+	}
+
+	public List<AddressConfig> getAddressConfig() {
+		return addressConfig;
+	}
+
+	public void setAddressConfig(List<AddressConfig> addressConfig) {
+		this.addressConfig = addressConfig;
+	}
+
+}

+ 1 - 4
src/main/java/com/persagy/cameractl/conf/CameraApiConfig.java

@@ -29,9 +29,6 @@ public class CameraApiConfig {
 	@Value("${hk-config.recordLocation:}")
 	private String recordLocation;
 	
-	@Value("${hk-config.nginx-address:}")
-	private String nginxAddress;
-	
 	public String getHkApiHost() {
 		return hkApiHost;
 	}
@@ -95,5 +92,5 @@ public class CameraApiConfig {
 	public void setRecordLocation(String recordLocation) {
 		this.recordLocation = recordLocation;
 	}
-	
+
 }

+ 12 - 104
src/main/java/com/persagy/cameractl/controller/Test2Controller.java

@@ -12,7 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import com.persagy.cameractl.cvr.HCNetSDK;
 import com.persagy.cameractl.cvr.HCNetSDK.NET_DVR_USER_LOGIN_INFO;
-import com.persagy.cameractl.init.SDKInit;
+import com.persagy.cameractl.init.DevInfoCallBack;
+import com.persagy.cameractl.init.SystemInit;
 import com.persagy.cameractl.utils.Camera;
 import com.persagy.cameractl.utils.ResultClass;
 import com.sun.jna.Structure;
@@ -46,7 +47,7 @@ public class Test2Controller {
 		returnResult.name = false;
 		
 		// SDK初始化
-		boolean init = SDKInit.init();
+		boolean init = SystemInit.init();
 		if (!init) {
 			returnResult.reason = "SDK初始化失败";
 			return returnResult;
@@ -54,18 +55,18 @@ public class Test2Controller {
 		
 		HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
         //NET_DVR_USER_LOGIN_INFO m_strLoginInfo = this.getLoginObject(cameraApiConfig.getDecodeDeviceUserName(), cameraApiConfig.getDecodeDevicePassword(), cameraApiConfig.getDecodeDeviceIp(), (short)cameraApiConfig.getDecodeDevicePort());
-		NET_DVR_USER_LOGIN_INFO m_strLoginInfo = SDKInit.getLoginObject(camera.userName, camera.password, camera.cameraIp, (short)camera.cameraPort);
-        int lUserID = SDKInit.hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
+		NET_DVR_USER_LOGIN_INFO m_strLoginInfo = SystemInit.getLoginObject(camera.userName, camera.password, camera.cameraIp, (short)camera.cameraPort);
+        int lUserID = SystemInit.hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
         if (lUserID == -1) {
-        	int errCode = SDKInit.hCNetSDK.NET_DVR_GetLastError();
+        	int errCode = SystemInit.hCNetSDK.NET_DVR_GetLastError();
         	returnResult.reason = "设备注册失败,错误码: " + errCode;
 			return returnResult;
         }
         
         DevInfoCallBack fDevInfoCallBack = new DevInfoCallBack(strStreamInfo);
-        int startRemoteHandle = SDKInit.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_STREAM_INFO, null, 0, fDevInfoCallBack, null);
+        int startRemoteHandle = SystemInit.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_STREAM_INFO, null, 0, fDevInfoCallBack, null);
         if (startRemoteHandle == -1) {
-        	returnResult.reason = "启动远程配置失败,错误码: " + SDKInit.hCNetSDK.NET_DVR_GetLastError();
+        	returnResult.reason = "启动远程配置失败,错误码: " + SystemInit.hCNetSDK.NET_DVR_GetLastError();
 			return returnResult;
         }
         
@@ -78,114 +79,21 @@ public class Test2Controller {
 		returnResult.resultData = STREAM_ID_2_CHANNEL;
 		
 		// 关闭资源
-        boolean remoteConfig = SDKInit.hCNetSDK.NET_DVR_StopRemoteConfig(startRemoteHandle);
+        boolean remoteConfig = SystemInit.hCNetSDK.NET_DVR_StopRemoteConfig(startRemoteHandle);
         if (!remoteConfig) {
-        	logger.warn("NET_DVR_StopRemoteConfig failure, errorCode: " + SDKInit.hCNetSDK.NET_DVR_GetLastError());
-			returnResult.reason = "关闭长连接配置接口所创建的句柄,释放资源失败,错误码: " + SDKInit.hCNetSDK.NET_DVR_GetLastError();
+        	logger.warn("NET_DVR_StopRemoteConfig failure, errorCode: " + SystemInit.hCNetSDK.NET_DVR_GetLastError());
+			returnResult.reason = "关闭长连接配置接口所创建的句柄,释放资源失败,错误码: " + SystemInit.hCNetSDK.NET_DVR_GetLastError();
 			return returnResult;
 		}
 		
 		//退出程序时调用,每一台设备分别注销
-        if (SDKInit.hCNetSDK.NET_DVR_Logout(lUserID)) {
+        if (SystemInit.hCNetSDK.NET_DVR_Logout(lUserID)) {
             logger.info("logout success");
         }
         
         returnResult.name = true;
 		return returnResult;
 	}
-	
-    public static class NET_DVR_STREAM_SRC_INFO_V40 extends Structure {
-        public int dwSize;
-        public byte byGetStreamType;
-        public byte[] byRes1 = new byte[3];
-        public NET_DVR_STREAM_TYPE_V40_UNION uGetStream = new NET_DVR_STREAM_TYPE_V40_UNION();
-        public byte[] byRes = new byte[512];
-    }
-	
-    public static class NET_DVR_STREAM_TYPE_V40_UNION extends Union {
-    	public NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40 struChanInfo = new NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40();
-    	public NET_DVR_PU_STREAM_URL struPuStreamUrl = new NET_DVR_PU_STREAM_URL();
-    	public NET_DVR_PU_STREAM_URL_CFG_V40 struStreamUrlCfg = new NET_DVR_PU_STREAM_URL_CFG_V40();
-    	public NET_DVR_RTSP_PROTOCAL_CFG struRtspCfg = new NET_DVR_RTSP_PROTOCAL_CFG();
-    	public NET_DVR_STREAM_URL_V40 struStreamUrlV40 = new NET_DVR_STREAM_URL_V40();
-    }
-    
-    public static class NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40 extends Structure {
-        public byte byEnable;
-        public byte byProType;
-        public byte byZeroChan;
-        public byte byRes1;
-        public byte[] sUserName = new byte[32];
-        public byte[] sPassword = new byte[16];
-        public byte[] byAddress = new byte[64];
-        public short wDVRPort;
-        public byte byStreamType;
-        public byte byOnline;
-        public int dwChannel;
-        public byte byTransProtocol;
-        public byte byLocalBackUp;
-        public byte[] byRes2 = new byte[2];
-        public byte[] byVAGChanNo = new byte[32];
-        public byte[] byRes = new byte[340];
-    }
-    
-    public static class NET_DVR_PU_STREAM_URL extends Structure {
-        public byte byEnable;//是否启用:0- 禁用,1- 启用
-        public byte[] strURL = new byte[240];//取流URL路径
-        public byte byTransPortocol;//传输协议类型:0-TCP,1-UDP
-        public short wIPID;//设备ID号,wIPID = iDevInfoIndex + iGroupNO*64 +1
-        public byte byChannel;//设备通道号
-        public byte[] byRes = new byte[7];//保留,置为0
-    }
-    
-    public static class NET_DVR_PU_STREAM_URL_CFG_V40 extends Structure {
-        public byte byEnable;
-        public byte[] byRes = new byte[3];
-        public byte[] byStreamMediaIP = new byte[64];
-        public short wStreamMediaPort;
-        public byte byTransmitType;
-        public byte byRes1;
-        public byte[] byDevIP = new byte[64];
-        public short wDevPort;
-        public byte byChannel;
-        public byte byTransMode;
-        public byte byProType;
-        public byte byTransProtocol;
-        public byte[] byRes3 = new byte[2];
-        public byte[] sUserName = new byte[32];
-        public byte[] sPassWord = new byte[16];
-        public byte[] byRes2 = new byte[308];
-    }
-    
-    public static class NET_DVR_RTSP_PROTOCAL_CFG extends Structure {
-        public byte byEnable;
-        public byte byLocalBackUp;
-        public byte[] byRes = new byte[2];
-        public byte[] strURL = new byte[256];
-        public int dwProtocalType;
-        public byte[] sUserName = new byte[32];
-        public byte[] sPassWord = new byte[16];
-        public byte[] byAddress = new byte[64];
-        public short wPort;
-        public byte[] byRes1 = new byte[122];
-    }   
-    
-    public static class NET_DVR_STREAM_URL_V40 extends Structure {
-        public byte byEnable;
-        public byte byStreamType;
-        public byte byLocalBackUp;
-        public byte byRes;
-        public byte[] strURL = new byte[256];
-        public int dwProtocalType;
-        public byte[] sUserName = new byte[32];
-        public byte[] sPassWord = new byte[16];
-        public byte[] byAddress = new byte[64];
-        public short wIPPort;
-        public short wChanNo;
-        public byte[] byVAGChanNo = new byte[32];
-        public byte[] byRes1 = new byte[88];
-    }
-    
     
     public static class NET_DVR_STREAM_SRC_CFG extends Structure {
         public int dwSize;

+ 90 - 0
src/main/java/com/persagy/cameractl/cvr/HCNetSDK.java

@@ -10420,6 +10420,96 @@ public class NET_DVR_PIC_PARAM extends Structure {
         public byte bySupport256PresetNo;
         public byte[] byRes = new byte[6];
     }
+    
+    // 流的来源信息结构体。
+    public static class NET_DVR_STREAM_SRC_INFO_V40 extends Structure {
+        public int dwSize;
+        public byte byGetStreamType;
+        public byte[] byRes1 = new byte[3];
+        public NET_DVR_STREAM_TYPE_V40_UNION uGetStream = new NET_DVR_STREAM_TYPE_V40_UNION();
+        public byte[] byRes = new byte[512];
+    }
+    
+    // 取流方式联合体。
+    public static class NET_DVR_STREAM_TYPE_V40_UNION extends Union {
+    	public NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40 struChanInfo = new NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40();
+    	public NET_DVR_PU_STREAM_URL struPuStreamUrl = new NET_DVR_PU_STREAM_URL();
+    	public NET_DVR_PU_STREAM_URL_CFG_V40 struStreamUrlCfg = new NET_DVR_PU_STREAM_URL_CFG_V40();
+    	public NET_DVR_RTSP_PROTOCAL_CFG struRtspCfg = new NET_DVR_RTSP_PROTOCAL_CFG();
+    	public NET_DVR_STREAM_URL_V40 struStreamUrlV40 = new NET_DVR_STREAM_URL_V40();
+    }
+    
+    // IP通道信息结构体
+    public static class NET_DVR_DIRECT_CONNECT_CHAN_INFO_V40 extends Structure {
+        public byte byEnable;
+        public byte byProType;
+        public byte byZeroChan;
+        public byte byRes1;
+        public byte[] sUserName = new byte[32];
+        public byte[] sPassword = new byte[16];
+        public byte[] byAddress = new byte[64];
+        public short wDVRPort;
+        public byte byStreamType;
+        public byte byOnline;
+        public int dwChannel;
+        public byte byTransProtocol;
+        public byte byLocalBackUp;
+        public byte[] byRes2 = new byte[2];
+        public byte[] byVAGChanNo = new byte[32];
+        public byte[] byRes = new byte[340];
+    }
+    
+    //URL取流路径构成参数结构体。
+    public static class NET_DVR_PU_STREAM_URL_CFG_V40 extends Structure {
+        public byte byEnable;
+        public byte[] byRes = new byte[3];
+        public byte[] byStreamMediaIP = new byte[64];
+        public short wStreamMediaPort;
+        public byte byTransmitType;
+        public byte byRes1;
+        public byte[] byDevIP = new byte[64];
+        public short wDevPort;
+        public byte byChannel;
+        public byte byTransMode;
+        public byte byProType;
+        public byte byTransProtocol;
+        public byte[] byRes3 = new byte[2];
+        public byte[] sUserName = new byte[32];
+        public byte[] sPassWord = new byte[16];
+        public byte[] byRes2 = new byte[308];
+    }
+    
+    // RTSP协议取流参数结构体。
+    public static class NET_DVR_RTSP_PROTOCAL_CFG extends Structure {
+        public byte byEnable;
+        public byte byLocalBackUp;
+        public byte[] byRes = new byte[2];
+        public byte[] strURL = new byte[256];
+        public int dwProtocalType;
+        public byte[] sUserName = new byte[32];
+        public byte[] sPassWord = new byte[16];
+        public byte[] byAddress = new byte[64];
+        public short wPort;
+        public byte[] byRes1 = new byte[122];
+    }   
+    
+    // 流媒体向流来源取流参数结构体
+    public static class NET_DVR_STREAM_URL_V40 extends Structure {
+        public byte byEnable;
+        public byte byStreamType;
+        public byte byLocalBackUp;
+        public byte byRes;
+        public byte[] strURL = new byte[256];
+        public int dwProtocalType;
+        public byte[] sUserName = new byte[32];
+        public byte[] sPassWord = new byte[16];
+        public byte[] byAddress = new byte[64];
+        public short wIPPort;
+        public short wChanNo;
+        public byte[] byVAGChanNo = new byte[32];
+        public byte[] byRes1 = new byte[88];
+    }
+    
 }
 
 //播放库函数声明,PlayCtrl.dll

+ 64 - 0
src/main/java/com/persagy/cameractl/cvr/TestController.java

@@ -0,0 +1,64 @@
+package com.persagy.cameractl.cvr;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+import com.persagy.cameractl.conf.AddressConfig;
+import com.persagy.cameractl.init.StreamInfoInit;
+import com.persagy.cameractl.init.SystemInit;
+import com.persagy.cameractl.utils.ResultClass;
+
+@RestController
+public class TestController {
+	public static Logger logger = LoggerFactory.getLogger(TestController.class);
+	
+	@Autowired
+	private StreamInfoInit streamInfoInit;
+	
+	@RequestMapping(value = "/query/stream", method = RequestMethod.POST)
+	public ResultClass queryStreamIds(@RequestBody AddressConfig addressConfig) throws Exception {
+		ResultClass returnResult = new ResultClass();
+		returnResult.name = false;
+		
+		// SDK初始化
+		boolean init = SystemInit.init();
+		if (!init) {
+			returnResult.reason = "SDK初始化失败";
+			return returnResult;
+		}
+		
+		streamInfoInit.queryStreamIds(addressConfig.getUsername(), addressConfig.getPassword(), addressConfig.getAddress(), addressConfig.getPort());
+		
+		returnResult.resultData = StreamInfoInit.STREAM_IDS;
+		returnResult.name = true;
+		returnResult.reason = "回放文件生成成功";
+		return returnResult;
+	}
+    
+	@RequestMapping(value = "/stream/{streamId}", method = RequestMethod.POST)
+	public ResultClass queryStreamIds(@RequestBody AddressConfig addressConfig, @PathVariable("streamId") String streamId) throws Exception {
+		ResultClass returnResult = new ResultClass();
+		returnResult.name = false;
+		
+		// SDK初始化
+		boolean init = SystemInit.init();
+		if (!init) {
+			returnResult.reason = "SDK初始化失败";
+			return returnResult;
+		}
+		
+		streamInfoInit.queryAddressByStreamId(streamId, addressConfig.getUsername(), addressConfig.getPassword(), addressConfig.getAddress(), addressConfig.getPort());
+		
+		returnResult.resultData = StreamInfoInit.STREAM_IDS;
+		returnResult.name = true;
+		returnResult.reason = "回放文件生成成功";
+		return returnResult;
+	}
+	
+}

+ 2 - 3
src/main/java/com/persagy/cameractl/controller/DevInfoCallBack.java

@@ -1,4 +1,4 @@
-package com.persagy.cameractl.controller;
+package com.persagy.cameractl.init;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,7 +30,6 @@ public class DevInfoCallBack implements FRemoteConfigCallBack {
 	
 	@Override
 	public void invoke(int dwType, Pointer lpBuffer, int dwBufLen, Pointer pUserData) {
-		logger.info("dwType: {}", dwType);
 		switch (dwType) {
 			case 2:
 				strStreamInfo = new HCNetSDK.NET_DVR_STREAM_INFO();
@@ -41,7 +40,7 @@ public class DevInfoCallBack implements FRemoteConfigCallBack {
 				String streamId = new String(strStreamInfo.byID);
 				logger.info("stream id: {}", streamId);
 				if (StrUtil.isNotBlank(streamId)) {
-					Test2Controller.STREAM_ID_2_CHANNEL.put(streamId.trim(), strStreamInfo.dwChannel);
+					StreamInfoInit.STREAM_IDS.add(streamId.trim());
 				}
 				break;
 			default:

+ 0 - 69
src/main/java/com/persagy/cameractl/init/SDKInit.java

@@ -1,69 +0,0 @@
-package com.persagy.cameractl.init;
-
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import com.persagy.cameractl.cvr.HCNetSDK;
-
-/**
- * SDK初始化
- *  
- * @version 1.0.0
- * @company persagy 
- * @author zhangqiankun
- * @date 2022年6月28日 下午4:48:09
- */
-@Component
-@Order(-100)
-public class SDKInit implements ApplicationRunner {
-	
-	public static volatile HCNetSDK hCNetSDK;
-	private static volatile boolean isInit = false;
-	
-	@Override
-	public void run(ApplicationArguments args) throws Exception {
-		// SDK初始化
-		init();
-	}
-
-	public static boolean init() {
-		if (!isInit) {
-			// 初始化
-			hCNetSDK = HCNetSDK.INSTANCE;
-			isInit = hCNetSDK.NET_DVR_Init();
-		}
-		return isInit;
-	}
-	
-	/**
-	 * 登录
-	 * 
-	 * @param m_sUsername
-	 * @param m_sPassword
-	 * @param m_sDeviceIP
-	 * @param wPort
-	 * @return
-	 * @date 2022年6月28日 下午4:55:40
-	 */
-	public static HCNetSDK.NET_DVR_USER_LOGIN_INFO getLoginObject(String m_sUsername, String m_sPassword, String m_sDeviceIP, short wPort) {
-		HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
-
-        m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
-        System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
-
-        m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
-        System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
-
-        m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
-        System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
-
-        m_strLoginInfo.wPort = wPort;
-        m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
-        m_strLoginInfo.write();
-        
-        return m_strLoginInfo;
-	}
-	
-}

+ 152 - 2
src/main/java/com/persagy/cameractl/init/StreamInfoInit.java

@@ -1,10 +1,27 @@
 package com.persagy.cameractl.init;
 
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 
+import com.persagy.cameractl.conf.AddressConfig;
+import com.persagy.cameractl.conf.CVRConfig;
+import com.persagy.cameractl.cvr.HCNetSDK;
+import com.persagy.cameractl.cvr.HCNetSDK.NET_DVR_STREAM_INFO;
+import com.persagy.cameractl.cvr.HCNetSDK.NET_DVR_STREAM_SRC_INFO_V40;
+import com.persagy.cameractl.cvr.HCNetSDK.NET_DVR_USER_LOGIN_INFO;
+import com.sun.jna.ptr.IntByReference;
+
+import cn.hutool.core.collection.CollectionUtil;
+
 /**
  * 
  * @version 1.0.0
@@ -15,10 +32,143 @@ import org.springframework.stereotype.Component;
 @Component
 @Order(10)
 public class StreamInfoInit implements ApplicationRunner {
+	public static Logger logger = LoggerFactory.getLogger(StreamInfoInit.class);
 
+	public static final Set<String> STREAM_IDS = new HashSet<String>(64);
+	
+	@Autowired
+	private CVRConfig cvrConfig;
+	
 	@Override
 	public void run(ApplicationArguments args) throws Exception {
-
+		if (!cvrConfig.isSdkEnable() || CollectionUtil.isEmpty(cvrConfig.getAddressConfig()) || !cvrConfig.isStreamEnable()) {
+			return;
+		}
+		
+		// SDK初始化
+		boolean init = SystemInit.init();
+		if (!init) {
+			logger.warn("sdk init error");
+			return;
+		}
+		
+		// 获取流ID集合
+		List<AddressConfig> addressConfigs = cvrConfig.getAddressConfig();
+		for (AddressConfig addressConfig : addressConfigs) {
+			this.queryStreamIds(addressConfig.getUsername(), addressConfig.getPassword(), addressConfig.getAddress(), addressConfig.getPort());
+		}
 	}
-
+	
+	/**
+	 * 获取流ID
+	 * 
+	 * @param username
+	 * @param password
+	 * @param ip
+	 * @param port
+	 * @throws Exception 
+	 * @date 2022年6月28日 下午6:28:06
+	 */
+	public void queryStreamIds(String username, String password, String ip, int port) throws Exception {
+		HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
+		NET_DVR_USER_LOGIN_INFO m_strLoginInfo = SystemInit.getLoginObject(username, password, ip, (short)port);
+        int lUserID = SystemInit.hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
+        if (lUserID == -1) {
+        	logger.warn("login device error, code: {}", SystemInit.hCNetSDK.NET_DVR_GetLastError());
+			return;
+        }
+        
+        HCNetSDK.NET_DVR_STREAM_INFO strStreamInfo = null;
+        DevInfoCallBack fDevInfoCallBack = new DevInfoCallBack(strStreamInfo);
+        int startRemoteHandle = SystemInit.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_STREAM_INFO, null, 0, fDevInfoCallBack, null);
+        if (startRemoteHandle == -1) {
+        	logger.warn("startRemoteConfig error, code: {}", SystemInit.hCNetSDK.NET_DVR_GetLastError());
+			return;
+        }
+        
+        while (!fDevInfoCallBack.endStatus) {
+        	Thread.sleep(1000);
+        }
+        
+		// 关闭资源
+        boolean remoteConfig = SystemInit.hCNetSDK.NET_DVR_StopRemoteConfig(startRemoteHandle);
+        if (!remoteConfig) {
+        	logger.warn("stopRemoteConfig error, code: {}", SystemInit.hCNetSDK.NET_DVR_GetLastError());
+			return;
+		}
+		
+		//退出程序时调用,每一台设备分别注销
+        if (SystemInit.hCNetSDK.NET_DVR_Logout(lUserID)) {
+            logger.info("logout device success");
+        }
+	}
+	
+	/**
+	 * 根据流ID,获取流来源信息
+	 * 
+	 * @param streamId
+	 * @param username
+	 * @param password
+	 * @param ip
+	 * @param port
+	 * @throws Exception
+	 * @date 2022年6月28日 下午7:38:07
+	 */
+	public void queryAddressByStreamId(String streamId, String username, String password, String ip, int port) throws Exception {
+		HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
+		NET_DVR_USER_LOGIN_INFO m_strLoginInfo = SystemInit.getLoginObject(username, password, ip, (short)port);
+        int lUserID = SystemInit.hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
+        if (lUserID == -1) {
+        	logger.warn("login device error, code: {}", SystemInit.hCNetSDK.NET_DVR_GetLastError());
+			return;
+        }
+        
+        // 获取流来源信息
+        this.queryAddressByStreamId(streamId, lUserID);
+        
+        //退出程序时调用,每一台设备分别注销
+        if (SystemInit.hCNetSDK.NET_DVR_Logout(lUserID)) {
+            logger.info("logout success");
+        }
+	}
+	
+	/**
+	 * 根据流ID,获取对应的摄像头的IP地址
+	 * 
+	 * @param streamId
+	 * @param lUserID
+	 * @throws Exception
+	 * @date 2022年6月28日 下午7:37:37
+	 */
+	private void queryAddressByStreamId(String streamId, int lUserID) throws Exception {
+        NET_DVR_STREAM_INFO struStreamID = new NET_DVR_STREAM_INFO();
+        struStreamID.dwSize = struStreamID.size();
+        struStreamID.byID = streamId.getBytes();
+        struStreamID.write();
+        
+        NET_DVR_STREAM_SRC_INFO_V40 stream_src_info_v40 = new NET_DVR_STREAM_SRC_INFO_V40();
+        stream_src_info_v40.write();
+        
+        IntByReference lpBytesReturned = new IntByReference(0);
+		boolean deviceConfig = SystemInit.hCNetSDK.NET_DVR_GetDeviceConfig(lUserID, 6024, 1, struStreamID.getPointer(), struStreamID.size(),
+				lpBytesReturned.getPointer(), stream_src_info_v40.getPointer(), stream_src_info_v40.size());
+		if (!deviceConfig) {
+			logger.warn("get stream source error, code: {}", SystemInit.hCNetSDK.NET_DVR_GetLastError());
+			return;
+		}
+		//stream_src_info_v40.getPointer().write(0, stream_src_info_v40.getPointer().getByteArray(0, stream_src_info_v40.size()), 0, stream_src_info_v40.size());
+		stream_src_info_v40.read();
+		
+		logger.info("address: {}", new String(stream_src_info_v40.uGetStream.struChanInfo.byAddress));
+		logger.info("port: {}", stream_src_info_v40.uGetStream.struChanInfo.wDVRPort);
+		logger.info("username: {}", new String(stream_src_info_v40.uGetStream.struChanInfo.sUserName));
+		logger.info("password: {}", new String(stream_src_info_v40.uGetStream.struChanInfo.sPassword));
+		logger.info("channel: {}", stream_src_info_v40.uGetStream.struChanInfo.dwChannel);
+		
+		logger.info("address: {}", new String(stream_src_info_v40.uGetStream.struStreamUrlV40.byAddress));
+		logger.info("port: {}", stream_src_info_v40.uGetStream.struStreamUrlV40.wIPPort);
+		logger.info("username: {}", new String(stream_src_info_v40.uGetStream.struStreamUrlV40.sUserName));
+		logger.info("password: {}", new String(stream_src_info_v40.uGetStream.struStreamUrlV40.sPassWord));
+	}
+	
 }

+ 55 - 14
src/main/java/com/persagy/cameractl/init/SystemInit.java

@@ -9,36 +9,77 @@ import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 
 import com.persagy.cameractl.conf.AllStaticConfig;
+import com.persagy.cameractl.conf.CVRConfig;
 import com.persagy.cameractl.conf.CameraApiConfig;
-import com.persagy.cameractl.conf.ServerConfig;
+import com.persagy.cameractl.cvr.HCNetSDK;
 import com.persagy.cameractl.utils.TimerInterval;
 
 @Component
 @Order(1)
 public class SystemInit implements ApplicationRunner {
-	Logger log = LoggerFactory.getLogger(SystemInit.class);
-
+	public static final Logger log = LoggerFactory.getLogger(SystemInit.class);
+	
+	public static volatile HCNetSDK hCNetSDK;
+	private static volatile boolean isInit = false;
+	
 	@Autowired
-	private ServerConfig serverConfig;
+	private CVRConfig cvrConfig;
 	
 	@Autowired
 	private CameraApiConfig cameraApiConfig;
 
 	@Override
 	public void run(ApplicationArguments args) throws Exception {
-		AllStaticConfig.decodeDeviceIp=cameraApiConfig.getDecodeDeviceIp();
-		AllStaticConfig.decodeDeviceUserName=cameraApiConfig.getDecodeDeviceUserName();
-		AllStaticConfig.decodeDevicePassword=cameraApiConfig.getDecodeDevicePassword();
-		AllStaticConfig.decodeDevicePort=cameraApiConfig.getDecodeDevicePort();
-		AllStaticConfig.recordLocation=cameraApiConfig.getRecordLocation();
+		AllStaticConfig.decodeDeviceIp = cameraApiConfig.getDecodeDeviceIp();
+		AllStaticConfig.decodeDeviceUserName = cameraApiConfig.getDecodeDeviceUserName();
+		AllStaticConfig.decodeDevicePassword = cameraApiConfig.getDecodeDevicePassword();
+		AllStaticConfig.decodeDevicePort = cameraApiConfig.getDecodeDevicePort();
 		
-		log.info("SystemInit start");
-		System.out.println("端口号:"+serverConfig.getUrl());
-		log.info("SystemInit ...");
-		log.info("SystemInit end");
-
 		//启动定时清除文件的定时器
 		TimerInterval.startClearFileTimer();
+		
+		if (cvrConfig.isSdkEnable()) {
+			// SDK初始化
+			init();
+		}
 	}
 
+	public static boolean init() {
+		if (!isInit) {
+			// 初始化
+			hCNetSDK = HCNetSDK.INSTANCE;
+			isInit = hCNetSDK.NET_DVR_Init();
+		}
+		return isInit;
+	}
+	
+	/**
+	 * 登录
+	 * 
+	 * @param m_sUsername
+	 * @param m_sPassword
+	 * @param m_sDeviceIP
+	 * @param wPort
+	 * @return
+	 * @date 2022年6月28日 下午4:55:40
+	 */
+	public static HCNetSDK.NET_DVR_USER_LOGIN_INFO getLoginObject(String m_sUsername, String m_sPassword, String m_sDeviceIP, short wPort) {
+		HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
+
+        m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
+        System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
+
+        m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
+        System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
+
+        m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
+        System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
+
+        m_strLoginInfo.wPort = wPort;
+        m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
+        m_strLoginInfo.write();
+        
+        return m_strLoginInfo;
+	}
+	
 }

+ 3 - 3
src/main/java/com/persagy/cameractl/service/HkCameraExecuteApi.java

@@ -12,7 +12,6 @@ import org.springframework.stereotype.Component;
 
 import com.hikvision.artemis.sdk.ArtemisHttpUtil;
 import com.hikvision.artemis.sdk.config.ArtemisConfig;
-import com.persagy.cameractl.conf.AllStaticConfig;
 import com.persagy.cameractl.conf.CameraApiConfig;
 import com.persagy.cameractl.utils.Camera;
 import com.persagy.cameractl.utils.CmdStreamThread;
@@ -29,6 +28,7 @@ import net.sf.json.JSONObject;
 @Component
 public class HkCameraExecuteApi {
 	Logger logger = LoggerFactory.getLogger(HkCameraExecuteApi.class);
+	
 	@Autowired
 	private CameraApiConfig cameraApiConfig;
 
@@ -174,8 +174,8 @@ public class HkCameraExecuteApi {
 
 			JSONObject jsonBody = new JSONObject();
 			jsonBody.put("cameraIndexCode", hkCamera.cameraIndexCode);
-			if (StrUtil.isNotBlank(AllStaticConfig.recordLocation)) {
-				jsonBody.put("recordLocation", AllStaticConfig.recordLocation);
+			if (StrUtil.isNotBlank(cameraApiConfig.getRecordLocation())) {
+				jsonBody.put("recordLocation", cameraApiConfig.getRecordLocation());
 			}
 			jsonBody.put("protocol", hkCamera.protocol);
 			jsonBody.put("beginTime", hkCamera.startDateStr.replace(" ", "T") + ".000+08:00");

文件差异内容过多而无法显示
+ 1 - 1
src/main/resources/application.yml