From 8a87e4226aa802d6a0e3566c66824fedf68e77da Mon Sep 17 00:00:00 2001 From: aijinhui <aijinhui> Date: 星期二, 24 十月 2023 16:30:48 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java | 212 +++++++++++++++++++++++++++-------------------------- 1 files changed, 108 insertions(+), 104 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java index 8c15c38..67171b8 100644 --- a/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java +++ b/ard-work/src/main/java/com/ruoyi/device/dhsdk/module/CapturePictureModule.java @@ -1,104 +1,108 @@ -package com.ruoyi.device.dhsdk.module; -import com.ruoyi.device.dhsdk.lib.NetSDKLib; -import com.ruoyi.device.dhsdk.lib.ToolKits; -import com.sun.jna.ptr.IntByReference; - -/** - * \if ENGLISH_LANG - * Capture Picture Interface - * contains:local銆乺emote銆乼imer and stop capture picture - * \else - * 鎶撳浘鎺ュ彛瀹炵幇 - * 鍖呭惈: 鏈湴銆佽繙绋嬨�佸畾鏃跺拰鍋滄鎶撳浘 - * \endif - */ -public class CapturePictureModule { - - /** - * \if ENGLISH_LANG - * Local Capture Picture - * \else - * 鏈湴鎶撳浘 - * \endif - */ - public static boolean localCapturePicture(NetSDKLib.LLong hPlayHandle, String picFileName) { - - if (!LoginModule.netsdk.CLIENT_CapturePictureEx(hPlayHandle, picFileName, NetSDKLib.NET_CAPTURE_FORMATS.NET_CAPTURE_JPEG)) { - System.err.printf("CLIENT_CapturePicture Failed!" + ToolKits.getErrorCodePrint()); - return false; - } else { - System.out.println("CLIENT_CapturePicture success"); - } - return true; - } - - /** - * \if ENGLISH_LANG - * Remote Capture Picture - * \else - * 杩滅▼鎶撳浘 - * \endif - */ - public static boolean remoteCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { - return snapPicture(m_hLoginHandle,chn, 0, 0); - } - - /** - * \if ENGLISH_LANG - * Timer Capture Picture - * \else - * 瀹氭椂鎶撳浘 - * \endif - */ - public static boolean timerCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { - return snapPicture(m_hLoginHandle,chn, 1, 2); - } - - /** - * \if ENGLISH_LANG - * Stop Timer Capture Picture - * \else - * 鍋滄瀹氭椂鎶撳浘 - * \endif - */ - public static boolean stopCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { - return snapPicture(m_hLoginHandle,chn, -1, 0); - } - - /** - * \if ENGLISH_LANG - * Capture Picture (except local capture picture, others all call this interface) - * \else - * 鎶撳浘 (闄ゆ湰鍦版姄鍥惧, 鍏朵粬鍏ㄩ儴璋冪敤姝ゆ帴鍙�) - * \endif - */ - private static boolean snapPicture(NetSDKLib.LLong m_hLoginHandle,int chn, int mode, int interval) { - // send caputre picture command to device - NetSDKLib.SNAP_PARAMS stuSnapParams = new NetSDKLib.SNAP_PARAMS(); - stuSnapParams.Channel = chn; // channel - stuSnapParams.mode = mode; // capture picture mode - stuSnapParams.Quality = 3; // picture quality - stuSnapParams.InterSnap = interval; // timer capture picture time interval - stuSnapParams.CmdSerial = 0; // request serial - - IntByReference reserved = new IntByReference(0); - if (!LoginModule.netsdk.CLIENT_SnapPictureEx(m_hLoginHandle, stuSnapParams, reserved)) { - System.err.printf("CLIENT_SnapPictureEx Failed!" + ToolKits.getErrorCodePrint()); - return false; - } else { - System.out.println("CLIENT_SnapPictureEx success"); - } - return true; - } - - /** - * \if ENGLISH_LANG - * Set Capture Picture Callback - * \else - * 璁剧疆鎶撳浘鍥炶皟鍑芥暟 - * \endif - */ - public static void setSnapRevCallBack(NetSDKLib.fSnapRev cbSnapReceive){ - LoginModule.netsdk.CLIENT_SetSnapRevCallBack(cbSnapReceive, null); - } -} +package com.ruoyi.device.dhsdk.module; +import com.ruoyi.device.dhsdk.lib.NetSDKLib; +import com.ruoyi.device.dhsdk.lib.ToolKits; +import com.sun.jna.ptr.IntByReference; +import lombok.extern.slf4j.Slf4j; + +/** + * \if ENGLISH_LANG + * Capture Picture Interface + * contains:local銆乺emote銆乼imer and stop capture picture + * \else + * 鎶撳浘鎺ュ彛瀹炵幇 + * 鍖呭惈: 鏈湴銆佽繙绋嬨�佸畾鏃跺拰鍋滄鎶撳浘 + * \endif + */ +@Slf4j(topic = "dhSdk") +public class CapturePictureModule { + + public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; + + /** + * \if ENGLISH_LANG + * Local Capture Picture + * \else + * 鏈湴鎶撳浘 + * \endif + */ + public static boolean localCapturePicture(NetSDKLib.LLong hPlayHandle, String picFileName) { + + if (!netsdk.CLIENT_CapturePictureEx(hPlayHandle, picFileName, NetSDKLib.NET_CAPTURE_FORMATS.NET_CAPTURE_JPEG)) { + log.error("CLIENT_CapturePicture Failed!" + ToolKits.getErrorCodePrint()); + return false; + } else { + log.debug("CLIENT_CapturePicture success"); + } + return true; + } + + /** + * \if ENGLISH_LANG + * Remote Capture Picture + * \else + * 杩滅▼鎶撳浘 + * \endif + */ + public static boolean remoteCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { + return snapPicture(m_hLoginHandle,chn, 0, 0); + } + + /** + * \if ENGLISH_LANG + * Timer Capture Picture + * \else + * 瀹氭椂鎶撳浘 + * \endif + */ + public static boolean timerCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { + return snapPicture(m_hLoginHandle,chn, 1, 2); + } + + /** + * \if ENGLISH_LANG + * Stop Timer Capture Picture + * \else + * 鍋滄瀹氭椂鎶撳浘 + * \endif + */ + public static boolean stopCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { + return snapPicture(m_hLoginHandle,chn, -1, 0); + } + + /** + * \if ENGLISH_LANG + * Capture Picture (except local capture picture, others all call this interface) + * \else + * 鎶撳浘 (闄ゆ湰鍦版姄鍥惧, 鍏朵粬鍏ㄩ儴璋冪敤姝ゆ帴鍙�) + * \endif + */ + private static boolean snapPicture(NetSDKLib.LLong m_hLoginHandle,int chn, int mode, int interval) { + // send caputre picture command to device + NetSDKLib.SNAP_PARAMS stuSnapParams = new NetSDKLib.SNAP_PARAMS(); + stuSnapParams.Channel = chn; // channel + stuSnapParams.mode = mode; // capture picture mode + stuSnapParams.Quality = 3; // picture quality + stuSnapParams.InterSnap = interval; // timer capture picture time interval + stuSnapParams.CmdSerial = 0; // request serial + + IntByReference reserved = new IntByReference(0); + if (!LoginModule.netsdk.CLIENT_SnapPictureEx(m_hLoginHandle, stuSnapParams, reserved)) { + log.error("CLIENT_SnapPictureEx Failed!" + ToolKits.getErrorCodePrint()); + return false; + } else { + log.debug("CLIENT_SnapPictureEx success"); + } + return true; + } + + /** + * \if ENGLISH_LANG + * Set Capture Picture Callback + * \else + * 璁剧疆鎶撳浘鍥炶皟鍑芥暟 + * \endif + */ + public static void setSnapRevCallBack(NetSDKLib.fSnapRev cbSnapReceive){ + LoginModule.netsdk.CLIENT_SetSnapRevCallBack(cbSnapReceive, null); + } +} -- Gitblit v1.9.3