提交 | 用户 | 时间
|
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 |
* 下载录像接口实现 |
|
11 |
* 主要有 : 查询录像、下载录像、设置码流类型功能 |
|
12 |
*/ |
|
13 |
public class DownLoadRecordModule { |
|
14 |
// 下载句柄 |
|
15 |
public static LLong m_hDownLoadHandle = new LLong(0); |
|
16 |
|
|
17 |
// 查找录像文件 |
|
18 |
public static boolean queryRecordFile(int nChannelId, |
|
19 |
NetSDKLib.NET_TIME stTimeStart, |
|
20 |
NetSDKLib.NET_TIME stTimeEnd, |
|
21 |
NetSDKLib.NET_RECORDFILE_INFO[] stFileInfo, |
|
22 |
IntByReference nFindCount) { |
|
23 |
// RecordFileType 录像类型 0:所有录像 1:外部报警 2:动态监测报警 3:所有报警 4:卡号查询 5:组合条件查询 |
|
24 |
// 6:录像位置与偏移量长度 8:按卡号查询图片(目前仅HB-U和NVS特殊型号的设备支持) 9:查询图片(目前仅HB-U和NVS特殊型号的设备支持) |
|
25 |
// 10:按字段查询 15:返回网络数据结构(金桥网吧) 16:查询所有透明串数据录像文件 |
|
26 |
int nRecordFileType = 0; |
|
27 |
boolean bRet = LoginModule.netsdk.CLIENT_QueryRecordFile(LoginModule.m_hLoginHandle, nChannelId, |
|
28 |
nRecordFileType, stTimeStart, stTimeEnd, null, stFileInfo, |
|
29 |
stFileInfo.length * stFileInfo[0].size(), nFindCount, 5000, false); |
|
30 |
|
|
31 |
if(bRet) { |
|
32 |
System.out.println("QueryRecordFile Succeed! \n" + "查询到的视频个数:" + nFindCount.getValue()); |
|
33 |
} else { |
|
34 |
System.err.println("QueryRecordFile Failed!" + ToolKits.getErrorCodePrint()); |
|
35 |
return false; |
|
36 |
} |
|
37 |
return true; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* 设置回放时的码流类型 |
|
42 |
* @param m_streamType 码流类型 |
|
43 |
*/ |
|
44 |
public static void setStreamType(int m_streamType) { |
|
45 |
|
|
46 |
IntByReference steamType = new IntByReference(m_streamType);// 0-主辅码流,1-主码流,2-辅码流 |
|
47 |
int emType = NetSDKLib.EM_USEDEV_MODE.NET_RECORD_STREAM_TYPE; |
|
48 |
|
|
49 |
boolean bret = LoginModule.netsdk.CLIENT_SetDeviceMode(LoginModule.m_hLoginHandle, emType, steamType.getPointer()); |
|
50 |
if (!bret) { |
|
51 |
System.err.println("Set Stream Type Failed, Get last error." + ToolKits.getErrorCodePrint()); |
|
52 |
} else { |
|
53 |
System.out.println("Set Stream Type Succeed!"); |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
public static LLong downloadRecordFile(int nChannelId, |
|
58 |
int nRecordFileType, |
|
59 |
NetSDKLib.NET_TIME stTimeStart, |
|
60 |
NetSDKLib.NET_TIME stTimeEnd, |
|
61 |
String SavedFileName, |
|
62 |
NetSDKLib.fTimeDownLoadPosCallBack cbTimeDownLoadPos) { |
|
63 |
|
|
64 |
m_hDownLoadHandle = LoginModule.netsdk.CLIENT_DownloadByTimeEx(LoginModule.m_hLoginHandle, nChannelId, nRecordFileType, |
|
65 |
stTimeStart, stTimeEnd, SavedFileName, |
|
66 |
cbTimeDownLoadPos, null, null, null, null); |
|
67 |
if(m_hDownLoadHandle.longValue() != 0) { |
|
68 |
System.out.println("Downloading RecordFile!"); |
|
69 |
} else { |
|
70 |
System.err.println("Download RecordFile Failed!" + ToolKits.getErrorCodePrint()); |
|
71 |
} |
|
72 |
return m_hDownLoadHandle; |
|
73 |
} |
|
74 |
|
|
75 |
public static void stopDownLoadRecordFile(LLong m_hDownLoadHandle) { |
|
76 |
if (m_hDownLoadHandle.longValue() == 0) { |
|
77 |
return; |
|
78 |
} |
|
79 |
LoginModule.netsdk.CLIENT_StopDownload(m_hDownLoadHandle); |
|
80 |
} |
|
81 |
} |