提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.demo.module; |
H |
2 |
|
|
3 |
import com.iailab.netsdk.lib.NetSDKLib; |
|
4 |
import com.iailab.netsdk.lib.NetSDKLib.LLong; |
|
5 |
import com.iailab.netsdk.lib.ToolKits; |
|
6 |
|
|
7 |
import com.sun.jna.ptr.IntByReference; |
|
8 |
|
|
9 |
/** |
|
10 |
* \if ENGLISH_LANG |
|
11 |
* Capture Picture Interface |
|
12 |
* contains:local、remote、timer and stop capture picture |
|
13 |
* \else |
|
14 |
* 抓图接口实现 |
|
15 |
* 包含: 本地、远程、定时和停止抓图 |
|
16 |
* \endif |
|
17 |
*/ |
|
18 |
public class CapturePictureModule { |
|
19 |
|
|
20 |
/** |
|
21 |
* \if ENGLISH_LANG |
|
22 |
* Local Capture Picture |
|
23 |
* \else |
|
24 |
* 本地抓图 |
|
25 |
* \endif |
|
26 |
*/ |
|
27 |
public static boolean localCapturePicture(LLong hPlayHandle, String picFileName) { |
|
28 |
|
|
29 |
if (!LoginModule.netsdk.CLIENT_CapturePictureEx(hPlayHandle, picFileName, NetSDKLib.NET_CAPTURE_FORMATS.NET_CAPTURE_JPEG)) { |
|
30 |
System.err.printf("CLIENT_CapturePicture Failed!" + ToolKits.getErrorCodePrint()); |
|
31 |
return false; |
|
32 |
} else { |
|
33 |
System.out.println("CLIENT_CapturePicture success"); |
|
34 |
} |
|
35 |
return true; |
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* \if ENGLISH_LANG |
|
40 |
* Remote Capture Picture |
|
41 |
* \else |
|
42 |
* 远程抓图 |
|
43 |
* \endif |
|
44 |
*/ |
|
45 |
public static boolean remoteCapturePicture(int chn) { |
|
46 |
return snapPicture(chn, 0, 0); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* \if ENGLISH_LANG |
|
51 |
* Timer Capture Picture |
|
52 |
* \else |
|
53 |
* 定时抓图 |
|
54 |
* \endif |
|
55 |
*/ |
|
56 |
public static boolean timerCapturePicture(int chn) { |
|
57 |
return snapPicture(chn, 1, 2); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* \if ENGLISH_LANG |
|
62 |
* Stop Timer Capture Picture |
|
63 |
* \else |
|
64 |
* 停止定时抓图 |
|
65 |
* \endif |
|
66 |
*/ |
|
67 |
public static boolean stopCapturePicture(int chn) { |
|
68 |
return snapPicture(chn, -1, 0); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* \if ENGLISH_LANG |
|
73 |
* Capture Picture (except local capture picture, others all call this interface) |
|
74 |
* \else |
|
75 |
* 抓图 (除本地抓图外, 其他全部调用此接口) |
|
76 |
* \endif |
|
77 |
*/ |
|
78 |
public static boolean snapPicture(int chn, int mode, int interval) { |
|
79 |
// send caputre picture command to device |
|
80 |
NetSDKLib.SNAP_PARAMS stuSnapParams = new NetSDKLib.SNAP_PARAMS(); |
|
81 |
stuSnapParams.Channel = chn; // channel |
|
82 |
stuSnapParams.mode = mode; // capture picture mode |
|
83 |
stuSnapParams.Quality = 3; // picture quality |
|
84 |
stuSnapParams.InterSnap = interval; // timer capture picture time interval |
|
85 |
stuSnapParams.CmdSerial = 0; // request serial |
|
86 |
|
|
87 |
IntByReference reserved = new IntByReference(0); |
|
88 |
if (!LoginModule.netsdk.CLIENT_SnapPictureEx(LoginModule.m_hLoginHandle, stuSnapParams, reserved)) { |
|
89 |
System.err.printf("CLIENT_SnapPictureEx Failed!" + ToolKits.getErrorCodePrint()); |
|
90 |
return false; |
|
91 |
} else { |
|
92 |
System.out.println("CLIENT_SnapPictureEx success"); |
|
93 |
} |
|
94 |
return true; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* \if ENGLISH_LANG |
|
99 |
* Set Capture Picture Callback |
|
100 |
* \else |
|
101 |
* 设置抓图回调函数 |
|
102 |
* \endif |
|
103 |
*/ |
|
104 |
public static void setSnapRevCallBack(NetSDKLib.fSnapRev cbSnapReceive){ |
|
105 |
LoginModule.netsdk.CLIENT_SetSnapRevCallBack(cbSnapReceive, null); |
|
106 |
} |
|
107 |
} |