Parcourir la source

添加dahua依赖

james il y a 1 jour
Parent
commit
dfb82578c0

+ 71 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/DahuaNvrInfo.java

@@ -0,0 +1,71 @@
+package com.usky.sas.common.dahua;
+
+public class DahuaNvrInfo {
+    private Long loginHandle;
+    private int maxChannelNum;
+
+    public DahuaNvrInfo() {
+    }
+
+    public Long getLoginHandle() {
+        return this.loginHandle;
+    }
+
+    public int getMaxChannelNum() {
+        return this.maxChannelNum;
+    }
+
+    public void setLoginHandle(Long loginHandle) {
+        this.loginHandle = loginHandle;
+    }
+
+    public void setMaxChannelNum(int maxChannelNum) {
+        this.maxChannelNum = maxChannelNum;
+    }
+
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        } else if (!(o instanceof DahuaNvrInfo)) {
+            return false;
+        } else {
+            DahuaNvrInfo other = (DahuaNvrInfo)o;
+            if (!other.canEqual(this)) {
+                return false;
+            } else {
+                Object this$loginHandle = this.getLoginHandle();
+                Object other$loginHandle = other.getLoginHandle();
+                if (this$loginHandle == null) {
+                    if (other$loginHandle != null) {
+                        return false;
+                    }
+                } else if (!this$loginHandle.equals(other$loginHandle)) {
+                    return false;
+                }
+
+                if (this.getMaxChannelNum() != other.getMaxChannelNum()) {
+                    return false;
+                } else {
+                    return true;
+                }
+            }
+        }
+    }
+
+    protected boolean canEqual(Object other) {
+        return other instanceof DahuaNvrInfo;
+    }
+
+    public int hashCode() {
+        int PRIME = 59;
+        int result = 1;
+        Object $loginHandle = this.getLoginHandle();
+        result = result * 59 + ($loginHandle == null ? 43 : $loginHandle.hashCode());
+        result = result * 59 + this.getMaxChannelNum();
+        return result;
+    }
+
+    public String toString() {
+        return "DahuaNvrInfo(loginHandle=" + this.getLoginHandle() + ", maxChannelNum=" + this.getMaxChannelNum() + ")";
+    }
+}

+ 88 - 72
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/DahuaVideoStreamService.java

