NetSDK C# ProgrammingManual V1.0.1
NetSDK C# ProgrammingManual V1.0.1
NetSDK_C#
User’s Manual
Programming Manual
V1.0.0
V1.0.1
Foreword
Purpose
Reader
Signals
The following categorized signal words with defined meaning might appear in the manual.
Signal Words Meaning
Revision History
As the device user or data controller, you might collect personal data of others such as face,
fingerprints, car plate number, email address, phone number, GPS and so on. You need to be in
compliance with the local privacy protection laws and regulations to protect the legitimate rights
and interests of other people by implementing measures include but not limited to: providing clear
I
and visible identification to inform data subject the existence of surveillance area and providing
related contact.
The manual is for reference only. If there is inconsistency between the manual and the actual
product, the actual product shall prevail.
We are not liable for any loss caused by the operations that do not comply with the manual.
The manual would be updated according to the latest laws and regulations of related
jurisdictions. For detailed information, refer to the paper manual, CD-ROM, QR code or our
official website. If there is inconsistency between paper manual and the electronic version, the
electronic version shall prevail.
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 in technical data, functions and operations description, or errors
in print. If there is any doubt or dispute, we reserve the right of final explanation.
Upgrade the reader software or try other mainstream reader software if the manual (in PDF
format) cannot be opened.
All trademarks, registered trademarks and the company names in the manual are the properties
of their respective owners.
Please visit our website, contact the supplier or customer service if there is any problem
occurring when using the device.
If there is any uncertainty or controversy, we reserve the right of final explanation.
II
Glossary
This chapter provides the definitions to some of the terms that appear in the manual to help you
understand the function of each module.
Term Definition
NVR Abbreviation for Network Video Recorder.
EVS Abbreviation for Enterprise Video Storage.
HDCVI Abbreviation for High Definition Composite Video Interface.
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 the
Sub Stream main stream but demands less network resources. The user can choose the
stream type according to the particular scenes.
Resolution is consisted of display resolution and image resolution. Display
resolution refers to the quantity of pixels in unit area, and the image
Resolution
resolution refers to information quantity (the quantity of pixels per inch)
stored in the image.
A measurement, usually in FPS and Hz, which shows the frames of video. The
Frame Rate more the frame, more smooth the video. The frames over 24 FPS make the
image feels coherent.
An abstract concept of the communication and video stream transmission
between NetSDK and devices. For example, if a number of cameras (SD, IPC)
Video Channel are mounted on a storage device (NVR), the storage device manages the
cameras as video channels which are numbered from 0. If NetSDK connects
to the camera directly, the video channel is usually numbered as 0.
Alarm of Dynamic When detecting a moving object on the image, an alarm by dynamic
Detection detection will be uploaded.
Alarm of Hard Disk
When detecting a hard disk failure, an alarm will be uploaded.
Failure
This alarm is only for analog channel. When the record disappeared from the
Alarm of Video Loss analog channel, an alarm will be uploaded. For the digital channel, refer to
IPC disconnection alarm.
Alarm of Hard Disk
When the hard disk is damaged, an alarm will be uploaded.
Damage
IPC Offline Alarm When the IPC device is disconnected, an alarm will be uploaded.
NVR local alarm. When the NVR alarm terminal connects with alarm device, an
External Alarm
alarm will be uploaded.
When the alarm on IPC device connects with alarm device, an external alarm
IPC External Alarm
will be uploaded.
III
Table of Contents
Foreword ............................................................................................................................................................ I
Glossary ........................................................................................................................................................... III
1 Overview ........................................................................................................................................................ 1
1.1 General ........................................................................................................................................................................................... 1
1.2 Applicability ................................................................................................................................................................................. 2
2 Function Modules .......................................................................................................................................... 3
2.1 NetSDK Initialization ................................................................................................................................................................. 3
2.1.1 Introduction .................................................................................................................................................................... 3
2.1.2 Interface Overview ....................................................................................................................................................... 3
2.1.3 Process .............................................................................................................................................................................. 3
2.1.4 Example Code ................................................................................................................................................................ 4
2.2 Device Login and Logout ........................................................................................................................................................ 5
2.2.1 Introduction .................................................................................................................................................................... 5
2.2.2 Interface Overview ....................................................................................................................................................... 5
2.2.3 Process .............................................................................................................................................................................. 6
2.2.4 Example Code ................................................................................................................................................................ 7
2.3 Real-time Monitoring ............................................................................................................................................................... 7
2.3.1 Introduction .................................................................................................................................................................... 7
2.3.2 Interface Overview ....................................................................................................................................................... 8
2.3.3 Process .............................................................................................................................................................................. 8
2.3.4 Example Code ..............................................................................................................................................................12
2.4 Record Playback .......................................................................................................................................................................13
2.4.1 Introduction ..................................................................................................................................................................13
2.4.2 Interface Overview .....................................................................................................................................................14
2.4.3 Process ............................................................................................................................................................................14
2.4.4 Example Code ..............................................................................................................................................................16
2.5 Record Download ....................................................................................................................................................................17
2.5.1 Introduction ..................................................................................................................................................................17
2.5.2 Interface Overview .....................................................................................................................................................18
2.5.3 Process ............................................................................................................................................................................18
2.5.4 Example Code ..............................................................................................................................................................22
2.6 PTZ Control .................................................................................................................................................................................27
2.6.1 Introduction ..................................................................................................................................................................27
2.6.2 Interface Overview .....................................................................................................................................................27
2.6.3 Process ............................................................................................................................................................................28
2.6.4 Example Code ..............................................................................................................................................................30
2.7 Voice Talk .....................................................................................................................................................................................30
2.7.1 Introduction ..................................................................................................................................................................30
2.7.2 Interface Overview .....................................................................................................................................................31
2.7.3 Process ............................................................................................................................................................................31
2.7.4 Example Code ..............................................................................................................................................................33
2.8 Video Snapshot .........................................................................................................................................................................36
2.8.1 Introduction ..................................................................................................................................................................36
IV
2.8.2 Interface Overview .....................................................................................................................................................36
2.8.3 Process ............................................................................................................................................................................37
2.8.4 Example Code ..............................................................................................................................................................39
2.9 Subscribing Intelligent Event ..............................................................................................................................................40
2.9.1 Introduction ..................................................................................................................................................................40
2.9.2 Interface Overview .....................................................................................................................................................40
2.9.3 Process ............................................................................................................................................................................41
2.9.4 Example Code ..............................................................................................................................................................42
2.10 Alarm Upload ..........................................................................................................................................................................43
2.10.1 Introduction ...............................................................................................................................................................43
2.10.2 Interface Overview ..................................................................................................................................................43
2.10.3 Process..........................................................................................................................................................................44
2.10.4 Example Code ............................................................................................................................................................45
2.11 Device Status and Information .........................................................................................................................................46
2.11.1 Introduction ...............................................................................................................................................................46
2.11.2 Interface Overview ..................................................................................................................................................46
2.11.3 Process..........................................................................................................................................................................47
2.11.4 Example Code ............................................................................................................................................................51
3 Interface Definition ..................................................................................................................................... 57
3.1 NetSDK Initialization ...............................................................................................................................................................57
3.1.1 NetSDK Initialization ..................................................................................................................................................57
3.1.2 NetSDK Cleanup ..........................................................................................................................................................57
3.1.3 Auto Reconnection Setting.....................................................................................................................................57
3.1.4 Network Parameter Setting ....................................................................................................................................58
3.2 Device Login ..............................................................................................................................................................................58
3.2.1 Login ................................................................................................................................................................................58
3.2.2 Logout .............................................................................................................................................................................59
3.3 Real-time Monitoring .............................................................................................................................................................59
3.3.1 Opening the Real-time Monitoring......................................................................................................................59
3.3.2 Stopping the Real-time Monitoring.....................................................................................................................60
3.3.3 Saving the Real-time Monitoring Data ...............................................................................................................60
3.3.4 Stopping Saving the Real-time Monitoring Data ...........................................................................................60
3.3.5 Setting Callback of Real-time Monitoring Data ...............................................................................................61
3.4 Record Playback .......................................................................................................................................................................62
3.4.1 Playback by Time.........................................................................................................................................................62
3.4.2 Setting the Work Mode .............................................................................................................................................62
3.4.3 Stopping Playback ......................................................................................................................................................63
3.4.4 Getting the OSD Playback Time ............................................................................................................................63
3.5 Record Download ....................................................................................................................................................................64
3.5.1 Querying Record Files within a Period ................................................................................................................64
3.5.2 Opening the Record Query Handle .....................................................................................................................65
3.5.3 Finding the Record File .............................................................................................................................................65
3.5.4 Closing the Record Query Handle ........................................................................................................................66
3.5.5 Downloading Record by File ..................................................................................................................................66
3.5.6 Downloading Record by Time................................................................................................................................67
3.5.7 Querying the record downloading progress ....................................................................................................68
3.5.8 Stopping Record Downloading .............................................................................................................................68
V
3.6 PTZ Control .................................................................................................................................................................................69
3.6.1 PTZ Control....................................................................................................................................................................69
3.7 Voice Talk .....................................................................................................................................................................................72
3.7.1 Opening Voice Talk .....................................................................................................................................................72
3.7.2 Stopping Voice Talk ....................................................................................................................................................72
3.7.3 Starting Local Recording ..........................................................................................................................................73
3.7.4 Stopping Local Recording .......................................................................................................................................73
3.7.5 Talk Data Sending .......................................................................................................................................................74
3.7.6 Audio Decoding ..........................................................................................................................................................74
3.8 Video Snapshot .........................................................................................................................................................................75
3.8.1 Capturing Picture to File...........................................................................................................................................75
3.8.2 Capturing Picture ........................................................................................................................................................75
3.9 Intelligent Event .......................................................................................................................................................................76
3.9.1 Subscribing Intelligent Event .................................................................................................................................76
3.9.2 Unsubscribing Smart .................................................................................................................................................76
3.10 Alarm Upload ..........................................................................................................................................................................77
3.10.1 Setting Alarm Callback ...........................................................................................................................................77
3.10.2 Subscribing to Alarm ..............................................................................................................................................77
3.10.3 Stopping Alarm Subscription ..............................................................................................................................77
3.11 Device Status and Information .........................................................................................................................................78
3.11.1 Querying Device State............................................................................................................................................78
3.11.2 Querying Device Information ..............................................................................................................................78
3.11.3 Subscribing to State of Remote Device ...........................................................................................................79
3.11.4 Stopping Subscribing State of Remote Device .............................................................................................79
3.11.5 Getting Information of Remote Device............................................................................................................79
3.11.6 Getting Channel Name...........................................................................................................................................80
4 Callback Function ........................................................................................................................................ 81
4.1 fDisConnectCallBack ...............................................................................................................................................................81
4.2 fHaveReConnectCallBack ......................................................................................................................................................81
4.3 fRealDataCallBackEx................................................................................................................................................................81
4.4 fAudioDataCallBack.................................................................................................................................................................82
4.5 fDownLoadPosCallBack .........................................................................................................................................................83
4.6 fDataCallBack .............................................................................................................................................................................83
4.7 fTimeDownLoadPosCallBack ...............................................................................................................................................83
4.8 fMessCallBackEx .......................................................................................................................................................................84
4.9 fCameraStateCallBack ............................................................................................................................................................85
4.10 fAnalyzerDataCallBack .........................................................................................................................................................86
Appendix 1 Cybersecurity Recommendations ............................................................................................. 87
VI
1 Overview
1.1 General
The manual introduces NetSDK interfaces reference information that includes main function
modules, interface functions, and callback functions.
The following are the main functions:
NetSDK initialization, device login, real-time monitoring, record playback, record download, PTZ
control, voice talk, video snapshot, IVS, alarm upload, and storage.
For the files included in NetSDK library of C#, see Table 1-1.
1
Support to directly reference the encapsulation project in your own project, use the files of
encapsulation project in your own project, or encapsulate by yourself referring to this
encapsulation project.
This manual mainly introduces the C# project which is used to encapsulate the interfaces of the
C library. For more details, see the manuals of C NetSDK library:
https://www.dahuasecurity.com/support/downloadCenter/softwares?id=2&child=3.
1.2 Applicability
Recommended memory: No less than 512 M
System supported by NetSDK:
Windows 10/Windows 8.1/Windows 7/vista and Windows Server 2008/2003
2
2 Function Modules
2.1.1 Introduction
Initialization is the first step of NetSDK to conduct all the function modules. NetSDK does not have
the surveillance function but can set some parameters that affect the NetSDK overall functions.
Initialization occupies some memory.
Only the first initialization is valid within one process.
After using this function, call cleanup interface to release NetSDK resource.
2.1.3 Process
Figure 2-1 Initialization process
Begin
Initialize SDK
NETClient.Init
Mandatory
End
Optional
3
Process Description
//Achieve to delegate
m_DisConnectCallBack = new fDisConnectCallBack(DisConnectCallBack);
m_ReConnectCallBack = new fHaveReConnectCallBack(ReConnectCallBack);
4
//Set network parameters
NET_PARAM param = new NET_PARAM()
{
nWaittime = 10000,// Timeout of waiting (ms)
nConnectTime = 5000,// Timeout of connection (ms)
};
NETClient.SetNetworkParam(param);
2.2.1 Introduction
Device login, also called user authentication, is the precondition of all the other function modules.
You can obtain a unique login ID upon logging in to the device and should call login ID before using
other NetSDK interfaces. The login ID becomes invalid once logged out.
5
2.2.3 Process
Figure 2-2 Log process
Begin
Initialize SDK
NETClient.Init
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 login 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
6
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 of lougout. For example, if you opened the monitoring function,
you should call the interface that stops the monitoring function when it is no longer required.
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 NETClient.GetLastError.
After reconnection, the original login ID will be invalid. After the device is reconnected, the login
ID will take effect again.
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.
7
NetSDK can get the main stream and sub stream from the device once it logged.
Supports calling the window handle for NetSDK to directly decode and play the stream
(Windows system only).
Supports calling the real-time stream to you for independent treatment.
Supports saving the real-time record to the specific file though saving the callback stream or
calling the NetSDK interface.
2.3.3 Process
You can realize the real-time monitoring through NetSDK decoding library or your play library.
Call PlaySDK library from the NetSDK auxiliary library to realize real-time play.
8
Figure 2-3 Process of playing by NetSDK decoding library
Begin
Initialize SDK
NETClient.Init
End
Mandotory Optional
Process Description
NetSDK decoding play only supports Windows system. You need to call the decoding after
getting the stream in other systems.
9
In step 6, make sure that the parameter hWnd of NETClient.RealPlay introduces the valid
window handle, when you want to perform the corresponding operations in the callback
function of NETClient.SetRealDataCallBack,
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 NETClient.Init.
NET_PARAM param = new NET_PARAM()
{
nGetConnInfoTime = 5000,//Timeout of getting connection information (ms)
};
NETClient.SetNetworkParam(param);
Failed to repeat opening: For some models, the same channel cannot be opened for multiple
times during a login. 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: NetSDK 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
and Table 1-2.
NetSDK calls back the real-time monitoring stream to you and you call PlaySDK to decode and play.
10
Figure 2-4 Process of calling the third party play library
Begin
Initialize SDK
NETClient.Init
Logout
NETClient.Logout
End
Process Description
11
When using PlaySDK for decoding, there is a default channel buffer size (the
PLAY_OpenStream interface in playsdk) for decoding. If the stream resolution value is big, it
is recommended to modify the parameter value smaller such as 3 M.
NetSDK callbacks can only moves into the next process after returning from you. It is not
recommended for you to consume time for the unnecessary operations; otherwise the
performance could be affected.
// Take opening the main stream monitoring of channel 1 as an example. The parameter hWnd is a window
handle.
IntPtr m_RealPlayID = NETClient.RealPlay(m_LoginID, 0, hWnd, EM_RealPlayType.Realplay);
if (IntPtr.Zero == m_RealPlayID)
{
MessageBox.Show(this, NETClient.GetLastError());
return;
}
// Stop monitoring
bool ret = NETClient.StopRealPlay(m_RealPlayID);
if (!ret)
{
MessageBox.Show(this, NETClient.GetLastError());
return;
}
m_RealPlayID = IntPtr.Zero;
12
m_RealDataCallBackEx2 = new fRealDataCallBackEx2(RealDataCallBackEx);
NETClient.SetRealDataCallBack(m_RealPlayID, m_RealDataCallBackEx2, IntPtr.Zero,
EM_REALDATA_FLAG.DATA_WITH_FRAME_INFO | EM_REALDATA_FLAG.PCM_AUDIO_DATA |
EM_REALDATA_FLAG.RAW_DATA | EM_REALDATA_FLAG.YUV_DATA);
private void RealDataCallBackEx(IntPtr lRealHandle, uint dwDataType, IntPtr pBuffer, uint dwBufSize, IntPtr
param, IntPtr dwUser)
{
//Call PlaySDK interface to get the stream data from the device. See NetSDK monitoring demo source data
for more details.
//Do some operations such as save data, send data, or change data to YUV.
EM_REALDATA_FLAG type = (EM_REALDATA_FLAG)dwDataType;
switch (type)
{
case EM_REALDATA_FLAG.RAW_DATA:
//Process operation
break;
}
}
// Stop monitoring
bool ret = NETClient.StopRealPlay(m_RealPlayID);
if (!ret)
{
MessageBox.Show(this, NETClient.GetLastError());
return;
}
m_RealPlayID = IntPtr.Zero;
2.4.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.
13
2.4.2 Interface Overview
Table 2-4 Interfaces of record playback
Interface Implication
Set the work mode such as voice talk, playback and
NETClient.SetDeviceMode
authority.
NETClient.PlayBackByTime Playback by time.
Stop, fast forward, slow forward, pause, or resume
NETClient.PlayBackControl
record playback.
NETClient.GetPlayBackOsdTime Get the playback OSD time.
2.4.3 Process
After NetSDK initialization, you need to enter channel number, start time, stop time, and valid
window handle to realize the playback of the required record.
14
Figure 2-5 Process of record playback
Begin
Initialize SDK
NETClient.Init
Optional
End
Process Description
15
Step 2 Call NETClient.LoginWithHighLevelSecurity to log in to the device.
Step 3 (Optional) Call NETClient.SetDeviceMode twice and set the stream type parameter emType
as EM_USEDEV_MODE.RECORD_STREAM_TYPE, and parameter pValue as
EM_STREAM_TYPE.MAIN.
Step 4 Call NETClient.PlayBackByTime to start playback. The parameter hWnd is a valid window
handle value.
Step 5 (Optional) Call NETClient.PlayBackControl. The playback will pause when the second
parameter is PlayBackType.Pause.
Step 6 (Optional) Call NETClient.PlayBackControl. The playback will resume when the second
parameter is PlayBackType.Play.
Step 7 After playback, call NETClient.PlayBackControl. The playback will stop when the second
parameter is PlayBackType.Stop.
Step 8 After using the function module, call NETClient.Logout to log out of the device.
Step 9 After using all NetSDK functions, call NETClient.Cleanup to release NetSDK resource.
16
// Pause playback
bool ret = NETClient.PlayBackControl(m_PlayBackID, PlayBackType. Pause);
if (!ret)
{
MessageBox.Show(NETClient.GetLastError());
return;
}
// Resume playback
bool ret = NETClient.PlayBackControl(m_PlayBackID, PlayBackType.Play);
if (!ret)
{
MessageBox.Show(NETClient.GetLastError());
return;
}
// Stop playback
if (IntPtr.Zero != m_PlayBackID)
{
NETClient.PlayBackControl(m_PlayBackID, PlayBackType.Stop);
m_PlayBackID = IntPtr.Zero;
}
2.5.1 Introduction
Video surveillance system widely applies to safe city, airport, metro, bank and factory. When and
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 NetSDK
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. The downloaded records are in the private format of Dahua. They can
only be played with Dahua player or integrated Dahua playsdk.
17
2.5.2 Interface Overview
Table 2-5 Interfaces of record download
Interface Implication
Set the work modes such as voice talk, playback, and
NETClient.SetDeviceMode
authority.
NETClient.QueryRecordFile Query all the record files within a period.
NETClient.FindFile Open the record query handle.
NETClient.FindNextFile Find the record file.
NETClient.FindClose Close the record query handle.
NETClient.DownloadByRecordFile Download the record by file.
NETClient.DownloadByTime Download the record by time.
NETClient.GetDownloadPos Get the record download progress.
NETClient.StopDownload Stop the record download.
2.5.3 Process
The record download is consisted of download by file and download by time.
You need to import the record file information to be downloaded. NetSDK can download the
specified record file and save to the required place.
You can also provide a callback pointer to NetSDK that calls back the specified record file to you for
treatment.
18
Figure 2-6 Process of download by file
Begin
Initialize SDK
NETClient.Init
Download by file
NETClient.DownloadByRecordFile
Mandotary
Stop download
NETClient.StopDownload Optional
End
Process Description
19
Step 3 Call NETClient.SetDeviceMode twice and set the stream type parameter emType as
EM_USEDEV_MODE.RECORD_STREAM_TYPE, and parameter pValue as
EM_STREAM_TYPE.MAIN.
Step 4 Query the record files by one of the following two ways:
Call NETClient.FindFile to obtain the record query handle, and then call
NETClient.FindNextFile several times to obtain the record file information and then
call NETClient.FindClose to close the record query handle at last.
Call NETClient.QueryRecordFile to obtain all the record files information for a period
one time.
Step 5 After getting the record file information, call NETClient.DownloadByRecordFile to start
downloading record files. You can decide whether to use cbDownLoadPos to query the
record downloading progress in real time, if not, set it as NULL.
Step 6 (Optional) During downloading, call NETClient.GetDownloadPos to query the record
downloading progress or use cbDownLoadPos mentioned in step 5 to obtain the real-time
download progress.
Step 7 Call NETClient.StopDownload to stop download.
Step 8 After using the function module, call NETClient.Logout to log out of the device.
Step 9 After using all NetSDK functions, call NETClient.Cleanup to release NetSDK resource.
You can import the start time and end time of download. NetSDK can download the specified record
file and save to the required place.
You can also provide a callback pointer to NetSDK which calls back the specified record file to you for
treatment.
20
Figure 2-7 Process of download by time
Begin
Initialize SDK
NETClient.Init
Download by time
NETClient.DownloadByTime
Stop download
NETClient.StopDownload
End
Process Description
21
Step 5 (Optional) During downloading, call NETClient.GetDownloadPos to query the record
downloading progress or use cbDownLoadPos mentioned in step 4 to obtain the real-time
download progress.
Step 6 Call NETClient_StopDownload to stop download. You can close the download process
after it is completed or it is just partially completed.
Step 7 After using the function module, call NETClient_Logout to log out of the device.
Step 8 After using all NetSDK functions, call NETClient_Cleanup to release NetSDK resource.
// Set the stream type of playback. Here is to set as the main stream.
EM_STREAM_TYPE streamType = EM_STREAM_TYPE.MAIN;
IntPtr pStream = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
Marshal.StructureToPtr((int)streamType, pStream, true);
NETClient.SetDeviceMode(m_LoginID, EM_USEDEV_MODE.RECORD_STREAM_TYPE, pStream);
// There are two ways of record query: 1. Get all the record files of a certain period one time; 2. Get all the
record files of a certain period by several times.
// Way 1: Get all the record files of a certain period one time
int nChannelID = 0; // Channel ID
int fileCount = 0;
NET_RECORDFILE_INFO[] recordFileArray = new NET_RECORDFILE_INFO[5000];
bool ret = NETClient.QueryRecordFile(m_LoginID, nChannelId, EM_QUERY_RECORD_TYPE.ALL, startTime,
endTime, null, ref recordFileArray, ref fileCount, m_WaitTime, false);
if (false == ret)
{
MessageBox.Show(this, NETClient.GetLastError());
return;
}
// Way 2: Get all the record files of a certain period by several times
NET_IN_MEDIA_QUERY_FILE stuCondition = new NET_IN_MEDIA_QUERY_FILE();
stuCondition = (NET_IN_MEDIA_QUERY_FILE)obj;
stuCondition.dwSize = (uint)Marshal.SizeOf(stuCondition);
stuCondition.stuCardInfo.dwSize = (uint)Marshal.SizeOf(stuCondition.stuCardInfo);
stuCondition.nChannelID = 0;// -1 means all channels;
stuCondition.nMediaType = 0;// File type,0:Query any type,1:Query jpg picture
stuCondition.emFalgLists[0] = EM_RECORD_SNAP_FLAG_TYPE.TIMING;
stuCondition.nFalgCount = 1;
22
stuCondition.stuStartTime = NET_TIME.FromDateTime (DateTime.Now.AddDays(-0.99));//
stuCondition.stuEndTime = NET_TIME.FromDateTime(DateTime.Now);
// Step 1: Get record query handle
IntPtr fileHandle = IntPtr.Zero;
IntPtr pQueryCondition = IntPtr.Zero;
try
{
pQueryCondition = Marshal.AllocHGlobal(Marshal.SizeOf(stuCondition));
Marshal.StructureToPtr(stuCondition, pQueryCondition, true);
fileHandle = NETClient.FindFile(m_LoginHandle, EM_FILE_QUERY_TYPE.FILE, (object)stuCondition,
stuCondition.GetType(), 5000);
if (fileHandle == IntPtr.Zero)
{
Console.WriteLine(NETClient.GetLastError());
}
return fileHandle;
}
finally
{
Marshal.FreeHGlobal(pQueryCondition);
}
// Step 2: Get single record file information
int nFilecount = 3;// max file count in one query
int nRetCount = 0;// return count in one query
NET_OUT_MEDIA_QUERY_FILE[] MediaFileInfos = new NET_OUT_MEDIA_QUERY_FILE[nFilecount];
List<object> infoList = new List<object>();
for (int i = 0; i < nFilecount; i++)
{
MediaFileInfos[i].dwSize = (uint)Marshal.SizeOf(MediaFileInfos[i]);
infoList.Add(MediaFileInfos[i]);
}
23
{
Console.WriteLine("find file 0");
return;
}
// Callback declaration
// Playback/download progress callback
// It is not recommended to call NetSDK interface in this callback
// dwDownLoadSize: "-1" that represents current playback/download has completed. "-2" represents
writing file failed. Other values represent valid data.
// Set this callback through NETClient.DownloadByRecordFile. When NetSDK receives playback/download
data, it will call this function.
private static fDownLoadPosCallBack m_DownLoadPosHandle;
m_DownLoadPosHandle = new fDownLoadPosCallBack(DownLoadPosCallBack);
// Record download
// Start record download
// Either sSavedFileName or cbTimeDownLoadPos is valid.
// In the application, save to sSavedFileName or callback to handle the data.
// stuFile is the file information queried before
NET_RECORDFILE_INFO stuRecordFile = new NET_RECORDFILE_INFO();
stuRecordFile.ch = (uint)stuFile.nChannelID;
stuRecordFile.bHint = stuFile.byPartition;
stuRecordFile.nRecordFileType = 255;
stuRecordFile.starttime = stuFile.stuStartTime;
stuRecordFile.endtime = stuFile.stuEndTime;
stuRecordFile.driveno = stuFile.nDriveNo;
stuRecordFile.size = stuFile.nFileSize/1024;
24
stuRecordFile.filename = stuFile.szFilePath;
stuRecordFile.startcluster = stuFile.nCluster;
IntPtr m_DownLoadHandle = NETClient.DownloadByRecordFile(m_LoginHandle, ref stuRecordFile,
storeFile, m_DownLoadPosHandle, IntPtr.Zero);
if (m_DownLoadHandle == IntPtr.Zero)
{
MessageBox.Show(NETClient.GetLastError());
}
// Callback definition
private void DownLoadPosCallBack(IntPtr lPlayHandle, uint dwTotalSize, uint dwDownLoadSize, IntPtr dwUser)
{
if ((int)dwDownLoadSize == -1)
{
Console.WriteLine("download over");
}
else if ((int)dwDownLoadSize == -2)
{
Console.WriteLine("write file error");
}
else
{
value = (int)(dwDownLoadSize * 100 / dwTotalSize);
Console.WriteLine(“Download" + value);
}
}
25
2.5.4.2 Downloading by Time
// Callback declaration
// Playback/download progress callback
// It is not recommended to call NetSDK interface in this callback
// dwDownLoadSize: "-1" represents current playback/download has completed. "-2" represents writing
file failed. Other values represent valid data.
// Set this callback through NETClient. DownloadByTime. When NetSDK receives playback/download data,
it will call this function.
private static fTimeDownLoadPosCallBack m_DownloadPosCallBack;
m_DownloadPosCallBack = new fTimeDownLoadPosCallBack(DownLoadPosCallBack);
// Set the stream type of playback. Here is to set as the main stream.
EM_STREAM_TYPE streamType = EM_STREAM_TYPE.MAIN;
IntPtr pStream = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
Marshal.StructureToPtr((int)streamType, pStream, true);
NETClient.SetDeviceMode(m_LoginID, EM_USEDEV_MODE.RECORD_STREAM_TYPE, pStream);
// Callback definition
26
private void DownLoadPosCallBack(IntPtr lPlayHandle, uint dwTotalSize, uint dwDownLoadSize, int index,
NET_RECORDFILE_INFO recordfileinfo, IntPtr dwUser)
{
if (lPlayHandle == m_DownloadID)
{
int value = 0;
if (-1 == (int)dwDownLoadSize)
{
value = DOWNLOAD_END;
}
else if (-2 == (int)dwDownLoadSize)
{
value = DOWNLOAD_FAILED;
}
else
{
value = (int)(dwDownLoadSize * 100 / dwTotalSize);
Console.WriteLine(“Download" + value);
}
}
2.6.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 NetSDK.
27
2.6.3 Process
Direction control, focus, zoom, and aperture are the continuous operations. NetSDK provides start
and stop interfaces to you for timing control.
Figure 2-8 Process of PTZ control (continuous)
Begin
Initialize SDK
NETClient.Init
End
Both fast positioning and 3-dimensional positioning belong to one-time action, which needs to call
the PTZ control interface just one time.
28
Figure 2-9 Process of PTZ control (one-time)
Begin
Initialize SDK
NETClient.Init
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.
29
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 NetSDK package on the website.
2.7.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 NetSDK to realize the voice talk with the front-end devices.
30
2.7.2 Interface Overview
Table 2-7 Interfaces of voice talk
Interface Implication
NETClient.StartTalk Start voice talk.
NETClient.StopTalk Stop voice talk.
NETClient.RecordStart Start NETClient record (valid only in Windows system).
NETClient.RecordStop Stop NETClient record (valid only in Windows system).
NETClient.TalkSendData Send voice data to the device.
NETClient.AudioDec Decode audio data (valid only in Windows system).
2.7.3 Process
When NetSDK has collected the audio data from the local audio card, or NetSDK has received the
audio data from the front-end devices, NetSDK will call the callback of audio data.
You can call the NetSDK interface in the callback parameters to send the local audio data to the
front-end devices, or call NetSDK interface to decode and playback the audio data received from the
front-end devices.
This process is valid only in Windows system.
31
Figure 2-10 Process of voice talk
Begin
Initialize SDK
NETClient.Init
Stop recording on PC
NETClient.RecordStop
Decode audio data of
Send audio data to device
device
NETClient.TalkSendData
NETClient.AudioDec
Stop voice talk
NETClient.StopTalk
End
Process Description
32
Step 4 Call NETClient.SetDeviceMode to set mode of voice talk. Set parameter emType as
EM_USEDEV_MODE.TALK_SPEAK_PARAM.
Step 5 Call NETClient.SetDeviceMode to set callback and start voice talk. In the callback, call
NETClient.AudioDec to decode the audio data sent from the decoding device, and call
NETClient.TalkSendData to send the audio data of the PC end to the device.
Step 6 Call NETClient.RecordStart to start recording at PC. After this interface is called, the voice
talk callback in NETClient.StartTalk will receive the local audio data.
Step 7 After using the voice talk function, call NETClient.RecordStop to stop recording.
Step 8 Call NETClient.StopTalk to stop voice talk.
Step 9 After using the function module, call NETClient.Logout to log out of the device.
Step 10 After using all NetSDK functions, call NETClient.Cleanup to release NetSDK resource.
Voice encoding format: The example uses the common PCM format. NetSDK supports accessing
the voice encoding format supported by the device. For more details of the example code, see
the NetSDK package on the website. 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 NETClient.RecordStart succeeded in returning.
33
talkSpeakPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SPEAK_PARAM)));
Marshal.StructureToPtr(speak, talkSpeakPointer, true);
NETClient.SetDeviceMode(m_LoginID, EM_USEDEV_MODE.TALK_SPEAK_PARAM, talkSpeakPointer);
34
}
}
DHDEV_TALKDECODE_INFO curTalkMode;
curTalkMode.encodeType = DH_TALK_PCM;
curTalkMode.nAudioBit = 16;
curTalkMode.dwSampleRate = 8000;
curTalkMode.nPacketPeriod = 25;
NETClient.SetDeviceMode(lLoginHandle, DH_TALK_ENCODE_TYPE, &curTalkMode);
// Start voice talk
lTalkHandle = NETClient.StartTalk(lLoginHandle, AudioDataCallBack, (DWORD)NULL);
if(0 != lTalkHandle)
{
BOOL bSuccess = NETClient.RecordStart(lLoginHandle);
}
35
if (0 != lTalkHandle)
{
NETClient.StopTalk(lTalkHandle);
}
void CALLBACK AudioDataCallBack(LLONG lTalkHandle, char *pDataBuf, DWORD dwBufSize, BYTE byAudioFlag,
DWORD dwUser)
{
if(0 == byAudioFlag)
{
// Send the sound data checked by the PC to the device
LONG lSendLen = NETClient.TalkSendData(lTalkHandle, pDataBuf, dwBufSize);
if(lSendLen != (LONG)dwBufSize)
{
printf("NETClient.TalkSendData Failed!Last Error[%x]\n" , CLIENT_GetLastError());
}
}
else if(1 == byAudioFlag)
{
// Send the voice data of the device to NetSDK encode and play.
NETClient.AudioDec(pDataBuf, dwBufSize);
}
}
2.8.1 Introduction
Video snapshot obtains the picture data of the current video. This section introduces the following
two snapshot ways:
Network snapshot: Call the NetSDK interface to send the capturing command to the device that
captures the current image and send to NetSDK through network, and then NetSDK returns the
image data to you.
Local snapshot: When the monitoring is opened, you can save the monitoring data to the
picture format that is the frame information that does not have an interaction with the device.
36
Interface Implication
handle or playback handle.
2.8.3 Process
Video snapshot is consisted of network snapshot and local snapshot.
Begin
Initialize SDK
NETClient.Init
End
Process Description
Multi-thread calling: Multi-thread calling is not supported for the functions within the same
login session.
37
Snapshot configuration: You can configure the items such as quality and definition for the
snapshot. However, it is not recommended to modify if the default configurations are
satisfactory.
Picture save: The picture data is returned as memory and the interface supports saving the
picture data as file (the precondition is that you have set the szFilePath field of
NET_IN_SNAP_PIC_TO_FILE_PARAM).
Begin
Initialize SDK
NETClient.Init
End
38
Process Description
// Example of local capturing, and m_RealPlayID is the handle for opening monitoring.
string filePath = path + "\\" + "client" + m_SnapSerialNum.ToString() + ".jpg";
bool result = NETClient.CapturePicture(m_RealPlayID, filePath, EM_NET_CAPTURE_FORMATS.JPEG);
39
if (!result)
{
MessageBox.Show(this, NETClient.GetLastError());
return;
}
2.9.1 Introduction
Smart event upload is that smart devices analyze real-time streams. When finding the events which
have been set in advance, the events will be sent to users. Smart events correspond to
EM_EVENT_IVS_TYPE enumeration. For details, see the value of enumeration.
NetSDK connects to the device and subscribes to smart event function. When the device gets the
smart events, they will be sent to NetSDK.
40
2.9.3 Process
Figure 2-13 Process of smart event upload
Begin
Initialize SDK
NETClient.Init
End
Process Description
41
Notes for Process
Event type: Subscribe to all smart events (EM_EVENT_IVS_TYPE.ALL) if different smart events
need to be uploaded. Also support to subscribe to a single smart event.
Image receiving or not: The network environment of some devices is 3G or 4G. When the
NetSDK is connected to the device, set bNeedPicFile parameter in the
NETClient.RealLoadPicture to false if images are bot needed. Then only receive information
about smart traffic event, without images.
Pass the channel number -1 for full channel subscription. Some intelligent transportation
products do not support full-channel subscription. If the -1 subscription fails, try a
single-channel subscription.
In the case of multi-device subscription, there are two main ways to distinguish which event is
reported by one device.
Establish the mapping relationship between the device IP, login handle, and subscription
handle. Locate the login handle through the subscription handle returned by the callback
function, and then find the device IP;
Use dwUser in the callback function. The dwUser passed in by the subscription function will
be returned in the callback function, thereby locating which device subscribes the event
that triggered the callback.
42
{
switch ((EM_EVENT_IVS_TYPE)dwAlarmType)
{
// Event of crowd density detection
case EM_EVENT_IVS_TYPE.CROWDDETECTION:
{
NET_DEV_EVENT_CROWD_DETECTION_INFO info =
(NET_DEV_EVENT_CROWD_DETECTION_INFO)Marshal.PtrToStructure(pAlarmInfo,
typeof(NET_DEV_EVENT_CROWD_DETECTION_INFO));
this.BeginInvoke(new Action(() =>
{
Console.WriteLine("Event: Crowd density detection;");
Console.WriteLine("Channel number: " + info.nChannelID + ";");
Console.WriteLine("Time: " + info.UTC.ToString() + ";");
/* ·········
**Other operations of event information **
·······*/
}));
}
break;
default:
break;
}
return 0;
}
2.10.1 Introduction
Alarm upload can be realized through NetSDK login the device and subscription of the alarm
function to the device which will send the detected alarm event to NetSDK. The alarm information
can be obtained through callback.
43
Interface Implication
NETClient.StopListen Stop subscribing to alarm.
2.10.3 Process
Figure 2-14 Process of alarm upload
Begin
Initialize SDK
NETClient.Init
End
Process Description
44
Step 4 Call NETClient.StartListen to subscribe to alarm to the device. If succeeded, the alarm
event uploaded by the device will be informed to you through the callback set by
NETClient.SetDVRMessCallBack.
Step 5 After using the alarm upload function, call NETClient.StopListen to stop subscribing alarm
to the device.
Step 6 After using the function module, call NETClient.Logout to log out of the device.
Step 7 After using all NetSDK functions, call NETClient.Cleanup to release NetSDK resource.
45
// Customize
}
break;
default:
Console.WriteLine(lCommand.ToString("X"));
break;
}
return true;
}
// Subscribe to alarm
bool ret = NETClient.StartListen(m_LoginID);
if (!ret)
{
MessageBox.Show(this, NETClient.GetLastError());
return;
}
// Stop alarm subscription
bool ret = NETClient.StopListen(m_LoginID);
if (!ret)
{
MessageBox.Show(this, NETClient.GetLastError());
return;
}
2.11.1 Introduction
The storage interface mainly includes access to remote device information, query subscription on
connection state of remote device, and modification of remote channel name.
46
Interface Implication
channels at the same time.
Set the parameter nQueryType as
EM_QUERY_DEV_INFO.GET_CAMERA_STATE.
Subscribe to the remote device state.
NETClient.AttachCameraState When the state changes, the corresponding information will be
reported.
Stop subscribing the remote device state.
NETClient.DetachCameraState
Used with NETClient.AttachCameraState in match.
Get the information of remote device, such as device type and
NETClient.MatrixGetCameras
IP.
Get the channel name.
NETClient.GetNewDevConfig
Set the parameter strCommand as ChannelTitle.
2.11.3 Process
The storage module has the following processes:
Direct access to connection state of remote device
Subscription to connection state of remote device
Access to the information of remote device
Access to channel name of remote device
47
2.11.3.1 Direct Access to Connection State of Remote Device
Begin
Initialize SDK
NETClient.Init
End
Process Description
The two interfaces are different depending on the device. It is suggested to have a test prior
to use, and then select the proper interface.
Step 4 After using the function module, call NETClient.Logout to log out of the device.
Step 5 After using all NetSDK functions, call NETClient.Cleanup to release NetSDK resource.
48
2.11.3.2 Subscription to Connection State of Remote Device
For the process of subscription to connection state of remote device, see Figure 2-16.
Figure 2-16 Process of subscription to connection state of remote device
Begin
Initialize SDK
NETClient.Init
End
Process Description
49
2.11.3.3 Access to the Information of Remote Device
Begin
Initialize SDK
NETClient.Init
End
Process Description
50
2.11.3.4 Access to channel name of remote device
Begin
Initialize SDK
NETClient.Init
End
Process Description
51
NET_VIRTUALCAMERA_STATE_INFO info = new NET_VIRTUALCAMERA_STATE_INFO()
{
nStructSize = (uint)Marshal.SizeOf(typeof(NET_VIRTUALCAMERA_STATE_INFO)),
};
for (int i = 0; i < device.nChanNum; ++i)
{
info.nChannelID = i;
object obj = (object)info;
result = NETClient.QueryDevState(lLoginID, EM_DEVICE_STATE.VIRTUALCAMERA, ref obj, typeof(NET_VIRT
UALCAMERA_STATE_INFO), 3000);
if (result)
{
info = (NET_VIRTUALCAMERA_STATE_INFO)obj;
Console.WriteLine("QueryDevState_ChannelState channel:{0}, state: {1}", info.nChannelID, info.emCo
nnectState.ToString());
}
else
{
Console.WriteLine("QueryDevState_ChannelState fail, {0}", NETClient.GetLastError());
}
}
inParam.dwSize = (uint)Marshal.SizeOf(typeof(NET_IN_GET_CAMERA_STATEINFO));
inParam.bGetAllFlag = true;
outParam.dwSize = (uint)Marshal.SizeOf(typeof(NET_OUT_GET_CAMERA_STATEINFO));
outParam.nMaxNum = DeviceInfo.nChanNum;// Total channel number
outParam.pCameraStateInfo = Marshal.AllocHGlobal(outParam.nMaxNum *
Marshal.SizeOf(typeof(NET_CAMERA_STATE_INFO)));
inPtr = Marshal.AllocHGlobal((int)inParam.dwSize);
Marshal.StructureToPtr(inParam, inPtr, true);
outPtr = Marshal.AllocHGlobal((int)outParam.dwSize);
Marshal.StructureToPtr(outParam, outPtr, true);
52
bool res = NETClient.QueryDevInfo(m_LoginID, EM_QUERY_DEV_INFO.GET_CAMERA_STATE, inPtr, outPtr,
3000);
if (!res)
{
MessageBox.Show(NETClient.GetLastError());
return;
}
outParam = (NET_OUT_GET_CAMERA_STATEINFO)Marshal.PtrToStructure(outPtr,
typeof(NET_OUT_GET_CAMERA_STATEINFO));
if (outParam.nValidNum > 0)
{
var status = new NET_CAMERA_STATE_INFO[outParam.nValidNum];
for (int i = 0; i < outParam.nValidNum; i++)
{
status[i] = (NET_CAMERA_STATE_INFO)Marshal.PtrToStructure(outParam.pCameraStateInfo + i *
Marshal.SizeOf(typeof(NET_CAMERA_STATE_INFO)), typeof(NET_CAMERA_STATE_INFO));
}
}
// Callback declaration of remote device state. Any change in state will return through this callback.
private static fCameraStateCallBack cameraStateCallBack = new fCameraStateCallBack(CameraStateCallBack);
53
};
54
2.11.4.3 Access to Information of Remote Device
// Access to information of remote device. This demo obtains the information of online remotedevices. You
have to call NETClient.QueryDevInfo at first, to get the online device number and device channel. And then call
NETClient.MatrixGetCameras, to get remote device information of the corresponding channel.
// nChanNum Channel number
NET_MATRIX_CAMERA_INFO[] infos = new NET_MATRIX_CAMERA_INFO[nChanNum];
NET_CAMERA_STATE_INFO[] status = new NET_CAMERA_STATE_INFO[nChanNum];
for (int i = 0; i < nChanNum; i++)
{
infos[i].dwSize = (uint)Marshal.SizeOf(typeof(NET_MATRIX_CAMERA_INFO));
}
bool ret = NETClient.MatrixGetCameras(m_LoginID, out infos, nChanNum, 5000);
if(!ret)
{
MessageBox.Show(NETClient.GetLastError());
return;
}
for (int i = 0; i < nChanNum; i++)
{
Console.WriteLine(string.Format("Channel{0}device name:{1}", i, infos[i].stuRemoteDevice.szDevType));
Console.WriteLine(string.Format("Channel{0}device name:{1}", i, infos[i].stuRemoteDevice.szDevName));
}
55
}
for (int i = 0; i < infos.Length; i++)
{
infos[i] = (AV_CFG_ChannelName)objs[i];
Console.WriteLine(infos[i].szName);
}
56
3 Interface Definition
57
Item Description
[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.
3.2.1 Login
Item Description
Name Log in to the device.
IntPtr LoginWithHighLevelSecurity(
string pchDVRIP,
ushort wDVRPort,
string pchUserName,
Function string pchPassword,
EM_LOGIN_SPAC_CAP_TYPE emSpecCap,
IntPtr pCapParam,
ref NET_DEVICEINFO_Ex deviceInfo
);
[in] pchDVRIP Device IP.
[in] wDVRPort Device port.
[in] pchUserName User name.
Parameter [in] pchPassword Password.
[in] emSpecCap Login category.
[in] pCapParam Login category parameter.
[out] deviceInfo Device information.
Success: Returns a non-zero value.
Return value
Failure: 0.
Note None.
58
3.2.2 Logout
Item Description
Name Log out of the device.
bool Logout(
Function IntPtr lLoginID
);
Parameter [in] lLoginID Return value of NETClient.LoginWithHighLevelSecurity.
Success: true
Return value
Failure: false.
Note None.
59
Live Type Meaning
DH_RType_Realplay_2 Real-time monitoring—sub stream 2.
DH_RType_Realplay_3 Real-time monitoring—sub stream 3.
DH_RType_Multiplay_1 Multi-picture live—1 picture.
DH_RType_Multiplay_4 Multi-picture live—4 pictures.
DH_RType_Multiplay_8 Multi-picture live—8 pictures.
DH_RType_Multiplay_9 Multi-picture live—9 pictures.
DH_RType_Multiplay_16 Multi-picture live—16 pictures.
DH_RType_Multiplay_6 Multi-picture live—6 pictures.
DH_RType_Multiplay_12 Multi-picture live—12 pictures.
DH_RType_Multiplay_25 Multi-picture live—25 pictures.
DH_RType_Multiplay_36 Multi-picture live—36 pictures.
60
Item Description
bool StopSaveRealData(
Function IntPtr lRealHandle
);
Parameter [in] lRealHandle Return value of NETClient.RealPlay.
Success: true
Return value
Failure: false.
Note None.
61
3.4 Record Playback
62
emType Enumeration Meaning Structure
0: Main and sub stream
1: Main stream
2: Sub stream
Set the record file type to playback
RECORD_TYPE EM_RECORD_TYPE
and download by time.
63
PlayBackType enumeration Meaning
Normal Normal play
64
EM_QUERY_RECORD_TYPE
Record File Type Card ID
Enumeration
ALARM External alarm NULL
Alarm by dynamical
MOTION_DETECT NULL
detection
ALARM_ALL All the alarms NULL
CARD Card IP query Card ID
Card ID && Transaction type &&
Combined conditions
CONDITION Transaction amount (If you want to
query
skip a field, set as blank)
Record location and
JOIN NULL
deviation length
Pictures queried by card ID
CARD_PICTURE (Only supported by some Card ID
models of HB-U and NVS)
Query pictures (Only
PICTURE supported by some NULL
models of HB-U and NVS)
FELD1&&FELD2&&FELD3&& (If you
FIELD Query by field
want to skip a field, set as blank)
65
Item Description
int FindNextFile(
IntPtr lFindHandle,
int nFilecount,
Function List<object> lsOMediaFileInfo,
Type tyFile ,
int waittime
);
Return value of NETClient.FindFile (open the record query
[in] lFindHandle
handle).
[in] nFilecount Number of the found files.
Parameter
[out] lsOMediaFileInfo Information of the found files.
[in] tyFile Information type of the found files.
[in] waittime Query timeout. The unit is millisecond.
Return value Number of the found file information.
Note Before calling this interface, call NETClient.FindFile to open the query handle.
66
Item Description
[in] cbDownLoadPos Download progress callback.
[in] dwUserData Download progress callback customized data.
Success: Returns a non-zero value.
Return value
Failure: 0.
For callback declaration of fDownLoadPosCallBack, see "Chapter 4 Callback ."
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 function.
67
Item Description
For callback declaration of fDataCallBack and fDownLoadPosCallBack, see
"Chapter 4 Callback ."
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.
68
3.6 PTZ Control
69
Table 3-6 Relationship between command and parameters
EM_EXTPTZ_ControlType
Function param1 param2 param3
Enumeration
Vertical speed
UP_CONTROL Up None None
(1–8)
Vertical speed
DOWN_CONTROL Down None None
(1–8)
Horizontal
LEFT_CONTROL Left None None
speed (1–8)
Horizontal
RIGHT_CONTROL Right None None
speed (1–8)
ZOOM_ADD_CONTROL Zoom+ None Multi-speed None
ZOOM_DEC_CONTROL Zoom- None Multi-speed None
FOCUS_ADD_CONTROL Focus+ None Multi-speed None
FOCUS_DEC_CONTROL Focus- None Multi-speed None
APERTURE_ADD_CONTROL Aperture+ None Multi-speed None
APERTURE_DEC_CONTROL Aperture - None Multi-speed None
Value of
POINT_MOVE_CONTROL Move to preset None None
preset
Value of
POINT_SET_CONTROL Set None None
preset
Value of
POINT_DEL_CONTROL Delete None None
preset
76: On
Cruise among
POINT_LOOP_CONTROL Cruise route None 99: Auto
presets
96: Off
0x01: On x00:
LAMP_CONTROL Lamp wiper None None
Off
Vertical speed Horizontal
LEFTTOP Left top None
(1–8) speed (1–8)
Vertical speed Horizontal
RIGHTTOP Right top None
(1–8) speed (1–8)
Vertical speed Horizontal
LEFTDOWN Left bottom None
(1–8) speed (1–8)
Vertical speed Horizontal
RIGHTDOWN Right bottom None
(1–8) speed (1–8)
Add preset to Value of
ADDTOLOOP Cruise route None
cruise preset
Delete preset Value of
DELFROMLOOP Cruise route None
point in cruise preset
CLOSELOOP Delete cruise Cruise route None None
Start horizontal
STARTPANCRUISE None None None
rotation
Stop horizontal
STOPPANCRUISE None None None
rotation
SETLEFTBORDER Set left border None None None
70
EM_EXTPTZ_ControlType
Function param1 param2 param3
Enumeration
SETRIGHTBORDER Set right border None None None
STARTLINESCAN Start line scan None None None
CLOSELINESCAN Stop line scan None None None
SETMODESTART Set mode start Mode route None None
SETMODESTOP Set mode stop Mode route None None
RUNMODE Running mode Mode route None None
STOPMODE Stop mode Mode route None None
DELETEMODE Delete mode Mode route None None
Reverse
REVERSECOMM None None None
command
Horizontal Vertical
Fast
FASTGOTO coordinate (0– coordinate Zoom (4)
positioning
8192) (0–8192)
Open auxiliary
AUXIOPEN Auxiliary point None None
switch
Close auxiliary
AUXICLOSE Auxiliary point None None
switch
OPENMENU Open menu None None None
CLOSEMENU Close menu None None None
MENUOK Menu confirm None None None
MENUCANCEL Menu cancel None None None
MENUUP Menu up None None None
MENUDOWN Menu down None None None
MENULEFT Menu left None None None
MENURIGHT Menu right None None None
Alarm action
Linkage
type:
Alarm action Alarm input value, such as
ALARMHANDLE Preset
with PTZ channel preset
Line scan
number
Cruise
Monitor device
Video input Matrix
MATRIXSWITCH Matrix switch number (video
number number
output number)
Refer to
LIGHTCONTROL Light controller DH_PTZ_LAMP None None
_CONTROL
Vertical
Horizontal
EXACTGOTO 3D positioning coordinate Zoom (1–128)
angle (0–3600)
(0–900)
RESETZERO Reset to zero None None None
UP_TELE Up +TELE Speed (1–8) None None
DOWN_TELE Down +TELE Speed (1–8) None None
LEFT_TELE Left +TELE Speed (1–8) None None
71
EM_EXTPTZ_ControlType
Function param1 param2 param3
Enumeration
RIGHT_TELE Right+TELE Speed (1–8) None None
LEFTUP_TELE Leftup +TELE Speed (1–8) None None
Leftdown
LEFTDOWN_TELE Speed (1–8) None None
+TELE
TIGHTUP_TELE Rightup+TELE Speed (1–8) None None
Rightdown
RIGHTDOWN_TELE Speed (1–8) None None
+TELE
UP_WIDE Up +WIDE Speed (1–8) None None
DOWN_WIDE Down+WIDE Speed (1–8) None None
LEFT_WIDE Left +WIDE Speed (1–8) None None
RIGHT_WIDE Right+WIDE Speed (1–8) None None
LEFTUP_WIDE Leftup+WIDE Speed (1–8) None None
Leftdown+WID
LEFTDOWN_WIDE Speed (1–8) None None
E
TIGHTUP_WIDE Rightup +WIDE Speed (1–8) None None
Rightdown
RIGHTDOWN_WIDE Speed (1–8) None None
+WIDE
72
Item Description
);
Parameter [in] lTalkHandle Return value of NETClient.StartTalk.
Success: true
Return value
Failure: false.
Note None.
73
3.7.5 Talk Data Sending
Item Description
Name Send audio data to device.
int TalkSendData(
IntPtr lTalkHandle,
Function IntPtr pSendBuf,
uint dwBufSize
);
[in] lTalkHandle Return value of NETClient.StartTalk.
[in] pSendBuf Pointer of audio data block that needs sending.
Parameter
Length of audio data block that needs sending. The unit
[in] dwBufSize
is byte.
Success: Length of audio data block.
Return value
Failure: -1.
Note None.
74
3.8 Video Snapshot
75
3.9 Intelligent Event
76
3.10 Alarm Upload
77
3.11 Device Status and Information
78
Item Description
obtained, the corresponding structure is
NET_OUT_GET_CAMERA_STATEINFO.
[in] nWaitTime Waiting time for query. The default is 1000ms.
Success: true
Return value
Failure: false.
Note None.
79
Item Description
bool MatrixGetCameras(
IntPtr lLoginID,
out NET_MATRIX_CAMERA_INFO[] stuCameras,
Function
int nMaxCameraCount,
int nWaitTime
);
[in] lLoginID Return value of NETClient.LoginWithHighLevelSecurity.
[out] stuCameras Structure array of information of query cameras.
Parameter
[in] nMaxCameraCount Number of query cameras.
[in] nWaitTime Waiting time for query.
Success: true
Return value
Failure: false.
Note None.
80
4 Callback Function
4.1 fDisConnectCallBack
Item Description
Name Disconnection callback.
public delegate void fDisConnectCallBack(
IntPtr lLoginID,
IntPtr pchDVRIP,
Function
int nDVRPort,
IntPtr dwUser
);
[out] lLoginID Return value of NETClient.LoginWithHighLevelSecurity.
[out] pchDVRIP IP of the disconnected device.
Parameter
[out] nDVRPort Port of the disconnected device.
[out] dwUser User parameter of the callback.
Return value None.
Note None.
4.2 fHaveReConnectCallBack
Item Description
Name Reconnection callback.
public delegate void fHaveReConnectCallBack(
IntPtr lLoginID,
IntPtr pchDVRIP,
Function
int nDVRPort,
IntPtr dwUser
);
[out] lLoginID Return value of NETClient.LoginWithHighLevelSecurity.
[out] pchDVRIP IP of the reconnected device.
Parameter
[out] nDVRPort Port of the reconnected device.
[out] dwUser User parameter of the callback.
Return value None.
Note None.
4.3 fRealDataCallBackEx
Item Description
Name Callback of real-time monitoring data.
Function public delegate void fRealDataCallBackEx(
81
Item Description
IntPtr lRealHandle,
uint dwDataType,
IntPtr pBuffer,
uint dwBufSize,
int param,
IntPtr dwUser
);
[out] lRealHandle Return value of NETClient.RealPlay.
Data type:
[out] dwDataType 0: Initial data.
2: YUV data.
[out] pBuffer Address of monitoring data block.
[out] dwBufSize Length of the monitoring data block. The unit is byte.
Parameter
Callback parameter structure. Different dwDataType value
corresponds to different type.
[out] param The param is blank pointer when dwDataType is 0.
The param is the pointer of tagCBYUVDataParam
structure when dwDataType is 2.
[out] dwUser User parameter of the callback.
Return value None.
Note None.
4.4 fAudioDataCallBack
Item Description
Name Callback of audio data of voice talk.
public delegate void fAudioDataCallBack(
IntPtr lTalkHandle,
IntPtr pDataBuf,
Function uint dwBufSize,
byte byAudioFlag,
IntPtr dwUser
);
[out] lTalkHandle Return value of NETClient.StartTalk.
[out] pDataBuf Address of audio data block.
[out] dwBufSize Length of the audio data block. The unit is byte.
Parameter Data type:
[out] byAudioFlag 0: Local collecting.
1: Device sending.
[out] dwUser User parameter of the callback.
Return value None.
Note None.
82
4.5 fDownLoadPosCallBack
Item Description
Name Progress callback of playback and download by file.
public delegate void fDownLoadPosCallBack(
IntPtr lPlayHandle,
uint dwTotalSize,
Function
uint dwDownLoadSize,
IntPtr dwUser
);
[out]lPlayHandle Return value of playback or download.
[out]dwTotalSize Total size. The unit is KB.
The downloaded size. The unit is KB
Parameter
[out]dwDownLoadSize -1: Current playback stopped.
-2: Failed to write file.
[out]dwUser User parameter of the callback.
Return value None.
Note None.
4.6 fDataCallBack
Item Description
Name Callback of playback and download data.
public delegate int fDataCallBack(
IntPtr lRealHandle,
uint dwDataType,
Function IntPtr pBuffer,
uint dwBufSize,
IntPtr dwUser
);
[out]lPlayHandle Return value of playback or download interface.
[out] dwDataType 0 (original data).
Parameter [out] pBuffer Data buffer.
[out] dwBufSize Buffer length. The unit is byte.
[out] dwUser User parameter of the callback.
Return value None.
Note None.
4.7 fTimeDownLoadPosCallBack
Item Description
Name Callback of download by time.
Function public delegate void fTimeDownLoadPosCallBack(
83
Item Description
IntPtr lPlayHandle,
uint dwTotalSize,
uint dwDownLoadSize,
int index,
NET_RECORDFILE_INFO recordfileinfo,
IntPtr dwUser
);
[out]lPlayHandle Return value of download interface.
[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 parameter of the callback.
Return value None.
Note None.
4.8 fMessCallBackEx
Item Description
Name Alarm callback.
public delegate bool fMessCallBackEx(
int lCommand,
IntPtr lLoginID,
IntPtr pBuf,
uint dwBufLen,
Function IntPtr pchDVRIP,
int nDVRPort,
bool bAlarmAckFlag,
int nEventID,
IntPtr dwUser
);
[out] lCommand Alarm type. For details, see Table 4-1.
[out] lLoginID Return value of login interface.
Receives the buffer of alarm data. The entered data is
[out] pBuf different dependent on the listen data and value of
ICommand.
Parameter [out] dwBufLen Length of pBuf. The unit is byte.
[out] pchDVRIP Device IP.
[out] nDVRPort Device port.
The event can be confirmed when the parameter is TRUE,
[out] bAlarmAckFlag and the event cannot be confirmed when the parameter is
FALSE.
84
Item Description
Assign values for CLIENT_AlarmAck interface. When
[out] nEventID
bAlarmAckFlag is TRUE, the data is valid.
[out] dwUser User parameter of the callback.
Success: true.
Return value
Failure: false.
In general, set the callback when initializing. Provide the different treatment to
Note
callback dependent on the device ID and command value.
For the information about alarm type, see Table 4-1.
4.9 fCameraStateCallBack
Item Description
Name Callback of remote device state.
public delegate void fCameraStateCallBack(
IntPtr lLoginID,
IntPtr lAttachHandle,
Function
IntPtr pBuf,
int nBufLen,
IntPtr dwUser
85
Item Description
);
[out] lLoginID Alarm type.
[out] lAttachHandle Return value of subscription.
Parameter [out] pBuf State of front-end device.
[out] nBufLen The length of returned data.
[out] dwUser User parameter of the callback.
Return value None.
After subscribing the remote device state, if the state of front-end device changes, the
Note
information of changed device will be reported.
4.10 fAnalyzerDataCallBack
Item Description
Name Callback of remote device state.
public delegate int fAnalyzerDataCallBack(
IntPtr lAnalyzerHandle,
uint dwEventType,
IntPtr pEventInfo,
IntPtr pBuffer,
Function
uint dwBufSize,
IntPtr dwUser,
int nSequence,
IntPtr reserved
);
[out] lAnalyzerHandle Return value of NETClient.RealLoadPicture.
[out] dwEventType Intelligrent event type.
[out] pEventInfo Event inforamtion buffer.
[out] pBuffer Image buffer.
Parameter
[out] dwBufSize Image buffer size.
[out] dwUser User data.
[out] nSequence Serial number.
[out] reserved Reserved.
Return value None.
After subscribing the remote device state, if the state of front-end device changes, the
Note
information of changed device will be reported.
86
Appendix 1 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 equipment 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
equipment (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 equipment 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 equipment network security:
1. Physical Protection
We suggest that you perform physical protection to equipment, especially storage devices. For
example, place the equipment 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 equipment (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 equipment 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
87
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.
6. Enable HTTPS
We suggest you to enable HTTPS, so that you visit Web service through a secure communication
channel.
7. Enable Allowlist
We suggest you to enable allowlist function to prevent everyone, except those with specified IP
addresses, from accessing the system. Therefore, please be sure to add your computer’s IP
address and the accompanying equipment’s IP address to the allowlist.
8. MAC Address Binding
We recommend you to bind the IP and MAC address of the gateway to the equipment, thus
reducing the risk of ARP spoofing.
9. Assign Accounts and Privileges Reasonably
According to business and management requirements, reasonably add users and assign a
minimum set of permissions to them.
10. 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.
11. 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.
12. Secure Auditing
Check online users: we suggest that you check online users regularly to see if the device is
logged in without authorization.
Check equipment log: By viewing the logs, you can know the IP addresses that were used
to log in to your devices and their key operations.
13. Network Log
Due to the limited storage capacity of the equipment, 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.
14. Construct a Safe Network Environment
In order to better ensure the safety of equipment 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
88
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.
It is recommended that you enable your device's firewall or blocklist and allowlist feature
to reduce the risk that your device might be attacked.
89