NetSDK JAVA ProgrammingManual
NetSDK JAVA ProgrammingManual
Programming Manual
V1.0.2
Foreword
Purpose
Welcome to use NetSDK (hereinafter referred to be "SDK") programming manual (hereinafter referred
to be "the manual").
SDK, also known as network device SDK, is a development kit for developer to develop the interfaces
for network communication among surveillance products such as Network Video Recorder (NVR),
Network Video Server (NVS), IP Camera (IPC), Speed Dome (SD), and intelligence devices.
The manual describes the SDK interfaces and processes of the general function modules for IPC, SD
and Thermal IP Camera (TPC). For more function modules and data structures, refer to NetSDK
Development Manual.
The example codes provided in the manual are only for demonstrating the procedure and not
assured to copy for use.
Reader
Signals
The following categorized signal words with defined meaning might appear in the manual.
Signal Words Meaning
Indicates a potential risk which, if not avoided, could result in
property damage, data loss, lower performance, or unpredictable
CAUTION result.
I
Revision History
The manual is for reference only. If there is inconsistency between the manual and the actual
product, the actual product shall govern.
All the designs and software are subject to change without prior written notice. The product
updates might cause some differences between the actual product and the manual. Please
contact the customer service for the latest program and supplementary documentation.
There still might be deviation between the actual value of some data and the value provided, if
there is any doubt or dispute, please refer to our final explanation.
Please contact the supplier or customer service if there is any problem occurred when using the
device.
We are not liable for any loss caused by the operations that do not comply with the manual.
All trademarks, registered trademarks and the company names in the manual are the properties
of their respective owners.
Please visit our website or contact your local service engineer for more information. If there is
any uncertainty or controversy, please refer to our final explanation.
II
Glossary
This chapter provides the definitions to some of the terms appear in the manual to help you
understand the function of each module.
Term Definition
A type of video stream that usually has better resolution and clarity and
Main Stream
provides a better experience if the network resource is not restricted.
A type of video stream that usually has lower resolution and clarity than
Sub Stream the main stream but demands less network resources. The user can
choose the stream type according to the particular scenes.
The video is numbered from 0 and each video receives a channel number.
Video Channel Currently, except the TPC, the other types of devices usually have only one
channel that is numbered as 0.
The first step to access to the device is login (authentication). The device
receives a unique ID that refers to the login handle upon the successful
Login Handle
login. This handle will be used by the subsequent procedures and stay
valid until logout.
A fast positioning method in PTZ control by providing the difference value
of the PTZ coordinates (X-axis and Y-axis) to the device which accord to
Relative Positioning
the present PTZ location and the difference value to calculate and transfer
to the final location. This method also supports ZOOM control.
A fast positioning method in PTZ control which provides certain
horizontal and vertical coordinates (angular coordinate) to the device. The
Absolute Positioning
device directly transfers to the user specified location. This method also
supports ZOOM control.
Pulse Code Modulation is one of the coding methods of digital
communication and converts the analog signal into digital signal without
PCM
encoding loss. It is suitable for the user who requires higher data transfer
rate and bandwidth.
PTZ Pan Tilt Zoom is all-round movement and lens zoom control.
III
Table of Contents
Foreword ............................................................................................................................................................ I
Glossary ........................................................................................................................................................... III
1 Overview ........................................................................................................................................................ 1
General ........................................................................................................................................................................................... 1
Applicability ................................................................................................................................................................................. 2
Solutions of Library Loading Error ....................................................................................................................................... 2
1.3.1 Using Java Project in Windows ................................................................................................................................ 2
1.3.2 Using Java Project in Linux ........................................................................................................................................ 3
1.3.3 Using Project as a jar Package .................................................................................................................................. 6
Upgrade early jna to latest version...................................................................................................................................... 7
2 Function Modules .......................................................................................................................................... 8
SDK Initialization ........................................................................................................................................................................ 8
2.1.1 Introduction .................................................................................................................................................................... 8
2.1.2 Interface Overview ....................................................................................................................................................... 8
2.1.3 Process .............................................................................................................................................................................. 9
2.1.4 Example Code ..............................................................................................................................................................10
Device Login ..............................................................................................................................................................................12
2.2.1 Introduction ..................................................................................................................................................................12
2.2.2 Interface Overview .....................................................................................................................................................12
2.2.3 Process ............................................................................................................................................................................13
2.2.4 Example Code ..............................................................................................................................................................14
Real-time Monitoring .............................................................................................................................................................16
2.3.1 Introduction ..................................................................................................................................................................16
2.3.2 Interface Overview .....................................................................................................................................................16
2.3.3 Process ............................................................................................................................................................................16
2.3.4 Example Code ..............................................................................................................................................................20
Video Snapshot .........................................................................................................................................................................22
2.4.1 Introduction ..................................................................................................................................................................22
2.4.2 Interface Overview .....................................................................................................................................................22
2.4.3 Process ............................................................................................................................................................................23
2.4.4 Example Code ..............................................................................................................................................................26
PTZ Control .................................................................................................................................................................................29
2.5.1 Introduction ..................................................................................................................................................................29
2.5.2 Interface Overview .....................................................................................................................................................29
2.5.3 Process ............................................................................................................................................................................29
2.5.4 Example Code ..............................................................................................................................................................31
Voice Talk .....................................................................................................................................................................................31
2.6.1 Introduction ..................................................................................................................................................................31
2.6.2 Interface Overview .....................................................................................................................................................32
2.6.3 Process ............................................................................................................................................................................32
2.6.4 Example Code ..............................................................................................................................................................33
Alarm Listening .........................................................................................................................................................................36
2.7.1 Introduction ..................................................................................................................................................................36
IV
2.7.2 Interface Overview .....................................................................................................................................................36
2.7.3 Process ............................................................................................................................................................................37
2.7.4 Example Code ..............................................................................................................................................................38
Intelligent Event .......................................................................................................................................................................39
2.8.1 Introduction ..................................................................................................................................................................39
2.8.2 Interface Overview .....................................................................................................................................................39
2.8.3 Process ............................................................................................................................................................................40
2.8.4 Example Code ..............................................................................................................................................................41
Record Playback .......................................................................................................................................................................41
2.9.1 Introduction ..................................................................................................................................................................44
2.9.2 Interface Overview .....................................................................................................................................................45
2.9.3 Process ............................................................................................................................................................................45
2.9.4 Example Code ..............................................................................................................................................................47
Record Download ..................................................................................................................................................................50
2.10.1 Introduction ...............................................................................................................................................................50
2.10.2 Interface Overview ..................................................................................................................................................50
2.10.3 Process..........................................................................................................................................................................50
2.10.4 Example Code ............................................................................................................................................................52
3 Interface Definition ..................................................................................................................................... 55
SDK Initialization ......................................................................................................................................................................55
3.1.1 SDK CLIENT_Init...........................................................................................................................................................55
3.1.2 CLIENT_Cleanup ..........................................................................................................................................................55
3.1.3 CLIENT_SetAutoReconnect .....................................................................................................................................55
3.1.4 CLIENT_SetNetworkParam ......................................................................................................................................56
Device Login ..............................................................................................................................................................................56
3.2.1 CLIENT_LoginWithHighLevelSecurity .................................................................................................................56
3.2.2 CLIENT_Logout ............................................................................................................................................................56
Real-time Monitoring .............................................................................................................................................................57
3.3.1 CLIENT_RealPlayEx .....................................................................................................................................................57
3.3.2 CLIENT_StopRealPlayEx ............................................................................................................................................57
3.3.3 CLIENT_SaveRealData ...............................................................................................................................................58
3.3.4 CLIENT_StopSaveRealData......................................................................................................................................58
3.3.5 CLIENT_SetRealDataCallBackEx.............................................................................................................................58
Video Snapshot .........................................................................................................................................................................59
3.4.1 CLIENT_SnapPictureToFile .......................................................................................................................................59
3.4.2 CLIENT_CapturePictureEx........................................................................................................................................59
3.4.3 CLIENT_CapturePictureEx........................................................................................................................................60
3.4.4 Setting Asynchronous Snapshot Callback.........................................................................................................60
PTZ Control .................................................................................................................................................................................60
3.5.1 CLIENT_DHPTZControlEx .........................................................................................................................................60
Voice Talk .....................................................................................................................................................................................64
3.6.1 CLIENT_StartTalkEx ....................................................................................................................................................64
3.6.2 CLIENT_StopTalkEx .....................................................................................................................................................65
3.6.3 CLIENT_TalkSendData ...............................................................................................................................................65
3.6.4 CLIENT_AudioDecEx ..................................................................................................................................................65
Alarm Listening .........................................................................................................................................................................66
3.7.1 CLIENT_StartListenEx ................................................................................................................................................66
V
3.7.2 CLIENT_StopListen .....................................................................................................................................................66
3.7.3 CLIENT_SetDVRMessCallBack.................................................................................................................................66
Intelligent Event .......................................................................................................................................................................67
3.8.1 CLIENT_RealLoadPictureEx .....................................................................................................................................67
3.8.2 CLIENT_StopLoadPic .................................................................................................................................................68
Record Playback .......................................................................................................................................................................68
3.9.1 CLIENT_PlayBackByTimeEx .....................................................................................................................................68
3.9.2 CLIENT_SetDeviceMode...........................................................................................................................................69
3.9.3 CLIENT_StopPlayBack ...............................................................................................................................................69
3.9.4 CLIENT_PausePlayBack .............................................................................................................................................70
Record Download ..................................................................................................................................................................70
3.10.1 CLIENT_QueryRecordFile.......................................................................................................................................70
3.10.2 CLIENT_DownloadByTimeEx................................................................................................................................71
3.10.3 CLIENT_StopDownload..........................................................................................................................................72
4 Callback Definition ...................................................................................................................................... 73
fDisConnect ................................................................................................................................................................................73
fHaveReConnect .......................................................................................................................................................................73
fRealDataCallBackEx................................................................................................................................................................74
pfAudioDataCallBack ..............................................................................................................................................................74
fAnalyzerDataCallBack ...........................................................................................................................................................75
fTimeDownLoadPosCallBack ...............................................................................................................................................75
fMessCallBack ............................................................................................................................................................................76
Asynchronous Snapshot........................................................................................................................................................77
Cybersecurity Recommendations ............................................................................................. 78
VI
1 Overview
General
The manual introduces SDK interfaces reference information that includes main function modules,
interface functions, and callback functions.
The following are the main functions:
SDK initialization, device login, real-time monitoring, PTZ control, voice talk, alarm listening, smart
subscription, record playback, record download and so on.
The development kit might be different dependent on the environment.
1
Applicability
There are three kinds of dynamic libraries, Windows(.dll), and Linux(.so).Windows and Linux have
64-bit version and 32-bit version. And there are two main methods to call the call C ++ dynamic
library, which are using the Java project directly and running the Java project as a jar package for
other projects. During the loading of the library, the error of "Unable to find the dynamic library" will
appear.
The root cause of "Unable to find the dynamic library" is the mismatch between the code path and
the physical path. Compared with the Windows version, the dynamic library name of the Linux has a
lib prefix. Therefore, when loading a dynamic library in the Linux environment, you need to pay
attention to the lib prefix and add the lib prefix when stitching the dynamic library path. When using
java.io.tmpdir to implement path mapping, note that this method has a lower priority.
2
if (osName.toLowerCase().startsWith("linux")) {
osType = ARCH_LINUX;
} else if (osName.toLowerCase().startsWith("mac")
|| osName.toLowerCase().startsWith("darwin")) {
osType = ARCH_MAC;
} else if (osName.toLowerCase().startsWith("windows")) {
osType = ARCH_WINDOWS;
} else {
osType = "";
}
String arch = System.getProperty("os.arch");
arch = arch.toLowerCase().trim();
if ("i386".equals(arch) || "i686".equals(arch) || "x86".equals(arch)) {
arch = PREFIX_32 + "";
} else if ("x86_64".equals(arch) || "amd64".equals(arch)) {
arch = PREFIX_64 + "";
} else if (arch.startsWith("arm")) {
arch = PREFIX_ARM + "";
}else {
arch = PREFIX_ARM + "";
}
System.out.println("Dynamic library folder:"+osType + arch);
return osType + arch;
}
Solution
The error is usually caused by a mismatch between the jdk version and the system environment: If
the jdk of the java project is 32-bit, the system environment is 64-bit, but the sdk is 64-bit, the error
above will occur. The version of the sdk project, jdk, and operating system must be the same. They
need to be win64 or win32.
Note
Winodws platform is less likely to have errors, and here is just an example. Note that the platform
must correspond to the dynamic library, and the dynamic library suffix for Windows is .dll.
Running the Example Code by Script Code in Linux (the script code path is run.sh
3
in the root directory)
4
at com.sun.jna.Native.extractFromResourcePath(Native.java:1095)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:276)
... 7 more
else
echo "--> linux 32 System."
#export LD_LIBRARY_PATH=../libs/linux32
cp -r ../resources/linux32 $BIN/linux32
fi
Note
Similar to windows. However, if the error is not found, check whether the PATH introduced in the
script is consistent with the system path when the dynamic library is correct.
Solution
Select one of the methods to solve the issue.
Method 1: Similar to Windows system, check whether the environment configuration is
consistent.
Method 2: Temporary folder loading method—java.io.tmpdir. This method is suitable for
multiple platforms. You need to change the path parameter in public static void
setExtractPath(String path) method to the absolute path.
Copy the required dynamic library to a folder, such as D:/win64.
Use the static statement block to call: (path should be consistent).
static{
LibraryLoad.setExtractPath(String path) };
}
5
1.3.3 Using Project as a jar Package
The advantage of having the dynamic library built into the jar package is that as long as the jar
package is exported, the jar can be executed directly regardless of the differences between the
platforms.
Here is a way to make the build-in jar package. You need to write the dynamic library of jar package
into the local temporary folder (java.io.tmpdir), read the dynamic library from the local machine, and
then load it to memory. The following is the example code.
public interface NetSDKLib extends Library {
NetSDKLib NETSDK_INSTANCE = Native.load(LibraryLoad.getLoadLibrary("dhnetsdk"),
NetSDKLib.class);
NetSDKLib CONFIG_INSTANCE = Native.load(LibraryLoad.getLoadLibrary("dhconfigsdk"),
NetSDKLib.class);
public class LibraryLoad {
public static String getLoadLibrary(String libraryName) {
currentFold = getLibraryFold();
if (dynamicParseUtil == null) {
try {
dynamicParseUtil =
new DynamicParseUtil(
LibraryLoad.class.getClassLoader().getResourceAsStream("dynamic-lib-load.xml"));
if (!written) {
for (String libName : dynamicParseUtil.getLibsSystem(currentFold)) {
extractLibrary(libName);
}
written = true;
}
} catch (ParserConfigurationException | IOException | SAXException e) {
e.printStackTrace();
}
}
String fullName = getLibraryName(libraryName);
String path = EXTRACT_PATH;
if (!(EXTRACT_PATH.endsWith("/") || EXTRACT_PATH.endsWith("\\"))) {
path = EXTRACT_PATH + "/";
}
System.out.println("load library: " + path + fullName);
return path + fullName;
}
}
6
1.3.4 System Permissions under Dynamic Library Path
For Windows and Linux, the Java project copies the dynamic library to a temporary directory in the
system. The temporary directory path can be obtained by using the following code function in the
LibraryLoad class.
Make sure that you have the read and write permissions for the dynamic library files in this path. If
not, you might fail to load the dynamic library.
String fullName = getLibraryName(libraryName);
String path = EXTRACT_PATH;
if (!(EXTRACT_PATH.endsWith("/") || EXTRACT_PATH.endsWith("\\"))) {
path = EXTRACT_PATH + "/";
}
System.out.println("load library: " + path + fullName);
Replace the jna package of the old version in the resources/ directory with the jna package
of the new version. Configure the new version of jna into the current environment.
Change the library loading method of NetSDKLib encapsulation class to the following.
NetSDKLib NETSDK_INSTANCE = Native.load(LibraryLoad.getLoadLibrary("dhnetsdk"),
NetSDKLib.class);
In the NativeString class, change the parameters in the Pointer.getString method and
Pointer.setString method to pointer.getString (0) and pointer.setString (0, string).
After upgrading the jna, if there is a callback function in the running demo and StdCallCallback is
inherited, you need to comment out StdCallCallback; otherwise it will crash when running under the
Linux environment.
7
2 Function Modules
There are 10 function modules in this chapter. Each function module includes SDK initialization,
device login, logout, and SDK resource release. The optional processes do not affect the use of other
processes.
SDK Initialization
2.1.1 Introduction
Initialization is the first step of SDK to conduct all the function modules. It does not have the
surveillance function but can set some parameters that affect the SDK overall functions.
Initialization occupies some memory.
Only the first initialization is valid within one process.
After using this function, call cleanup interface to release SDK resource.
8
2.1.3 Process
Process of initialization
Begin
Initialize SDK
CLIENT_Init
Process Description
Call CLIENT_Init and CLIENT_Cleanup in pairs. It supports single thread multiple calling but it
is suggested to call the pair for only one time overall.
Initialization: Calling CLIENT_Init multiple times is only for internal count without repeating
applying resources.
Cleaning up: The interface CLIENT_Cleanup clears all the opened processes, such as login,
real-time monitoring, and alarm subscription.
Reconnection: SDK can set the reconnection function for the situations such as network
disconnection and power off. SDK will keep logging the device until succeeded. Only the
real-time monitoring, alarm and snapshot subscription resume after reconnection is successful.
Dynamic library loading: If there is an error "Unable to load library
'./wrongpath/libs/win64/dhnetsdk': The specified module cannot be found" when loading the
dynamic library, usually the path does not match. You need to adjust the path of the dynamic
library or modify the code based on the error codes. This problem is more common when
packaging the whole project and providing the jar package to other projects. Because this
9
problem is related to the use of the platform and the project, it cannot be generalized and
requires specific analysis.
For example, if you want to use the project directly on the Linux platform, you can load the
dynamic library path into the dynamic library search path by the following ways:
Enter “export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: / XXX” in the terminal. The current
terminal takes effect.
Modify “~ / .bashrc” or “~ / .bash_profile”, and add “export LD_LIBRARY_PATH =
$ LD_LIBRARY_PATH: / XXX” in the last line. After saving, you can use “source.bashrc” to
execute the file. The current user takes effect.
Modify “/ etc / profile”, and then add “export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: /
XXX”. After saving, you can use “source” to execute the file. Effective for all users.
import main.java.com.netsdk.lib.NetSDKLib;
import main.java.com.netsdk.lib.NetSDKLib.LLong;
import main.java.com.netsdk.lib.ToolKits;
import com.sun.jna.ptr.IntByReference;
/**
* Implement login interface
* Mainly are initialization, login and logout functions.
*/
public class LoginModule {
// Login handle
public static LLong m_hLoginHandle = new LLong(0);
//Initialize
public static boolean init(NetSDKLib.fDisConnect disConnect, NetSDKLib.fHaveReConnect
haveReConnect) {
bInit = netsdk.CLIENT_Init(disConnect, null);
if(!bInit) {
10
System.out.println("Initialize SDK failed");
return false;
}
// Set the callback of reconnection after disconnection. After setting, the SDK will automatically
reconnect when device disconnects.
// This operation is optional but recommended.
netsdk.CLIENT_SetAutoReconnect(haveReConnect, null);
return true;
11
}
// Clean up environment
public static void cleanup() {
if(bLogopen) {
netsdk.CLIENT_LogClose();
}
if(bInit) {
netsdk.CLIENT_Cleanup();
}
}
}
Device Login
2.2.1 Introduction
Device login, also called user authentication, is the precondition of all the other function modules.
You will obtain a unique login ID upon log in to the device and should introduce login ID before
using other SDK interfaces. The login ID becomes invalid once logged out.
12
2.2.3 Process
Process of login
Begin
Initialize SDK
CLIENT_Init
Log out
CLIENT_Logout
End
Process Description
Login handle: When the login is successful, the returned value is not 0 (even the handle is
smaller than 0, the login is also successful). One device can log in for multiple times with
different handle at each login. If there is not special function module, it is suggested to login
only one time. The login handle can be repeatedly used on other function modules.
Duplicate handles: It is normal that the login handle is the same as the existed handle. For
example, log in to device A and get handle loginIDA. However, if you log out of loginIDA and
then log in, you may get LoginIDA again. But the duplicate handles do not occur throughout the
lifetime of the handle.
Logout: The interface will release the opened functions internally, but it is not suggested to rely
on the cleaning up function. For example, if you opened the monitoring function, you should
call the interface that stops the monitoring function when it is no longer required.
13
Use login and logout in pairs: The login consumes some memory and socket information and
release sources once logout.
Login failure: It is suggested to check the failure through the error parameter of the login
interface. For the common error code, see Table 2-3.
Multi-device login: After the SDK is initialized, you can log in to multiple devices, but the
corresponding login handle and login information need to be adjusted.
import main.java.com.netsdk.lib.NetSDKLib;
import main.java.com.netsdk.lib.NetSDKLib.LLong;
import main.java.com.netsdk.lib.ToolKits;
import com.sun.jna.ptr.IntByReference;
14
//Initialize SDK and skip SDK cleanup
// Device information
public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
// Login handle
public static LLong m_hLoginHandle = new LLong(0);
// Log in to device
public static boolean login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword) {
IntByReference nError = new IntByReference(0);
m_hLoginHandle = netsdk.CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, m_strPassword, 0, null,
m_stDeviceInfo, nError);
if(m_hLoginHandle.longValue() == 0) {
System.err.printf("Login Device[%s] Port[%d]Failed. %s\n", m_strIp, m_nPort,
ToolKits.getErrorCodePrint());
} else {
System.out.println("Login Success [ " + m_strIp + " ]");
}
return bRet;
}
}
15
Real-time Monitoring
2.3.1 Introduction
Real-time monitoring obtains the real-time stream from the storage device or front-end device,
which is an important part of the surveillance system.
SDK can get the main stream and sub stream from the device once it logged.
Supports calling the window handle for SDK to directly decode and play the stream (Windows
system only).
Supports calling the real-time stream to you to perform independent treatment.
Supports saving the real-time record to the specific file though saving the callback stream or
calling the SDK interface.
2.3.3 Process
You can realize the real-time monitoring through SDK decoding library or your play library.
Call PlaySDK library from the SDK auxiliary library to realize real-time play.
16
Process of playing by SDK decoding library
Begin
Initialize SDK
CLIENT_Init
Log out
CLIENT_Logout
End Optional
Process Description
17
Notes for Process
SDK decoding play only supports Windows system. You need to call the decoding after getting
the stream in other systems.
Multi-thread calling: Multi-thread calling is not supported for the functions within the same
login session; however, multi-thread calling can deal with the functions of different login
sessions although such calling is not recommended.
Timeout: The request on applying for monitoring resources should have made some agreement
with the device before requiring the monitoring data. There are some timeout settings (see
"NET_PARAM structure"), and the field about monitoring is nGetConnInfoTime. If there is
timeout due to the reasons such as bad network connection, you can modify the value of
nGetConnInfoTime bigger.
The example code is as follows. Call it for only one time after having called CLIENT_Init.
NET_PARAM stuNetParam = new NET_PARAM();
stuNetParam. nGetConnInfoTime = 5000; 0, default is 1000 ms.
CLIENT_SetNetworkParam (stuNetParam);
Failed to repeat opening: For some models, the same channel cannot be opened for multiple
times during the one entire logged in status. If you are trying to open it repeatedly, you will
success in the first try but get failed afterwards. In this case, you can try the following:
Close the opened channel. For example, if you already opened the main stream video on
the channel 1 and still want to open the sub stream video on the same channel, you can
close the main stream first and then open the sub stream.
Login twice to obtain two login handles to deal with the main stream and sub stream
respectively.
Calling succeeded but no image: SDK decoding needs to use dhplay.dll. It is suggested to check
if dhplay.dll and its auxiliary library are missing under the running directory. See Table 1-1.
If the system resource is insufficient, the device might return error instead of stream. You can
receive an event DH_REALPLAY_FAILD_EVENT in the alarm callback that is set in
CLIENT_SetDVRMessCallBack. This event includes the detailed error codes. See
"DEV_PLAY_RESULT Structure" in Network SDK Development Manual.chm.
32 channels limit: The decoding consumes resources especially for the high definition videos.
Considering the limited resources at the client, currently the maximum channels are set to be 32.
If more than 32, it is suggested to use third party play library. See "2.3.3.2 Call Third Party Play
Library."
SDK calls back the real-time monitoring stream to you and you call PlaySDK to decode and play.
18
Process of calling third party play library
Begin
Initialize SDK
CLIENT_Init
Log out
CLIENT_Logout
End
Process Description
19
Notes for Process
import java.awt.Panel;
import main.java.com.netsdk.lib.NetSDKLib.LLong;
import main.java.com.netsdk.lib.ToolKits;
import com.sun.jna.Native;
/**
* Implement live interface
* Mainly are streaming starting function and streamimg stopping function.
*/
public class RealPlayModule {
// Start live view
public static LLong startRealPlay(int channel, int stream, Panel realPlayWindow) {
LLong m_hPlayHandle = LoginModule.netsdk.CLIENT_RealPlayEx(LoginModule.m_hLoginHandle,
channel, Native.getComponentPointer(realPlayWindow), stream);
if(m_hPlayHandle.longValue() == 0) {
System.err.println("failed to real-time monitoring, and the error code " +
ToolKits.getErrorCodePrint());
} else {
System.out.println("Success to start realplay");
// Customize stream to save file. Do this operation when you need to save the video.
String outFile="example/outputfile";
LoginModule.netsdk.CLIENT_SaveRealData(m_hPlayHandle,outFile);
20
}
return m_hPlayHandle;
}
}
}
private DataCallBackEx m_DataCallBackEx = new DataCallBackEx();
public LLong startRealPlay(int channel, int stream, Panel realPlayWindow) {
LLong m_hPlayHandle = LoginModule.netsdk.CLIENT_RealPlayEx(LoginModule.m_hLoginHandle,
channel, Native.getComponentPointer(realPlayWindow), stream);
LoginModule.netsdk.CLIENT_SetRealDataCallBackEx(m_hPlayHandle,m_DataCallBackEx, null,
0x00000001);
if(m_hPlayHandle.longValue() == 0) {
21
System.err.println("failed to real-time monitoring, and the error code" +
ToolKits.getErrorCodePrint());
} else {
System.out.println("Success to start realplay");
}
return m_hPlayHandle;
}
Video Snapshot
2.4.1 Introduction
Video snapshot can get the picture data of the playing video. This section introduces the following
snapshot ways:
Synchronous snapshot: Call the SDK interface which sends the snapshot command to the
device. The device will capture the current image and send to SDK through network, and then
SDK returns the image data to you
Asynchronous snapshot: Call the SDK interface and set snapshot callback so that the captured
image data shows in callback function. At the same time, call asynchronous snapshot interface
to snapshot.
Local snapshot: When the monitoring is opened, you can save the monitoring data in the
picture format which is the frame information that does not have network interaction with the
device.
22
Interface Implication
Local snap and the parameter could be the handle of
CLIENT_CapturePictureEx
monitoring or playback.
CLIENT_SetSnapRevCallBack Set snapshot callback to implement fSnapRev interface.
Asynchronous snapshot which is suitable for
CLIENT_SnapPictureEx non-intelligent traffic devices and parking lot devices,
such as IPC and speed dome.
2.4.3 Process
Video snapshot is consisted of synchronous snapshot, asynchronous snapshot and local snapshot.
Begin
Initialize SDK
CLIENT_Init
Log out
CLIENT_Logout
End
Process Description
23
After using all SDK functions, call CLIENT_Cleanup to release SDK resource.
Picture size limit: SDK allocates the fixed memory to receive the picture data returned from the
device. If the picture is larger than the fixed memory, SDK will return the truncated data.
SDK provides the interface to modify the default memory. If the picture (for example, the high
definition picture) is truncated, you can modify the value of nPicBufSize bigger. The example
code is as follows. After calling CLIENT_Init, call the example code just one time.
NET_PARAM stuNetParam = new NET_PARAM();
stuNetParam. nPicBufSize = 4000*1024*1024; nPicBufSize is 2M by default
CLIENT_SetNetworkParam (stuNetParam);
Multi-thread calling: Multi-thread calling is not supported for the functions within the same
login session.
Snapshot configuration: You can configure the network snapshot such as quality and definition.
However, if you are satisfied with the default configurations, do not modify them.
Picture save format: The picture data returns as memory and the interface supports saving it as
file (the precondition is that you have set the szFilePath field of
NET_IN_SNAP_PIC_TO_FILE_PARAM).
24
2.4.3.2 Asynchronous Snapshot
Beg in
Initi alize S DK
CLIENT_Init
Log in to d evi ce
CLIENT_Log inWith Hig hLevelSecurity
Trigger snapshot
CLIENT_Sna pPictu reEx
Log ou t
CLIENT_Log out
End
Process Description
25
2.4.3.3 Local Snapshot
Begin
Initialize SDK
CLIENT_Init
Log in to device
CLIENT_LoginWithHighLevelSecurity
Log out
CLIENT_Logout
End
Process Description
26
NetSDKLib.NET_OUT_SNAP_PIC_TO_FILE_PARAM snapParamOut= new
NetSDKLib.NET_OUT_SNAP_PIC_TO_FILE_PARAM(1024 * 1024);
snapParamIn.stuParam.Channel = 0;
snapParamIn.stuParam.Quality = 3;
snapParamIn.stuParam.ImageSize = 1; // 0:QCIF,1:CIF,2:D1
snapParamIn.stuParam.mode = 0; // -1: Stop capturing, 0: Request one frame, 1: Send request by schedule, 2:
Request continuously
snapParamIn.stuParam.InterSnap = 5;
snapParamIn.stuParam.CmdSerial = serialNum;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyMMddHHmmss");
final String fileName = "SyncSnapPicture_" + dateFormat.format(new Date()) + "_" + serialNum + ".jpg";
System.arraycopy(fileName.getBytes(),0,snapParamIn.szFilePath,0, fileName.getBytes().length);
final int timeOut = 5000; // 5 second
Pointer pInbuf =new Memory(snapParamIn.size());
pInbuf.clear(snapParamIn.size());
ToolKits.SetStructDataToPointer(snapParamIn, pInbuf, 0);
Pointer pOutbuf =new Memory(snapParamOut.size());
pOutbuf.clear(snapParamOut.size());
ToolKits.SetStructDataToPointer(snapParamOut, pOutbuf, 0);
if (!netsdkApi.CLIENT_SnapPictureToFile(loginHandle, pInbuf, pOutbuf, timeOut)) {
System.err.printf("CLIENT_SnapPictureEx Failed! Last Error[%x]\n",
netsdkApi.CLIENT_GetLastError());
}else {
System.out.println("CLIENT_SnapPictureToFile Success. " + new
File(fileName).getAbsolutePath());
}
Native.free(Pointer.nativeValue(pInbuf ));//Clear up memory
Pointer.nativeValue(pInbuf, 0); //Prevent repeated gc collection
Native.free(Pointer.nativeValue(pOutbuf ));
Pointer.nativeValue(pOutbuf, 0);
/*
*Example of local snapshot
*/
//Live view
int playType = NetSDKLib.NET_RealPlayType.NET_RType_Realplay; // Live view
m_hRealPlayHandle = netsdkApi.CLIENT_RealPlayEx(m_hLoginHandle, channel,
Native.getComponentPointer(realplayPanel), playType);
if (m_hRealPlayHandle.longValue() == 0) {
System.err.println("Failed to start real-time monitoring , and error code " +
ToolKits.getErrorCode());
27
return false;
} else {
System.out.println("Success to start realplay");
}
//Local snapshot
if (!LoginModule.netsdk.CLIENT_CapturePictureEx(hPlayHandle, picFileName,
NetSDKLib.NET_CAPTURE_FORMATS.NET_CAPTURE_JPEG))
{
System.err.printf("CLIENT_CapturePicture Failed!" + ToolKits.getErrorCodePrint());
} else {
System.out.println("CLIENT_CapturePicture success");
}
/*
* Example of asynchronous snapshot
*/
/// Set snapshot callback: Pictures are mainly returned from SnapCallback.getInstance() invoke.
netsdkApi.CLIENT_SetSnapRevCallBack(SnapCallback.getInstance(), null);
28
}
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("--> " + Thread.currentThread().getName() + " CLIENT_SnapPictureEx Success." +
System.currentTimeMillis());
PTZ Control
2.5.1 Introduction
PTZ is a mechanical platform that carries the device and the protective enclosure and performs
remote control in all directions.
PTZ is consisted of two motors that can perform horizontal and vertical movement to provide the
all-around vision.
This section provides guidance to you about how to control directions (there are eight directions:
upper, lower, left, right, upper left, upper right, bottom left, and bottom right), focus, zoom, iris, fast
positioning, and 3-dimensional positioning through SDK.
2.5.3 Process
Direction control, focus, zoom and iris are the continuous operations. SDK provides start and stop
interfaces to you for timing control.
29
Process of PTZ control
Begin
Initialize SDK
CLIENT_Init
Log in to device
CLIENT_LoginWithHighLevelSecurity
Log out
CLIENT_Logout
End
Process Description
Fast positioning: For the SD, take the current monitoring image center as origin, and the valid
range of horizontal and vertical coordinates is [–8191, 8191]. For example, if the horizontal
coordinate is 2000 and the vertical is 2000, the SD moves toward upper right and gets a new
origin, which means the coordinate specified every time is only relative to the current location.
30
3-dimensional positioning: For the SD, there is an initial position first. The horizontal coordinate
is [0, 3600] and the vertical is [–1800, 1800]. The coordinate specified each time is the absolute
coordinate and is irrelevant to the location of the SD image last time.
For more example code see the SDK package on the website (NetSDK_Chn_java\
src\main\java\com\netsdk\demo\frame\PTZControl.java).
Voice Talk
2.6.1 Introduction
Voice talk realizes the voice interaction between the local platform and the environment where
front-end devices are located.
This section introduces how to use SDK to realize the voice talk with the front-end devices.
31
2.6.2 Interface Overview
Table 2-7 Interfaces of voice talk
Interface Implication
CLIENT_StartTalkEx Start voice talk
CLIENT_StopTalkEx Stop voice talk
CLIENT_TalkSendData Send voice data to the device
CLIENT_AudioDecEx Decode audio data (valid only in Windows system)
2.6.3 Process
When SDK has collected the audio data from the local audio card, or SDK has received the audio data
from the front-end devices, SDK will call the callback of audio data.
You can call the SDK interface in the callback parameters to send the local audio data to the
front-end devices, or call SDK interface to decode and play the audio data received from the
front-end devices.
Process of voice talk
Begin
Initialize SDK
CLIENT_Init
Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_SetDeviceMode to set decoding information of voice talk. Set parameter
emType as DH_TALK_ENCODE_TYPE.
Call CLIENT_StartTalkEx to set callback and start voice talk. In the callback, call
CLIENT_AudioDec to decode the audio data that is sent from the decoding device, and call
CLIENT_TalkSendData to send the audio data of the PC end to the device.
32
Call CLIENT_StopTalkEx to stop voice talk.
After using the function module, call CLIENT_Logout to log out of the device.
After using all SDK functions, call CLIENT_Cleanup to release SDK resource.
Voice encoding format: The example uses the common PCM format. SDK supports accessing the
voice encoding format supported by the device. For more details of the example code, see the
SDK package on the website (NetSDK_Chn_java\
src\main\java\com\netsdk\demo\frame\Talk.java). If the default PCM can satisfy the
requirement, it is not recommended to obtain the voice encoding format from the device.
No sound at the device: The audio data needs to be collected by the device such as microphone.
It is recommended to check if the microphone or other equivalent device is plugged in and if
the CLIENT_RecordStartEx succeeded in returning.
33
return false;
}
// Set the speak parameter of voice talk
NetSDKLib.NET_SPEAK_PARAM speak = new NetSDKLib.NET_SPEAK_PARAM();
speak.nMode = 0;
speak.bEnableWait = false;
speak.nSpeakerChannel = 0;
speak.write();
if (LoginModule.netsdk.CLIENT_SetDeviceMode(LoginModule.m_hLoginHandle,
NetSDKLib.EM_USEDEV_MODE.NET_TALK_SPEAK_PARAM, speak.getPointer())) {
System.out.println("Set Talk Speak Mode Succeed!");
} else {
System.err.println("Set Talk Speak Mode Failed!" + ToolKits.getErrorCodePrint());
return false;
}
// Set the voice talk in transfer mode
NetSDKLib.NET_TALK_TRANSFER_PARAM talkTransfer = new
NetSDKLib.NET_TALK_TRANSFER_PARAM();
talkTransfer.bTransfer = transferType;
talkTransfer.write();
if(LoginModule.netsdk.CLIENT_SetDeviceMode(LoginModule.m_hLoginHandle,
NetSDKLib.EM_USEDEV_MODE.NET_TALK_TRANSFER_MODE, talkTransfer.getPointer())) {
System.out.println("Set Talk Transfer Mode Succeed!");
} else {
System.err.println("Set Talk Transfer Mode Failed!" + ToolKits.getErrorCodePrint());
return false;
}
if (talkTransfer.bTransfer == 1) { // Set transfer channel for transfer mode
IntByReference nChn = new IntByReference(chn);
if(LoginModule.netsdk.CLIENT_SetDeviceMode(LoginModule.m_hLoginHandle,
NetSDKLib.EM_USEDEV_MODE.NET_TALK_TALK_CHANNEL, nChn.getPointer())) {
System.out.println("Set Talk Channel Succeed!");
} else {
System.err.println("Set Talk Channel Failed!" + ToolKits.getErrorCodePrint());
return false;
}
}
m_hTalkHandle = LoginModule.netsdk.CLIENT_StartTalkEx(LoginModule.m_hLoginHandle,
AudioDataCB.getInstance(), null);
if(m_hTalkHandle.longValue() == 0) {
34
System.err.println("Start Talk Failed!" + ToolKits.getErrorCodePrint());
return false;
} else {
System.out.println("Start Talk Success");
if(LoginModule.netsdk.CLIENT_RecordStart()){
System.out.println("Start Record Success");
m_bRecordStatus = true;
} else {
System.err.println("Start Local Record Failed!" + ToolKits.getErrorCodePrint());
stopTalk();
return false;
}
}
return true;
}
/**
* Stop voice talk
*/
public static void stopTalk() {
if(m_hTalkHandle.longValue() == 0) {
return;
}
if (m_bRecordStatus){
LoginModule.netsdk.CLIENT_RecordStop();
m_bRecordStatus = false;
}
if(LoginModule.netsdk.CLIENT_StopTalkEx(m_hTalkHandle)) {
m_hTalkHandle.setValue(0);
}else {
System.err.println("Stop Talk Failed!" + ToolKits.getErrorCodePrint());
}
}
/**
* Data callback of voice talk
*/
private static class AudioDataCB implements NetSDKLib.pfAudioDataCallBack {
private AudioDataCB() {}
private static AudioDataCB audioCallBack = new AudioDataCB();
35
public static AudioDataCB getInstance() {
return audioCallBack;
}
public void invoke(LLong lTalkHandle, Pointer pDataBuf, int dwBufSize, byte byAudioFlag, Pointer
dwUser){
if(lTalkHandle.longValue() != m_hTalkHandle.longValue()) {
return;
}
if (byAudioFlag == 0) { // Send the sound card data which is detected by the local PC to the
device
Alarm Listening
2.7.1 Introduction
Alarm listening is the function to analyze real-time stream by smart devices. When the set event
occurs, alarm triggers.
36
2.7.3 Process
Process of alarm listening
Begin
Initialize SDK
CLIENT_Init
Log out
CLIENT_Logout
End
Process Description
No uploaded data: Only when you call CLIENT_SetDVRMessCallBack, will alarm data be acquired.
37
2.7.4 Example Code
// Set alarm callback
netSdk.CLIENT_SetDVRMessCallBack(callback, null);
// Start alarm listening
if (listening) {
return true;
}
listening = netSdk.CLIENT_StartListenEx(loginHandle);
if (!listening) {
System.err.println("Start Listen Failed!" + ToolKits.getErrorCode());
} else {
System.out.println("Start Listen Success.");
}
//fmessCallback
public class MessCallBack implements NetSDKLib.fMessCallBack {
private MessCallBack() {}
private static class CallBackHolder {
private static final MessCallBack cb = new MessCallBack();
}
38
listening = false;
}
Intelligent Event
2.8.1 Introduction
Intelligent event is the function to analyze real-time stream by smart devices. When the set event
occurs, the alarm events will be sent to users, such as traffic violation and parking space.
SDK connects to the device and subscribes intelligent event function. When the device gets the
intelligent events, they will be sent to SDK.
For the supported intelligent events, see the constants starting with EVENT_IVS_ in NetSDKLib.java,
which include events such as regular traffic violation.
39
2.8.3 Process
Process of intelligent event upload
Begin
Initialize SDK
CLIENT_Init
Log out
CLIENT_Logout
End
Process Description
Event type: Subscribe to all intelligent events (EVENT_IVS_ALL) if different intelligent events
need to be uploaded. Also support to subscribe to a single intelligent event.
Image receiving or not: The network environment of some devices is 3G or 4G. When the SDK is
connected to the device, set bNeedPicFile parameter in the CLIENT_RealLoadPictureEx to false if
images are not needed. Then only receive information about smart traffic event, without
40
images.
//The intelligence event callback of the access control system inherits the logic from
fAnalyzerDataCallBack and implements it itself.
private static class AnalyzerDataCB implements NetSDKLib.fAnalyzerDataCallBack {
private final File picturePath;
private static AnalyzerDataCB instance;
41
private AnalyzerDataCB() {
picturePath = new File("./AnalyzerPicture/");
if (!picturePath.exists()) {
picturePath.mkdirs();
}
}
switch(dwAlarmType)
{
case NetSDKLib.EVENT_IVS_ACCESS_CTL: ///< Access control event
{
DEV_EVENT_ACCESS_CTL_INFO msg = new DEV_EVENT_ACCESS_CTL_INFO();
ToolKits.GetPointerData(pAlarmInfo, msg);
42
if(msg.bStatus == 1) {
System.out.println("Card swiping result: Successful.");
} else if(msg.bStatus == 0) {
System.out.println("Card swiping result: Failed.");
}
try {
System.out.println("Role:" + new String(msg.stuCustomWorkerInfo.szRole, "GBK").trim());
System.out.println("Project Number:" + new String(msg.stuCustomWorkerInfo.szProjectNo).trim());
System.out.println("Project Name:" + new String(msg.stuCustomWorkerInfo.szProjectName,
"GBK").trim());
System.out.println("Contractor Name:" + new String(msg.stuCustomWorkerInfo.szBuilderName,
"GBK").trim());
}catch(UnsupportedEncodingException e) {
System.err.println("...UnsupportedEncodingException...");
}
if (msg.nImageInfoCount == 0) {
// Take snapshot and the device only returns one snapshot.
String snapPicPath = path + "\\" + System.currentTimeMillis() +
"AccessSnapPicture.jpg"; //Image storage address
byte[] buffer = pBuffer.getByteArray(0, dwBufSize);
ByteArrayInputStream byteArrInputGlobal = new
ByteArrayInputStream(buffer);
try {
BufferedImage bufferedImage = ImageIO.read(byteArrInputGlobal);
if(bufferedImage != null) {
ImageIO.write(bufferedImage, "jpg", new File(snapPicPath));
System.out.println("Snapshot storage path:" + snapPicPath);
}
} catch (IOException e2) {
43
e2.printStackTrace();
}
}else {
String snapPicPath;
for (int i = 0; i < msg.nImageInfoCount; ++i) {
snapPicPath = path + "\\" + System.currentTimeMillis() + "_AccessSnapPicture_" + i + ".jpg";
// Image storage address
byte[] buffer=pBuffer.getByteArray(msg.stuImageInfo[i].nOffSet, msg.stuImageInfo[i].nLength);
ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer);
try {
BufferedImage bufferedImage = ImageIO.read(byteArrInputGlobal);
if(bufferedImage != null) {
ImageIO.write(bufferedImage, "jpg", new File(snapPicPath));
System.out.println("Snapshot storage path:" + snapPicPath);
}
} catch (IOException e2) {
e2.printStackTrace();
}
}
}
break;
}
default:
break;
}
Record Playback
2.9.1 Introduction
Record playback function plays the videos of a particular period in some channels to find the target
videos for check.
The playback includes the following functions: Start playback, pause Playback, resume playback, and
stop playback.
44
2.9.2 Interface Overview
Table 2-10 Interfaces of record playback
Interface Implication
CLIENT_PlayBackByTimeEx Playback by time.
Set the work mode such as voice talk, playback, and
CLIENT_SetDeviceMode
authority.
CLIENT_StopPlayBack Stop record playback.
CLIENT_PausePlayBack Pause or resume playback.
2.9.3 Process
After SDK initialization, you need to input channel number, start time, stop time, and valid window
handle to realize the playback of the required record.
45
Process of record playback
Begin
Initialize SDK
CLIENT_Init
Log in to device
CLIENT_LoginWithHighLevelSecurity
Log out
CLIENT_Logout
Mandatory
End Optional
Process Description
46
(Optional) Call CLIENT_PausePlayBack. The playback will resume when the second
parameter is 0.
Call CLIENT_StopPlayBack to stop playback.
After using the function module, call CLIENT_Logout to log out of the device.
After using all SDK functions, call CLIENT_Cleanup to release SDK resource.
// Playback and download cannot be performed simultaneously with the same login handle.
if (m_hDownLoadHandle.longValue() != 0) {
JOptionPane.showMessageDialog(playFrame, "Please stop downloading");
return;
}
47
NetSdk.CLIENT_GetLastError());
}
// Stop playback
private void StopPlayBack() {
if (m_hPlayHandle.longValue() == 0) {
System.err.println("Please make sure the PlayBack Handle is valid");
return;
}
if (!NetSdk.CLIENT_StopPlayBack(m_hPlayHandle)) {
System.err.println("StopPlayBack Failed");
return;
}
48
m_hPlayHandle.setValue(0);
m_playFlag = false;
m_pauseFlag = true;
playPos = 0;
playButton.setText("Start playback");
pauseButton.setText("Pause");
panelPlayBack.repaint();
}
/**
* Pause and play
* @param pause true - Pause; false - Play
*/
private void PausePlayBack(boolean pause) {
if (m_hPlayHandle.longValue() == 0) {
System.err.println("Please make sure the PlayBack Handle is valid");
return;
}
NetSdk.CLIENT_NormalPlayBack(m_hPlayHandle);
}
// Fast play
private void FastPlayBack() {
if (m_hPlayHandle.longValue() == 0) {
System.err.println("Please make sure the PlayBack Handle is valid");
return;
}
49
NetSdk.CLIENT_FastPlayBack(m_hPlayHandle);
}
// Slow play
private void SlowPlayBack() {
if (m_hPlayHandle.longValue() == 0) {
System.err.println("Please make sure the PlayBack Handle is valid");
return;
}
NetSdk.CLIENT_SlowPlayBack(m_hPlayHandle);
}
Record Download
2.10.1 Introduction
Video surveillance system widely applies to city, airport, metro, bank and factory. When any event
occurs, you need to download the video records and report to the leaders, public security bureau, or
mass media. Therefore, record download is an important function.
The record download function helps you obtain the records saved on the device through SDK and
save into the local. It allows you to download from the selected channels and export to the local disk
or external USB flash drive.
This function is available for some select models.
2.10.3 Process
You can import the start time and end time of download. SDK can download the specified record file
and save to the required place.
You can also provide a callback pointer to SDK which calls back the specified record file to you for
treatment.
50
Process of record download
Begin
Initialize SDK
CLIENT_Init
Log in to device
CLIENT_LoginWithHighLevelSecurity
Download by time
CLIENT_DownLoadByTimeEx
Stop download
CLIENT_StopDownLoad
Log out
CLIENT_Logout
End
Process Description
51
2.10.4 Example Code
import main.java.com.netsdk.lib.NetSDKLib;
import main.java.com.netsdk.lib.NetSDKLib.LLong;
import main.java.com.netsdk.lib.ToolKits;
import com.sun.jna.ptr.IntByReference;
/**
* Implement record download
* Mainly are record query, record download and setting of stream type.
*/
public class DownLoadRecordModule {
// Download handle
public static LLong m_hDownLoadHandle = new LLong(0);
if(bRet) {
System.out.println("QueryRecordFile Succeed! \n" + "The number of queried videos: " +
nFindCount.getValue());
} else {
System.err.println("QueryRecordFile Failed!" + ToolKits.getErrorCodePrint());
return false;
}
return true;
52
}
/**
* Set stream type of playback
* @param m_streamType
*/
public static void setStreamType(int m_streamType) {
m_hDownLoadHandle =
LoginModule.netsdk.CLIENT_DownloadByTimeEx(LoginModule.m_hLoginHandle, nChannelId,
nRecordFileType, stTimeStart, stTimeEnd, SavedFileName, cbTimeDownLoadPos, null, null, null, null);
if(m_hDownLoadHandle.longValue() != 0) {
System.out.println("Downloading RecordFile!");
} else {
System.err.println("Download RecordFile Failed!" + ToolKits.getErrorCodePrint());
}
return m_hDownLoadHandle;
}
53
public static void stopDownLoadRecordFile(LLong m_hDownLoadHandle) {
if (m_hDownLoadHandle.longValue() == 0) {
return;
}
LoginModule.netsdk.CLIENT_StopDownload(m_hDownLoadHandle);
}
}
54
3 Interface Definition
SDK Initialization
3.1.2 CLIENT_Cleanup
Table 3-2 Clean up SDK
Item Description
Name Clean up SDK.
Function public void CLIENT_Cleanup();
Parameter None.
Return value None.
Note Call the SDK cleanup interface before the process ends.
3.1.3 CLIENT_SetAutoReconnect
Table 3-3 Set reconnection callback
Item Description
Name Set auto reconnection callback.
public void CLIENT_SetAutoReconnect(
Function
Callback cbAutoConnect, Pointer dwUser);
[in]cbAutoConnect Reconnection callback.
Parameter
[in]dwUser User parameter of disconnection callback.
Return value None.
Set the reconnection callback interface. If the callback is set as NULL, it will not
Note
connect automatically.
55
3.1.4 CLIENT_SetNetworkParam
Table 3-4 Set network parameter
Item Description
Name Set the related parameters for network environment.
public void CLIENT_SetNetworkParam(
Function
NET_PARAM pNetParam);
Parameters such as network delay, reconnection times,
Parameter [in]pNetParam
and buffer size.
Return value None.
Note Adjust the parameters according to the actual network environment.
Device Login
3.2.1 CLIENT_LoginWithHighLevelSecurity
Table 3-5 Log in
Item Description
Name Log in to the device.
public LLong CLIENT_LoginWithHighLevelSecurity(
Function NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY pstInParam,
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam);
[in] pstInParam Input parameter.
Parameter
[out] pstOutParam Output parameter.
Success: not 0.
Return value
Failure: 0.
This method is encapsulated in the NetSDKLib interface and is usually called by:
Note m_hLoginHandle =
netsdk.CLIENT_CLIENT_LoginWithHighLevelSecurity(pstInParam, pstOutParam);
3.2.2 CLIENT_Logout
Table 3-6 Log out
Item Description
Name User logout the device.
Function public boolean CLIENT_Logout(LLong lLoginID);
Parameter [in]lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Success: TRUE.
Return value
Failure: FALSE.
This method is encapsulated in the NetSDKLib interface and is usually called by:
Note
netsdk.CLIENT_Logout(m_hLoginHandle);
56
Real-time Monitoring
3.3.1 CLIENT_RealPlayEx
Table 3-7 Start monitoring
Item Description
Name Open the real-time monitoring.
public LLong CLIENT_RealPlayEx(
Function
LLong lLoginID, int nChannelID, Pointer hWnd, int rType);
[in]lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Video channel number is a round number starting from
[in]nChannelID
Parameter 0.
[in]hWnd Window handle valid only under Windows system.
[in]rType Live type.
Success: not 0
Return value
Failure: 0
Windows system:
When hWnd is valid, the corresponding window displays picture.
Note
When hWnd is NULL, get the video data through setting a callback and send to
user for handle.
3.3.2 CLIENT_StopRealPlayEx
Table 3-9 Stop monitoring
Item Description
Name Stop the real-time monitoring.
57
Item Description
Function public boolean CLIENT_StopRealPlayEx(LLong lRealHandle);
Parameter [in]lRealHandle Return value of CLIENT_RealPlayEx.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
3.3.3 CLIENT_SaveRealData
Table 3-10 Save monitoring data
Item Description
Name Save the real-time monitoring data as file.
public boolean CLIENT_SaveRealData(
Function
LLong lRealHandle, String pchFileName);
[in] lRealHandle Return value of CLIENT_RealPlayEx.
Parameter
[in] pchFileName Save path.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
3.3.4 CLIENT_StopSaveRealData
Table 3-11 Stop saving monitoring data
Item Description
Name Stop saving the real-time monitoring data as file.
Function public boolean CLIENT_StopSaveRealData(LLong lRealHandle);
Parameter [in] lRealHandle Return value of CLIENT_RealPlayEx.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
3.3.5 CLIENT_SetRealDataCallBackEx
Table 3-12 Set the callback of real-time monitoring data
Item Description
Name Set the callback of real-time monitoring data.
public boolean CLIENT_SetRealDataCallBackEx(
Function LLong lRealHandle, StdCallCallback cbRealData,
Pointer dwUser, int dwFlag);
[in] lRealHandle Return value of CLIENT_RealPlayEx.
[in] cbRealData Callback of monitoring data flow.
Parameter
[in] dwUser Parameter of callback for monitoring data flow.
[in] dwFlag Type of monitoring data in callback.
Success: TRUE.
Return value
Failure: FALSE.
58
Item Description
Note None.
Video Snapshot
3.4.1 CLIENT_SnapPictureToFile
Table 3-14 Synchronous snapshot
Item Description
Name Synchronous snapshot.
public boolean CLIENT_SnapPictureToFile(
Function LLong lLoginID,
Pointer pInParam, Pointer pOutParam, int nWaitTime)
[in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Input parameter. Refer to
[in] pInParam
NET_IN_SNAP_PIC_TO_FILE_PARAM.
Parameter
Output parameter. Refer to
[in] pOutParam
NET_OUT_SNAP_PIC_TO_FILE_PARAM.
[in] nWaitTime Timeout. The unit is millisecond.
Success: TRUE.
Return value
Failure: FALSE.
Synchronous interface. The device captures snapshot and sends to the user
Note through internet.
This function is available for some select models.
3.4.2 CLIENT_CapturePictureEx
Table 3-15 Asynchronous snapshot
Item Description
Name Asynchronous snapshot.
public boolean CLIENT_SnapPictureEx(
Function LLong lLoginID,
SNAP_PARAMS stParam, IntByReference reserved);
[in] lLoginID Return value of
CLIENT_LoginWithHighLevelSecurity.
Parameter
[in] stParam Snapshot parameters structure.
[in] reserved Picture format.
Success: TRUE.
Return value
Failure: FALSE.
59
Item Description
Synchronous interface. Directly write the picture data as file.
Note
Capture the pictures from the real-time monitoring data stream from device.
3.4.3 CLIENT_CapturePictureEx
Table 3-16 Local snapshot
Item Description
Name Local snapshot.
public boolean CLIENT_CapturePictureEx(
Function LLong hPlayHandle,
String pchPicFileName, int eFormat);
[in] hPlayHandle Return value of CLIENT_RealPlayEx.
Parameter [in] pchPicFileName Save path.
[in] eFormat Picture format.
Success: TRUE.
Return value
Failure: FALSE.
Synchronous interface. Directly write the picture data as file.
Note
Capture the pictures from the real-time monitoring data stream from device.
PTZ Control
3.5.1 CLIENT_DHPTZControlEx
Table 3-18 Control PTZ
Item Description
Name PTZ control.
60
Item Description
public boolean CLIENT_DHPTZControlEx(
LLong lLoginID,
Function int nChannelID, int dwPTZCommand,
int lParam1, int lParam2, int lParam3,
int dwStop);
[in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Video channel number that is a round number starting
[in] nChannelID
from 0.
[in] dwPTZCommand Control command type.
[in] lParam1 Parameter 1.
Parameter
[in] lParam2 Parameter 2.
[in] lParam3 Parameter 3.
Stop mark, which is valid for operations of eight
[in] dwStop directions. When performing other operations, enter
FALSE for this parameter.
Success: TRUE.
Return value
Failure: FALSE.
For the relationship between dwPTZCommand and Param1, Param2 and Param3,
Note
see Table 3-19.
61
dwPTZCommand
Function param1 param2 param3
macro definition
DH_PTZ_POINT_SET_CO Value of preset
Set None None
NTROL point
DH_PTZ_POINT_DEL_CO Value of preset
Delete None None
NTROL point
76: Start
DH_PTZ_POINT_LOOP_C Cruise among
Cruise route None 99: Automatic
ONTROL points
96: Stop
DH_PTZ_LAMP_CONTR 0x01: Start
Lamp wiper None None
OL x00: Stop
Vertical speed Horizontal
DH_EXTPTZ_LEFTTOP Left top None
(1–8) speed (1–8)
Vertical speed Horizontal
DH_EXTPTZ_RIGHTTOP Right top None
(1–8) speed (1–8)
Vertical speed Horizontal
DH_EXTPTZ_LEFTDOWN Left bottom None
(1–8) speed (1–8)
DH_EXTPTZ_RIGHTDOW Vertical speed Horizontal
Right bottom None
N (1–8) speed (1–8)
DH_EXTPTZ_ADDTOLOO Add preset point Value of preset
Tour route None
P to tour point
DH_EXTPTZ_DELFROML Delete preset Value of preset
Cruise route None
OOP point in cruise point
DH_EXTPTZ_CLOSELOO
Delete cruise Cruise route None None
P
DH_EXTPTZ_STARTPANC Start horizontal
None None None
RUISE rotation
DH_EXTPTZ_STOPPANC Stop horizontal
None None None
RUISE rotation
DH_EXTPTZ_SETLEFTBO
Set left border None None None
RDER
DH_EXTPTZ_RIGHTBOR
Set right border None None None
DER
DH_EXTPTZ_STARTLINES
Start line scan None None None
CAN
DH_EXTPTZ_CLOSELINE
Stop line scan None None None
SCAN
DH_EXTPTZ_SETMODES
Set mode start Mode route None None
TART
DH_EXTPTZ_SETMODES
Set mode stop Mode route None None
TOP
DH_EXTPTZ_RUNMODE Running mode Mode route None None
DH_EXTPTZ_STOPMODE Stop mode Mode route None None
DH_EXTPTZ_DELETEMO
Delete mode Mode route None None
DE
62
dwPTZCommand
Function param1 param2 param3
macro definition
DH_EXTPTZ_REVERSECO
Reverse command None None None
MM
Horizontal Vertical
DH_EXTPTZ_FASTGOTO Fast positioning coordinate (0– coordinate Zoom (4)
8192) (0–8192)
Open auxiliary
DH_EXTPTZ_AUXIOPEN Auxiliary point None None
switch
Close auxiliary
DH_EXTPTZ_AUXICLOSE Auxiliary point None None
switch
DH_EXTPTZ_OPENMEN
Open SD menu None None None
U
DH_EXTPTZ_CLOSEMEN
Close menu None None None
U
DH_EXTPTZ_MENUOK Menu confirm None None None
DH_EXTPTZ_MENUCAN
Menu cancel None None None
CEL
DH_EXTPTZ_MENUUP Menu up None None None
DH_EXTPTZ_MENUDOW
Menu down None None None
N
DH_EXTPTZ_MENULEFT Menu left None None None
DH_EXTPTZ_MENURIGH
Menu right None None None
T
Alarm action
type:
Linkage value,
DH_EXTPTZ_ALARMHAN Alarm action with Alarm input Preset
such as preset
DLE PTZ channel point
point number
Line scan
Cruise
Monitor device
DH_EXTPTZ_MATRIXSWI number (video Video input
Matrix switch Matrix number
TCH output number
number)
Refer to
DH_EXTPTZ_LIGHTCONT
Light controller DH_PTZ_LAMP None None
ROL
_CONTROL
Vertical
DH_EXTPTZ_EXACTGOT Horizontal
3D positioning coordinate (0– Zoom (1–128)
O angle (0–3600)
900)
DH_EXTPTZ_RESETZERO Reset to zero None None None
DH_EXTPTZ_UP_TELE Up +TELE Speed (1–8) None None
DH_EXTPTZ_DOWN_TEL Down +TELE
Speed (1–8) None None
E
DH_EXTPTZ_LEFT_TELE Left +TELE Speed (1–8) None None
63
dwPTZCommand
Function param1 param2 param3
macro definition
DH_EXTPTZ_RIGHT_TEL Right+TELE
Speed (1–8) None None
E
DH_EXTPTZ_LEFTUP_TE Leftup +TELE
Speed (1–8) None None
LE
DH_EXTPTZ_LEFTDOWN Leftdown +TELE
Speed (1–8) None None
_TELE
DH_EXTPTZ_TIGHTUP_T Rightup+TELE
Speed (1–8) None None
ELE
DH_EXTPTZ_RIGHTDOW Rightdown +TELE
Speed (1–8) None None
N_TELE
DH_EXTPTZ_UP_WIDE Up +WIDE Speed (1–8) None None
DH_EXTPTZ_DOWN_WI Down+WIDE
Speed (1–8) None None
DE
DH_EXTPTZ_LEFT_WIDE Left +WIDE Speed (1–8) None None
DH_EXTPTZ_RIGHT_WID Right+WIDE
Speed (1–8) None None
E
DH_EXTPTZ_LEFTUP_WI Leftup+WIDE
Speed (1–8) None None
DE
DH_EXTPTZ_LEFTDOWN Leftdown+WIDE
Speed (1–8) None None
_WIDE
DH_EXTPTZ_RIGHTUP_ Rightup +WIDE
Speed (1–8) None None
WIDE
DH_EXTPTZ_RIGHTDOW Rightdown +WIDE
Speed (1–8) None None
N_WIDE
Voice Talk
3.6.1 CLIENT_StartTalkEx
Table 3-20 Start voice talk
Item Description
Name Start voice talk.
public LLong CLIENT_StartTalkEx(
Function LLong lLoginID,
Callback pfcb, Pointer dwUser);
[in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Parameter [in] pfcb Audio data callback.
[in] dwUser Parameter of audio data callback.
Success: Not 0.
Return value
Failure: 0.
Note None.
64
3.6.2 CLIENT_StopTalkEx
Table 3-21 Stop voice talk
Item Description
Name Stop voice talk.
Function public boolean CLIENT_StopTalkEx(LLong lTalkHandle);
Parameter [in] lTalkHandle Return value of CLIENT_StartTalkEx.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
3.6.3 CLIENT_TalkSendData
Table 3-22 Send voice talk data
Item Description
Name Send audio data to device.
public LLong CLIENT_TalkSendData(
Function LLong lTalkHandle,
Pointer pSendBuf, int dwBufSize);
[in] lTalkHandle Return value of CLIENT_StartTalkEx.
[in] pSendBuf Pointer of audio data block that needs to be sent.
Parameter
Length of audio data black that needs to be sent. The
[in] dwBufSize
unit is byte.
Success: Length of audio data block.
Return value
Failure: -1.
Note None.
3.6.4 CLIENT_AudioDecEx
Table 3-23 Decode audio data
Item Description
Name Decode audio data.
public boolean CLIENT_AudioDecEx(
Function LLong lTalkHandle,
Pointer pAudioDataBuf, int dwBufSize);
[in] lTalkHandle Return value of CLIENT_StartTalkEx.
[in] pAudioDataBuf Pointer of audio data block that needs decoding.
Parameter
Length of audio data black that needs decoding. The
[in] dwBufSize
unit is byte.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
65
Alarm Listening
3.7.1 CLIENT_StartListenEx
Table 3-24 Start alarm listening
Item Description
Name Start alarm listening.
public boolean CLIENT_StartListenEx(
Function
LLong lLoginID);
Parameter [in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Success: Not 0.
Return value
Failure: 0.
Note None.
3.7.2 CLIENT_StopListen
Table 3-25 Stop alarm listening
Item Description
Name Stop alarm listening.
public boolean CLIENT_StopListen(
Function
LLong lLoginID);
Parameter [in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
3.7.3 CLIENT_SetDVRMessCallBack
Table 3-26 Set alarm listening
Item Description
Name Set alarm listening.
public void CLIENT_SetDVRMessCallBack(
Function
Callback cbMessage , Pointer dwUser);
[in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Parameter
[in] dwUser Returned user information.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
66
Intelligent Event
3.8.1 CLIENT_RealLoadPictureEx
Table 3-27 Start subscribing intelligent event
Item Description
Name Start subscribing intelligent event.
public LLong CLIENT_RealLoadPictureEx(
LLong lLoginID, int nChannelID,
Function int dwAlarmType, int bNeedPicFile,
StdCallCallback cbAnalyzerData,
Pointer dwUser, Pointer Reserved);
[in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
[in] nChannelID Device channel number, starting from 0.
[in] dwAlarmType Type of subscribed alarm event.
Parameter [in] bNeedPicFile Subscribe to image file or not?
[in] cbAnalyzerData Callback of intelligent event.
[in] dwUser Type of customized data.
[in] Reserved Reserved handle.
Success: Subscription handle of LLONG type.
Return value
Failure: FALSE.
Note Get error code by CLIENT_GetLastError when the interface fails to return.
67
dwAlarmType macro Value of macro Corresponding structure of
Meaning
definition definition pAlarmInfo
Sticker
EVENT_IVS_CLIMBDETECTION 0x00000128 DEV_EVENT_IVS_CLIMB_INFO
detection
Fighting
EVENT_IVS_FIGHTDETECTION 0x0000000E DEV_EVENT_FLOWSTAT_INFO
detection
AWOL
EVENT_IVS_LEAVEDETECTION 0x00000129 DEV_EVENT_IVS_LEAVE_INFO
detection
Stand DEV_EVENT_PSRISEDETECTIO
EVENT_IVS_PSRISEDETECTION 0x0000011E
detection N_INFO
Sticker
EVENT_IVS_PASTEDETECTION 0x00000004 DEV_EVENT_PASTE_INFO
detection
3.8.2 CLIENT_StopLoadPic
Table 3-29 Stop subscribing intelligent event
Item Description
Name Stop subscribing intelligent event.
Function public boolean CLIENT_StopLoadPic(LLong lAnalyzerHandle);
Parameter [in] lAnalyzerHandle Subscription handle of intelligent event.
BOOL type:
Return value Success: TRUE.
Failure: FALSE.
Note Get error code by CLIENT_GetLastError when the interface fails to return.
Record Playback
3.9.1 CLIENT_PlayBackByTimeEx
Table 3-30 Playback by time
Item Description
Name Playback by time.
public LLong CLIENT_PlayBackByTimeEx(
LLong lLoginID, int nChannelID,
Function NET_TIME lpStartTime, NET_TIME lpStopTime,
Pointer hWnd, Callback cbDownLoadPos, Pointer dwPosUser,
Callback fDownLoadDataCallBack, Pointer dwDataUser);
[in] lLoginID Login handle.
[in] nChannelID Device channel number, starting from 0.
[in] lpStartTime Start time.
Parameter
[in] lpStopTime Stop time.
[in] hWnd Window handle (valid only in Windows
system).
68
Item Description
[in] cbDownLoadPos Callback of fDownLoadPosCallBack.
[out] dwPosUser None.
[out] fDownLoadDataCallBack Callback of fDataCallBack.
[in] dwDataUser None.
Success: Network playback ID.
Return value
Failure: 0.
Note None.
3.9.2 CLIENT_SetDeviceMode
Table 3-31 Set the work mode
Item Description
Name Set the work mode.
public boolean CLIENT_SetDeviceMode(
Function
LLong lLoginID, int emType, Pointer pValue);
[in] ILoginID Return value of CLIENT_LoginWithHighLevelSecurity.
Parameter [in] emType Work mode enumeration.
[in] pValue The corresponding structure of work mode.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
The following table shows information about work mode enumeration and structure.
3.9.3 CLIENT_StopPlayBack
Table 3-33 Stop record playback
Item Description
Name Stop video playback.
Function public boolean CLIENT_StopPlayBack(LLong lPlayHandle);
Parameter [in] 1PlayHandle Return value of playback interface.
Success: TRUE.
Return value
Failure: FALSE.
Note None.
69
3.9.4 CLIENT_PausePlayBack
Table 3-34 Pause or resume record playback
Item Description
Name Pause or resume playback.
Function public boolean CLIENT_PausePlayBack(LLong lPlayHandle, int bPause);
[in] lPlayHandle Return value of playback interface.
Parameters for network playback stops and resumes:
Parameter
[out] bPause 1: Pause
0: Resume
Success: TRUE.
Return value
Failure: FALSE.
Note Pause or resume the ongoing playback.
Record Download
3.10.1 CLIENT_QueryRecordFile
Table 3-35 Query for all record files within a period
Item Description
Name Query for all record files within a period.
public boolean CLIENT_QueryRecordFile(
LLong lLoginID, int nChannelId, int nRecordFileType,
NET_TIME tmStart, NET_TIME tmEnd, String pchCardid,
Function
NET_RECORDFILE_INFO[] stFileInfo,
int maxlen, IntByReference filecount,
int waittime, boolean bTime);
[in] lLoginID Return value of CLIENT_LoginWithHighLevelSecurity.
[in] nChannelId Device channel number, starting from 0.
[in] nRecordFileType Record file type.
[in] tmStart Record start time.
[in] tmEnd Record end time.
[in] pchCardid Card ID.
The returned record file is a LPNET_RECORDFILE_INFO
Parameter [out] nriFileinfo
structured data.
The maximum length of nriFileinfo buffer, whose unit is
[in] maxlen byte and recommended to be between
"(100~200) *sizeof(NET_RECORDFILE_INFO)".
[out] filecount Check the number of returned files only in the cache.
[in] waittime Waiting time.
[in] bTime Currently invalid.
Success: TRUE.
Return value
Failure: FALSE.
70
Item Description
Before playback, call this interface to query for the records. When the queried records
Note within the defined time are larger than the cache size, it will only return the records
that can be stored by cache. Continue with the query if needed.
The following table shows information about record file and card ID.
3.10.2 CLIENT_DownloadByTimeEx
Table 3-37 Download record by file
Item Description
Name Download record by time.
public LLong CLIENT_DownloadByTimeEx(
LLong lLoginID, int nChannelId, int nRecordFileType,
NET_TIME tmStart, NET_TIME tmEnd, String sSavedFileName,
Function
StdCallCallback cbTimeDownLoadPos, Pointer dwUserData,
StdCallCallback fDownLoadDataCallBack, Pointer dwDataUser,
Pointer pReserved);
Return value of
[in] lLoginID
Parameter CLIENT_LoginWithHighLevelSecurity.
[in] nChannelId The device channel number starting from 0.
71
Item Description
Query type of file.
0: All recorded videos.
1: External alarm.
2: Records of motion detection.
3: All alarms.
[in] nRecordFileType
4: Recorded video query by card ID.
5: Combined condition query.
8: Image query by card ID.
9: Image query.
10: Query by field.
[in] tmStart Start time of download.
[in] tmEnd End time of download.
[in] sSavedFileName The record file name and full save path.
[in]cbTimeDownLoadPos Download progress callback.
[in] dwUserData Download progress callback customized data.
[in] fDownLoadDataCallBack Data callback.
[in] dwUserData Download data callback customized data.
[in] pReserved Parameter reserved and the default is NULL.
Success: Download ID.
Return value
Failure: 0.
For callback declaration of fDownLoadPosCallBack and fDataCallBack, see
"Chapter 错误!未找到引用源。 错误!未找到引用源。."
sSavedFileName is not blank, and the record data is input into the file
Note
corresponding with the path.
fDownLoadDataCallBack is not blank, and the record data is returned through
callback.
3.10.3 CLIENT_StopDownload
Table 3-38 Stop record download
Item Description
Name Stop record download.
Function public boolean CLIENT_StopDownload(LLong lFileHandle);
Parameter [in] lFileHandle Return value of CLIENT_DownloadByTimeEx.
Success: ID of download.
Return value
Failure: 0.
Stop downloading after it is completed or partially completed according to particular
Note
situation.
72
4 Callback Definition
fDisConnect
fHaveReConnect
73
fRealDataCallBackEx
pfAudioDataCallBack
74
Item Description
[out] dwUser User parameter of the callback.
Return value None.
Note None.
fAnalyzerDataCallBack
fTimeDownLoadPosCallBack
75
Item Description
[out]lPlayHandle Return value of CLIENT_DownloadByTimeEx.
[out] dwTotalSize Total size of playback. The unit is KB.
The size that has been played. The unit is KB.
[out]dwDownLoadSize -1: Current download finished.
Parameter
-2: Write file failed.
[out] index Index.
[out] recordfileinfo Record file information.
[out] dwUser User data.
Return value None.
fMessCallBack
76
Asynchronous Snapshot
77
Cybersecurity Recommendations
Cybersecurity is more than just a buzzword: it’s something that pertains to every device that is
connected to the internet. IP video surveillance is not immune to cyber risks, but taking basic steps
toward protecting and strengthening networks and networked appliances will make them less
susceptible to attacks. Below are some tips and recommendations on how to create a more secured
security system.
Mandatory actions to be taken for basic device network security:
1. Use Strong Passwords
Please refer to the following suggestions to set passwords:
The length should not be less than 8 characters;
Include at least two types of characters; character types include upper and lower case
letters, numbers and symbols;
Do not contain the account name or the account name in reverse order;
Do not use continuous characters, such as 123, abc, etc.;
Do not use overlapped characters, such as 111, aaa, etc.;
2. Update Firmware and Client Software in Time
According to the standard procedure in Tech-industry, we recommend to keep your device
(such as NVR, DVR, IP camera, etc.) firmware up-to-date to ensure the system is equipped
with the latest security patches and fixes. When the device is connected to the public
network, it is recommended to enable the “auto-check for updates” function to obtain
timely information of firmware updates released by the manufacturer.
We suggest that you download and use the latest version of client software.
"Nice to have" recommendations to improve your device network security:
1. Physical Protection
We suggest that you perform physical protection to device, especially storage devices. For
example, place the device in a special computer room and cabinet, and implement well-done
access control permission and key management to prevent unauthorized personnel from
carrying out physical contacts such as damaging hardware, unauthorized connection of
removable device (such as USB flash disk, serial port), etc.
2. Change Passwords Regularly
We suggest that you change passwords regularly to reduce the risk of being guessed or cracked.
3. Set and Update Passwords Reset Information Timely
The device supports password reset function. Please set up related information for password
reset in time, including the end user’s mailbox and password protection questions. If the
information changes, please modify it in time. When setting password protection questions, it is
suggested not to use those that can be easily guessed.
4. Enable Account Lock
The account lock feature is enabled by default, and we recommend you to keep it on to
guarantee the account security. If an attacker attempts to log in with the wrong password
several times, the corresponding account and the source IP address will be locked.
5. Change Default HTTP and Other Service Ports
We suggest you to change default HTTP and other service ports into any set of numbers
between 1024~65535, reducing the risk of outsiders being able to guess which ports you are
using.
78
6. Enable HTTPS
We suggest you to enable HTTPS, so that you visit Web service through a secure communication
channel.
7. MAC Address Binding
We recommend you to bind the IP and MAC address of the gateway to the device, thus reducing
the risk of ARP spoofing.
8. Assign Accounts and Privileges Reasonably
According to business and management requirements, reasonably add users and assign a
minimum set of permissions to them.
9. Disable Unnecessary Services and Choose Secure Modes
If not needed, it is recommended to turn off some services such as SNMP, SMTP, UPnP, etc., to
reduce risks.
If necessary, it is highly recommended that you use safe modes, including but not limited to the
following services:
SNMP: Choose SNMP v3, and set up strong encryption passwords and authentication
passwords.
SMTP: Choose TLS to access mailbox server.
FTP: Choose SFTP, and set up strong passwords.
AP hotspot: Choose WPA2-PSK encryption mode, and set up strong passwords.
10. Audio and Video Encrypted Transmission
If your audio and video data contents are very important or sensitive, we recommend that you
use encrypted transmission function, to reduce the risk of audio and video data being stolen
during transmission.
Reminder: encrypted transmission will cause some loss in transmission efficiency.
11. Secure Auditing
Check online users: we suggest that you check online users regularly to see if the device is
logged in without authorization.
Check device log: By viewing the logs, you can know the IP addresses that were used to log
in to your devices and their key operations.
12. Network Log
Due to the limited storage capacity of the device, the stored log is limited. If you need to save
the log for a long time, it is recommended that you enable the network log function to ensure
that the critical logs are synchronized to the network log server for tracing.
13. Construct a Safe Network Environment
In order to better ensure the safety of device and reduce potential cyber risks, we recommend:
Disable the port mapping function of the router to avoid direct access to the intranet
devices from external network.
The network should be partitioned and isolated according to the actual network needs. If
there are no communication requirements between two sub networks, it is suggested to
use VLAN, network GAP and other technologies to partition the network, so as to achieve
the network isolation effect.
Establish the 802.1x access authentication system to reduce the risk of unauthorized access
to private networks.
Enable IP/MAC address filtering function to limit the range of hosts allowed to access the
device.
79