@@ -20,77 +20,57 @@ import static java.lang.Long.toHexString;
 @Component
 public class DahuaVideoStreamService {
     private static final Logger log = LoggerFactory.getLogger(DahuaVideoStreamService.class);
-    
-    // Placeholder constants and maps
-    public static class Constant {
-        public static long globalSsrc = 0;
-    }
-    
-    // Placeholder StreamContext
-    public static class StreamContext {
-        public long ssrc;
-        public StreamContext(String ip, int port) throws IOException {}
-        public void close() {}
-    }
-    
-    // Placeholder FPlayDataCallBackEx
-    public static class FPlayDataCallBackEx implements NetSDKLib.fDataCallBack {
-        public FPlayDataCallBackEx(StreamContext context, String mac) {}
-        public int invoke(Long lPlayHandle, int dwDataType, byte[] pBuffer, int dwBufSize, int dwUser) { return 0; }
+    static int iPlayBack;
+    static final int RTP_HEADER_SIZE = 12;
+    static final int RTP_VERSION = 2;
+    static final int RTP_PAYLOAD_TYPE = 96;
+    public static final int MAX_RTP_PACKET_SIZE = 1400;
+    static Map<String, NetSDKLib.fDataCallBack> dahuaPlayDataCallBackMap;
+    static Map<String, StreamContext> streamContextMap;
+    static Map<String, DahuaVideoInfo> dahuaVideoInfo;
+
+    public DahuaVideoStreamService() {
     }
 
-    // Placeholder NetSDKLib interface
-    public interface NetSDKLib {
-        interface fDataCallBack {
-            int invoke(Long lPlayHandle, int dwDataType, byte[] pBuffer, int dwBufSize, int dwUser);
-        }
-        class NET_TIME {
-            public void setTime(int year, int month, int day, int hour, int minute, int second) {}
+    public static byte[] createRtpPacket(byte[] data, int offset, int size, boolean marker, long timestamp, int sequenceNumber, long ssrc) {
+        byte[] rtpPacket = new byte[12 + size];
+        rtpPacket[0] = -128;
+        rtpPacket[1] = 96;
+        if (marker) {
+            rtpPacket[1] |= -128;
         }
-        class NET_IN_PLAYBACK_BY_DATA_TYPE {
-            public int emDataType;
-            public int nChannelID;
-            public NET_TIME stStartTime;
-            public NET_TIME stStopTime;
-            public int nPlayDirection;
-            public Object dwPosUser;
-            public Object hWnd;
-            public Object cbDownLoadPos;
-            public fDataCallBack fDownLoadDataCallBack;
-            public Object fDownLoadDataCallBackEx;
-            public Object dwDataUser;
-        }
-        class NET_OUT_PLAYBACK_BY_DATA_TYPE {}
-        
-        Long CLIENT_PlayBackByDataType(Long userID, NET_IN_PLAYBACK_BY_DATA_TYPE stIn, NET_OUT_PLAYBACK_BY_DATA_TYPE stOut, int timeout);
-        int CLIENT_GetLastError();
-        boolean CLIENT_StopPlayBack(Long lPlayHandle);
-    }
-    
-    // Mocking InitNetSDKLib.dhNetSDK
-    public static class InitNetSDKLib {
-        public static NetSDKLib dhNetSDK = new NetSDKLib() {
-            @Override
-            public Long CLIENT_PlayBackByDataType(Long userID, NET_IN_PLAYBACK_BY_DATA_TYPE stIn, NET_OUT_PLAYBACK_BY_DATA_TYPE stOut, int timeout) { return 1L; }
-            @Override
-            public int CLIENT_GetLastError() { return 0; }
-            @Override
-            public boolean CLIENT_StopPlayBack(Long lPlayHandle) { return true; }
-        };
+
+        rtpPacket[2] = (byte)(sequenceNumber >> 8);
+        rtpPacket[3] = (byte)(sequenceNumber & 255);
+        rtpPacket[4] = (byte)((int)(timestamp >> 24));
+        rtpPacket[5] = (byte)((int)(timestamp >> 16));
+        rtpPacket[6] = (byte)((int)(timestamp >> 8));
+        rtpPacket[7] = (byte)((int)(timestamp & 255L));
+        rtpPacket[8] = (byte)((int)(ssrc >> 24));
+        rtpPacket[9] = (byte)((int)(ssrc >> 16));
+        rtpPacket[10] = (byte)((int)(ssrc >> 8));
+        rtpPacket[11] = (byte)((int)(ssrc & 255L));
+        System.arraycopy(data, offset, rtpPacket, 12, size);
+        return rtpPacket;
     }
 
-    static Map<String, NetSDKLib.fDataCallBack> dahuaPlayDataCallBackMap = new ConcurrentHashMap<>();
-    static Map<String, StreamContext> streamContextMap = new ConcurrentHashMap<>();
-    static Map<String, Object> dahuaVideoInfo = new ConcurrentHashMap<>();
+    public static byte[] createTcpPacket(byte[] rtpPacket) {
+        byte[] tcpPacket = new byte[rtpPacket.length + 2];
+        tcpPacket[0] = (byte)(rtpPacket.length >> 8 & 255);
+        tcpPacket[1] = (byte)(rtpPacket.length & 255);
+        System.arraycopy(rtpPacket, 0, tcpPacket, 2, rtpPacket.length);
+        return tcpPacket;
+    }
 
     public static VideoStreamVo playBackByTime(String oldMac, String macAddr, Long userID, int lChannel, int mediaRtpPort, Integer mediaHttpPort, Date beginTime, Date endTime) {
         if (StrUtil.isNotBlank(oldMac) && streamContextMap.containsKey(oldMac)) {
-            streamContextMap.get(oldMac).close();
+            ((StreamContext)streamContextMap.get(oldMac)).close();
             streamContextMap.remove(oldMac);
             dahuaPlayDataCallBackMap.remove(oldMac);
         }
 
         StreamContext context = null;
+
         try {
             context = new StreamContext(GetIpUtils.getServerIP(), mediaRtpPort);
             log.info("设备 {} RTP连接已建立: {}:{}", new Object[]{macAddr, GetIpUtils.getServerIP(), mediaRtpPort});
@@ -105,8 +85,6 @@ public class DahuaVideoStreamService {
         streamContextMap.put(newMac, context);
         FPlayDataCallBackEx playDataCallBack = new FPlayDataCallBackEx(context, newMac);
         dahuaPlayDataCallBackMap.put(newMac, playDataCallBack);
-
-        NetSDKLib.NET_IN_PLAYBACK_BY_DATA_TYPE stIn = new NetSDKLib.NET_IN_PLAYBACK_BY_DATA_TYPE();
         int beginYear = DateUtil.year(beginTime);
         int beginMonth = DateUtil.month(beginTime) + 1;
         int beginDay = DateUtil.dayOfMonth(beginTime);
@@ -123,13 +101,20 @@ public class DahuaVideoStreamService {
         int endSecond = DateUtil.second(endTime);
         NetSDKLib.NET_TIME end = new NetSDKLib.NET_TIME();
         end.setTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);
-        
+        NetSDKLib.NET_IN_PLAYBACK_BY_DATA_TYPE stIn = new NetSDKLib.NET_IN_PLAYBACK_BY_DATA_TYPE();
+        stIn.emDataType = 1;
+        stIn.nChannelID = lChannel;
         stIn.stStartTime = begin;
         stIn.stStopTime = end;
-        
+        stIn.nPlayDirection = 0;
+        stIn.dwPosUser = null;
+        stIn.hWnd = null;
+        stIn.cbDownLoadPos = null;
+        stIn.fDownLoadDataCallBack = playDataCallBack;
+        stIn.fDownLoadDataCallBackEx = null;
+        stIn.dwDataUser = null;
         NetSDKLib.NET_OUT_PLAYBACK_BY_DATA_TYPE stOut = new NetSDKLib.NET_OUT_PLAYBACK_BY_DATA_TYPE();
         Long lPlayHandle = InitNetSDKLib.dhNetSDK.CLIENT_PlayBackByDataType(userID, stIn, stOut, 5000);
-        
         if (lPlayHandle != 0L) {
             log.info("回放取流成功,回放句柄:{}", lPlayHandle);
             log.info("取流成功,播放地址:" + GetIpUtils.getServerIP() + ":" + mediaHttpPort + "/index/api/webrtc?app=rtp&stream=" + context.ssrc + "&type=play");
@@ -150,17 +135,48 @@ public class DahuaVideoStreamService {
     }
 
     public static void stopPlayStreamData(Long PlayHandle, String macAddr) {
-        if (PlayHandle != 0L) {
-            if (!InitNetSDKLib.dhNetSDK.CLIENT_StopPlayBack(PlayHandle)) {
-                log.error("停止取流失败,err:" + InitNetSDKLib.dhNetSDK.CLIENT_GetLastError());
-            } else {
-                log.info("停止取流成功");
-                StreamContext context = streamContextMap.get(macAddr);
-                if (context != null) {
-                    context.close();
+        if (PlayHandle == 0L) {
+            log.info("回放取流未开启,请先开启回放取流");
+        } else if (!InitNetSDKLib.dhNetSDK.CLIENT_StopPlayBack(PlayHandle)) {
+            log.error("停止取流失败,err:" + InitNetSDKLib.dhNetSDK.CLIENT_GetLastError());
+        } else {
+            log.info("停止取流成功");
+            StreamContext context = (StreamContext)streamContextMap.get(macAddr);
+            if (context != null) {
+                context.close();
+            }
+
+            dahuaPlayDataCallBackMap.remove(macAddr);
+        }
+    }
+
+    public static String toHexString(long number) {
+        if (number == 0L) {
+            return "0";
+        } else {
+            StringBuilder hex = new StringBuilder();
+            char[] hexChars = "0123456789ABCDEF".toCharArray();
+
+            for(long current = number; current != 0L; current >>>= 4) {
+                int digit = (int)(current & 15L);
+                hex.insert(0, hexChars[digit]);
+            }
+
+            if (hex.length() < 8) {
+                int zerosToAdd = 8 - hex.length();
+
+                for(int i = 0; i < zerosToAdd; ++i) {
+                    hex.insert(0, '0');
                 }
-                dahuaPlayDataCallBackMap.remove(macAddr);
             }
+
+            return hex.toString();
         }
     }
+
+    static {
+        dahuaPlayDataCallBackMap = GlobalMemoryMap.dahuaPlayDataCallBackMap;
+        streamContextMap = GlobalMemoryMap.streamContextMap;
+        dahuaVideoInfo = GlobalMemoryMap.dahuaVideoInfo;
+    }
 }

+ 10 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/EM_SEND_SEARCH_TYPE.java

@@ -0,0 +1,10 @@
+package com.usky.sas.common.dahua;
+
+public enum EM_SEND_SEARCH_TYPE {
+    EM_SEND_SEARCH_TYPE_MULTICAST_AND_BROADCAST,
+    EM_SEND_SEARCH_TYPE_MULTICAST,
+    EM_SEND_SEARCH_TYPE_BROADCAST;
+
+    private EM_SEND_SEARCH_TYPE() {
+    }
+}

+ 58 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/FPlayDataCallBackEx.java

@@ -0,0 +1,58 @@
+package com.usky.sas.common.dahua;
+
+import com.usky.sas.common.global.StreamContext;
+import com.sun.jna.Pointer;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FPlayDataCallBackEx implements NetSDKLib.fDataCallBack {
+    private static final Logger log = LoggerFactory.getLogger(FPlayDataCallBackEx.class);
+    StreamContext context;
+    String macAddr;
+
+    public FPlayDataCallBackEx(StreamContext context, String macAddr) {
+        this.context = context;
+        this.macAddr = macAddr;
+    }
+
+    public void invoke(Long lRealHandle, int dwDataType, Pointer pBuffer, int dwBufSize, Pointer dwUser) {
+        try {
+            if (dwBufSize > 2097152) {
+                log.warn("Frame size too large ({}) - truncating to {}", dwBufSize, 2097152);
+                dwBufSize = 2097152;
+            }
+
+            ByteBuffer buffer = pBuffer.getByteBuffer(0L, (long)dwBufSize);
+            buffer.get(this.context.frameBuffer, 0, dwBufSize);
+            long currentTimestamp = (long)this.context.baseTimestamp;
+            StreamContext var10000 = this.context;
+            var10000.baseTimestamp += 3600;
+            int offset = 0;
+
+            int packetSize;
+            for(int remaining = dwBufSize; remaining > 0; remaining -= packetSize) {
+                packetSize = Math.min(remaining, 1400);
+                boolean marker = remaining == packetSize;
+                byte[] rtpPacket = DahuaVideoStreamService.createRtpPacket(this.context.frameBuffer, offset, packetSize, marker, currentTimestamp, this.context.sequenceNumber, this.context.ssrc);
+                byte[] tcpPacket = DahuaVideoStreamService.createTcpPacket(rtpPacket);
+                this.context.sendExecutor.submit(() -> {
+                    try {
+                        this.context.rtpOutputStream.write(tcpPacket);
+                        this.context.rtpOutputStream.flush();
+                    } catch (IOException e) {
+                        log.error("RTP数据发送失败: {}", e.getMessage(), e);
+                    }
+
+                });
+                this.context.sequenceNumber = this.context.sequenceNumber + 1 & '\uffff';
+                offset += packetSize;
+            }
+        } catch (Exception var15) {
+            DahuaVideoStreamService.stopPlayStreamData(lRealHandle, this.macAddr);
+            this.context.close();
+        }
+
+    }
+}

+ 62 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/FRealDataCallBackEx.java

@@ -0,0 +1,62 @@
+package com.usky.sas.common.dahua;
+
+import com.usky.sas.common.global.StreamContext;
+import com.sun.jna.Pointer;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FRealDataCallBackEx implements NetSDKLib.fRealDataCallBackEx {
+    private static final Logger log = LoggerFactory.getLogger(FRealDataCallBackEx.class);
+    StreamContext context;
+    String macAddr;
+
+    public FRealDataCallBackEx(StreamContext context, String macAddr) {
+        this.context = context;
+        this.macAddr = macAddr;
+    }
+
+    public void invoke(Long lRealHandle, int dwDataType, Pointer pBuffer, int dwBufSize, int param, Pointer dwUser) {
+        try {
+            log.info("实时预览回调");
+            if (dwBufSize > 2097152) {
+                log.warn("Frame size too large ({}) - truncating to {}", dwBufSize, 2097152);
+                dwBufSize = 2097152;
+            }
+
+            ByteBuffer buffer = pBuffer.getByteBuffer(0L, (long)dwBufSize);
+            buffer.get(this.context.frameBuffer, 0, dwBufSize);
+            if (dwDataType == 0) {
+                log.info("原始数据");
+                long currentTimestamp = (long)this.context.baseTimestamp;
+                StreamContext var10000 = this.context;
+                var10000.baseTimestamp += 3600;
+                int offset = 0;
+
+                int packetSize;
+                for(int remaining = dwBufSize; remaining > 0; remaining -= packetSize) {
+                    packetSize = Math.min(remaining, 1400);
+                    boolean marker = remaining == packetSize;
+                    byte[] rtpPacket = DahuaVideoStreamService.createRtpPacket(this.context.frameBuffer, offset, packetSize, marker, currentTimestamp, this.context.sequenceNumber, this.context.ssrc);
+                    byte[] tcpPacket = DahuaVideoStreamService.createTcpPacket(rtpPacket);
+                    this.context.sendExecutor.submit(() -> {
+                        try {
+                            this.context.rtpOutputStream.write(tcpPacket);
+                            this.context.rtpOutputStream.flush();
+                        } catch (IOException e) {
+                            log.error("RTP数据发送失败: {}", e.getMessage(), e);
+                        }
+
+                    });
+                    this.context.sequenceNumber = this.context.sequenceNumber + 1 & '\uffff';
+                    offset += packetSize;
+                }
+            }
+        } catch (Exception e) {
+            log.error("设备 {} 数据发送失败: {}", this.macAddr, e.getMessage());
+            this.context.close();
+        }
+
+    }
+}

+ 247 - 5
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/InitNetSDKLib.java

@@ -1,12 +1,254 @@
 package com.usky.sas.common.dahua;
 
-import com.usky.sas.common.entity.DahuaNvrInfo;
+import cn.hutool.core.util.StrUtil;
+import com.usky.sas.common.exception.BusinessException;
+import com.usky.sas.common.global.GlobalMemoryMap;
+import com.usky.sas.common.hik.OsSelect;
+import com.usky.sas.service.impl.DeviceServiceImpl;
+import com.sun.jna.Callback;
+import com.sun.jna.Memory;
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class InitNetSDKLib {
-    public static Integer getIpcChannel(Long loginHandle, String ip, Integer maxChannel) {
-        return 1;
+    private static final Logger log = LoggerFactory.getLogger(InitNetSDKLib.class);
+    static Map<String, DahuaNvrInfo> dhNvrUser;
+    public static Map<String, NetSDKLib> dhSDKHashMap;
+    public static NetSDKLib dhNetSDK;
+
+    public InitNetSDKLib() {
+    }
+
+    private static boolean createSDKInstance() {
+        if (dhNetSDK == null) {
+            synchronized(NetSDKLib.class) {
+                String strDllPath = "";
+
+                try {
+                    if (OsSelect.isWindows()) {
+                        strDllPath = "C:\\Users\\41932\\Desktop\\dahua\\libs\\win64\\dhnetsdk.dll";
+                    } else if (OsSelect.isLinux()) {
+                        strDllPath = "/www/wwwroot/fjkjagapp.fj724.com/dhSDK/libdhnetsdk.so";
+                    }
+
+                    dhNetSDK = (NetSDKLib)Native.loadLibrary(strDllPath, NetSDKLib.class);
+                    log.info("初始化NetSDKLib成功============");
+                    dhNetSDK.CLIENT_Init((Callback)null, (Pointer)null);
+                    dhNetSDK.CLIENT_SetAutoReconnect((Callback)null, (Pointer)null);
+                    dhNetSDK.CLIENT_SetConnectTime(10000, 1);
+                    dhSDKHashMap.put("dhNetSDK", dhNetSDK);
+                    NetSDKLib.LOG_SET_PRINT_INFO setLog = new NetSDKLib.LOG_SET_PRINT_INFO();
+                    File path = new File("./dhsdklog/");
+                    if (!path.exists()) {
+                        path.mkdir();
+                    }
+
+                    String logPath = path.getAbsoluteFile().getParent() + "\\dhsdklog\\" + getDate() + ".log";
+                    setLog.nPrintStrategy = 0;
+                    setLog.bSetFilePath = 1;
+                    System.arraycopy(logPath.getBytes(), 0, setLog.szLogFilePath, 0, logPath.getBytes().length);
+                    setLog.bSetPrintStrategy = 1;
+                    boolean bLogopen = dhNetSDK.CLIENT_LogOpen(setLog);
+                    if (!bLogopen) {
+                        log.error("打开日志失败");
+                    }
+                } catch (Exception ex) {
+                    log.error("初始化失败,loadLibrary: " + strDllPath + " Error: " + ex.getMessage());
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    public static String getDate() {
+        SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String date = simpleDate.format(new Date()).replace(" ", "_").replace(":", "-");
+        return date;
+    }
+
+    public static Long login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword) {
+        NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY pstInParam = new NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY();
+        pstInParam.nPort = m_nPort;
+        pstInParam.szIP = m_strIp.getBytes();
+        pstInParam.szPassword = m_strPassword.getBytes();
+        pstInParam.szUserName = m_strUser.getBytes();
+        NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam = new NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY();
+        Long m_hLoginHandle = dhNetSDK.CLIENT_LoginWithHighLevelSecurity(pstInParam, pstOutParam);
+        if (m_hLoginHandle == 0L) {
+            log.error("设备:{}:{}登录失败,原因:{}", new Object[]{m_strIp, m_nPort, dhNetSDK.CLIENT_GetLastError()});
+            throw new BusinessException("请检查设备IP、端口、用户名、密码等配置是否正确!", -1);
+        } else {
+            log.info("设备:{}:{}登陆成功,句柄:{}", new Object[]{m_strIp, m_nPort, m_hLoginHandle});
+            return m_hLoginHandle;
+        }
+    }
+
+    public static DahuaNvrInfo nvrLogin(String m_strIp, int m_nPort, String m_strUser, String m_strPassword, String mac) {
+        NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY pstInParam = new NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY();
+        pstInParam.nPort = m_nPort;
+        pstInParam.szIP = m_strIp.getBytes();
+        pstInParam.szPassword = m_strPassword.getBytes();
+        pstInParam.szUserName = m_strUser.getBytes();
+        NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam = new NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY();
+        Long m_hLoginHandle = dhNetSDK.CLIENT_LoginWithHighLevelSecurity(pstInParam, pstOutParam);
+        if (m_hLoginHandle == 0L) {
+            log.error("设备:{}:{}登录失败,原因:{}", new Object[]{m_strIp, m_nPort, dhNetSDK.CLIENT_GetLastError()});
+            throw new BusinessException("请检查设备IP、端口、用户名、密码等配置是否正确!", -1);
+        } else {
+            log.info("设备:{}:{}登陆成功,句柄:{}", new Object[]{m_strIp, m_nPort, m_hLoginHandle});
+            DahuaNvrInfo dahuaNvrInfo = new DahuaNvrInfo();
+            dahuaNvrInfo.setLoginHandle(m_hLoginHandle);
+            dahuaNvrInfo.setMaxChannelNum(pstOutParam.stuDeviceInfo.byChanNum);
+            dhNvrUser.put(mac, dahuaNvrInfo);
+            return dahuaNvrInfo;
+        }
+    }
+
+    public static List<RemoteDeviceInfo> getNvrChannel(String m_strIp, int m_nPort, String m_strUser, String m_strPassword) {
+        NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY pstInParam = new NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY();
+        pstInParam.nPort = m_nPort;
+        pstInParam.szIP = m_strIp.getBytes();
+        pstInParam.szPassword = m_strPassword.getBytes();
+        pstInParam.szUserName = m_strUser.getBytes();
+        NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam = new NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY();
+        Long m_hLoginHandle = dhNetSDK.CLIENT_LoginWithHighLevelSecurity(pstInParam, pstOutParam);
+        if (m_hLoginHandle == 0L) {
+            log.error("设备:{}:{}登录失败,原因:{}", new Object[]{m_strIp, m_nPort, dhNetSDK.CLIENT_GetLastError()});
+            throw new BusinessException("请检查NVR设备IP、端口、用户名、密码等配置是否正确!", -1);
+        } else {
+            log.info("设备:{}:{}登陆成功,句柄:{}", new Object[]{m_strIp, m_nPort, m_hLoginHandle});
+            DahuaNvrInfo dahuaNvrInfo = new DahuaNvrInfo();
+            dahuaNvrInfo.setLoginHandle(m_hLoginHandle);
+            dahuaNvrInfo.setMaxChannelNum(pstOutParam.stuDeviceInfo.byChanNum);
+            dhNvrUser.put(m_strIp, dahuaNvrInfo);
+            List<RemoteDeviceInfo> list = new ArrayList();
+            int byChanNum = pstOutParam.stuDeviceInfo.byChanNum;
+            if (byChanNum != 0) {
+                NetSDKLib.NET_MATRIX_CAMERA_INFO[] cameras = new NetSDKLib.NET_MATRIX_CAMERA_INFO[byChanNum];
+
+                for(int i = 0; i < byChanNum; ++i) {
+                    NetSDKLib.NET_MATRIX_CAMERA_INFO camera = new NetSDKLib.NET_MATRIX_CAMERA_INFO();
+                    NetSDKLib.NET_REMOTE_DEVICE device = new NetSDKLib.NET_REMOTE_DEVICE();
+                    camera.stuRemoteDevice = device;
+                    cameras[i] = camera;
+                }
+
+                NetSDKLib.NET_IN_MATRIX_GET_CAMERAS inMatrixGetCameras = new NetSDKLib.NET_IN_MATRIX_GET_CAMERAS();
+                inMatrixGetCameras.dwSize = inMatrixGetCameras.size();
+                NetSDKLib.NET_OUT_MATRIX_GET_CAMERAS outMatrixGetCameras = new NetSDKLib.NET_OUT_MATRIX_GET_CAMERAS();
+                outMatrixGetCameras.dwSize = outMatrixGetCameras.size();
+                outMatrixGetCameras.nMaxCameraCount = byChanNum;
+                outMatrixGetCameras.pstuCameras = new Memory((long)(cameras[0].size() * byChanNum));
+                outMatrixGetCameras.pstuCameras.clear((long)(cameras[0].size() * byChanNum));
+                SetStructArrToPointerData(cameras, outMatrixGetCameras.pstuCameras);
+                boolean getCameras = dhNetSDK.CLIENT_MatrixGetCameras(m_hLoginHandle, inMatrixGetCameras, outMatrixGetCameras, 5000);
+                if (getCameras) {
+                    GetPointerDataToStructArr(outMatrixGetCameras.pstuCameras, cameras);
+
+                    for(int i = 0; i < outMatrixGetCameras.nRetCameraCount; ++i) {
+                        int isRemoteDevice = cameras[i].bRemoteDevice;
+                        if (isRemoteDevice == 1) {
+                            NetSDKLib.NET_REMOTE_DEVICE remoteDevice = cameras[i].stuRemoteDevice;
+                            String deviceName = (new String(remoteDevice.szDevName)).trim();
+                            String ipAddr = (new String(remoteDevice.szIp)).trim();
+                            if (StrUtil.isNotBlank(ipAddr) && !ipAddr.equals("0.0.0.0") && !ipAddr.equals("192.168.0.0") && StrUtil.isNotBlank(deviceName)) {
+                                RemoteDeviceInfo info = new RemoteDeviceInfo();
+                                info.setChannel(cameras[i].nUniqueChannel + 1);
+                                info.setIpAddr(ipAddr);
+                                info.setNote(deviceName);
+                                list.add(info);
+                            }
+                        }
+                    }
+                }
+            }
+
+            return list;
+        }
+    }
+
+    public static Integer getIpcChannel(Long loginHandle, String ipAddr, int byChanNum) {
+        if (byChanNum != 0) {
+            NetSDKLib.NET_MATRIX_CAMERA_INFO[] cameras = new NetSDKLib.NET_MATRIX_CAMERA_INFO[byChanNum];
+
+            for(int i = 0; i < byChanNum; ++i) {
+                NetSDKLib.NET_MATRIX_CAMERA_INFO camera = new NetSDKLib.NET_MATRIX_CAMERA_INFO();
+                NetSDKLib.NET_REMOTE_DEVICE device = new NetSDKLib.NET_REMOTE_DEVICE();
+                camera.stuRemoteDevice = device;
+                cameras[i] = camera;
+            }
+
+            NetSDKLib.NET_IN_MATRIX_GET_CAMERAS inMatrixGetCameras = new NetSDKLib.NET_IN_MATRIX_GET_CAMERAS();
+            inMatrixGetCameras.dwSize = inMatrixGetCameras.size();
+            NetSDKLib.NET_OUT_MATRIX_GET_CAMERAS outMatrixGetCameras = new NetSDKLib.NET_OUT_MATRIX_GET_CAMERAS();
+            outMatrixGetCameras.dwSize = outMatrixGetCameras.size();
+            outMatrixGetCameras.nMaxCameraCount = byChanNum;
+            outMatrixGetCameras.pstuCameras = new Memory((long)(cameras[0].size() * byChanNum));
+            outMatrixGetCameras.pstuCameras.clear((long)(cameras[0].size() * byChanNum));
+            SetStructArrToPointerData(cameras, outMatrixGetCameras.pstuCameras);
+            boolean getCameras = dhNetSDK.CLIENT_MatrixGetCameras(loginHandle, inMatrixGetCameras, outMatrixGetCameras, 5000);
+            if (getCameras) {
+                GetPointerDataToStructArr(outMatrixGetCameras.pstuCameras, cameras);
+
+                for(int i = 0; i < outMatrixGetCameras.nRetCameraCount; ++i) {
+                    int isRemoteDevice = cameras[i].bRemoteDevice;
+                    if (isRemoteDevice == 1) {
+                        NetSDKLib.NET_REMOTE_DEVICE remoteDevice = cameras[i].stuRemoteDevice;
+                        String ip = (new String(remoteDevice.szIp)).trim();
+                        if (ip.equals(ipAddr)) {
+                            return cameras[i].nUniqueChannel;
+                        }
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+
+    public static void SetStructArrToPointerData(Structure[] pJavaStuArr, Pointer pNativeData) {
+        long offset = 0L;
+
+        for(int i = 0; i < pJavaStuArr.length; ++i) {
+            DeviceServiceImpl.SetStructDataToPointer(pJavaStuArr[i], pNativeData, offset);
+            offset += (long)pJavaStuArr[i].size();
+        }
+
     }
-    public static DahuaNvrInfo nvrLogin(String ip, Integer port, String user, String password, String deviceId) {
-        return new DahuaNvrInfo();
+
+    public static void GetPointerDataToStruct(Pointer pNativeData, long OffsetOfpNativeData, Structure pJavaStu) {
+        pJavaStu.write();
+        Pointer pJavaMem = pJavaStu.getPointer();
+        pJavaMem.write(0L, pNativeData.getByteArray(OffsetOfpNativeData, pJavaStu.size()), 0, pJavaStu.size());
+        pJavaStu.read();
+    }
+
+    public static void GetPointerDataToStructArr(Pointer pNativeData, Structure[] pJavaStuArr) {
+        long offset = 0L;
+
+        for(int i = 0; i < pJavaStuArr.length; ++i) {
+            GetPointerDataToStruct(pNativeData, offset, pJavaStuArr[i]);
+            offset += (long)pJavaStuArr[i].size();
+        }
+
+    }
+
+    static {
+        dhNvrUser = GlobalMemoryMap.dhNvrUser;
+        dhSDKHashMap = new ConcurrentHashMap();
+        dhNetSDK = (NetSDKLib)dhSDKHashMap.get("dhNetSDK");
+        createSDKInstance();
     }
 }

+ 13 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/NET_BRIDGE_NET_CARDS_MAC_LIST.java

@@ -0,0 +1,13 @@
+package com.usky.sas.common.dahua;
+
+import com.sun.jna.Structure;
+
+public class NET_BRIDGE_NET_CARDS_MAC_LIST extends Structure {
+    public byte[] szNetCardName = new byte[32];
+    public byte[] szNetCardMac = new byte[18];
+    public byte[] szReserved = new byte[14];
+
+    public NET_BRIDGE_NET_CARDS_MAC_LIST() {
+    }
+}
+

+ 21 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/NET_IN_STARTSERACH_DEVICE.java

@@ -0,0 +1,21 @@
+package com.usky.sas.common.dahua;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+import java.util.Arrays;
+import java.util.List;
+
+public class NET_IN_STARTSERACH_DEVICE extends Structure {
+    public int dwSize = this.size();
+    public byte[] szLocalIp = new byte[64];
+    public NetSDKLib.fSearchDevicesCBEx cbSearchDevices;
+    public Pointer pUserData;
+    public int emSendType;
+
+    public NET_IN_STARTSERACH_DEVICE() {
+    }
+
+    protected List<String> getFieldOrder() {
+        return Arrays.asList("dwSize", "szLocalIp", "cbSearchDevices", "pUserData", "emSendType");
+    }
+}

+ 16 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/NET_OUT_STARTSERACH_DEVICE.java

@@ -0,0 +1,16 @@
+package com.usky.sas.common.dahua;
+
+import com.sun.jna.Structure;
+import java.util.Arrays;
+import java.util.List;
+
+public class NET_OUT_STARTSERACH_DEVICE extends Structure {
+    public int dwSize = this.size();
+
+    public NET_OUT_STARTSERACH_DEVICE() {
+    }
+
+    protected List<String> getFieldOrder() {
+        return Arrays.asList("dwSize");
+    }
+}

+ 575 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/NetSDKLib.java

@@ -0,0 +1,575 @@
+package com.usky.sas.common.dahua;
+
+import com.sun.jna.Callback;
+import com.sun.jna.Library;
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+import java.util.Arrays;
+import java.util.List;
+
+public interface NetSDKLib extends Library {
+    int NET_SERIALNO_LEN = 48;
+    int MAX_LOG_PATH_LEN = 260;
+    int NET_MAX_SAERCH_IP_NUM = 256;
+    int NET_COMMON_STRING_64 = 64;
+    int NET_USER_NAME_LENGTH_EX = 16;
+    int NET_MACHINE_NAME_NUM = 64;
+    int NET_MACADDR_LEN = 40;
+    int NET_DEV_TYPE_LEN = 32;
+    int NET_DEV_SERIALNO_LEN = 48;
+    int NET_MAX_URL_LEN = 128;
+    int NET_MAX_STRING_LEN = 128;
+    int NET_DEV_ID_LEN_EX = 128;
+    int NET_DEV_NAME_LEN = 128;
+    int NET_COMMON_STRING_512 = 512;
+    int NET_DEV_CLASS_LEN = 16;
+    int NET_MAX_IPADDR_LEN = 16;
+    int NET_COMMON_STRING_128 = 128;
+    int NET_COMMON_STRING_32 = 32;
+
+    boolean CLIENT_Init(Callback var1, Pointer var2);
+
+    void CLIENT_Cleanup();
+
+    void CLIENT_SetAutoReconnect(Callback var1, Pointer var2);
+
+    int CLIENT_GetLastError();
+
+    void CLIENT_SetConnectTime(int var1, int var2);
+
+    void CLIENT_SetNetworkParam(NET_PARAM var1);
+
+    Long CLIENT_LoginWithHighLevelSecurity(NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY var1, NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY var2);
+
+    boolean CLIENT_Logout(Long var1);
+
+    Long CLIENT_StartSearchDevicesEx(Pointer var1, Pointer var2);
+
+    boolean CLIENT_SearchDevicesByIPs(DEVICE_IP_SEARCH_INFO var1, Callback var2, Pointer var3, String var4, int var5);
+
+    boolean CLIENT_StopSearchDevices(Long var1);
+
+    boolean CLIENT_LogOpen(LOG_SET_PRINT_INFO var1);
+
+    boolean CLIENT_GetChannelInfo(Long var1, NET_IN_GET_CHANNEL_INFO var2, NET_OUT_GET_CHANNEL_INFO var3, int var4);
+
+    Long CLIENT_StartRealPlay(Long var1, int var2, Pointer var3, int var4, Callback var5, Callback var6, Pointer var7, int var8);
+
+    boolean CLIENT_StopRealPlay(Long var1);
+
+    Long CLIENT_PlayBackByTimeEx(Long var1, int var2, NET_TIME var3, NET_TIME var4, Pointer var5, Callback var6, Pointer var7, Callback var8, Pointer var9);
+
+    Long CLIENT_PlayBackByDataType(Long var1, NET_IN_PLAYBACK_BY_DATA_TYPE var2, NET_OUT_PLAYBACK_BY_DATA_TYPE var3, int var4);
+
+    boolean CLIENT_FastPlayBack(Long var1);
+
+    boolean CLIENT_SlowPlayBack(Long var1);
+
+    boolean CLIENT_SetPlayBackSpeed(Long var1, int var2);
+
+    boolean CLIENT_MatrixGetCameras(Long var1, NET_IN_MATRIX_GET_CAMERAS var2, NET_OUT_MATRIX_GET_CAMERAS var3, int var4);
+
+    boolean CLIENT_SetDeviceMode(Long var1, int var2, Pointer var3);
+
+    boolean CLIENT_StopPlayBack(Long var1);
+
+    public static class NET_REMOTE_DEVICE extends Structure {
+        public int dwSize = this.size();
+        public int bEnable;
+        public byte[] szIp = new byte[16];
+        public byte[] szUser = new byte[8];
+        public byte[] szPwd = new byte[8];
+        public int nPort;
+        public int nDefinition;
+        public int emProtocol;
+        public byte[] szDevName = new byte[64];
+        public int nVideoInputChannels;
+        public int nAudioInputChannels;
+        public byte[] szDevClass = new byte[32];
+        public byte[] szDevType = new byte[32];
+        public int nHttpPort;
+        public int nMaxVideoInputCount;
+        public int nRetVideoInputCount;
+        public Pointer pstuVideoInputs;
+        public byte[] szMachineAddress = new byte[256];
+        public byte[] szSerialNo = new byte[48];
+        public int nRtspPort;
+        public byte[] szUserEx = new byte[32];
+        public byte[] szPwdEx = new byte[32];
+        public byte[] szVendorAbbr = new byte[32];
+        public byte[] szSoftwareVersion = new byte[64];
+        public NET_TIME stuActivationTime;
+        public byte[] szMac = new byte[20];
+        public int nHttpsPort;
+        public byte[] byReserved = new byte[4];
+        public Pointer pstuRemoteDevEx;
+
+        public NET_REMOTE_DEVICE() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "bEnable", "szIp", "szUser", "szPwd", "nPort", "nDefinition", "emProtocol", "szDevName", "nVideoInputChannels", "nAudioInputChannels", "szDevClass", "szDevType", "nHttpPort", "nMaxVideoInputCount", "nRetVideoInputCount", "pstuVideoInputs", "szMachineAddress", "szSerialNo", "nRtspPort", "szUserEx", "szPwdEx", "szVendorAbbr", "szSoftwareVersion", "stuActivationTime", "szMac", "nHttpsPort", "byReserved", "pstuRemoteDevEx");
+        }
+    }
+
+    public static class NET_MATRIX_CAMERA_INFO extends Structure {
+        public int dwSize = this.size();
+        public byte[] szName = new byte[128];
+        public byte[] szDevID = new byte[128];
+        public byte[] szszControlID = new byte[128];
+        public int nChannelID;
+        public int nUniqueChannel;
+        public int bRemoteDevice;
+        public NET_REMOTE_DEVICE stuRemoteDevice = new NET_REMOTE_DEVICE();
+        public int emStreamType;
+        public int emChannelType;
+        public int bEnable;
+        public int emVideoStream;
+
+        public NET_MATRIX_CAMERA_INFO() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "szName", "szDevID", "szszControlID", "nChannelID", "nUniqueChannel", "bRemoteDevice", "stuRemoteDevice", "emStreamType", "emChannelType", "bEnable", "emVideoStream");
+        }
+    }
+
+    public static class NET_IN_MATRIX_GET_CAMERAS extends Structure {
+        public int dwSize = this.size();
+
+        public NET_IN_MATRIX_GET_CAMERAS() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize");
+        }
+    }
+
+    public static class NET_OUT_MATRIX_GET_CAMERAS extends Structure {
+        public int dwSize = this.size();
+        public Pointer pstuCameras;
+        public int nMaxCameraCount;
+        public int nRetCameraCount;
+
+        public NET_OUT_MATRIX_GET_CAMERAS() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "pstuCameras", "nMaxCameraCount", "nRetCameraCount");
+        }
+    }
+
+    public static class EM_REAL_DATA_TYPE extends Structure {
+        public static final int EM_REAL_DATA_TYPE_PRIVATE = 0;
+        public static final int EM_REAL_DATA_TYPE_GBPS = 1;
+        public static final int EM_REAL_DATA_TYPE_TS = 2;
+        public static final int EM_REAL_DATA_TYPE_MP4 = 3;
+        public static final int EM_REAL_DATA_TYPE_H264 = 4;
+        public static final int EM_REAL_DATA_TYPE_FLV_STREAM = 5;
+
+        public EM_REAL_DATA_TYPE() {
+        }
+    }
+
+    public static class NET_IN_PLAYBACK_BY_DATA_TYPE extends Structure {
+        public int dwSize = this.size();
+        public int nChannelID;
+        public NET_TIME stStartTime;
+        public NET_TIME stStopTime;
+        public Pointer hWnd;
+        public Callback cbDownLoadPos;
+        public Pointer dwPosUser;
+        public Callback fDownLoadDataCallBack;
+        public int emDataType;
+        public Pointer dwDataUser;
+        public int nPlayDirection;
+        public int emAudioType;
+        public Callback fDownLoadDataCallBackEx;
+
+        public NET_IN_PLAYBACK_BY_DATA_TYPE() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "nChannelID", "stStartTime", "stStopTime", "hWnd", "cbDownLoadPos", "dwPosUser", "fDownLoadDataCallBack", "emDataType", "dwDataUser", "nPlayDirection", "emAudioType", "fDownLoadDataCallBackEx");
+        }
+    }
+
+    public static class NET_OUT_PLAYBACK_BY_DATA_TYPE extends Structure {
+        public int dwSize = this.size();
+
+        public NET_OUT_PLAYBACK_BY_DATA_TYPE() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize");
+        }
+    }
+
+    public static class NET_IN_GET_CHANNEL_INFO extends Structure {
+        public int dwSize = this.size();
+        public byte[] szDeviceID = new byte[128];
+
+        public NET_IN_GET_CHANNEL_INFO() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "szDeviceID");
+        }
+    }
+
+    public static class NET_OUT_GET_CHANNEL_INFO extends Structure {
+        public int dwSize = this.size();
+        public int nMaxCount;
+        public int nRetCount;
+        public Pointer pstuChannelInfo;
+
+        public NET_OUT_GET_CHANNEL_INFO() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "nMaxCount", "nRetCount", "pstuChannelInfo");
+        }
+    }
+
+    public static class NET_GET_CHANNEL_INFO extends Structure {
+        public int nRemoteChannel;
+        public int nLogicChannel;
+        public byte[] szName = new byte[128];
+        public byte[] szDetail = new byte[512];
+        public byte[] szDeviceType = new byte[64];
+        public byte[] szDeviceClass = new byte[16];
+        public byte[] szIP = new byte[16];
+        public byte[] szMac = new byte[40];
+        public byte[] szSerialNo = new byte[48];
+        public byte[] szDevSoftVersion = new byte[128];
+        public int nVideoInputCh;
+        public int nVideoOutputCh;
+        public int nAudioInputCh;
+        public int nAudioOutputCh;
+        public int nAlarmInputCh;
+        public int nAlarmOutputCh;
+        public byte byOnline;
+        public byte byUsed;
+        public byte[] byReserved = new byte[510];
+
+        public NET_GET_CHANNEL_INFO() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("nRemoteChannel", "nLogicChannel", "szName", "szDetail", "szDeviceType", "szDeviceClass", "szIP", "szMac", "szSerialNo", "szDevSoftVersion", "nVideoInputCh", "nVideoOutputCh", "nAudioInputCh", "nAudioOutputCh", "nAlarmInputCh", "nAlarmOutputCh", "byOnline", "byUsed", "byReserved");
+        }
+    }
+
+    public static class NET_PARAM extends Structure {
+        public int nWaittime;
+        public int nConnectTime;
+        public int nConnectTryNum;
+        public int nSubConnectSpaceTime;
+        public int nGetDevInfoTime;
+        public int nConnectBufSize;
+        public int nGetConnInfoTime;
+        public int nSearchRecordTime;
+        public int nsubDisconnetTime;
+        public byte byNetType;
+        public byte byPlaybackBufSize;
+        public byte bDetectDisconnTime;
+        public byte bKeepLifeInterval;
+        public int nPicBufSize;
+        public short wBSIDLowPowerSubDisconnTime;
+        public byte[] bReserved = new byte[2];
+
+        public NET_PARAM() {
+        }
+    }
+
+    public static class EM_USEDEV_MODE extends Structure {
+        public static final int NET_TALK_CLIENT_MODE = 0;
+        public static final int NET_TALK_SERVER_MODE = 1;
+        public static final int NET_TALK_ENCODE_TYPE = 2;
+        public static final int NET_ALARM_LISTEN_MODE = 3;
+        public static final int NET_CONFIG_AUTHORITY_MODE = 4;
+        public static final int NET_TALK_TALK_CHANNEL = 5;
+        public static final int NET_RECORD_STREAM_TYPE = 6;
+        public static final int NET_TALK_SPEAK_PARAM = 7;
+        public static final int NET_RECORD_TYPE = 8;
+        public static final int NET_TALK_MODE3 = 9;
+        public static final int NET_PLAYBACK_REALTIME_MODE = 10;
+        public static final int NET_TALK_TRANSFER_MODE = 11;
+        public static final int NET_TALK_VT_PARAM = 12;
+        public static final int NET_TARGET_DEV_ID = 13;
+
+        public EM_USEDEV_MODE() {
+        }
+    }
+
+    public static class NET_TIME extends Structure {
+        public int dwYear;
+        public int dwMonth;
+        public int dwDay;
+        public int dwHour;
+        public int dwMinute;
+        public int dwSecond;
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwYear", "dwMonth", "dwDay", "dwHour", "dwMinute", "dwSecond");
+        }
+
+        public NET_TIME() {
+            this.dwYear = 0;
+            this.dwMonth = 0;
+            this.dwDay = 0;
+            this.dwHour = 0;
+            this.dwMinute = 0;
+            this.dwSecond = 0;
+        }
+
+        public void setTime(int year, int month, int day, int hour, int minute, int second) {
+            this.dwYear = year;
+            this.dwMonth = month;
+            this.dwDay = day;
+            this.dwHour = hour;
+            this.dwMinute = minute;
+            this.dwSecond = second;
+        }
+
+        public NET_TIME(NET_TIME other) {
+            this.dwYear = other.dwYear;
+            this.dwMonth = other.dwMonth;
+            this.dwDay = other.dwDay;
+            this.dwHour = other.dwHour;
+            this.dwMinute = other.dwMinute;
+            this.dwSecond = other.dwSecond;
+        }
+
+        public String toStringTime() {
+            return String.format("%02d/%02d/%02d %02d:%02d:%02d", this.dwYear, this.dwMonth, this.dwDay, this.dwHour, this.dwMinute, this.dwSecond);
+        }
+
+        public String toStringTimeEx() {
+            return String.format("%02d-%02d-%02d %02d:%02d:%02d", this.dwYear, this.dwMonth, this.dwDay, this.dwHour, this.dwMinute, this.dwSecond);
+        }
+
+        public String toString() {
+            return String.format("%02d%02d%02d%02d%02d%02d", this.dwYear, this.dwMonth, this.dwDay, this.dwHour, this.dwMinute, this.dwSecond);
+        }
+    }
+
+    public static class NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY extends Structure {
+        public int dwSize = this.size();
+        public byte[] szIP = new byte[64];
+        public int nPort;
+        public byte[] szUserName = new byte[64];
+        public byte[] szPassword = new byte[64];
+        public int emSpecCap;
+        public byte[] byReserved = new byte[4];
+        public Pointer pCapParam;
+        public int emTLSCap;
+        public byte[] szLocalIP = new byte[64];
+
+        public NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "szIP", "nPort", "szUserName", "szPassword", "emSpecCap", "byReserved", "pCapParam", "emTLSCap", "szLocalIP");
+        }
+    }
+
+    public static class DEVICE_NET_INFO_EX2 extends Structure {
+        public DEVICE_NET_INFO_EX stuDevInfo;
+        public byte[] szLocalIP = new byte[64];
+        public byte[] szDeviceSubClass = new byte[16];
+        public byte[] szSID = new byte[32];
+        public byte byRole;
+        public byte[] szReserved = new byte[3];
+        public int nBridgeNetCardsMacListNum;
+        public NET_BRIDGE_NET_CARDS_MAC_LIST[] stuBridgeNetCardsMacList = new NET_BRIDGE_NET_CARDS_MAC_LIST[64];
+        public byte[] cReserved = new byte[1992];
+
+        public DEVICE_NET_INFO_EX2() {
+        }
+    }
+
+    public static class NET_DEVICEINFO_Ex extends Structure {
+        public byte[] sSerialNumber = new byte[48];
+        public int byAlarmInPortNum;
+        public int byAlarmOutPortNum;
+        public int byDiskNum;
+        public int byDVRType;
+        public int byChanNum;
+        public byte byLimitLoginTime;
+        public byte byLeftLogTimes;
+        public byte[] bReserved = new byte[2];
+        public int byLockLeftTime;
+        public byte[] Reserved = new byte[4];
+        public int nNTlsPort;
+        public byte[] Reserved2 = new byte[16];
+
+        public NET_DEVICEINFO_Ex() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("sSerialNumber", "byAlarmInPortNum", "byAlarmOutPortNum", "byDiskNum", "byDVRType", "byChanNum", "byLimitLoginTime", "byLeftLogTimes", "bReserved", "byLockLeftTime", "Reserved", "nNTlsPort", "Reserved2");
+        }
+    }
+
+    public static class DEVICE_IP_SEARCH_INFO extends Structure {
+        public int dwSize = this.size();
+        public int nIpNum;
+        public DEVICE_IP[] szIPArr = (DEVICE_IP[])(new DEVICE_IP()).toArray(256);
+        public fSearchDevicesCBEx cbSearchDevicesEx;
+
+        public DEVICE_IP_SEARCH_INFO() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "nIpNum", "szIPArr", "cbSearchDevicesEx");
+        }
+    }
+
+    public static class DEVICE_IP extends Structure {
+        public byte[] szIP = new byte[64];
+
+        public DEVICE_IP() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("szIP");
+        }
+    }
+
+    public static class NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY extends Structure {
+        public int dwSize = this.size();
+        public NET_DEVICEINFO_Ex stuDeviceInfo;
+        public int nError;
+        public byte[] byReserved = new byte[132];
+
+        public NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "stuDeviceInfo", "nError", "byReserved");
+        }
+    }
+
+    public static class DEVICE_NET_INFO_EX extends Structure {
+        public int iIPVersion;
+        public byte[] szIP = new byte[64];
+        public int nPort;
+        public byte[] szSubmask = new byte[64];
+        public byte[] szGateway = new byte[64];
+        public byte[] szMac = new byte[40];
+        public byte[] szDeviceType = new byte[32];
+        public byte byManuFactory;
+        public byte byDefinition;
+        public byte bDhcpEn;
+        public byte byReserved1;
+        public byte[] verifyData = new byte[88];
+        public byte[] szSerialNo = new byte[48];
+        public byte[] szDevSoftVersion = new byte[128];
+        public byte[] szDetailType = new byte[32];
+        public byte[] szVendor = new byte[128];
+        public byte[] szDevName = new byte[64];
+        public byte[] szUserName = new byte[16];
+        public byte[] szPassWord = new byte[16];
+        public short nHttpPort;
+        public short wVideoInputCh;
+        public short wRemoteVideoInputCh;
+        public short wVideoOutputCh;
+        public short wAlarmInputCh;
+        public short wAlarmOutputCh;
+        public int bNewWordLen;
+        public byte[] szNewPassWord = new byte[64];
+        public byte byInitStatus;
+        public byte byPwdResetWay;
+        public byte bySpecialAbility;
+        public byte[] szNewDetailType = new byte[64];
+        public int bNewUserName;
+        public byte[] szNewUserName = new byte[64];
+        public byte byPwdFindVersion;
+        public byte[] szDeviceID = new byte[24];
+        public int dwUnLoginFuncMask;
+        public byte[] szMachineGroup = new byte[64];
+        public int emIPVersionFrom;
+        public byte[] szCountryCode = new byte[3];
+        public byte byAbroadInfo;
+        public byte[] cReserved = new byte[4];
+
+        public DEVICE_NET_INFO_EX(Pointer p) {
+            super(p);
+        }
+
+        public DEVICE_NET_INFO_EX() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("iIPVersion", "szIP", "nPort", "szSubmask", "szGateway", "szMac", "szDeviceType", "byManuFactory", "byDefinition", "bDhcpEn", "byReserved1", "verifyData", "szSerialNo", "szDevSoftVersion", "szDetailType", "szVendor", "szDevName", "szUserName", "szPassWord", "nHttpPort", "wVideoInputCh", "wRemoteVideoInputCh", "wVideoOutputCh", "wAlarmInputCh", "wAlarmOutputCh", "bNewWordLen", "szNewPassWord", "byInitStatus", "byPwdResetWay", "bySpecialAbility", "szNewDetailType", "bNewUserName", "szNewUserName", "byPwdFindVersion", "szDeviceID", "dwUnLoginFuncMask", "szMachineGroup", "emIPVersionFrom", "szCountryCode", "byAbroadInfo", "cReserved");
+        }
+    }
+
+    public static class LOG_SET_PRINT_INFO extends Structure {
+        public int dwSize = this.size();
+        public int bSetFilePath;
+        public byte[] szLogFilePath = new byte[260];
+        public int bSetFileSize;
+        public int nFileSize;
+        public int bSetFileNum;
+        public int nFileNum;
+        public int bSetPrintStrategy;
+        public int nPrintStrategy;
+        public byte[] byReserved = new byte[4];
+        public Pointer cbSDKLogCallBack;
+        public Pointer dwUser;
+
+        public LOG_SET_PRINT_INFO() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("dwSize", "bSetFilePath", "szLogFilePath", "bSetFileSize", "nFileSize", "bSetFileNum", "nFileNum", "bSetPrintStrategy", "nPrintStrategy", "byReserved", "cbSDKLogCallBack", "dwUser");
+        }
+    }
+
+    public static class NET_RealPlayType extends Structure {
+        public static final int NET_RType_Realplay = 0;
+        public static final int NET_RType_Multiplay = 1;
+        public static final int NET_RType_Realplay_0 = 2;
+        public static final int NET_RType_Realplay_1 = 3;
+        public static final int NET_RType_Realplay_2 = 4;
+        public static final int NET_RType_Realplay_3 = 5;
+        public static final int NET_RType_Multiplay_1 = 6;
+        public static final int NET_RType_Multiplay_4 = 7;
+        public static final int NET_RType_Multiplay_8 = 8;
+        public static final int NET_RType_Multiplay_9 = 9;
+        public static final int NET_RType_Multiplay_16 = 10;
+        public static final int NET_RType_Multiplay_6 = 11;
+        public static final int NET_RType_Multiplay_12 = 12;
+        public static final int NET_RType_Multiplay_25 = 13;
+        public static final int NET_RType_Multiplay_36 = 14;
+        public static final int NET_RType_Multiplay_64 = 15;
+        public static final int NET_RType_Multiplay_255 = 16;
+        public static final int NET_RType_Realplay_Audio = 17;
+        public static final int NET_RType_Realplay_Test = 255;
+
+        public NET_RealPlayType() {
+        }
+
+        protected List<String> getFieldOrder() {
+            return Arrays.asList("NET_RType_Realplay", "NET_RType_Multiplay", "NET_RType_Realplay_0", "NET_RType_Realplay_1", "NET_RType_Realplay_2", "NET_RType_Realplay_3", "NET_RType_Multiplay_1", "NET_RType_Multiplay_4", "NET_RType_Multiplay_8", "NET_RType_Multiplay_9", "NET_RType_Multiplay_16", "NET_RType_Multiplay_6", "NET_RType_Multiplay_12", "NET_RType_Multiplay_25", "NET_RType_Multiplay_36", "NET_RType_Multiplay_64", "NET_RType_Multiplay_255", "NET_RType_Realplay_Audio", "NET_RType_Realplay_Test");
+        }
+    }
+
+    public interface fDataCallBack extends Callback {
+        void invoke(Long var1, int var2, Pointer var3, int var4, Pointer var5);
+    }
+
+    public interface fDisConnect extends Callback {
+        void invoke(Long var1, String var2, int var3, Pointer var4);
+    }
+
+    public interface fRealDataCallBackEx extends Callback {
+        void invoke(Long var1, int var2, Pointer var3, int var4, int var5, Pointer var6);
+    }
+
+    public interface fSearchDevicesCBEx extends Callback {
+        void invoke(Long var1, Pointer var2, Pointer var3);
+    }
+}

+ 99 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/common/dahua/RemoteDeviceInfo.java

@@ -0,0 +1,99 @@
+package com.usky.sas.common.dahua;
+
+public class RemoteDeviceInfo {
+    private String note;
+    private String ipAddr;
+    private Integer channel;
+
+    public RemoteDeviceInfo() {
+    }
+
+    public String getNote() {
+        return this.note;
+    }
+
+    public String getIpAddr() {
+        return this.ipAddr;
+    }
+
+    public Integer getChannel() {
+        return this.channel;
+    }
+
+    public void setNote(String note) {
+        this.note = note;
+    }
+
+    public void setIpAddr(String ipAddr) {
+        this.ipAddr = ipAddr;
+    }
+
+    public void setChannel(Integer channel) {
+        this.channel = channel;
+    }
+
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        } else if (!(o instanceof RemoteDeviceInfo)) {
+            return false;
+        } else {
+            RemoteDeviceInfo other = (RemoteDeviceInfo)o;
+            if (!other.canEqual(this)) {
+                return false;
+            } else {
+                Object this$note = this.getNote();
+                Object other$note = other.getNote();
+                if (this$note == null) {
+                    if (other$note != null) {
+                        return false;
+                    }
+                } else if (!this$note.equals(other$note)) {
+                    return false;
+                }
+
+                Object this$ipAddr = this.getIpAddr();
+                Object other$ipAddr = other.getIpAddr();
+                if (this$ipAddr == null) {
+                    if (other$ipAddr != null) {
+                        return false;
+                    }
+                } else if (!this$ipAddr.equals(other$ipAddr)) {
+                    return false;
+                }
+
+                Object this$channel = this.getChannel();
+                Object other$channel = other.getChannel();
+                if (this$channel == null) {
+                    if (other$channel != null) {
+                        return false;
+                    }
+                } else if (!this$channel.equals(other$channel)) {
+                    return false;
+                }
+
+                return true;
+            }
+        }
+    }
+
+    protected boolean canEqual(Object other) {
+        return other instanceof RemoteDeviceInfo;
+    }
+
+    public int hashCode() {
+        int PRIME = 59;
+        int result = 1;
+        Object $note = this.getNote();
+        result = result * 59 + ($note == null ? 43 : $note.hashCode());
+        Object $ipAddr = this.getIpAddr();
+        result = result * 59 + ($ipAddr == null ? 43 : $ipAddr.hashCode());
+        Object $channel = this.getChannel();
+        result = result * 59 + ($channel == null ? 43 : $channel.hashCode());
+        return result;
+    }
+
+    public String toString() {
+        return "RemoteDeviceInfo(note=" + this.getNote() + ", ipAddr=" + this.getIpAddr() + ", channel=" + this.getChannel() + ")";
+    }
+}