0% found this document useful (0 votes)
7 views356 pages

NetSDK Programming Guide

The SDK Programming Guide provides developers with essential information on using the NetSDK for network communication among surveillance products. It includes details on interfaces, functions, and example codes for various operations such as device login, real-time monitoring, and record playback. The manual is intended for SDK software development engineers and project managers, and it emphasizes the importance of adhering to the guidelines to avoid potential hazards.

Uploaded by

Jonathan Páez
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views356 pages

NetSDK Programming Guide

The SDK Programming Guide provides developers with essential information on using the NetSDK for network communication among surveillance products. It includes details on interfaces, functions, and example codes for various operations such as device login, real-time monitoring, and record playback. The manual is intended for SDK software development engineers and project managers, and it emphasizes the importance of adhering to the guidelines to avoid potential hazards.

Uploaded by

Jonathan Páez
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SDK Programming Guide

User’s Manual

V3.5.2
Foreword

Purpose
Welcome to use NetSDK (hereinafter referred to be "the SDK") programming guide (hereinafter
referred to be "the guide").
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 interfaces, functions and calling relationships, and provides code
examples.
The example codes provided in the guide are only for demonstrating the procedure and not
assured to copy for use.

Readers
⚫ SDK software development engineers
⚫ Project managers
⚫ Product managers

Safety Instructions
The following categorized signal words with defined meaning might appear in the manual.
Signal Words Meaning

Indicates a high potential hazard which, if not avoided, will result


DANGER in death or serious injury.

Indicates a medium or low potential hazard which, if not


WARNING avoided, could result in slight or moderate injury.

Indicates a potential risk which, if not avoided, could result in


property damage, data loss, lower performance, or
CAUTION
unpredictable result.

TIPS Provides methods to help you solve a problem or save you time.

Provides additional information as the emphasis and


NOTE supplement to the text.

Revision History
Version Revision Content Release Time

V3.5.2 Added transcoding content September 2025

I
Version Revision Content Release Time

V3.5.1 Added section 2.12 App Management. July 2025

Modified the interfaces to optimize hard disk


V3.5.0 February 2025
information retrieval and error code output.

V3.4.11 Updated some descriptions February 2022

Added reminders for NVR6 series device login.


Moved structure, enumeration and interface
V3.4.10 function chapters to mainbody, and changed May 2021
manual format.
Deleted fisheye correction library.
Deleted function library [Link] and
V3.4.9 March 2021
[Link] related content, and changed font.

V3.4.8 Update to the latest version. February 2020

V1.0.0 First release. February 2018

About the Manual


⚫ 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
Table of Contents
Foreword..................................................................................................................................................... I
1 Overview................................................................................................................................................. 1
General................................................................................................................................................................................ 1
Applicability ...................................................................................................................................................................... 2
2 Overview................................................................................................................................................. 3
SDK Initialization ............................................................................................................................................................. 3
2.1.1 Introduction ......................................................................................................................................................... 3
2.1.2 Interface Overview............................................................................................................................................. 3
2.1.3 Process ................................................................................................................................................................... 4
2.1.4 Example Code...................................................................................................................................................... 4
Device Login ..................................................................................................................................................................... 8
2.2.1 Introduction ......................................................................................................................................................... 8
2.2.2 Interface Overview............................................................................................................................................. 9
2.2.3 Process ................................................................................................................................................................... 9
2.2.4 Example Code....................................................................................................................................................10
Real-time Monitoring ..................................................................................................................................................15
2.3.1 Introduction .......................................................................................................................................................15
2.3.2 Interface Overview...........................................................................................................................................15
2.3.3 Process .................................................................................................................................................................16
2.3.4 Example Code....................................................................................................................................................18
Record Playback ............................................................................................................................................................30
2.4.1 Introduction .......................................................................................................................................................30
2.4.2 Interface Overview...........................................................................................................................................30
2.4.3 Process .................................................................................................................................................................31
2.4.4 Example Code....................................................................................................................................................35
Record Download .........................................................................................................................................................51
2.5.1 Introduction .......................................................................................................................................................51
2.5.2 Interface Overview...........................................................................................................................................51
2.5.3 Process .................................................................................................................................................................52
2.5.4 Example Code....................................................................................................................................................56
Real-Time Monitoring Transcoding .......................................................................................................................72
2.6.1 Introduction .......................................................................................................................................................72
2.6.2 Interface Overview...........................................................................................................................................72
2.6.3 Process .................................................................................................................................................................73
2.6.4 Example Code....................................................................................................................................................74
Record Playback Transcoding ..................................................................................................................................80
2.7.1 Introduction .......................................................................................................................................................80
2.7.2 Interface Overview...........................................................................................................................................81
2.7.3 Process .................................................................................................................................................................81
2.7.4 Example Code....................................................................................................................................................82
Record Download Transcoding ...............................................................................................................................89
2.8.1 Introduction .......................................................................................................................................................89
2.8.2 Interface Overview...........................................................................................................................................89

III
2.8.3 Process .................................................................................................................................................................89
2.8.4 Example Code....................................................................................................................................................90
PTZ Control .....................................................................................................................................................................99
2.9.1 Introduction .......................................................................................................................................................99
2.9.2 INTERFACE OVERVIEW ........................................................................................................................................99
2.9.3 Process .............................................................................................................................................................. 100
2.9.4 Example Code................................................................................................................................................. 100
Voice Talk .................................................................................................................................................................... 114
2.10.1 Introduction .................................................................................................................................................. 114
2.10.2 Interface Overview ..................................................................................................................................... 115
2.10.3 Process ............................................................................................................................................................ 115
2.10.4 Example Code .............................................................................................................................................. 119
Video Snapshot ........................................................................................................................................................ 146
2.11.1 Introduction .................................................................................................................................................. 146
2.11.2 Interface Overview ..................................................................................................................................... 146
2.11.3 Process ............................................................................................................................................................ 148
2.11.4 Example Code .............................................................................................................................................. 149
Alarm Report ............................................................................................................................................................. 161
2.12.1 Introduction .................................................................................................................................................. 161
2.12.2 Interface Overview ..................................................................................................................................... 161
2.12.3 Process ............................................................................................................................................................ 162
2.12.4 Example Code .............................................................................................................................................. 163
Device Search............................................................................................................................................................ 171
2.13.1 Introduction .................................................................................................................................................. 171
2.13.2 Interface Overview ..................................................................................................................................... 171
2.13.3 Process ............................................................................................................................................................ 172
2.13.4 Example Code .............................................................................................................................................. 173
Smart Event Report and Snapshot ................................................................................................................... 185
2.14.1 Introduction .................................................................................................................................................. 185
2.14.2 Interface Overview ..................................................................................................................................... 185
2.14.3 Process ............................................................................................................................................................ 186
2.14.4 Example Code .............................................................................................................................................. 187
App Management ................................................................................................................................................... 196
2.15.1 Introduction .................................................................................................................................................. 196
2.15.2 Interface Overview ..................................................................................................................................... 196
2.15.3 Process ............................................................................................................................................................ 197
2.15.4 Example Code .............................................................................................................................................. 198
3 Callback Function............................................................................................................................... 208
fDisConnect.................................................................................................................................................................. 208
fHaveReConnect ......................................................................................................................................................... 208
fRealDataCallBackEx.................................................................................................................................................. 209
fRealDataCallBackEx2 ............................................................................................................................................... 210
fDataCallBackEx .......................................................................................................................................................... 211
fDownLoadPosCallBack ........................................................................................................................................... 212
fDataCallBack............................................................................................................................................................... 213
fTimeDownLoadPosCallBack ................................................................................................................................. 213
fMessCallBack.............................................................................................................................................................. 214

IV
fSearchDevicesCB .................................................................................................................................................... 215
fSearchDevicesCBEx ............................................................................................................................................... 215
fAnalyzerDataCallBack ........................................................................................................................................... 216
fSnapRev ..................................................................................................................................................................... 217
fRealPlayDisConnect .............................................................................................................................................. 218
pfAudioDataCallBack ............................................................................................................................................. 219
4 Structure Definition ........................................................................................................................... 220
NET_DEVICEINFO ....................................................................................................................................................... 220
NET_PARAM ................................................................................................................................................................. 220
NET_DEVICEINFO_Ex................................................................................................................................................. 222
NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY ................................................................................................. 222
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY ............................................................................................ 223
NET_IN_STARTSERACH_DEVICE ............................................................................................................................ 224
NET_OUT_STARTSERACH_DEVICE ....................................................................................................................... 225
tagVideoFrameParam............................................................................................................................................... 225
tagCBPCMDataParam .............................................................................................................................................. 226
NET_TIME.................................................................................................................................................................... 227
NET_RECORDFILE_INFO ........................................................................................................................................ 227
CFG_PTZ_PROTOCOL_CAPS_INFO .................................................................................................................... 229
CFG_PTZ_MOTION_RANGE.................................................................................................................................. 232
CFG_PTZ_LIGHTING_CONTROL.......................................................................................................................... 232
DHDEV_TALKFORMAT_LIST ................................................................................................................................. 233
DHDEV_TALKDECODE_INFO ............................................................................................................................... 233
DHDEV_SYSTEM_ATTR_CFG ................................................................................................................................ 234
NET_SPEAK_PARAM ................................................................................................................................................ 236
NET_TALK_TRANSFER_PARAM............................................................................................................................ 236
DEVICE_NET_INFO_EX............................................................................................................................................ 237
MANUAL_SNAP_PARAMETER ............................................................................................................................. 238
OPR_RIGHT_EX ......................................................................................................................................................... 239
OPR_RIGHT_NEW .................................................................................................................................................... 239
NET_DEV_CHN_COUNT_INFO ............................................................................................................................ 239
NET_CHN_COUNT_INFO....................................................................................................................................... 240
NET_IN_SNAP_CFG_CAPS ..................................................................................................................................... 240
NET_OUT_SNAP_CFG_CAPS ................................................................................................................................ 241
DH_RESOLUTION_INFO ........................................................................................................................................ 242
CFG_VIDEOENC_OPT ............................................................................................................................................. 242
CFG_VIDEO_FORMAT ............................................................................................................................................. 243
CFG_AUDIO_ENCODE_FORMAT......................................................................................................................... 245
CFG_VIDEO_COVER ................................................................................................................................................ 246
CFG_COVER_INFO ................................................................................................................................................... 246
CFG_RECT ................................................................................................................................................................... 247
CFG_ENCODE_INFO................................................................................................................................................ 248
SNAP_PARAMS ......................................................................................................................................................... 249
DH_VERSION_INFO................................................................................................................................................. 250
NET_IN_REALPLAY_BY_DATA_TYPE ................................................................................................................... 251
NET_OUT_REALPLAY_BY_DATA_TYPE ............................................................................................................... 251
NET_IN_PLAYBACK_BY_DATA_TYPE .................................................................................................................. 252

V
NET_OUT_PLAYBACK_BY_DATA_TYPE .............................................................................................................. 253
NET_IN_DOWNLOAD_BY_DATA_TYPE ............................................................................................................. 253
NET_OUT_DOWNLOAD_BY_DATA_TYPE ......................................................................................................... 254
DH_DSP_ENCODECAP ........................................................................................................................................... 255
DHDEV_UPGRADE_STATE_INFO ......................................................................................................................... 256
NET_IN_START_APP................................................................................................................................................. 257
NET_OUT_START_APP ............................................................................................................................................ 257
CFG_DEV_DISPOSITION_INFO ............................................................................................................................ 258
NET_IN_GET_INSTALLED_APP_INFO ................................................................................................................. 259
NET_OUT_GET_INSTALLED_APP_INFO ............................................................................................................ 259
NET_IN_INSTALL_PREPAREEX.............................................................................................................................. 260
NET_OUT_INSTALL_PREPAREEX ......................................................................................................................... 261
NET_IN_INSTALL_APPEND_DATA ....................................................................................................................... 261
NET_OUT_INSTALL_APPEND_DATA .................................................................................................................. 262
NET_IN_INSTALL_EXECUTE................................................................................................................................... 262
NET_OUT_INSTALL_EXECUTE .............................................................................................................................. 262
NET_IN_STOP_APP .................................................................................................................................................. 263
NET_OUT_STOP_APP .............................................................................................................................................. 263
NET_IN_INSTALL_EXECUTE................................................................................................................................... 263
NET_OUT_INSTALL_EXECUTE .............................................................................................................................. 264
5 Enumeration Definition..................................................................................................................... 265
NET_DEVICE_TYPE ..................................................................................................................................................... 265
EM_OPTIMIZE_TYPE .................................................................................................................................................. 266
EM_LOGIN_SPAC_CAP_TYPE .................................................................................................................................. 267
DH_RealPlayType........................................................................................................................................................ 267
EM_QUERY_RECORD_TYPE..................................................................................................................................... 268
EM_USEDEV_MODE .................................................................................................................................................. 268
EM_SUPPORT_FOCUS_MODE ............................................................................................................................... 269
DH_PTZ_ControlType ................................................................................................................................................ 269
DH_EXTPTZ_ControlType ........................................................................................................................................ 270
DH_TALK_CODING_TYPE ...................................................................................................................................... 272
CtrlType ....................................................................................................................................................................... 272
CFG_VIDEO_COMPRESSION ............................................................................................................................... 278
CFG_BITRATE_CONTROL ....................................................................................................................................... 279
CFG_IMAGE_QUALITY ............................................................................................................................................ 279
CFG_H264_PROFILE_RANK .................................................................................................................................. 279
CFG_AUDIO_FORMAT ............................................................................................................................................ 280
EM_SEND_SEARCH_TYPE...................................................................................................................................... 280
EM_REALPLAY_DISCONNECT_EVENT_TYPE .................................................................................................. 280
EM_NET_UPGRADE_INSTALL_TYPE ................................................................................................................... 281
EM_APP_RUNNING_STATE ................................................................................................................................... 281
EM_APP_LICENSE_STATE ....................................................................................................................................... 281
EM_APP_DEBUG_STATE ......................................................................................................................................... 282
EM_NET_NEXT_OPERATE ...................................................................................................................................... 282
EM_NET_UPGRADE_INSTALL_TYPE ................................................................................................................... 282
6 Interface Function Definition ........................................................................................................... 284
CLIENT_Init ................................................................................................................................................................... 284

VI
CLIENT_Cleanup ......................................................................................................................................................... 285
CLIENT_GetSDKVersion ........................................................................................................................................... 285
CLIENT_GetLastError ................................................................................................................................................. 286
CLIENT_SetAutoReconnect..................................................................................................................................... 287
CLIENT_SetConnectTime ......................................................................................................................................... 288
CLIENT_SetNetworkParam ..................................................................................................................................... 288
CLIENT_SetOptimizeMode ..................................................................................................................................... 289
CLIENT_LoginWithHighLevelSecurity ................................................................................................................. 289
CLIENT_Logout ......................................................................................................................................................... 290
CLIENT_RealPlayEx .................................................................................................................................................. 291
CLIENT_RealPlayByDataType ............................................................................................................................... 292
CLIENT_SetRealDataCallBackEx .......................................................................................................................... 293
CLIENT_StopRealPlayEx ......................................................................................................................................... 296
CLIENT_FindFile ........................................................................................................................................................ 296
CLIENT_FindNextFile .............................................................................................................................................. 298
CLIENT_FindClose.................................................................................................................................................... 299
CLIENT_PlayBackByDataType .............................................................................................................................. 299
CLIENT_PlayBackByTimeEx................................................................................................................................... 301
CLIENT_StopPlayBack............................................................................................................................................. 303
CLIENT_GetPlayBackOsdTime............................................................................................................................. 304
CLIENT_QueryRecordFile ...................................................................................................................................... 305
CLIENT_DownloadByTimeEx................................................................................................................................ 307
CLIENT_DownloadByDataType ........................................................................................................................... 309
CLIENT_StopDownload ......................................................................................................................................... 310
CLIENT_PlayBackByRecordFileEx ....................................................................................................................... 311
CLIENT_PausePlayBack .......................................................................................................................................... 313
CLIENT_SeekPlayBack ............................................................................................................................................ 313
CLIENT_FastPlayBack .............................................................................................................................................. 314
CLIENT_SlowPlayBack ............................................................................................................................................ 314
CLIENT_NormalPlayBack....................................................................................................................................... 315
CLIENT_DownloadByRecordFileEx .................................................................................................................... 316
CLIENT_ParseData ................................................................................................................................................... 317
CLIENT_DHPTZControlEx2 ................................................................................................................................... 318
CLIENT_QueryNewSystemInfo ........................................................................................................................... 320
CLIENT_SetDeviceMode........................................................................................................................................ 321
CLIENT_StartSearchDevicesEx............................................................................................................................. 322
CLIENT_QueryDevState ......................................................................................................................................... 323
CLIENT_StartTalkEx .................................................................................................................................................. 324
CLIENT_StopTalkEx .................................................................................................................................................. 325
CLIENT_RecordStartEx ........................................................................................................................................... 325
CLIENT_RecordStopEx............................................................................................................................................ 326
CLIENT_TalkSendData ............................................................................................................................................ 327
CLIENT_AudioDecEx ............................................................................................................................................... 327
CLIENT_SetDVRMessCallBack ............................................................................................................................. 328
CLIENT_StartListenEx .............................................................................................................................................. 329
CLIENT_StopListen .................................................................................................................................................. 329
CLIENT_StopSearchDevices ................................................................................................................................. 330

VII
CLIENT_SearchDevicesByIPs ................................................................................................................................ 331
CLIENT_RealLoadPictureEx................................................................................................................................... 332
CLIENT_ControlDeviceEx ...................................................................................................................................... 333
CLIENT_StopLoadPic............................................................................................................................................... 334
CLIENT_GetDownloadPos..................................................................................................................................... 335
CLIENT_SetSnapRevCallBack ............................................................................................................................... 336
CLIENT_SnapPictureEx ........................................................................................................................................... 336
CLIENT_StartApp...................................................................................................................................................... 337
CLIENT_GetNewDevConfig .................................................................................................................................. 338
CLIENT_GetInstalledAppInfo ............................................................................................................................... 339
CLIENT_UpgraderInstall ........................................................................................................................................ 340
CLIENT_UpgraderInstall ........................................................................................................................................ 341
CLIENT_UpgraderInstall ........................................................................................................................................ 342
CLIENT_StopApp ...................................................................................................................................................... 343
CLIENT_RemoveApp ............................................................................................................................................... 344
Cybersecurity Recommendations ................................................................................... 345

VIII
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, record playback, download, PTZ control,
voice talk, video snapshot, alarm upload, device search, smart event upload and snapshot, user
management, device restart, decide upgrade, device timing, video parameter setting, channel
name setting, and network parameter setting of device.
The development kit might be different dependent on the environment.
There are files included in development.

Table 1-1 Files included in Windows development kit


Library type Library file name Library file description
dhnetsdk.h Header file
[Link] Lib file
Function library
[Link] Library file
[Link] Library file
avglobal.h Header file
dhconfigsdk.h Configuration Header file
Configuration library
[Link] Lib file
[Link] Library file
Auxiliary library of
playing (coding and [Link] Playing library
decoding)
Auxiliary library of [Link] Image display library
"[Link]" [Link] Transcoding library

Table 1-2 files included in Linux development kit


Library type Library file name Library file description
dhnetsdk.h Header file
Function library [Link] Library file
[Link] Library file
avglobal.h Header file
Configuration library dhconfigsdk.h Configuration Header file
[Link] Configuration library
Auxiliary library of
[Link] Transcoding library
"[Link]"

⚫ The function library and configuration library are necessary libraries.

1
⚫ The function library is the main body of SDK, which is used for communication interaction
between client and products, remotely controls device, queries device data, configures
device data information, as well as gets and handles the streams.
⚫ The configuration library packs and parses the structures of configuration functions.
⚫ It is recommended to use auxiliary library of playing (coding and decoding) to parse and
play the streams.
⚫ The auxiliary library decodes the audio and video streams for the functions such as
monitoring and voice talk, and collects the local audio.

Applicability
⚫ Recommended memory: No less than 512 M
⚫ System supported by SDK:
Windows
Windows 10, Windows 8, Windows 7, and Windows Server 2008/2003
Linux
The common Linux systems such as Red Hat and SUSE

Table 1-3 The device suitable for functions


Function Supported device
Device login DVR, NVR, IPC and SD
Real-time monitoring DVR, NVR, IPC and SD
Record playback Storage devices, such as DVR and NVR
Download Storage devices, such as DVR and NVR
PTZ control SD
Voice talk DVR, NVR, IPC and SD
Video snapshot DVR, NVR, IPC and SD
Alarm upload DVR, NVR, IPC and SD
Device search DVR, NVR, IPC and SD
Smart event upload and snapshot IVS, mobile and smart SD
ser management DVR, NVR, IPC and SD

2
2 Overview

All the example codes are tested by VS2005sp1 under Windows OS.

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.

2.1.2 Interface Overview


Table 2-1 Interfaces of SDK initialization
Interface Implication
CLIENT_Init SDK initialization
CLIENT_Cleanup SDK cleaning up
CLIENT_GetSDKVersion Get SDK version information
Get error codes of other interfaces whichare
CLIENT_GetLastError
fail to call
Set reconnection callback after
CLIENT_SetAutoReconnect
disconnection
Set the device connection timeout and the
CLIENT_SetConnectTime
number of attempts
CLIENT_SetNetworkParam Set login network environment

3
2.1.3 Process
Process of SDK initialization

Start

SDK Initialziation
CLIENT_Init

Get SDK version information


CLIENT_GetSDKVersion

Set reconnection callback after disconnection


CLIENT_SetAutoReconnet

Set the device connection timeout


and the number of attempts
CLIENT_SetConnectTime

Set login network environment


CLIENT_SetNetworkParam

Release SDK resource


CLIENT_Cleanup Optional

Mandatory
Stop

Process Description
Call CLIENT_Init to initialize SDK.
(Optional) Call CLIENT_GetSDKVersion to get SDK version information.
(Optional but suggested) Call CLIENT_SetAutoReconnect to set reconnection callback.
Internal SDK auto connects when the device disconnected.
(Optional) Call CLIENT_SetConnectTime to set device connection timeout and trial
times.
(Optional) Call CLIENT_SetNetworkParam to set network login parameters, including
device login timeout and trial times.
After using all SDK functions, call CLIENT_Cleanup to release SDK resource.

2.1.4 Example Code


#include <windows.h>

4
#include <stdio.h>
#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function set after the device reconnected successfully


// It is not recommended to call SDK interface in the SDK callback function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);
//*********************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Optional operation
// Get the SDK version information
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]", dwNetSdkVersion);

5
// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
// Task realizing operation
;
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();

6
// Logout operation

// Clean up initialization resources


if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}
int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}
//*********************************************************************************
// Commonly used callback function definition
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}

7
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

Device Login

2.2.1 Introduction

Precondition
Before logging to device, successfully initialization should be done.

Overview
Device login, as device registration, is the precondition of other businesses.
When SDK initialization completing, users need to login to Dahua device first. Only when the
sole valid login ID is generated, can we operate other businesses. Login ID is the unique sign to
recognize the login, other function SDK follows will require this login ID.

Reconnection
SDK can set device reconnection function. When encounter some special conditions (offline,
outage) which makes device become offline, it will try to reconnect to device continuously
within SDK until being online.

⚫ Among the three login methods, auto registration login don’t support reconnection.
⚫ User can call SDK self-carried reconnection function, as well as can call login and logout
interface at application layer to manually control reconnection business.

Note
⚫ The provided login operation is for Dahua devices only, not for other manufactures'
devices. Do the login operation carefully; otherwise the device will not be able to login
successfully.
⚫ Login and logout should be used as a pair. In case of resource leak, you must call logout
interface to logout user and release SDK resource.
⚫ The login of NVR6 series devices (supports 16 and more HDD) can take long due to the
large number of HDD. To avoid that, we recommend using CLIENT_SetOptimizeMode
interface to obtain HDD information before device login. After above configuration, the
returned parameter of HDD number when logging in the interface becomes invalid. You
can obtain through CLIENT_QueryDevState (DH_DEVSTATE_DISK) interface. Example code
of optimizing obtaining HDD information is shown below:
int opt = OPTTYPE_MOBILE_DISK_INFO;

8
CLIENT_SetOptimizeMode(EM_OPT_TYPE_MOBILE_OPTION, &opt);

2.2.2 Interface Overview


Table 2-2 Interfaces of device login
Interface Implication
CLIENT_Init SDK initialization
CLIENT_Cleanup SDK cleaning up
Log in to the device with high level security.
CLIENT_LoginEx2 can still be used,but there are
CLIENT_LoginWithHighLevelSecurity security risks,so it is highly recommended to use the
interface CLIENT_LoginWithHighLevelSecurity to log
in to the device.
CLIENT_Logout Logout
Get error codes of other interfaces which fail to be
CLIENT_GetLastError
called.
CLIENT_SetOptimizeMode Optimize obtaining hard disk information.

2.2.3 Process
When client with SDK has fluent connection to Dahua device, you can start the login operation.
When the login interface return a valid login ID, your login is successful.

9
Process of sync login

Start

SDK Initialization

CLIENT_SetOptimizeMode

Get the error code and analyze the


Log in to device successfully? No failure reason
CLIENT_LoginWithHighLevelSec dhnetsdk.h
urity CLIENT_Login

Yes

Implement functions

Log out of the device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup
Optional

Stop Required

Process Description
Call CLIENT_Init to initialize SDK.
Optional. Call CLIENT_SetOptimizeMode to optimize obtaining hard disk information.
After initialization,call CLIENT_LoginWithHighLevelSecurity to log in to device.
After login, users can realize business as needed.
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.

2.2.4 Example Code


#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

static LLONG g_lLoginHandle = 0L;


static char g_szDevIp[32] = "[Link]";

10
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";
static BOOL g_bNetSDKInitFlag = FALSE;

//*********************************************************************************
// Commonly used callback set declaration.
// Callback function used when device disconnected.
// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function set after the device reconnected successfully


// It is not recommended to call SDK interface in the SDK callback function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

//*********************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Get the SDK version information


// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.

11
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

//This operation is optional. It is to optimize obtaining hard disk information.

int opt = OPTTYPE_MOBILE_DISK_INFO;

CLIENT_SetOptimizeMode(EM_OPT_TYPE_MOBILE_OPTION, &opt);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)
{
// Log in to device
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{

12
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23)
// Do not support this function. The corresponding error code is 0x80000017, and the
corresponding hexadecimal is 0x17.

printf("CLIENT_LoginEx %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,


CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
// Task realizing operation
;
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Log out of device
if (0 != g_lLoginHandle)
{
if (FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{

13
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}

int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}
//*********************************************************************************
// Commonly used callback function definition
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{

14
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

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.
⚫ Support configuring bit stream resolution, encode, bit rate and other parameters of
front-end devices.
⚫ Support setting of image saturation, contrast, exposure and so on.
⚫ Support conveying window handle from users, and SDK analyzes stream and play directly.
⚫ Support calling back real-time stream data to users, and let users process by themselves.
⚫ Support saving real-time record to specific folder, user can save callback stream to achieve
it or call SDK interface to realize it.

2.3.2 Interface Overview


Table 2-3 Interfaces of real-time monitoring
Interface Implication
CLIENT_Init SDK initialization
CLIENT_Cleanup SDK cleaning up
Log in to the device with high level security.
CLIENT_LoginEx2 can still be used,but there are
CLIENT_LoginWithHighLevelSecurity security risks,so it is highly recommended to use the
interface CLIENT_LoginWithHighLevelSecurity to log
in to the device.
CLIENT_RealPlay Start real-time monitoring
CLIENT_StopRealPlay Stop real-time monitoring
CLIENT_RealPlayEx Extensive interface of starting real-time monitoring
CLIENT_StopRealPlayEx Extensive interface of stopping real-time monitoring
Callback interface of starting real-time monitoring
CLIENT_StartRealPlay
and supporting to set bit stream
Extensive interface of setting real-time monitoring
CLIENT_SetRealDataCallBackEx
data callback
CLIENT_ClientGetVideoEffect Get image attributes

15
Interface Implication
CLIENT_ClientSetVideoEffect Set image attributes
CLIENT_AdjustFluency Adjust image playback fluency
CLIENT_Logout Logout
Get error codes of other interfaces which fail to be
CLIENT_GetLastError
called.

2.3.3 Process
There are two methods of real-time monitoring:
⚫ SDK decoding play
SDK realizes real-time play by calling playsdk library in aux library.
⚫ The third party decoding play
SDK only calls back real-time monitoring data stream to users, and then users decodes and
plays with a third-party library.

[Link] SDK Decoding Play


Process of playing by SDK decoding library

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Start monitoring, and hWnd calls the


valid handle CLIENT_RealPlayEx

Stop real-time monitoring


CLIENT_StopRealPlayEx

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.

16
Call CLIENT_RealPlayEx to enable the real-time monitoring. The parameter hWnd is a
valid window handle.
After using the real-time function, call CLIENT_StopRealPlayEx to stop real-time
monitoring.
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.

[Link] Third Party Decoding Play


Process of calling third party play library

Start

Initialize SDK
CLIENT_Init

Login the device


CLIENT_LoginWithHighLevelSecurity

Start real-time monitoring, hWnd calls


NULL
CLIENT_RealPlayEx

The callback receives data


Set callback
and call playsdk series
CLIENT_SetRealDataCallBackEx
interface to play

Stop real-time monitoring


CLIENT_StopRealPlayEx

Logout
CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
After successful login, call CLIENT_RealPlayEx to enable real-time monitoring. The
parameter hWnd is NULL.
Call CLIENT_SetRealDataCallBackEx to set the real-time data callback.
Save real-time data in the callback for further using. It is not recommended to do other
operations in this callback other than data transfer and storage; otherwise, it will affect
performance when there are many monitoring channels.

17
After completing the real-time monitoring, call CLIENT_StopRealPlayEx to stop
real-time monitoring.
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.

2.3.4 Example Code

[Link] SDK Decoding Play


#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)();


PROCGETCONSOLEWINDOW GetConsoleWindow;

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lRealHandle = 0;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function set after the device reconnected successfully


// It is not recommended to call SDK interface in the SDK callback function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

18
//*********************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Get the SDK version information


// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

19
NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
while(0 == g_lLoginHandle)
{
// Log in to device
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,
g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
// Check whether the initialization is success

20
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
// Check whether to log in to device
if (0 == g_lLoginHandle)
{
return;
}

// Implement real-time monitoring


// Get window handle of control unit
HMODULE hKernel32 = GetModuleHandle("kernel32");
GetConsoleWindow =
(PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWindow");
HWND hWnd = GetConsoleWindow();

printf("user can input any key to quit during real play!\n");


Sleep(1000);

// Start real-time monitoring


int nChannelID = 0; // Live channel number
DH_RealPlayType emRealPlayType = DH_RType_Realplay; // Real-time monitoring
g_lRealHandle = CLIENT_RealPlayEx(g_lLoginHandle, nChannelID, hWnd, emRealPlayType);
if (0 == g_lRealHandle)
{
printf("CLIENT_RealPlayEx: failed! Error code: %x.\n", CLIENT_GetLastError());
}
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Stop live viewing
if (0 != g_lRealHandle)
{
if(FALSE == CLIENT_StopRealPlayEx(g_lRealHandle))
{
printf("CLIENT_StopRealPlayEx Failed!Last Error[%x]\n" , CLIENT_GetLastError());

21
}
else
{
g_lRealHandle = 0;
}
}
// Log out of device
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
}

int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}

//*********************************************************************************
// Commonly used callback function definition
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);

22
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

[Link] Third Party Decoding Play


#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lRealHandle = 0;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";

//*********************************************************************************

23
// Commonly used callback set definition.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function set after the device reconnected successfully


// It is not recommended to call SDK interface in the SDK callback function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Real-time monitoring data callback


// It is not recommended to call SDK interface in the SDK callback function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
// It is recommended that users only do the data saving operation in this callback. You are not
recommended encode and dedcode data directly.
// That is to copy the correspomding data to own storage space and then do operations such as
encoding and edcodign data after leaving callback function.
void CALLBACK RealDataCallBackEx(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD
dwBufSize, LONG param, LDWORD dwUser);

//*********************************************************************************
void InitTest()
{
// SDK initilization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Get the SDK version information

24
// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
while(0 == g_lLoginHandle)
{
// Log in to device
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

25
if (0 == g_lLoginHandle)
{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,
g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}

// Implement real-time monitoring


printf("user can input any key to quit during real play data callback!\n");
Sleep(1000);

// Start real-time monitoring


int nChannelID = 0; // Live channel number
DH_RealPlayType emRealPlayType = DH_RType_Realplay; // Real-time monitoring

26
g_lRealHandle = CLIENT_RealPlayEx(g_lLoginHandle, nChannelID, NULL, emRealPlayType);
if (0 == g_lRealHandle)
{
printf("CLIENT_RealPlayEx: failed! Error code: %x.\n", CLIENT_GetLastError());
return;
}
else
{
DWORD dwFlag = 0x00000001;
if (FALSE == CLIENT_SetRealDataCallBackEx(g_lRealHandle, &RealDataCallBackEx, NULL,
dwFlag))
{
printf("CLIENT_SetRealDataCallBackEx: failed! Error code: %x.\n", CLIENT_GetLastError());
return;
}
}
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Stop live viewing
if (0 != g_lRealHandle)
{
if (FALSE == CLIENT_StopRealPlayEx(g_lRealHandle))
{
printf("CLIENT_StopRealPlayEx Failed, g_lRealHandle[%x]!Last Error[%x]\n" , g_lRealHandle,
CLIENT_GetLastError());
}
else
{
g_lRealHandle = 0;
}
}
// Log out of device
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{

27
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
}

int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}

//*********************************************************************************
// Commonly used callback function definition
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{

28
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK RealDataCallBackEx(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD


dwBufSize, LONG param, LDWORD dwUser)
{
// If more than one real-time monitorings use the data callback, users can do one-to-one
correspondence by lRealHandle.
if (lRealHandle == g_lRealHandle)
{
switch(dwDataType)
{
case 0:
// OriginalA/V hybrid data
printf("receive real data, param: lRealHandle[%p], dwDataType[%d], pBuffer[%p],
dwBufSize[%d], param[%p], dwUser[%p]\n",
lRealHandle, dwDataType, pBuffer, dwBufSize, param, dwUser);

break;
case 1:
// Standard video data

break;
case 2:
// yuv data

break;
case 3:
// pcm audio data

break;
case 4:

29
// Original audio data

break;
default:
break;
}

}
}

Record Playback

2.4.1 Introduction

Overview
Record playback is to playback record of certain channels during specific periods, in order to
locate target video for research from a large quantity of videos.
Playback function includes several operations, such as play, pause, quick play, slow play,
draggering play and so on.

Record Playback Method


According to the different decoding method selected by users, record playback have two
methods: SDK decoding playback and third-party decoding playback.

2.4.2 Interface Overview


Table 2-4 Interfaces of record playback
Interface Implication
CLIENT_Init Interface for SDK initialization
CLIENT_Cleanup Interface for cleaning up SDK resources
CLIENT_LoginWithHighLevelSecurity Login with high level security
CLIENT_PlayBackByTimeEx Extensive interface for playback by time
Interface for setting work mode such as voice talk,
CLIENT_SetDeviceMode
playback, authority.
CLIENT_StopPlayBack Interface for stopping record playback
CLIENT_GetPlayBackOsdTime Interface for getting playback OSD time
CLIENT_PausePlayBack Interface for pause or restoring playback
CLIENT_FastPlayBack Interface for fast [Link] frame rate by 1x
CLIENT_SlowPlayBack Interface for slow [Link] frame rate by 1x
CLIENT_NormalPlayBack Interface for restoring normal play speed

30
Interface Implication
CLIENT_SeekPlayBack Interface for positioning record playback start point
CLIENT_Logout Interface for logout
Interface for getting error code after failed calling
CLIENT_GetLastError
interface

2.4.3 Process
According to the different decoding method selected by users, record playback have the
following two methods.
⚫ SDK decoding playback
Firstly user inputs start time, end time and valid window handle of record, then SDK will call
corresponding decoding library to analyze stream and show the video in display window.
⚫ Third party decoding playback
Firstly user inputs start time, end time and valid window handle (window handle is set to NULL
in this method) and valid playback stream callback function of [Link] SDK receives
playback stream data, the data is called back to user for saving by playback stream callback
[Link] leaving callback function, user calls a third-party library to analyze and display
the saved stream data.

31
[Link] SDK Decoding Playback

Process of SDK decoding playback

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set emType parameter of playback


stream type as
DH_RECORD_STREAM_TYPE
CLIENT_SetDeviceMode

Set emType parameter of playback record


file type as DH_RECORD_TYPE
CLIENT_SetDeviceMode

Start record playback


Set hWnd parameter as a valid window
handle value
CLIENT_PlayBackByTimeEx

CLIENT_SlowPlayBack: Slow play


CLIENT_FastPlayBack: Fast play
CLIENT_NormalPlayBack: Normal play
CLIENT_PausePlayBack: Pause/ resume
CLIENT_SeekPlayBack: Play by dragging

Stop playback
CLIENT_StopPlayBack

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Call CLIENT_Init to initialize SDK.


Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
After successful login, call CLIENT_SetDeviceMode twice to separately set playback
stream type and playback record file type.

32
Call CLIENT_PlayBackByTimeEx to start playback, parameter hWnd is set to valid
window handle value.
During playback, call CLIENT_SlowPlayBack to slowly play, CLIENT_FastPlayBack to
fast play, CLIENT_NormalPlayBack to play at normal speed, CLIENT_PausePlayBack
to pause or resuem play, CLIENT_SeekPlayBack to play by dragging.
After playback is done, 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.

33
[Link] Third Party Decoding Playback

Process of third party decoding playback

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set emType parameter of playback


stream type as
emTypeDH_RECORD_STREAM_TYPE
CLIENT_SetDeviceMode

Set emType parameter of


playback record file type as
DH_RECORD_TYPE
CLIENT_SetDeviceMode

Start record playback


Set hWnd parameter as NULL and
Data playback callback
fDownLoadDataCallBack Parameter
fDataCallBack
as a valid pointer of callback
CLIENT_PlayBackByTimeEx

CLIENT_SlowPlayBack: Slow play


CLIENT_FastPlayBack: Fast play
CLIENT_NormalPlayBack: Normal play
CLIENT_PausePlayBack: Pause/ resume
CLIENT_SeekPlayBack: Play by dragging
Use with corresponding interfaces of third-party libraries

Stop playback
CLIENT_StopPlayBack

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Call CLIENT_Init to initialize SDK.

34
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
After successful login, call CLIENT_SetDeviceMode twice to separately set playback
stream type and playback record file type.
After successful login, call CLIENT_PlayBackByTimeEx to start playback. The
parameter hWnd is set to NULL, and parameter fDownLoadDataCallBack is a valid
pointer pointing to a callback function.
After SDK receives playback stream data, the data is called back to user for saving by
playback stream callback function fDownLoadDataCallBack .After leaving callback
function, user calls a third-party library to analyze and display the saved stream data.
During playback, call CLIENT_SlowPlayBack to slowly play, CLIENT_FastPlayBack to
fast play, CLIENT_NormalPlayBack to play at normal speed, CLIENT_PausePlayBack
to pause or resuem play, CLIENT_SeekPlayBack to play by dragging and call the
third-party interfaces at the same time.
After playback is done, 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.

2.4.4 Example Code

[Link] SDK Decoding Playback

#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"
#pragma comment(lib , "[Link]")

extern "C" HWND WINAPI GetConsoleWindow();

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lPlayHandle = 0L;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.

35
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function..
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

/// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in the SDK callback function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

//*********************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}
// Get the SDK version information
// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

36
// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
while(0 == g_lLoginHandle)
{
// Log in to device
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,
g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);

37
printf("\n");
}
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}

// Record playback
// Get window handle of control unit
HWND hWnd = GetConsoleWindow();

// Set bit stream of playback


int nStreamType = 0; // 0-main and sub stream, 1-main stream, 2-sub stream
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_STREAM_TYPE, &nStreamType);

// Set playback record file type


NET_RECORD_TYPE emFileType = NET_RECORD_TYPE_ALL; // All recorded videos
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_TYPE, &emFileType);

// Start record playback


int nChannelID = 0; // Channel number
NET_TIME stuStartTime = {0};
[Link] = 2015;
[Link] = 11;
[Link] = 20;

NET_TIME stuStopTime = {0};


[Link] = 2015;
[Link] = 11;
[Link] = 21;

38
g_lPlayHandle = CLIENT_PlayBackByTimeEx(g_lLoginHandle, nChannelID, &stuStartTime,
&stuStopTime, hWnd, NULL, NULL, NULL, NULL);
if (0 == g_lPlayHandle)
{
printf("CLIENT_PlayBackByTimeEx: failed! Error code: %x.\n", CLIENT_GetLastError());
}

// Implement playback controlling as needed


// The example code is for reference because it is a control unit demo that cannot display the record
palyback and playback controlling at the same time.

// CLIENT_SlowPlayBack To slow play


/* Example code
if (FALSE == CLIENT_SlowPlayBack (g_lPlayHandle))
{
printf("CLIENT_SlowPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
*/

// CLIENT_FastPlayBack To fast play


/* Example code
if (FALSE == CLIENT_FastPlayBack (g_lPlayHandle))
{
printf("CLIENT_FastPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
*/

// CLIENT_NormalPlayBack To play at t normal speed


/* Example code
if (FALSE == CLIENT_NormalPlayBack (g_lPlayHandle))
{
printf("CLIENT_NormalPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
*/

// CLIENT_PausePlayBack To pause and resume play


/* Example code

39
if (FALSE == CLIENT_PausePlayBack (g_lPlayHandle, TRUE))
{
printf("CLIENT_PausePlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
*/

// CLIENT_SeekPlayBack To play by dragging


/* Example code
int nOffsetSeconds = 2 * 60 * 60; // Drag to 2*60*60s after stuStartTime to start play stuStartTime.
if (FALSE == CLIENT_SeekPlayBack (g_lPlayHandle, nOffsetSeconds, 0))
{
printf("CLIENT_SeekPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
*/
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Close playback
if (0 != g_lPlayHandle)
{
if (FALSE == CLIENT_StopPlayBack(g_lPlayHandle))
{
printf("CLIENT_StopPlayBack Failed, g_lRealHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
else
{
g_lPlayHandle = 0;
}
}
// Log out of device
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{

40
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}

int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}

//*********************************************************************************
// Commonly used callback function definition

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

41
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

[Link] Third Party Decoding Playback

#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"
#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lPlayHandle = 0L;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";

//*********************************************************************************
// Commonly used callback set definition.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function set after the device reconnected successfully


// It is not recommended to call SDK interface in the SDK callback function.

42
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Playback progress callback


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_PlayBackByTimeEx. When you receive playback data from device,
SDK will call the function.
void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD
dwDownLoadSize, LDWORD dwUser);

// Playback data callback


// It is not recommended to call SDK interface in this function.
// When you set this callback, if hWnd is NULL, returned parameter 0 means that the callback failed and
the next callingwill return the same data, and returned parameter means the callback succeeded and
the next calling will return the following data.
// When you set this callback, if hWnd is not NULL, the callback succeeded no matter how much the
return value and the next calling will return the following data.
// Set the callback function by CLIENT_PlayBackByTimeEx. When you receive playback data from device,
SDK will call the function.
int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD
dwBufSize, LDWORD dwUser);

//*************************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}
// Get the SDK version information
// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

43
// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
while(0 == g_lLoginHandle)
{
// Log in to device
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.

44
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,
g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}

// Record playback

// Set bit stream of playback


int nStreamType = 0; // 0-main and sub stream, 1-main stream, 2-sub stream
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_STREAM_TYPE, &nStreamType);

// Set playback record file type


NET_RECORD_TYPE emFileType = NET_RECORD_TYPE_ALL; // All recorded videos
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_TYPE, &emFileType);

// Start record playback

45
int nChannelID = 0; // Channel number
NET_TIME stuStartTime = {0};
[Link] = 2015;
[Link] = 11;
[Link] = 20;

NET_TIME stuStopTime = {0};


[Link] = 2015;
[Link] = 11;
[Link] = 21;

// Function parameter hWnd should be NULL


// Function parameter fDownLoadDataCallBack should be a valid callback function pointer
g_lPlayHandle = CLIENT_PlayBackByTimeEx(g_lLoginHandle, nChannelID, &stuStartTime,
&stuStopTime, NULL, &DownLoadPosCallBack, NULL, &DataCallBack, NULL);
if (g_lPlayHandle == 0)
{
printf("CLIENT_PlayBackByTimeEx: failed! Error code: %x.\n", CLIENT_GetLastError());
}

// Implement playback controlling as needed


// Call the corresponding controlling interfaces of third party when call SDK playback controlling
interface because it is the third party library decoding.
// The example code is for reference because it is a control unit demo that cannot display the record
palyback and playback controlling at the same time.

// CLIENT_SlowPlayBack To slow play


/* Example code
if (FALSE == CLIENT_SlowPlayBack (g_lPlayHandle))
{
printf("CLIENT_SlowPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
// Call corresponding interface of third party library

*/

// CLIENT_FastPlayBack To fast play


/* Example code
if (FALSE == CLIENT_FastPlayBack (g_lPlayHandle))

46
{
printf("CLIENT_FastPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
// Call corresponding interface of third party library

*/

// CLIENT_NormalPlayBack To play at t normal speed


/* Example code
if (FALSE == CLIENT_NormalPlayBack (g_lPlayHandle))
{
printf("CLIENT_NormalPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
// Call corresponding interface of third party library

*/

// CLIENT_PausePlayBack To pause and resume play


/* Example code
if (FALSE == CLIENT_PausePlayBack (g_lPlayHandle, TRUE))
{
printf("CLIENT_PausePlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
// Call corresponding interface of third party library

*/

// CLIENT_SeekPlayBack To play by dragging


/* Example code
int nOffsetSeconds = 2 * 60 * 60; // Drag to 2*60*60s after stuStartTime to start play stuStartTime.
if (FALSE == CLIENT_SeekPlayBack (g_lPlayHandle, nOffsetSeconds, 0))
{
printf("CLIENT_SeekPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
// Call corresponding interface of third party library

47
*/
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Close playback
if (0 != g_lPlayHandle)
{
if (FALSE == CLIENT_StopPlayBack(g_lPlayHandle))
{
printf("CLIENT_StopPlayBack Failed, g_lRealHandle[%x]!Last Error[%x]\n" , g_lPlayHandle,
CLIENT_GetLastError());
}
else
{
g_lPlayHandle = 0;
}
}
// Log out of device
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}

48
int main()
{
InitTest();

RunTest();

EndTest();

return 0;
}

//*********************************************************************************
/ Commonly used callback function definition

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

49
void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD
dwDownLoadSize, LDWORD dwUser)
{
// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lPlayHandle.
if (lPlayHandle == g_lPlayHandle)
{
printf("lPlayHandle[%p]\n", lPlayHandle);
printf("dwTotalSize[%d]\n", dwTotalSize);
printf("dwDownLoadSize[%d]\n", dwDownLoadSize);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
}

int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD


dwBufSize, LDWORD dwUser)
{
int nRet = 0;
printf("call DataCallBack\n");
// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lRealHandle.
if(lRealHandle == g_lPlayHandle)
{
BOOL bSuccess = TRUE;
// The following print will result in screen brushing during playback and download. Take care.
printf("lPlayHandle[%p]\n", lRealHandle);
printf("dwDataType[%d]\n", dwDataType);
printf("pBuffer[%p]\n", pBuffer);
printf("dwBufSize[%d]\n", dwBufSize);
printf("dwUser[%p]\n", dwUser);
printf("\n");
switch(dwDataType)
{
case 0:
//Original data
// Uses can save bit stream data here, and do other operations after leaving callback such
as decoding and forwarding.
nRet = 1;//

50
break;
case 1:
//Standard video data

break;
case 2:
//yuv data

break;
case 3:
//pcm audio data

break;
case 4:
//Original audio data

break;
default:
break;
}
}
return nRet;
}

Record Download

2.5.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.
Record download have two methods: download by file and download by time.

2.5.2 Interface Overview


Table 2-5 Interfaces of record download

51
Interface Implication
CLIENT_Init Interface for SDK initialization.
CLIENT_Cleanup Interface for cleaning up SDK resources.
CLIENT_LoginWithHighLevelSecurity Login with high level security
Interface for setting work mode of device voice talk,
CLIENT_SetDeviceMode
playback and right
Interface for searching all files in a specified time
CLIENT_QueryRecordFile
period
CLIENT_FindFile Interface for opening record search handle
CLIENT_FindNextFile Interface for searching record file
CLIENT_FindClose Interface for closing record search handle
CLIENT_DownloadByRecordFileEx Extensive interface for downloading record by file
CLIENT_DownloadByTimeEx Extensive interface for downloading record by time
CLIENT_GetDownloadPos Interface for searching record download process
CLIENT_StopDownload Interface for stopping record download
CLIENT_Logout Interface for logout
Interface for getting error code after failed calling
CLIENT_GetLastError
interface.

2.5.3 Process
Record download includes the following two methods.

Download by file
Users need to point the downloaded record file’s information and SDK can download the
specified file and save it to a specified file. At the same time, user can also provide a callback
function pointer, so that SDK send the downloaded file info to users for further use by
callbackfunction.

Download by time
User will need to point the start time and end time of the download file, SDK can download the
specified file in a specified time period and save it to a specified [Link] the same time, user can
also provide a callback function pointer, so that SDK send the downloaded file info to users for
further use by callback function.

52
[Link] Download by File
Process of download by file

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set stream type for query


Query for all records CLIENT_SetDeviceMode
Query for the records
within a period at once within a period one by one

Get record query handle


CLIENT_QueryRecordFile
CLIENT_FindFile

Get one single record


CLIENT_FindNextFile

Close record query handle


CLIENT_FindClose

Download by file
CLIENT_DownloadByRecordFileEx

Query for record download


CLIENT_GetDownLoadPos

Stop download
CLIENT_StopDownload

Log out of device


CLIENT_Logout
Optional
Release SDK resource
CLIENT_Cleanup Mandatory

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.

53
Call CLIENT_SetDeviceMode to set the stream type, and set parameter emType as
DH_RECORD_STREAM_TYPE. It is recommend to set stream as 0-mian ans sub stream,
otherwise some devices might be unable to get results. If you only need main stream
recordings, you can filter sub stream recordings of results.
Query the record files by one of the following two ways:
⚫ Call CLIENT_FindFile to obtain the record query handle, and then call
CLIENT_FindNextFile several times to obtain the record file information and then
call CLIENT_FindClose to close the record query handle at last.
⚫ Call CLIENT_QueryRecordFile to obtain all the record files information for a
period one time.
After getting the record file information, call CLIENT_DownloadByRecordFileEx to
start downloading record files. At least one of the sSavedFileName and
fDownLoadDataCallBack should be valid.
During downloading, call CLIENT_GetDownloadPos to query the record downloading
progress.
Call CLIENT_StopDownload to stop download.
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.

54
[Link] Download by Time
Process of download by time

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set stream type for query


CLIENT_SetDeviceMode

Download by time
CLIENT_DownloadByTimeEx

Stop download
CLIENT_StopDownload

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_SetDeviceMode to set the stream type, and set parameter emType as
DH_RECORD_STREAM_TYPE.
Call CLIENT_DownloadByTimeEx to start downloading by time. At least one of the
sSavedFileName and fDownLoadDataCallBack should be valid.
Call CLIENT_StopDownload to stop download. You can close the download process
after it is completed or it is just partially completed.
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.

55
2.5.4 Example Code

[Link] Download by File


#include <windows.h>
#include <stdio.h>
#include <vector>
#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lDownloadHandle = 0L;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";
static const int g_nMaxRecordFileCount = 5000;
//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Playback/ download progress callback


// It is not recommended to call SDK interface in this function.
// dwDownLoadSize:-1 means playback/download finished,-2 means failed to write file,other value
means valid data
// Set this callback function in CLIENT_DownloadByRecordFileEx.When SDK receives
playback/downloaded data, SDK will call this function.

56
void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD
dwDownLoadSize, LDWORD dwUser);

// Playback/ download progress callback


// It is not recommended to call SDK interface in this function.
//Playback: return value:0 means this playback failed,next callback will return the same data, 1 means this
callback successful, next callback will return the following data
// Download: No matter what return from the callback function, it will be treated as callback is successful,
next callback will return the following data
// Set this callback function in CLIENT_DownloadByRecordFileEx.When SDK receives
playback/downloaded data, SDK will call this function.
int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD
dwBufSize, LDWORD dwUser);

//*********************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Get the SDK version information


// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

57
// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
while(0 == g_lLoginHandle)
{
// Log in to device
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if (0 == g_lLoginHandle)
{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,
g_nPort , CLIENT_GetLastError());
}

58
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}
// Recorded files search
// Set stream type of recordings
int nStreamType = 0; // 0-main and sub stream, 1-main stream, 2-sub stream
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_STREAM_TYPE, &nStreamType);

// There are two methods to search files:[Link] all record files in the specified time period once;
2,take all records in the specified time period in several times
// Here is the second method, and the first method can see CLIENT_QueryRecordFile interface.
int nChannelID = 0; // Channel number
NET_TIME stuStartTime = {0};
[Link] = 2015;
[Link] = 9;
[Link] = 20;

NET_TIME stuStopTime = {0};


[Link] = 2015;
[Link] = 9;
[Link] = 30;

59
int lFindHandle = CLIENT_FindFile(g_lLoginHandle, nChannelID, 0, NULL, &stuStartTime,
&stuStopTime, FALSE, 5000);
if (0 == lFindHandle)
{
printf("CLIENT_FindFile Failed!Last Error[%x]\n",CLIENT_GetLastError());
return;
}
// Example code of demo which takes max supported g_nMaxRecordFileCountrecorded files as an
example.
std::vector<NET_RECORDFILE_INFO> bufFileInfo(g_nMaxRecordFileCount);

for (int nFileIndex = 0; nFileIndex < g_nMaxRecordFileCount; ++nFileIndex)


{
int result = CLIENT_FindNextFile(lFindHandle, &bufFileInfo[nFileIndex]);
if (0 == result)// Finish taking recorded files info
{
break;
}
else if (1 != result)// Parameter error
{
printf("CLIENT_FindNextFile Failed!Last Error[%x]\n",CLIENT_GetLastError());
break;
}
}

// Stop searching
if(0 != lFindHandle)
{
CLIENT_FindClose(lFindHandle);
}
// Set the first searched file as download file
NET_RECORDFILE_INFO stuNetFileInfo;
if (nFileIndex > 0)
{
memcpy(&stuNetFileInfo, (void *)&bufFileInfo[0], sizeof(stuNetFileInfo));
}
else
{
printf("no record, return\n");
return;

60
}

// Recorded file download


// Start recordings download
// At least one of the function parameters sSavedFileName and fDownLoadDataCallBack shold be
valid.
// In pratical, save directly to sSavedFileName or call back to process data ass needed.
g_lDownloadHandle = CLIENT_DownloadByRecordFileEx(g_lLoginHandle, &stuNetFileInfo,
"[Link]", DownLoadPosCallBack, NULL, DataCallBack, NULL);
if (0 == g_lDownloadHandle)
{
printf("CLIENT_DownloadByRecordFileEx: failed! Error code: %x.\n", CLIENT_GetLastError());
}
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Stop download, users can call this interface after download ends or during download.
if (0 != g_lDownloadHandle)
{
if (FALSE == CLIENT_StopDownload(g_lDownloadHandle))
{
printf("CLIENT_StopDownload Failed, g_lDownloadHandle[%x]!Last Error[%x]\n" ,
g_lDownloadHandle, CLIENT_GetLastError());
}
else
{
g_lDownloadHandle = 0;
}
}
// Log out of device
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else

61
{
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}

return;
}

int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}

//*********************************************************************************
// Commonly used callback function definition

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{

62
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD


dwDownLoadSize, LDWORD dwUser)
{
// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lPlayHandle.
if (lPlayHandle == g_lDownloadHandle)
{
printf("lPlayHandle[%p]\n", lPlayHandle);
printf("dwTotalSize[%d]\n", dwTotalSize);
printf("dwDownLoadSize[%d]\n", dwDownLoadSize);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
}

int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD


dwBufSize, LDWORD dwUser)
{
int nRet = 0;
printf("call DataCallBack\n");
// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lPlayHandle.
if(lRealHandle == g_lDownloadHandle)
{
printf("lPlayHandle[%p]\n", lRealHandle);
printf("dwDataType[%d]\n", dwDataType);
printf("pBuffer[%p]\n", pBuffer);
printf("dwBufSize[%d]\n", dwBufSize);
printf("dwUser[%p]\n", dwUser);

63
printf("\n");
switch(dwDataType)
{
case 0:
//Original data
// Users can save stream data here for further process such as decoding and transferring
after getting out of callback function.
nRet = 1;

break;
case 1:
//Standard video data

break;
case 2:
//yuv data

break;
case 3:
//pcm audio data

break;
case 4:
//Original audio data

break;
default:
break;
}
}
return nRet;
}

[Link] Download by Time


#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

64
static BOOL g_bNetSDKInitFlag = FALSE;
static LLONG g_lLoginHandle = 0L;
static LLONG g_lDownloadHandle = 0L;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";

//*********************************************************************************
// Commonly used callback set definition.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Playback by time progress callback function


// It is not recommended to call SDK interfaces in this callback function.
// dwDownLoadSize:-1 means playback/download finished, -2 means failed to write file, other value
means valid data.
// Set this callback function in CLIENT_DownloadByTimeEx.When SDK receives playback/downloaded
data, SDK will call this function.
void CALLBACK TimeDownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD
dwDownLoadSize, int index, NET_RECORDFILE_INFO recordfileinfo, LDWORD dwUser);

// Playback/download data callback function


// It is not recommended to call SDK interfaces in this callback function.
// Playback: return value:0 means this playback failed, next callback will return the same data, 1 means
this callback successful, next callback will return the following data.
// Download: No matter what return from the callback function, it will be treated as callback is successful,
next callback will return the following data.
// Set this callback function in CLIENT_DownloadByTimeEx.When SDK receives playback/downloaded
data, SDK will call this function.

65
int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD
dwBufSize, LDWORD dwUser);

//*********************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Get the SDK version information


// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

66
[Link] = 3000; // The timeout of connection when login.
CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
while(0 == g_lLoginHandle)
{
// Log in to device
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The corresponding
error code is 0x80000017, and the corresponding hexadecimal is 0x17.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,
g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}
}

67
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}
// Recorded files search
// Set stream type of recordings
int nStreamType = 0; // 0-main and sub stream, 1-main stream, 2-sub stream
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_STREAM_TYPE, &nStreamType);

int nChannelID = 0; // channel number


NET_TIME stuStartTime = {0};
[Link] = 2015;
[Link] = 9;
[Link] = 17;

NET_TIME stuStopTime = {0};


[Link] = 2015;
[Link] = 9;
[Link] = 18;

// Implement record download

// Start recordings download


// At least one of the function parameters sSavedFileName and fDownLoadDataCallBack shold be
valid.
g_lDownloadHandle = CLIENT_DownloadByTimeEx(g_lLoginHandle, nChannelID,
EM_RECORD_TYPE_ALL, &stuStartTime, &stuStopTime, "[Link]", TimeDownLoadPosCallBack, NULL,
DataCallBack, NULL);
if (g_lDownloadHandle == 0)
{
printf("CLIENT_DownloadByTimeEx: failed! Error code: %x.\n", CLIENT_GetLastError());
}
}

68
void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Stop download, users can call this interface after download ends or during download.
if (0 != g_lDownloadHandle)
{
if (FALSE == CLIENT_StopDownload(g_lDownloadHandle))
{
printf("CLIENT_StopDownload Failed, g_lDownloadHandle[%x]!Last Error[%x]\n" ,
g_lDownloadHandle, CLIENT_GetLastError());
}
else
{
g_lDownloadHandle = 0;
}
}
// Log out of device
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}

int main()

69
{
InitTest();
RunTest();
EndTest();
return 0;
}

//*********************************************************************************
// Commonly used callback function definition

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK TimeDownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD


dwDownLoadSize, int index, NET_RECORDFILE_INFO recordfileinfo, LDWORD dwUser)
{

70
// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lPlayHandle.
if (lPlayHandle == g_lDownloadHandle)
{
printf("lPlayHandle[%p]\n", lPlayHandle);
printf("dwTotalSize[%d]\n", dwTotalSize);
printf("dwDownLoadSize[%d]\n", dwDownLoadSize);
printf("index[%d]\n", index);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
}

int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD


dwBufSize, LDWORD dwUser)
{
int nRet = 0;
printf("call DataCallBack\n");
// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lPlayHandle.
if(lRealHandle == g_lDownloadHandle)
{
printf("lPlayHandle[%p]\n", lRealHandle);
printf("dwDataType[%d]\n", dwDataType);
printf("pBuffer[%p]\n", pBuffer);
printf("dwBufSize[%d]\n", dwBufSize);
printf("dwUser[%p]\n", dwUser);
printf("\n");
switch(dwDataType)
{
case 0:
//Original data
// Users can save stream data here for further process such as decoding and transferring
after getting out of callback function.
nRet = 1;//

break;
case 1:
//Standard video data

71
break;
case 2:
//yuv data

break;
case 3:
//pcm audio data

break;
case 4:
//Original audio data

break;
default:
break;
}
}
return nRet;
}

Real-Time Monitoring Transcoding

2.6.1 Introduction
Real-time monitoring transcoding involves getting live videos from storage devices or front-end
devices and transcoding the videos into the stream type that you need. The supported stream
types include:
⚫ GB program stream.
⚫ Transport streams.
⚫ MP4 format.
⚫ H.264 and H.265.
⚫ Program streams.
⚫ RTP streams.

2.6.2 Interface Overview


Table 2-6 Interfaces of real-time monitoring
Interface Implication
CLIENT_Init SDK initialization.
CLIENT_Cleanup SDK cleaning up.

72
Interface Implication
Log in with high level security.

CLIENT_LoginEx2 can still be used, but there are


CLIENT_LoginWithHighLevelSecurity
security risks, so it is highly recommended to use the
interface CLIENT_LoginWithHighLevelSecurity to log in
to the device.
CLIENT_RealPlayByDataType Start real-time monitoring transcoding interface.
CLIENT_StopRealPlayEx Stop live view extension interface.
CLIENT_Logout Log out of the interface.
CLIENT_GetLastError Get error codes of interfaces that fail to be called.

2.6.3 Process
The process of real-time monitoring transcoding is shown as below.
Process of real-time monitoring transcoding

Start

Initialize SDK

Log in to device
CLIENT_LoginWithHighLevelSecurity

Start real-time monitoring transcoding Set callback function


CLIENT_RealPlayByDataType fRealDataCallBackEx

Stop real-time live video


CLIENT_StopRealPlayEx

Log out of device


CLIENT_Logout

Release SDK resorces


CLIENT_Cleanup

Stop

Process Description
Complete SDK initialization.
After successful initialization, call CLIENT_LoginWithHighLevelSecurity to log in to the
device.

73
Call CLIENT_RealPlayByDataType to start real-time monitoring. The parameter hWnd
can be set to null.
Set the real-time data callback function fRealDataCallBackEx to save the transcoded
data.
After using the real-time monitoring transcoding, call CLIENT_StopRealPlayEx to stop
it.
After using the service, call CLIENT_Logout to log out of the device.
After using SDK, call CLIENT_Cleanup to release SDK resources.

2.6.4 Example Code


#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

extern "C" HWND WINAPI GetConsoleWindow();

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lRealHandle = 0;
static char g_szDevIp[32] = "[Link] ";
static WORD g_nPort = 37777; // The TCP port for connections must match the TCP port
configured on the device login page.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";

//*********************************************************************************
// (Collective declaration of) Common callback functions

// Callback function for device disconnection


// We recommend you not call SDK interface under this callback function.
// Set the callback function through CLIENT_Init. When the device is disconnected, SDK will call
the function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD
dwUser);

// Callback function for device auto reconnection.


// We recommend you not call SDK interface under this callback function.
// Set the callback function through CLIENT_SetAutoReconnect. When the device is reconnected,
SDK will call the function.

74
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD
dwUser);

// Set this callback function through CLIENT_RealPlayByDataType. The SDK will call this function
when receiving playback data from the device.
int CALLBACK OnDataCallBackEx(LLONG lRealHandle, NET_DATA_CALL_BACK_INFO
*pDataCallBack, LDWORD dwUser);
//*********************************************************************************
void InitTest()
{
// Initialize SDK.
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Get SDK version information.


// This operation is optional.
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set the reconnection callback interface. After the reconnection callback is successfully set,
when the device is disconnected, the SDK will automatically reconnect it.
// This operation is optional, but it is recommended to set it.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set login timeout duration and number of attempts.


// This operation is optional.
int nWaitTime = 5000; // Set the timeout duration of response to login request to 5
seconds.
int nTryTimes = 3; // Set the login attempts to 3.
CLIENT_SetConnectTime(nWaitTime, nTryTimes);

75
// Set more network parameters. The nWaittime and nConnectTryNum members of
NET_PARAM have the same meaning as the login device timeout and number of attempts set
by the CLIENT_SetConnectTime interface.
// This operation is optional.
NET_PARAM stuNetParm = {0};
[Link] = 3000; // The timeout period for trying to establish a link upon
login.
CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], g_szDevIp, sizeof([Link]) - 1);
strncpy([Link], g_szPasswd, sizeof([Link]) - 1);
strncpy([Link], g_szUserName, sizeof([Link]) - 1);
[Link] = g_nPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)
{
// Log in to the device
g_lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{
// Find corresponding explanation from dhnetsdk.h based on the error code. Note
the transfer between the hexadecimal format in printing and the decimal format in header file.
// For example,
// #define NET_NOT_SUPPORTED_EC(23) // The current SDK does not support this
function. The corresponding error code is 0x80000017, or 0x17 in hexadecimal format.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" ,
g_szDevIp , g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp ,
g_nPort);

76
}
// When users first log in to the device, the device needs to initialize some data before
functions can be realized. We recommend you wait for a while after logging in. The actual
waiting time depends on the device.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
// Determine whether initialization is successful.
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
// Determine whether the device is logged in.
if (0 == g_lLoginHandle)
{
return;
}

// Enable real-time monitoring transcoding.


NET_IN_REALPLAY_BY_DATA_TYPE stIn = {sizeof(stIn)};
NET_OUT_REALPLAY_BY_DATA_TYPE stOut = {sizeof(stOut)};
[Link] = EM_REAL_DATA_TYPE_H264;
[Link] = DH_RType_Realplay;
[Link] = 0;
[Link] = NULL;
[Link] = NULL;
stIn.cbRealDataEx2 = OnDataCallBackEx;

g_lRealHandle = CLIENT_RealPlayByDataType(g_lLoginHandle, &stIn, &stOut, 5000);


if (0 == g_lRealHandle)
{
printf("CLIENT_RealPlayByDataType: failed! Error code: %x.\n", CLIENT_GetLastError());
}
}

void EndTest()

77
{
printf("input any key to quit!\n");
getchar();
// Disable live video.
if (0 != g_lRealHandle)
{
if(FALSE == CLIENT_StopRealPlayEx(g_lRealHandle))
{
printf("CLIENT_StopRealPlayEx Failed!Last Error[%x]\n" , CLIENT_GetLastError());
}
else
{
g_lRealHandle = 0;
}
}
// Log out of the device.
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean initialization resources.
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
}

int main()
{
InitTest();
RunTest();
EndTest();

78
return 0;
}

//*********************************************************************************
// Common callback set definition
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD
dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD


dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

int CALLBACK OnDataCallBackEx(LLONG lRealHandle, NET_DATA_CALL_BACK_INFO


*pDataCallBack, LDWORD dwUser)
{
if(pDataCallBack->dwDataType == (NET_DATA_CALL_BACK_VALUE +
EM_REAL_DATA_TYPE_H264))
{
printf("Frame Type subType=%d\n",pDataCallBack->emFramSubType);

79
if ( pDataCallBack->emFramSubType != 4 && pDataCallBack->emFramSubType != 11
&& pDataCallBack->emFramSubType != 15)
{
SYSTEMTIME tm;
GetLocalTime(&tm);
static SYSTEMTIME oldTime = tm;

char buffer[4096] = {0};


sprintf( buffer, "Frame Type:%02d
LocalTime:%04d-%02d-%02d %02d:%02d:%02d %03d
DevTime:%04d-%02d-%02d %02d:%02d:%02d %d\n", pDataCallBack->emFramSubType,

[Link],[Link],[Link],[Link],[Link],[Link],[Link],
pDataCallBack->[Link],
pDataCallBack->[Link],pDataCallBack->[Link],pDataCallBack->stuTime.d
wHour,pDataCallBack->[Link],pDataCallBack->[Link],
pDataCallBack->[Link]);

oldTime = tm;
}
}
return 0;
}

Record Playback Transcoding

2.7.1 Introduction
Record playback transcoding refers to remotely playing videos from a specific time period on
the client, searching for the needed videos, and transcoding them into the stream type that you
need.
⚫ GB program stream.
⚫ Transport streams.
⚫ MP4 format.
⚫ H.264 and H.265.
⚫ Program streams.
⚫ RTP streams.

80
2.7.2 Interface Overview
Table 2-7 Interfaces of real-time monitoring
Interface Implication
CLIENT_Init SDK initialization.
CLIENT_Cleanup SDK cleaning up.
Log in with high level security.

CLIENT_LoginEx2 can still be used, but there are


CLIENT_LoginWithHighLevelSecurity
security risks, so it is highly recommended to use the
interface CLIENT_LoginWithHighLevelSecurity to log in
to the device.
CLIENT_PlayBackByDataType Start record playback transcoding interface.
CLIENT_StopPlayBack Stop record playback interface
CLIENT_Logout Log out of the interface.
CLIENT_GetLastError Get error codes of interfaces that fail to be called.

2.7.3 Process
The process of real-time monitoring transcoding is shown as below.
Process of record playback transcoding

Start

Initialize SDK

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set callback function


Start video playback transcoding fDataCallBack
CLIENT_PlayBackByDataType fDataCallBackEx
fDownLoadPosCallBack
Stop real-time live video
CLIENT_StopPlayBack

Log out of device


CLIENT_Logout

Release SDK resources


CLIENT_Cleanup

Stop

81
Process
Complete SDK initialization.
After successful initialization, call CLIENT_LoginWithHighLevelSecurity to log in to the
device.
Call CLIENT_PlayBackByDataType to start downloading videos. The parameter hWnd
can be set to null.
Set the video playback data callback functions fDataCallBackEx and fDataCallBack, and
the video playback process callback function fDownLoadPosCallBack to save the
transcoded data.
After using the record playback transcoding, call CLIENT_StopPlayBack to stop it.
After using the function module, call CLIENT_Logout to log out of the device.
After using SDK, call CLIENT_Cleanup to release SDK resources.

2.7.4 Example Code


#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"
#pragma comment(lib , "[Link]")

extern "C" HWND WINAPI GetConsoleWindow();

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lPlayHandle = 0L;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // The TCP port for connections must match the TCP port
configured on the device login page.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";

//*********************************************************************************
// (Collective declaration of) Common callback functions

// Callback function for device disconnection


// We recommend you not call SDK interface under this callback function.
// Set the callback function through CLIENT_Init. When the device is disconnected, SDK will call
the function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD
dwUser);

82
// Callback function for device auto reconnection.
// We recommend you not call SDK interface under this callback function.
// Set the callback function through CLIENT_SetAutoReconnect. When the device is reconnected,
SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD
dwUser);

// Playback process callback function prototype.


void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD
dwDownLoadSize, LDWORD dwUser);

// Video playback data callback function prototype.


int CALLBACK PlayBackDataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer,
DWORD dwBufSize, LDWORD dwUser);

// Video playback data callback function prototype (extended).


int CALLBACK DataCallBackEx(LLONG lRealHandle, NET_DATA_CALL_BACK_INFO
*pDataCallBack, LDWORD dwUser);
//*********************************************************************************
void InitTest()
{
// Initialize SDK.
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}
// Get SDK version information.
// This operation is optional.
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set the reconnection callback interface. After the reconnection callback is successfully set,
when the device is disconnected, the SDK will automatically reconnect it.
// This operation is optional, but it is recommended to set it.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

83
// Set login timeout duration and number of attempts.
// This operation is optional.
int nWaitTime = 5000; // Set the timeout duration of response to login request to 5
seconds.
int nTryTimes = 3; // Set the login attempts to 3.
CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum members of


NET_PARAM have the same meaning as the login device timeout and number of attempts set
by the CLIENT_SetConnectTime interface.
// This operation is optional.
NET_PARAM stuNetParm = {0};
[Link] = 3000; // The timeout period for trying to establish a link upon
login.
CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], g_szDevIp, sizeof([Link]) - 1);
strncpy([Link], g_szPasswd, sizeof([Link]) - 1);
strncpy([Link], g_szUserName, sizeof([Link]) - 1);
[Link] = g_nPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)
{
// Log in to the device
g_lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{
// Find corresponding explanation from dhnetsdk.h based on the error code. Note
the transfer between the hexadecimal format in printing and the decimal format in header file.
// For example,

84
// #define NET_NOT_SUPPORTED_EC(23) // The current SDK does not support this
function. The corresponding error code is 0x80000017, or 0x17 in hexadecimal format.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" ,
g_szDevIp , g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp ,
g_nPort);
}
// When users first log in to the device, the device needs to initialize some data before
functions can be realized. We recommend you wait for a while after logging in. The actual
waiting time depends on the device.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}

NET_IN_PLAYBACK_BY_DATA_TYPE stuIn = {sizeof(stuIn)};


[Link] = 0;
[Link] = EM_REAL_DATA_TYPE_MP4;
[Link] = EM_AUDIO_DATA_TYPE_G711A;
[Link] = 0;
[Link] = DownLoadPosCallBack;
[Link] = PlayBackDataCallBack;
[Link] = DataCallBackEx;
[Link] = NULL;
[Link] = 2023;

85
[Link] = 2;
[Link] = 1;
[Link] = 11;
[Link] = 10;
[Link] = 12;

[Link] = 2023;
[Link] = 2;
[Link] = 1;
[Link] = 11;
[Link] = 11;
[Link] = 12;

NET_OUT_PLAYBACK_BY_DATA_TYPE stuOut = {sizeof(stuOut)};

g_lPlayHandle = CLIENT_PlayBackByDataType(g_lLoginHandle, &stuIn, &stuOut, 5000);


if (0 == g_lPlayHandle)
{
printf("CLIENT_PlayBackByDataType fail,error:%X\n", CLIENT_GetLastError());
}
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Close playback.
if (0 != g_lPlayHandle)
{
if (FALSE == CLIENT_StopPlayBack(g_lPlayHandle))
{
printf("CLIENT_StopPlayBack Failed, g_lRealHandle[%x]!Last Error[%x]\n" ,
g_lPlayHandle, CLIENT_GetLastError());
}
else
{
g_lPlayHandle = 0;
}
}
// Log out of the device.

86
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean initialization resources.
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}

int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}

//*********************************************************************************
// Common callback set definition

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD


dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}

87
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD


dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD


dwDownLoadSize, LDWORD dwUser)
{
printf("DownLoad Progress:%d/%d\n", dwDownLoadSize, dwTotalSize);
}

int CALLBACK PlayBackDataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer,


DWORD dwBufSize, LDWORD dwUser)
{
printf("dwDataType:%d, dwBufSize:%d\n", dwDataType, dwBufSize);

return 0;
}

int CALLBACK DataCallBackEx(LLONG lRealHandle, NET_DATA_CALL_BACK_INFO


*pDataCallBack, LDWORD dwUser)
{
NET_DATA_CALL_BACK_INFO stuDataCallBack = *pDataCallBack;

printf("DataCallBackEx:dwDataType:%d, dwBufSize:%d, emFramType:%d\n",


[Link], [Link], [Link]);

88
return 0;
}

Record Download Transcoding

2.8.1 Introduction
The record download function helps you obtain the records saved on the storage device
through SDK and save into the local. It allows you to download records of different stream types
from the selected channels and export to the local disk or external USB flash drive.
⚫ GB program stream.
⚫ Transport streams.
⚫ MP4 format.
⚫ H.264 and H.265.
⚫ Program streams.
⚫ RTP streams.

2.8.2 Interface Overview


Table 2-8 Interfaces of real-time monitoring
Interface Implication
CLIENT_Init SDK initialization.
CLIENT_Cleanup SDK cleaning up.
Log in with high level security.

CLIENT_LoginEx2 can still be used, but there are


CLIENT_LoginWithHighLevelSecurity
security risks, so it is highly recommended to use the
interface CLIENT_LoginWithHighLevelSecurity to log in
to the device.
CLIENT_DownloadByDataType Start record download transcoding interface.
CLIENT_StopDownload Stop record download interface.
CLIENT_Logout Log out of the interface.
CLIENT_GetLastError Get error codes of interfaces that fail to be called.

2.8.3 Process
The process of real-time monitoring transcoding is shown as below.

89
Process of record playback transcoding

Start

Initialize SDK

Log in to device
CLIENT_LoginWithHighLevelSecurity

Start video download transcoding Set callback function


CLIENT_DownloadByDataType fTimeDownloadPosCallBack
fDataCallBack

Stop real-time live video


CLIENT_StopDownload

Log out of device


CLIENT_Logout

Release SDK resources


CLIENT_Cleanup

Stop

Process
Complete SDK initialization.
After successful initialization, call CLIENT_LoginWithHighLevelSecurity to log in to the
device.
Call CLIENT_DownloadByDataType to start record download transcoding. The
parameter hWnd can be set as null.
Set the video download process callback function fTimeDownloadPosCallBack, and the
video download data callback function fDataCallBackEx to save the transcoded data.
After using the record download transcoding, call CLIENT_StopDownload to stop it.
After using the function module, call CLIENT_Logout to log out of the device.
After using SDK, call CLIENT_Cleanup to release SDK resources.

2.8.4 Example Code


#include <windows.h>
#include <stdio.h>
#include <vector>
#include "dhnetsdk.h"

90
#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static LLONG g_lDownloadHandle = 0L;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // The TCP port for connections must match the TCP port
configured on the device login page.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";
static const int g_nMaxRecordFileCount = 5000;
char g_szFileName[260] = {0};
//*********************************************************************************
// (Collective declaration of) Common callback functions

// Callback function for device disconnection


// We recommend you not call SDK interface under this callback function.
// Set the callback function through CLIENT_Init. When the device is disconnected, SDK will call
the function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD
dwUser);

// Callback function for device auto reconnection.


// We recommend you not call SDK interface under this callback function.
// Set the callback function through CLIENT_SetAutoReconnect. When the device is reconnected,
SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD
dwUser);

// Callback function for playback or download progress.


// We recommend you not call SDK interface under this callback function.
// dwDownLoadSize: -1 indicates that the playback or download is finished. -2 indicates that the
file writing failed, and other values indicate valid data.
// Set the callback function through CLIENT_DownloadByDataType. When the SDK receives the
download data, the SDK will call this function.
void CALLBACK TimeDownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD
dwDownLoadSize, int index, NET_RECORDFILE_INFO recordfileinfo, LDWORD dwUser);

// Callback function for playback or download data.


// We recommend you not call SDK interface under this callback function.

91
// During playback, returning 0 indicates that the current callback failed, and the next callback
will return the same data. Returning 1 indicates that the current callback succeeded, and the
next callback will return subsequent data.
// During downloads, callbacks are treated as successful regardless of their return value, and the
next callback will return the subsequent data.
// Set the callback function through CLIENT_DownloadByDataType. When the SDK receives the
download data, the SDK will call this function.
int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD
dwBufSize, LDWORD dwUser);

//*********************************************************************************
void InitTest()
{
// Initialize SDK.
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}

// Get SDK version information.


// This operation is optional.
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set the reconnection callback interface. After the reconnection callback is successfully set,
when the device is disconnected, the SDK will automatically reconnect it.
// This operation is optional, but it is recommended to set it.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set login timeout duration and number of attempts.


// This operation is optional.
int nWaitTime = 5000; // Set the timeout duration of response to login request to 5
seconds.

92
int nTryTimes = 3; // Set the login attempts to 3.
CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum members of


NET_PARAM have the same meaning as the login device timeout and number of attempts set
by the CLIENT_SetConnectTime interface.
// This operation is optional.
NET_PARAM stuNetParm = {0};
[Link] = 3000; // The timeout period for trying to establish a link upon
login.
CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], g_szDevIp, sizeof([Link]) - 1);
strncpy([Link], g_szPasswd, sizeof([Link]) - 1);
strncpy([Link], g_szUserName, sizeof([Link]) - 1);
[Link] = g_nPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)
{
// Log in to the device
g_lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if (0 == g_lLoginHandle)
{
// Find corresponding explanation from dhnetsdk.h based on the error code. Note
the transfer between the hexadecimal format in printing and the decimal format in header file.
// For example,
// #define NET_NOT_SUPPORTED_EC(23) // The current SDK does not support this
function. The corresponding error code is 0x80000017, or 0x17 in hexadecimal format.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" ,
g_szDevIp , g_nPort , CLIENT_GetLastError());
}
else

93
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp ,
g_nPort);
}
// When users first log in to the device, the device needs to initialize some data before
functions can be realized. We recommend you wait for a while after logging in. The actual
waiting time depends on the device.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}
// Video file search
// Set the video stream type for search.
int nStreamType = 0; // 0: Main and sub stream, 1: main stream, 2: sub stream.
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_STREAM_TYPE, &nStreamType);

// Start downloading video.


// One of the function variables of sSavedFileName and fDownLoadDataCallBack must be
valid.
// In actual applications, you usually choose to save directly to sSavedFileName or call back
to process the data based on your needs.
NET_IN_DOWNLOAD_BY_DATA_TYPE stuIn = {sizeof(stuIn)};
[Link] = 0;
[Link] = EM_REAL_DATA_TYPE_MP4;
[Link] = EM_AUDIO_DATA_TYPE_G711A;
[Link] = TimeDownLoadPosCallBack;
[Link] = DataCallBack;
[Link] = NULL;

94
[Link] = 2023;
[Link] = 2;
[Link] = 1;
[Link] = 11;
[Link] = 10;
[Link] = 12;

[Link] = 2023;
[Link] = 2;
[Link] = 1;
[Link] = 11;
[Link] = 11;
[Link] = 12;

strncpy(g_szFileName, "D:\\file.mp4", sizeof(g_szFileName) - 1);


[Link] = g_szFileName;

NET_OUT_DOWNLOAD_BY_DATA_TYPE stuOut = {sizeof(stuOut)};


g_lDownloadHandle = CLIENT_DownloadByDataType(g_lLoginHandle, &stuIn, &stuOut,
5000);
if (0 == g_lDownloadHandle)
{
printf("CLIENT_DownloadByDataType fail,error:%X\n", CLIENT_GetLastError());
}
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();
// Stop downloading, call either during or at the end of download.
if (0 != g_lDownloadHandle)
{
if (FALSE == CLIENT_StopDownload(g_lDownloadHandle))
{
printf("CLIENT_StopDownload Failed, g_lDownloadHandle[%x]!Last Error[%x]\n" ,
g_lDownloadHandle, CLIENT_GetLastError());
}
else
{

95
g_lDownloadHandle = 0;
}
}
// Log out of the device.
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean initialization resources.
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}

return;
}

int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}

//*********************************************************************************
// Common callback set definition

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD


dwUser)
{
printf("Call DisConnectFunc\n");

96
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD


dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK TimeDownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD


dwDownLoadSize, int index, NET_RECORDFILE_INFO recordfileinfo, LDWORD dwUser)
{
// If multiple playbacks or downloads use the same progress callback function, users can
use lPlayHandle to map them one to one.
if (lPlayHandle == g_lDownloadHandle)
{
printf("TimeDownLoad Progress:%d/%d\n", dwDownLoadSize, dwTotalSize);
}
}

int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD


dwBufSize, LDWORD dwUser)
{
int nRet = 0;
printf("call DataCallBack\n");

97
// If multiple playbacks or downloads use the same data callback function, users can use
lRealHandle to map them one to one.
if(lRealHandle == g_lDownloadHandle)
{
printf("lPlayHandle[%p]\n", lRealHandle);
printf("dwDataType[%d]\n", dwDataType);
printf("pBuffer[%p]\n", pBuffer);
printf("dwBufSize[%d]\n", dwBufSize);
printf("dwUser[%p]\n", dwUser);
printf("\n");
switch(dwDataType)
{
case 0:
//Original data
// Users save the stream data here and perform a series of processing such as
decoding or forwarding after leaving the callback function
nRet = 1;

break;
case 1:
//Standard video data

break;
case 2:
//yuv data

break;
case 3:
//pcm audio data

break;
case 4:
//Original audio data

break;
default:
break;
}
}
return nRet;

98
}

PTZ Control

2.9.1 Introduction
PTZ is a mechanical platform which carries camera device and protective cover can remote
monitor and control in all [Link] is made of two motors and capable for horizontal and
vertical motion, therefore it can provide omnibearing and multi-angle viewing for video camere.
PTZ control is an important part of a surveillance [Link] have different demands for
suiveillance in different application [Link] example, users may want to track the surveillance
screen in a normal application [Link] can control PTZ device via SDK, such as move
up/down/left/right, focus, zoom in/out, point-to-point tour and 3D positioning.

2.9.2 INTERFACE OVERVIEW


Table 2-9 Interfaces of PTZ control
Interface Implication
CLIENT_Init Interface for SDK initialization.
CLIENT_Cleanup Interface for cleaning up SDK resources.
CLIENT_LoginWithHighLevelSecurity Login with high level security.
CLIENT_ParseData Interface for analyzing the obtained config info.
CLIENT_DHPTZControlEx2 Extensive interface for private PTZ control.
CLIENT_QueryNewSystemInfo Interface for obtaining new system capacity set.
CLIENT_Logout Interface for logout device.
Interface for getting error code after failed calling
CLIENT_GetLastError
interface.

99
2.9.3 Process
Process of PTZ control

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Get PTZ capacity set


CLIENT_QueryNewSystemInfo

Analyze obtained json data


CLIENT_ParseData

Control PTZ
CLIENT_DHPTZControlEx2

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
After successfully login, call CLIENT_QueryNewSystemInfo and obtain PTZ capacity
set by CFG_CAP_CMD_PTZ; and then call CLIENT_ParseData and analyze PTZ capacity
set by CFG_CAP_CMD_PTZ.
Call CLIENT_DHPTZControlEx2 as needed to operate PTZ. Different PTZ command
may requires different parameters.,and some commands may require corresponding
stopping command, such as left/right movement. For details, see example code.
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.

2.9.4 Example Code


#include <windows.h>

100
#include <stdio.h>

#include <vector>

#include <string>

#include "dhnetsdk.h"

#include "dhconfigsdk.h"

#pragma comment(lib , "[Link]")

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;

static LLONG g_lLoginHandle = 0L;

static LLONG g_lDownloadHandle = 0L;

static char g_szDevIp[32] = "[Link]";

static int g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port of
expected login device.

static char g_szUserName[64] = "admin";

static char g_szPasswd[64] = "admin";

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

//**********************************************************************************************

void InitTest()

// SDK initialization

101
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);

if (FALSE == g_bNetSDKInitFlag)

printf("Initialize client SDK fail; \n");

return;

else

printf("Initialize client SDK done; \n");

}
// Get the SDK version information
// Optional operation

DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();

printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.

CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.

CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;

memset(&stInparam, 0, sizeof(stInparam));

[Link] = sizeof(stInparam);

102
strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

[Link] = sPort;

[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;

memset(&stOutparam, 0, sizeof(stOutparam));

[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)

// Log in to device

LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)

{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:

// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The


corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.

printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,


g_nPort , CLIENT_GetLastError());

else

printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);

}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.

Sleep(1000);

printf("\n");

// Ptz control info structure

typedef struct tagPtzControlInfo

103
{

tagPtzControlInfo():m_iCmd(-1), m_bStopFlag(false){}

tagPtzControlInfo(int iCmd, const std::string& sDescription, bool bStopFlag):m_iCmd(iCmd),


m_sDescription(sDescription), m_bStopFlag(bStopFlag){}

int m_iCmd;

std::string m_sDescription;

bool m_bStopFlag; // Parial Ptz operation. Call corresponding stop operations after start.

}PtzControlInfo;

// Get int input

int GetIntInput(char *szPromt, int& nError);

void RunTest()

if (FALSE == g_bNetSDKInitFlag)

return;

if (0 == g_lLoginHandle)

return;

// Get PTZ capacity set

char szBuffer[2048] = "";

int nError = 0;

if (FALSE == CLIENT_QueryNewSystemInfo(g_lLoginHandle, CFG_CAP_CMD_PTZ, 0, szBuffer,


(DWORD)sizeof(szBuffer), &nError))

printf("CLIENT_QueryNewSystemInfo Failed, cmd[CFG_CAP_CMD_PTZ], Last Error[%x]\n" ,


CLIENT_GetLastError());

return;

104
CFG_PTZ_PROTOCOL_CAPS_INFO stuPtzCapsInfo = {sizeof(CFG_PTZ_PROTOCOL_CAPS_INFO)};

if (FALSE == CLIENT_ParseData(CFG_CAP_CMD_PTZ, szBuffer, &stuPtzCapsInfo,


sizeof(stuPtzCapsInfo), NULL))

printf("CLIENT_ParseData Failed, cmd[CFG_CAP_CMD_PTZ], Last Error[%x]\n" ,


CLIENT_GetLastError());

return;

// PTZ operation

std::vector<PtzControlInfo> vecPtzControl;

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_UP_CONTROL), "up", true));

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_DOWN_CONTROL), "down", true));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_LEFT_CONTROL), "left", true));

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_RIGHT_CONTROL), "right", true));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_ZOOM_ADD_CONTROL), " zoom +", true));

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_ZOOM_DEC_CONTROL), " zoom -", true));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_FOCUS_ADD_CONTROL), "focus +", true));

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_FOCUS_DEC_CONTROL), "focus -", true));

105
if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_APERTURE_ADD_CONTROL), " aperture +",


true));

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_APERTURE_DEC_CONTROL), " aperture -",


true));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_MOVE_CONTROL), " go to preset",


false));

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_SET_CONTROL), " set preset ",


false));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_DEL_CONTROL), " delete preset ",


false));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_LOOP_CONTROL), "scan", false));

vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_ADDTOLOOP), " add preset to tour ",


false));

vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_DELFROMLOOP), " delete preset in


tour ", false));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_CLOSELOOP), "clear tour", false));

106
if (TRUE == [Link] && TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_LEFTTOP), "left up",


vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_RIGHTTOP), "right up",
vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_LEFTDOWN), "left down",

vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_RIGHTDOWN), "right down", true));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_FASTGOTO), "quick position", false));

if (TRUE == [Link])

vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_EXACTGOTO), "3D precisely opsition",


false));

vecPtzControl.push_back(PtzControlInfo(int(-2), "pause", false));

vecPtzControl.push_back(PtzControlInfo(int(-1), "exit", true));

PtzControlInfo cLastChoose;

while(TRUE)

printf("PTZ control operation: \n");

for (std::vector<PtzControlInfo>::const_iterator iter = [Link](); iter !=


[Link](); ++iter)

printf("\t%d\t:%s\n", iter->m_iCmd, iter->m_sDescription.c_str());

int nError = 0;

int nChoose = GetIntInput("\t selection:", nError);

if (0 != nError)

107
printf("invalid input!\n");

continue;

std::vector<PtzControlInfo>::iterator iterFind = [Link]();

for (; iterFind != [Link](); ++iterFind)

if (nChoose == iterFind->m_iCmd)

break;

if (iterFind == [Link]())

printf("input operation within range\n");

continue;

// Stop the last operation

int nChannelId = 0;

if (true == cLastChoose.m_bStopFlag)

if (FALSE == CLIENT_DHPTZControlEx2(g_lLoginHandle, nChannelId, cLastChoose.m_iCmd,


0, 0, 0, TRUE))

printf("CLIENT_DHPTZControlEx2 Failed, cLastChoose->GetCmd()[%x]!Last


Error[%x]\n" , cLastChoose.m_iCmd, CLIENT_GetLastError());

if (iterFind->m_sDescription == "pause")

cLastChoose = *iterFind;

continue;

108
}

if (iterFind->m_sDescription == "exit")

break;

// Different PTZ commands correspond to different extra parameter setup [Link]


setup guide are showing below.

// Extra parameter

LONG lParam1 = 0;

LONG lParam2 = 0;

LONG lParam3 = 0;

void* pParam4 = NULL;

if (DH_PTZ_UP_CONTROL <= iterFind->m_iCmd && iterFind->m_iCmd <=


DH_PTZ_RIGHT_CONTROL)

// Vertical/horizontal movement speed,valid range (1-8)

lParam2 = 3;

else if (DH_PTZ_ZOOM_ADD_CONTROL <= iterFind->m_iCmd && iterFind->m_iCmd <=


DH_PTZ_APERTURE_DEC_CONTROL)

// Speed, valid range (1-8)

lParam1 = 3;

else if (DH_PTZ_POINT_MOVE_CONTROL <= iterFind->m_iCmd && iterFind->m_iCmd <=


DH_PTZ_POINT_DEL_CONTROL)

// lParam2 is preset number

printf("\t preset number (%2d-%2d):",


[Link],[Link]);

scanf("%d", &lParam2);

else if (DH_PTZ_POINT_LOOP_CONTROL == iterFind->m_iCmd)

// lParam1 is scan path, lParam3: 76 sartt and 96 stop

109
printf("\t scan path (%2d-%2d):", [Link],[Link]);

scanf("%d", &lParam1);

printf("\t1:start \n\t2: stop \n\t select:");

int nTmp = 0;

scanf("%d", &nTmp);

if (1 == nTmp)

lParam3 = 76;

else if (2 == nTmp)

lParam3 = 96;

else if (DH_PTZ_LAMP_CONTROL == iterFind->m_iCmd)

// lParam1 is switch control

printf("\t1:start \n\t2: stop \n\t select:");

scanf("%d", &lParam1);

else if (DH_EXTPTZ_LEFTTOP <= iterFind->m_iCmd && iterFind->m_iCmd <=


DH_EXTPTZ_RIGHTDOWN)

// vertical speed, valid range (1-8)

lParam1 = 1;

// horizontal speed, valid range (1-8)

lParam2 = 1;

else if (DH_EXTPTZ_ADDTOLOOP <= iterFind->m_iCmd && iterFind->m_iCmd <=


DH_EXTPTZ_DELFROMLOOP)

// lParam1 is tour path

printf("\t scan path (%2d-%2d):", [Link],[Link]);

scanf("%d", &lParam1);

// lParam2 is tour number

110
printf("\t preset number (%2d-%2d):",
[Link],[Link]);

scanf("%d", &lParam2);

else if (DH_EXTPTZ_CLOSELOOP == iterFind->m_iCmd)

// lParam1 is tour path

printf("\t tour path (%2d-%2d):", [Link],[Link]);

scanf("%d", &lParam1);

else if (DH_EXTPTZ_FASTGOTO == iterFind->m_iCmd)

// Horizontal coordinate, valid range (-8191 ~ 8191)

lParam1 = 2000;

// Vertical coordinate, valid range (-8191 ~ 8191)

lParam2 = 2000;

// Zoom, valid range (-16 ~ 16)

lParam3 = 2;

else if (DH_EXTPTZ_EXACTGOTO == iterFind->m_iCmd)

// Horizontal coordinate, valid range and accuracy is 10x of capacity set acquisition range.

printf("\t horizontal coordinate (%2d-%2d):",


10*[Link],
10*[Link]);

scanf("%d", &lParam1);

// Vertical coordinate, valid range and accuracy is 10x of capacity set acquisition range.

printf("\t vertical coordinate (%2d-%2d):",


10*[Link],
10*[Link]);

scanf("%d", &lParam2);

// zoom, valid range (1 ~ 128)

lParam3 = 2;

111
if (FALSE == CLIENT_DHPTZControlEx2(g_lLoginHandle, nChannelId, iterFind->m_iCmd,
lParam1, lParam2, lParam3, FALSE, pParam4))

printf("CLIENT_DHPTZControlEx2 Failed, nChoose[%x]!Last Error[%x]\n" , nChoose,


CLIENT_GetLastError());

cLastChoose = *iterFind;

void EndTest()

printf("input any key to quit!\n");

getchar();

// Log out of device

if (0 != g_lLoginHandle)

if(FALSE == CLIENT_Logout(g_lLoginHandle))

printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lLoginHandle = 0;

// Clean uo initilization resources

if (TRUE == g_bNetSDKInitFlag)

CLIENT_Cleanup();

g_bNetSDKInitFlag = FALSE;

return;

112
int main()

InitTest();

RunTest();

EndTest();

return 0;

//*********************************************************************************
// Commonly used callback set definition.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)

printf("Call DisConnectFunc\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Call HaveReConnect\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

113
}

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

int GetIntInput(char *szPromt, int& nError)

long int nGet = 0;

char* pError = NULL;

printf(szPromt);

char szUserInput[32] = "";

gets(szUserInput);

nGet = strtol(szUserInput, &pError, 10);

if ('\0' != *pError)

// Parameter error

nError = -1;

else

nError = 0;

return nGet;
}

Voice Talk

2.10.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.

114
Voice talk has two modes: client mode and server mode. For detailed description, please refer
to "2.10.3 Process".

2.10.2 Interface Overview


Table 2-10 Interfaces of voice talk
Interface Implication
CLIENT_Init Interface for SDK Initialization.
CLIENT_Cleanup Interface for cleaning up SDK resources.
CLIENT_LoginWithHighLevelSecurity Login with high level security.
CLIENT_QueryDevState Interface for searching device status.
CLIENT_GetDevConfig Extensive interface for opening voice talk.
CLIENT_StartTalkEx Extensive interface for stopping voice talk.
Extensive interface for starting client
CLIENT_StopTalkEx
recording(valid in Windows platform only).
Extensive interface for stopping client
CLIENT_RecordStartEx
recording(valid in Windowsplatform only).
CLIENT_RecordStopEx Interface for sending audio data to device
Extensive interface for decoding audio data(valid
CLIENT_TalkSendData
in Windows platform only).
CLIENT_AudioDecEx Interface for logout.
Interface for getting error code after failed calling
CLIENT_Logout
interface.
CLIENT_GetLastError Interface for sending audio data to device.

2.10.3 Process
Voice talk has two modes.

Client mode
SDK allows user to provide a callback [Link] callback function is called when SDK
collects audio data from local sound card or receives data from the [Link] callback
function user can not only send collected local audio data to front-end device but decode
and play the received front-end audio [Link] mode is valid in Windows platform only.

Server mode
SDK allows user to provide one callback [Link] callback function is called when SDK
receives audio data from front-end [Link] callback function user can save audio data received
from front-end device for future use such as audio data transfer, calling a third-party library
todecode and play audio data and etc. For local audio data, user can collect it by calling a
third-party library and then send it to device by calling SDK interface.

115
[Link] Client Mode

Process of client mode

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set voice talk mode for client


CLIENT_SetDeviceMode

Get supported encode type of voice talk


for IPC
CLIENT_QueryDevState

Set encode info for voice talk


CLIENT_SetDeviceMode

Get channel ID of voice talk


CLIENT_GetDevConfig

Set voice talk mode


CLIENT_SetDeviceMode

Set forward mode


CLIENT_SetDeviceMode

Start voice talk


CLIENT_StartTalkEx
Set callback pfAudioDataCallBack
Decode device audio data in callback
Decode audio data of device
Start recording on PC CLIENT_AudioDec
CLIENT_RecordStartEx
Send PC audio data in callback
Send PC audio data to device
Stop recording on PC
CLIENT_TalkSendData
CLIENT_RecordStopEx

Stop voice talk


CLIENT_StopTalkEx

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

116
Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_SetDeviceMode to set voice talk mode as clinet mode, and set the
parameter emType as DH_TALK_CLIENT_MODE.
Call CLIENT_QueryDevState to get aupported voice talk encoding type list, and set the
parameter nType as DH_DEVSTATE_TALK_ECTYPE.
Call CLIENT_SetDeviceMode to set voice talk decoding info and set the parameter
emType as DH_TALK_ENCODE_TYPE.
Call CLIENT_GetDevConfig to get voice talk channel number and set parameter
dwCommand as DH_DEV_DEVICECFG. If the acquired channel number is o, use o
channel by default.
Call CLIENT_SetDeviceMode to set voice talk parameter and set the parameter
emType as DH_TALK_SPEAK_PARAM.
Call CLIENT_SetDeviceMode to set voice talk transfer mode. No-transfer mode is to
implement voice talk between local PC and logined device; and transfer mode is to
implement voice talk between local PC and front-end device connected with specific
channel of the logined device.
Call CLIENT_StartTalkEx to set callback function and start voice [Link] callback
function, call CLIENT_AudioDec to decode audio data sent by device and call
CLIENT_TalkSendData to send audio data from PC to device.
Call CLIENT_RecordStartEx to start PC [Link] after this interface is called, can
avoice talk callback function set by CLIENT_StartTalkEx will receive local audio data.
After voice talk is finished, call CLIENT_RecordStopEx to stop PC recording.
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.

117
[Link] Server Mode

Process of server mode

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set voice talk mode for client


CLIENT_SetDeviceMode

Get supported encode type of voice talk


for IPC
CLIENT_QueryDevState

Set encode info for voice talk


CLIENT_SetDeviceMode

Get channel ID of voice talk


CLIENT_GetDevConfig

Set parameters of voice talk


CLIENT_SetDeviceMode

Set forward mode


CLIENT_SetDeviceMode

Start voice talk


Forward by the user or decode
CLIENT_StartTalkEx
audio data of device in callback
Set callback pfAudioDataCallBack

1. Encode raw audio data to be the same type with


encode type of voice talk
2. Add corresponding 8 private protocol bytes to
the encoded data header
3. call CLIENT_TalkSendData to send audio data

Stop voice talk


CLIENT_StopTalkEx

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

118
Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_SetDeviceMode to set voice talk mode as server mode, and set the
parameter emType as DH_TALK_SERVER_MODE.
Call CLIENT_QueryDevState to get aupported voice talk encoding type list, and set the
parameter nType as DH_DEVSTATE_TALK_ECTYPE.
Call CLIENT_SetDeviceMode to set voice talk decoding info and set the parameter
emType as DH_TALK_ENCODE_TYPE.
Call CLIENT_GetDevConfig to get voice talk channel number and set parameter
dwCommand as DH_DEV_DEVICECFG. If the acquired channel number is o, use o
channel by default.
Call CLIENT_SetDeviceMode to set voice talk parameter and set the parameter
emType as DH_TALK_SPEAK_PARAM.
Call CLIENT_SetDeviceMode to set voice talk transfer mode. No-transfer mode is to
implement voice talk between local PC and logined device; and transfer mode is to
implement voice talk between local PC and front-end device connected with specific
channel of the logined device.
Call CLIENT_StartTalkEx to set callback function and start voice [Link] callback
function, users can process audio data which is sent from device by themselves, such as
transfer or decding for palying.
Users decode original audio data to be the same type with talk encoding type, then add
8 corresponding private protocol bytes in front of encoded data, and call
CLIENT_TalkSendData to send audio data to device.
After voice talk is finished, call CLIENT_RecordStopEx to stop PC recording.
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.

2.10.4 Example Code

[Link] Client Mode

#include <windows.h>

#include <stdio.h>

#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;

static LLONG g_lLoginHandle = 0L;

static LLONG g_lTalkHandle = 0L;

static BOOL g_bRecordFlag = FALSE;

119
static char g_szDevIp[32] = "[Link]";

static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.

static char g_szUserName[64] = "admin";

static char g_szPasswd[64] = "admin";

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Voice talk data callback function

// It is not recommended to call SDK interface in this function, but in this callback function
CLIENT_TalkSendData and CLIENT_AudioDec SDK interfaces can be called.

// Set the callback function in CLIENT_StartTalkEx.SDK will call this function when receiving sound card
data detected by local PC, or audio data sent by device.

void CALLBACK AudioDataCallBack(LLONG lTalkHandle, char *pDataBuf, DWORD dwBufSize, BYTE


byAudioFlag, DWORD dwUser);

//*********************************************************************************

void InitTest()

// SDK initialization

g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);

if (FALSE == g_bNetSDKInitFlag)

printf("Initialize client SDK fail; \n");

120
return;

else

printf("Initialize client SDK done; \n");

}
// Get the SDK version information
// Optional operation

DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();

printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.

CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.

CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;

memset(&stInparam, 0, sizeof(stInparam));

[Link] = sizeof(stInparam);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

[Link] = sPort;

121
[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;

memset(&stOutparam, 0, sizeof(stOutparam));

[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)

// Log in to device

LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)

{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.

printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,


g_nPort , CLIENT_GetLastError());

else

printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);

}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.

Sleep(1000);

printf("\n");

void RunTest()

if (FALSE == g_bNetSDKInitFlag)

return;

122
}

if (0 == g_lLoginHandle)

return;

// Set as voice talk client mode.

BOOL bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_CLIENT_MODE, NULL);

if (FALSE == bSuccess)

printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_CLIENT_MODE,


CLIENT_GetLastError());

return;

// Get voice talk encoding type supported by front-end device.

DHDEV_TALKFORMAT_LIST stulstTalkEncode;

int retlen = 0;

bSuccess = CLIENT_QueryDevState(g_lLoginHandle, DH_DEVSTATE_TALK_ECTYPE,


(char*)&stulstTalkEncode, sizeof(stulstTalkEncode), &retlen, 3000);

if (FALSE == bSuccess || retlen != sizeof(stulstTalkEncode))

printf("CLIENT_QueryDevState cmd[%d] Failed!Last Error[%x]\n" , DH_DEVSTATE_TALK_ECTYPE,


CLIENT_GetLastError());

return;

// Set voice talk decoding info

DHDEV_TALKDECODE_INFO curTalkMode;

// Select the first encode method in the list, and users can select other encode method asneeded.

curTalkMode = [Link][0];

bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_ENCODE_TYPE, &curTalkMode);

if (FALSE == bSuccess)

123
printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_ENCODE_TYPE,
CLIENT_GetLastError());

return;

// Get voice talk channel number of device

DWORD dwRetBytes = 0;

DHDEV_SYSTEM_ATTR_CFG stuAttr = { sizeof(stuAttr) };

if (FALSE == CLIENT_GetDevConfig(g_lLoginHandle, DH_DEV_DEVICECFG, -1, &stuAttr,


[Link], &dwRetBytes, 3000))

printf("CLIENT_GetDevConfig cmd[%d] Failed!Last Error[%x]\n" , DH_DEV_DEVICECFG,


CLIENT_GetLastError());

return;

// Set voice talk parameter.

NET_SPEAK_PARAM stuSpeak = {sizeof(stuSpeak)};

[Link] = 0; // 0: talk(default mode); 1: shout, reset when switch from shout to intercom.

// Even if partial devices support voice talk, the returned channel number can be 0.

// When [Link] is 0, the talk channel number is 0; otherwise, the range is 0 -


([Link]-1).

if (0 == [Link])

[Link] = 0; // Voice talk channel number

else

// The example code select channel number as [Link]-1 to implement


voice talk, and userds can select the neededvalue from range 0 - ([Link]-1).

[Link] = [Link]-1; // Voice talk channel number

bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_SPEAK_PARAM, &stuSpeak);

if (FALSE == bSuccess)

124
printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_SPEAK_PARAM,
CLIENT_GetLastError());

return;

// Set transfer mode

NET_TALK_TRANSFER_PARAM stuTransfer = {sizeof(stuTransfer)};

[Link] = FALSE; // Close transfer mode because it is voice talk with logindevices.

bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_TRANSFER_MODE, &stuTransfer);

if (FALSE == bSuccess)

printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_TRANSFER_MODE,


CLIENT_GetLastError());

return;

g_lTalkHandle = CLIENT_StartTalkEx(g_lLoginHandle, AudioDataCallBack, (DWORD)NULL);

if(0 != g_lTalkHandle)

// Start local [Link] is no need to call this interface if it is one-way voice talk between DVR
and PC.

BOOL bSuccess = CLIENT_RecordStartEx(g_lLoginHandle);

if(TRUE == bSuccess)

g_bRecordFlag = TRUE;

else

if (FALSE == CLIENT_StopTalkEx(g_lTalkHandle))

printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lTalkHandle = 0;

125
}

else

printf("CLIENT_StartTalkEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

void EndTest()

printf("input any key to quit!\n");

getchar();

// Stop local audio recording

if (TRUE == g_bRecordFlag)

if (!CLIENT_RecordStopEx(g_lLoginHandle))

printf("CLIENT_RecordStop Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_bRecordFlag = FALSE;

// Stop voice talk

if (0 != g_lTalkHandle)

if(FALSE == CLIENT_StopTalkEx(g_lTalkHandle))

printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

126
g_lTalkHandle = 0;

// Log out of device

if (0 != g_lLoginHandle)

if(FALSE == CLIENT_Logout(g_lLoginHandle))

printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lLoginHandle = 0;

// Clean up initialization resources

if (TRUE == g_bNetSDKInitFlag)

CLIENT_Cleanup();

g_bNetSDKInitFlag = FALSE;

return;

int main()

InitTest();

RunTest();

EndTest();

return 0;

//*********************************************************************************

127
// Commonly used callback set definition.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)

printf("Call DisConnectFunc\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Call HaveReConnect\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK AudioDataCallBack(LLONG lTalkHandle, char *pDataBuf, DWORD dwBufSize, BYTE


byAudioFlag, DWORD dwUser)

// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lTalkHandle.

if (g_lTalkHandle != lTalkHandle)

128
return;

if(0 == byAudioFlag)

// Send received sound card data which is detected by local PC to [Link] interface must
follow the interface CLIENT_RecordStartEx.

LONG lSendLen = CLIENT_TalkSendData(lTalkHandle, pDataBuf, dwBufSize);

if(lSendLen != (LONG)dwBufSize)

printf("CLIENT_TalkSendData Failed!Last Error[%x]\n" , CLIENT_GetLastError());

else if(1 == byAudioFlag)

// Send received audio data sent by device to SDK for decoding and playing.

CLIENT_AudioDec(pDataBuf, dwBufSize);

#ifdef _DEBUG

FILE *stream;

if( (stream = fopen("E:\\[Link]", "a+b")) != NULL )

int numwritten = fwrite( pDataBuf, sizeof( char ), dwBufSize, stream );

fclose( stream );

#endif

[Link] Server Mode

#include <windows.h>

#include <stdio.h>

#include "dhplay.h"

#include "Alaw_encoder.h"

#include "dhnetsdk.h"

129
static LLONG g_nPlayPort = 0;

#pragma comment(lib , "[Link]") // The third-party encoding/decoding library. Take Dahua


encoding/decoding library for example in the following example code.

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;

static LLONG g_lLoginHandle = 0L;

static LLONG g_lTalkHandle = 0L;

static BOOL g_bOpenAudioRecord = FALSE;

static char g_szDevIp[32] = "[Link]";

static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.

static char g_szUserName[64] = "admin";

static char g_szPasswd[64] = "admin";

static DHDEV_TALKDECODE_INFO g_curTalkMode;

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Voice talk data callback function

// Only audio data sent by device can be received in server mode

// It is not recommended to call SDK interface in this function, but in this callback function
CLIENT_TalkSendData and CLIENT_AudioDec SDK interfaces can be called.

// Set the callback function in CLIENT_StartTalkEx.SDK will call this function when receiving sound card
data detected by local PC, or audio data sent by device.

130
void CALLBACK AudioDataCallBack(LLONG lTalkHandle, char *pDataBuf, DWORD dwBufSize, BYTE
byAudioFlag, DWORD dwUser);

// PC audio encode send callback function

//pDataBuffer is original audio data, DataLength is the length of valid data.

//Set up PLAY_OpenAudioRecord interface By Dahua encoding/decoding library, when detecting sound


card data, Dahua encoding/decoding library will call this function.

void CALLBACK AudioCallFunction(LPBYTE pDataBuffer, DWORD DataLength, void* pUser);

//*********************************************************************************

//Function declaration

// This interface is an example to call Dahua encoding/decoding library to collect voice talk [Link]
Dahua encoding/decoding library to get PC original audio stream.

BOOL StartAudioRecord();

BOOL StopAudioRecord();

//*********************************************************************************

void InitTest()

// SDK initialization

g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);

if (FALSE == g_bNetSDKInitFlag)

printf("Initialize client SDK fail; \n");

return;

else

printf("Initialize client SDK done; \n");

}
// Get the SDK version information
// Optional operation

DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();

printf("NetSDK version is [%d]\n", dwNetSdkVersion);

131
// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.

CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.

CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;

memset(&stInparam, 0, sizeof(stInparam));

[Link] = sizeof(stInparam);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

[Link] = sPort;

[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;

memset(&stOutparam, 0, sizeof(stOutparam));

[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)

// Log in to device

LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)

132
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.

printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,


g_nPort , CLIENT_GetLastError());

else

printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);

// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.

Sleep(1000);

printf("\n");

void RunTest()

if (FALSE == g_bNetSDKInitFlag)

return;

if (0 == g_lLoginHandle)

return;

// Set as voice talk server mode.

BOOL bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_SERVER_MODE, NULL);

if (FALSE == bSuccess)

133
printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_SERVER_MODE,
CLIENT_GetLastError());

return;

// Get voice talk encoding type supported by front-end device.

DHDEV_TALKFORMAT_LIST stulstTalkEncode;

int retlen = 0;

bSuccess = CLIENT_QueryDevState(g_lLoginHandle, DH_DEVSTATE_TALK_ECTYPE,


(char*)&stulstTalkEncode, sizeof(stulstTalkEncode), &retlen, 3000);

if (FALSE == bSuccess || retlen != sizeof(stulstTalkEncode))

printf("CLIENT_QueryDevState cmd[%d] Failed!Last Error[%x]\n" , DH_DEVSTATE_TALK_ECTYPE,


CLIENT_GetLastError());

return;

// Set voice talk decoding info

g_curTalkMode.encodeType = [Link][0];

bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_ENCODE_TYPE, &g_curTalkMode);

if (FALSE == bSuccess)

printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_ENCODE_TYPE,


CLIENT_GetLastError());

return;

// Get voice talk channel number of device

DWORD dwRetBytes = 0;

DHDEV_SYSTEM_ATTR_CFG stuAttr = { sizeof(stuAttr) };

if (FALSE == CLIENT_GetDevConfig(g_lLoginHandle, DH_DEV_DEVICECFG, -1, &stuAttr,


[Link], &dwRetBytes, 3000))

printf("CLIENT_GetDevConfig cmd[%d] Failed!Last Error[%x]\n" , DH_DEV_DEVICECFG,


CLIENT_GetLastError());

return;

134
// Set voice talk parameter.

NET_SPEAK_PARAM stuSpeak = {sizeof(stuSpeak)};

[Link] = 0; // 0: talk(default mode); 1: shout, reset when switch from shout to intercom.

// Even if partial devices support voice talk, the returned channel number can be 0.

// When [Link] is 0, the talk channel number is 0; otherwise, the range is 0 -


([Link]-1).

if (0 == [Link])

[Link] = 0; // Voice talk channel number

else

// The example code select channel number as [Link]-1 to implement


voice talk, and userds can select the neededvalue from range 0 - ([Link]-1).

[Link] = [Link]-1; // Voice talk channel number

bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_SPEAK_PARAM, &stuSpeak);

if (FALSE == bSuccess)

printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_SPEAK_PARAM,


CLIENT_GetLastError());

return;

// Set transfer mode

NET_TALK_TRANSFER_PARAM stuTransfer = {sizeof(stuTransfer)};

[Link] = FALSE; // Close transfer mode because it is voice talk with logindevices.

bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle, DH_TALK_TRANSFER_MODE, &stuTransfer);

if (FALSE == bSuccess)

printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" , DH_TALK_TRANSFER_MODE,


CLIENT_GetLastError());

return;

135
g_lTalkHandle = CLIENT_StartTalkEx(g_lLoginHandle, AudioDataCallBack, (DWORD)NULL);

if(0 != g_lTalkHandle)

bSuccess = StartAudioRecord();

if(TRUE == bSuccess)

g_bOpenAudioRecord = TRUE;

else

printf("StartAudioRecord Failed!\n");

CLIENT_StopTalkEx(g_lTalkHandle);

g_lTalkHandle = 0;

else

printf("CLIENT_StartTalkEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

void EndTest()

printf("input any key to quit!\n");

getchar();

// Clean up talk resources of Dahua encoding/decodinglibrary.

if(TRUE == g_bOpenAudioRecord)

if (TRUE == StopAudioRecord())

g_bOpenAudioRecord = FALSE;

136
// Stop voice talk

if (0 != g_lTalkHandle)

if(FALSE == CLIENT_StopTalkEx(g_lTalkHandle))

printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lTalkHandle = 0;

// Log out of device

if (0 != g_lLoginHandle)

if(FALSE == CLIENT_Logout(g_lLoginHandle))

printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lLoginHandle = 0;

// Clean up initialization resources

if (TRUE == g_bNetSDKInitFlag)

CLIENT_Cleanup();

g_bNetSDKInitFlag = FALSE;

return;

137
int main()

InitTest();

RunTest();

EndTest();

return 0;

//*********************************************************************************

// Commonly used callback set definition.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)

printf("Call DisConnectFunc\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Call HaveReConnect\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

138
printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK AudioDataCallBack(LLONG lTalkHandle, char *pDataBuf, DWORD dwBufSize, BYTE


byAudioFlag, DWORD dwUser)

// If more than one playbacks or downloads use the progress callback, users can do one-to-one
correspondence by lTalkHandle.

if (g_lTalkHandle != lTalkHandle)

return;

if(1 == byAudioFlag)

// User can handle the audio data sent by device by himself such as transfer and decoding and
playing.

// The following is an example of dealing with the data with Dahua encoding/decoding library.

PLAY_GetFreePort(&g_nPlayPort);

//For PCM format withour header , please add 128.

if (g_curTalkMode.encodeType == DH_TALK_DEFAULT)

for (unsigned int i = 0; i < dwBufSize; i++)

pDataBuf[i] += (char)128;

//You can use PLAY SDK to decode to get PCM and then encode to other formats if you to get a
uniform formats.

PLAY_InputData(g_nPlayPort,(BYTE *)pDataBuf,dwBufSize);

#ifdef _DEBUG

FILE *stream;

if( (stream = fopen("E:\\[Link]", "a+b")) != NULL )

139
{

int numwritten = fwrite( pDataBuf, sizeof( char ), dwBufSize, stream );

fclose( stream );

#endif

void CALLBACK AudioCallFunction(LPBYTE pDataBuffer, DWORD DataLength, void* pUser)

char* pCbData = NULL;

pCbData = new char[102400];

if (NULL == pCbData)

return;

int iCbLen = 0;

//Former 8 bytes in intercom stream are private protocol data, others are audio data of
corresponding intercom encode type.

// The following codes show that what the former 8 bytes are when PCM 、 g711a and g711u
encoding.

if (g_curTalkMode.encodeType == DH_TALK_DEFAULT || g_curTalkMode.encodeType ==


DH_TALK_PCM)

if (g_curTalkMode.nAudioBit == 8)

for(unsigned int j = 0 ; j < DataLength; j++)

*(pDataBuffer + j) += 128;

pCbData[0]=0x00;

pCbData[1]=0x00;

pCbData[2]=0x01;

140
pCbData[3]=0xF0;

pCbData[4]=g_curTalkMode.nAudioBit==8?0x07:0x0C;

if( 8000 == g_curTalkMode.dwSampleRate )

pCbData[5]=0x02;//8k

else if(16000 == g_curTalkMode.dwSampleRate)

pCbData[5] = 0x04;

else if(48000 == g_curTalkMode.dwSampleRate)

pCbData[5] = 0x09;

*(DWORD*)(pCbData+6)=DataLength;

memcpy(pCbData+8, pDataBuffer, DataLength);

iCbLen = 8+DataLength;

else if (g_curTalkMode.encodeType == DH_TALK_G711a)

// Encode the original audio data to g711a.

if (g711a_Encode((char*)pDataBuffer, pCbData+8, DataLength, &iCbLen) != 1)

goto end;

//Private bit stream format frame head

pCbData[0]=0x00;

pCbData[1]=0x00;

pCbData[2]=0x01;

pCbData[3]=0xF0;

141
pCbData[4]=0x0E; //G711A

if( 8000 == g_curTalkMode.dwSampleRate )

pCbData[5]=0x02;//8k

else if(16000 == g_curTalkMode.dwSampleRate)

pCbData[5] = 0x04;

else if(48000 == g_curTalkMode.dwSampleRate)

pCbData[5] = 0x09;

pCbData[6]=BYTE(iCbLen&0xff);

pCbData[7]=BYTE(iCbLen>>8);

iCbLen += 8;

else if (g_curTalkMode.encodeType == DH_TALK_G711u)

// Encode the original audio data to g711u.

if (g711u_Encode((char*)pDataBuffer, pCbData+8, DataLength, &iCbLen) != 1)

goto end;

//Private bit stream format frame head

pCbData[0]=0x00;

pCbData[1]=0x00;

pCbData[2]=0x01;

pCbData[3]=0xF0;

142
pCbData[4]=0x0A; //G711u

if( 8000 == g_curTalkMode.dwSampleRate )

pCbData[5]=0x02;//8k

else if(16000 == g_curTalkMode.dwSampleRate)

pCbData[5] = 0x04;

else if(48000 == g_curTalkMode.dwSampleRate)

pCbData[5] = 0x09;

pCbData[6]=BYTE(iCbLen&0xff);

pCbData[7]=BYTE(iCbLen>>8);

iCbLen += 8;

else

goto end;

// Send the data from the PC to DVR

CLIENT_TalkSendData(g_lTalkHandle, (char *)pCbData, iCbLen);

end:

if (pCbData != NULL)

delete[] pCbData;

143
//*********************************************************************************

BOOL StartAudioRecord()

// It is the characteristics of Dahua encoding/decoding library.

PLAY_GetFreePort(&g_nPlayPort);

// Then specify frame length

int nFrameLength = 1024;

switch(g_curTalkMode.encodeType)

case DH_TALK_DEFAULT:

case DH_TALK_PCM:

nFrameLength = 1024;

break;

case DH_TALK_G711a:

nFrameLength = 1280;

break;

case DH_TALK_AMR:

nFrameLength = 320;

break;

case DH_TALK_G711u:

nFrameLength = 320;

break;

case DH_TALK_G726:

nFrameLength = 320;

break;

case DH_TALK_AAC:

nFrameLength = 1024;

default:

break;

if (g_curTalkMode.dwSampleRate == 48000)// If sampling rate is 48K,update audiolength.

144
nFrameLength = 48*40*2; // Sampling rate multiply by 40 and 2.

BOOL bRet = FALSE;

// Then call PLAYSDK library to begin recording audio

BOOL bOpenRet = PLAY_OpenStream(g_nPlayPort,0,0,1024*900);

if(bOpenRet)

BOOL bPlayRet = PLAY_Play(g_nPlayPort,0);

if(bPlayRet)

PLAY_PlaySoundShare(g_nPlayPort);

BOOL bSuccess = PLAY_OpenAudioRecord(AudioCallFunction,g_curTalkMode.nAudioBit,

g_curTalkMode.dwSampleRate,nFrameLength,0,NULL);

if(bSuccess)

bRet = TRUE;

else

PLAY_StopSoundShare(g_nPlayPort);

PLAY_Stop(g_nPlayPort);

PLAY_CloseStream(g_nPlayPort);

else

PLAY_CloseStream(g_nPlayPort);

return bRet;

145
BOOL StopAudioRecord()

// // It is the characteristics of Dahua encoding/decoding library.

BOOL bSuccess = PLAY_CloseAudioRecord();

if(TRUE == bSuccess)

PLAY_Stop(g_nPlayPort);

PLAY_StopSoundShare(g_nPlayPort);

PLAY_CloseStream(g_nPlayPort);

else

printf("PLAY_CloseAudioRecord Failed!\n");

return bSuccess;

Video Snapshot

2.11.1 Introduction
Video snapshot, as to snapshot picture not only from video, but also from device, which is used
by upper users for platform development requirements.
Snapshot picture from device: Users call SDK interface to send snapshot command to device,
device snapshots current image in real-time monitoring and sends to SDK. SDK will return
picture data to users, and users can configure interface by SDK to set some parameters, such as
picture encoding type and resolution.

2.11.2 Interface Overview


Table 2-11 Interfaces of video snapshot
Interface Implication
CLIENT_Init Interface for SDK Initialization.
CLIENT_Cleanup Interface for cleaning up SDK resources.
CLIENT_LoginWithHighLevelSecurity Login with high level security.

146
Interface Implication
CLIENT_QueryDevState Interface for querying device status.
CLIENT_GetDevCaps Interface for getting device caplicity.
CLIENT_GetNewDevConfig Interface for getting new device configurations.
CLIENT_ParseData Interface for analyzing the acquired configuration info.
CLIENT_PacketData Interface for packeting the set configuration info.
CLIENT_SetNewDevConfig Inferface for setting new device configuration.
CLIENT_SnapPictureEx Extensive interface for snapshot request.
CLIENT_Logout Interface for logout device.
Interface for getting error code after failed calling
CLIENT_GetLastError
interface.

147
2.11.3 Process
Process of video snapshot

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Get and save snapshot info for


Set callback of video snapshot data further using by callback
CLIENT_SetSnapRevCallBack fSnapRev

Get video input and output channel


number of IPC
CLIENT_QueryDevState

Query snapshot of certain channel


CLIENT_GetDevCaps

Get snapshot configuration of certain


channel
Use CLIENT_GetNewDevConfig and
CLIENT_ParseData in pair

Set snapshot configuration of certain


channel which changed parameters
Use CLIENT_PacketData and
CLIENT_SetNewDevConfig in pair

Send snapshot command to IPC


CLIENT_SnapPictureEx

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

148
Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_SetSnapRevCallBack to set snapshot callback function. SDK will call
fSnapRev callback function to recall picture information and data to users, when SDK
receives snapshot data sent from device,
Call CLIENT_GetDevCaps and set the cprresponding type parameter as
NET_SNAP_CFG_CAPS, to query for the snapshot capalicity of secified channel.
Call CLIENT_GetNewDevConfig and CLIENT_ParseData, and set the cprresponding
type parameter as CFG_CMD_ENCODE, to get the snapshot configuration of secified
channel.
Change the corresponding snapshot configuration, and then Call CLIENT_PacketData
and CLIENT_SetNewDevConfig. Then set the cprresponding parameter type as
CFG_CMD_ENCODE, to set the snapshot configuration of secified channel.
Call CLIENT_SnapPictureEx to send snapshot command to the front–end devices, and
wait for devices to reply picture information in fSnapRev callback.
Call CLIENT_Logout to log out of the device.
After using all SDK functions, call CLIENT_Cleanup to release SDK resources.

2.11.4 Example Code


#include <windows.h>
#include <stdio.h>
#include <time.h>
#include "dhnetsdk.h"
#include "dhconfigsdk.h"

#pragma comment(lib, "[Link]")


#pragma comment(lib, "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;


static LLONG g_lLoginHandle = 0L;
static char g_szDevIp[32] = "[Link]";
static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.
static char g_szUserName[64] = "admin";
static char g_szPasswd[64] = "admin";
static short g_nCmdSerial = 0; // Snapshot SN

//*********************************************************************************
// Commonly used callback set declaration.

149
// Callback function used when device disconnected.
// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

//Snapshot callback function.


// It is not recommended to call SDK interfaces in this callback.
//Set the callback function in CLIENT_SetSnapRevCallBack,when snapshot data is sent over by
front-end device,SDK will call this function.
void CALLBACK SnapRev(LLONG lLoginID, BYTE *pBuf, UINT RevLen, UINT EncodeType, DWORD
CmdSerial, LDWORD dwUser);

//*********************************************************************************
// Commonly used funvtion det declaration.

// Get int input


int GetIntInput(char *szPromt, int& nError);

// Get input string


void GetStringInput(const char *szPromt , char *szBuffer);

//*********************************************************************************
void InitTest()
{
// SDK initialization
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");

150
}

// Get the SDK version information


// Optional operation
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.


CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
strncpy([Link], [Link](0), sizeof([Link]) - 1);
[Link] = sPort;
[Link] = EM_LOGIN_SPEC_CAP_TCP;
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
while(0 == g_lLoginHandle)
{
// Log in to device

151
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)
{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.
printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,
g_nPort , CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.
Sleep(1000);
printf("\n");
}
}

void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}

if (0 == g_lLoginHandle)
{
return;
}

// Set snapshot callback.


CLIENT_SetSnapRevCallBack(SnapRev, NULL);

int nChannelId = 0;

152
unsigned int i = 0;
unsigned int nRealNum = 0;
// Get the front-end video input/output channel number.
NET_DEV_CHN_COUNT_INFO stuChnCountInfo = {sizeof(stuChnCountInfo)};
[Link] = sizeof([Link]);
[Link] = sizeof([Link]);
int nRetLen = 0;
int nRet = CLIENT_QueryDevState(g_lLoginHandle, DH_DEVSTATE_DEV_CHN_COUNT, (char
*)&stuChnCountInfo, sizeof(NET_DEV_CHN_COUNT_INFO), &nRetLen);
if(nRet == FALSE || nRetLen != sizeof(NET_DEV_CHN_COUNT_INFO))
{
printf("CLIENT_QueryDevState cmd[DH_DEVSTATE_DEV_CHN_COUNT] Failed!Last Error[%x]\n",
CLIENT_GetLastError());
return;
}

char szUserChoose[128] = "";


do
{
printf("Select snapshot channel (%d-%d)\n", 0, [Link]-1);
int nError = 0;
unsigned int nTmp = GetIntInput("\t Select: ", nError);
if (0 != nError || nTmp >= [Link])
{
printf("Inout error!\n");
continue;
}
unsigned int nSnapChannelId = nTmp;

// Query for the snapshot capacility of specified channel.


NET_IN_SNAP_CFG_CAPS stuSnapCapInParam = {0};
[Link] = nSnapChannelId;
NET_OUT_SNAP_CFG_CAPS stuSnapCapOutParam = {0};
if (FALSE == CLIENT_GetDevCaps(g_lLoginHandle, NET_SNAP_CFG_CAPS, &stuSnapCapInParam,
&stuSnapCapOutParam, 5000))
{
printf("CLIENT_GetDevCaps cmd[NET_SNAP_CFG_CAPS] Failed!Last Error[%x]\n",
CLIENT_GetLastError());
return;
}

153
// Get the snapshot configuration of specified channel.
char * pszSnapAttr = new char[1024*100];
if (NULL == pszSnapAttr)
{
printf("pszSnapAttr new fail!\n");
return;
}
memset(pszSnapAttr, 0, 1024*100);
DWORD dwRetLen = 0;
if(FALSE == CLIENT_GetNewDevConfig(g_lLoginHandle, CFG_CMD_ENCODE, nSnapChannelId,
pszSnapAttr, 1024*100, NULL, 5000))
{
printf("CLIENT_GetNewDevConfig cmd[CFG_CMD_ENCODE] Failed!Last Error[%x]\n",
CLIENT_GetLastError());
delete []pszSnapAttr;
return;
}

CFG_ENCODE_INFO stuEncodeInfo = {0};


if(FALSE == CLIENT_ParseData(CFG_CMD_ENCODE, pszSnapAttr, (LPVOID)&stuEncodeInfo,
sizeof(CFG_ENCODE_INFO), NULL))
{
printf("CLIENT_ParseData cmd[CFG_CMD_ENCODE] Failed!Last Error[%x]\n",
CLIENT_GetLastError());
delete []pszSnapAttr;
return;
}
delete []pszSnapAttr;
pszSnapAttr = NULL;

nTmp = GetIntInput("Select anpshot method: \n\t0 manuallysnapshot \n\t1 Snapshot by time


\n\t Select:", nError);
if (0 != nError || nTmp >= 2)
{
printf("Input error!\n");
continue;
}

// Change the snapshot configuration of specified channel.

154
unsigned int nSnapType = nTmp;
if (1 == nTmp)
{
[Link][0].abSnapEnable = true;
[Link][0].bSnapEnable = TRUE;
printf("Support snapshot interval:\n");
nRealNum = min([Link], DH_MAX_FPS_NUM);
for (i = 0; i < nRealNum; ++i)
{
if ([Link][i] < 0)
{
printf("\t[%2d]: [%d]Second of one frame \n", i,
abs([Link][i]));
}
else
{
printf("\t[%2d]: [%d]Frame of one second \n", i,
[Link][i]);
}
}
nTmp = GetIntInput("\t Select:", nError);
if (0 != nError || nTmp >= nRealNum)
{
printf("Input error!\n");
continue;
}

double dbFps = 0;
if ([Link][nTmp] >= 0)
{
dbFps = [Link][nTmp];
}
else
{
dbFps = 1 / (double)([Link][nTmp]);
}
[Link][0].[Link] = (float)dbFps;
}

printf("Supported resolution:\n");

155
nRealNum = min([Link], DH_MAX_CAPTURE_SIZE_NUM);
for (i = 0; i < nRealNum; ++i)
{
printf("\t[%2d]:[%dx%d]\n", i, [Link][i].snWidth,
[Link][i].snHight);
}
nTmp = GetIntInput("\t Select:", nError);
if (0 != nError || nTmp >= nRealNum)
{
printf("Input error!\n");
continue;
}

// Set the related snapshot configuration


[Link][0].[Link] =
[Link][nTmp].snWidth;
[Link][0].[Link] =
[Link][nTmp].snHight;

printf("Supported image quality (higer value, higer quality) :\n");


nRealNum = min([Link], DH_MAX_QUALITY_NUM);
for (i = 0; i < nRealNum; ++i)
{
printf("\t[%2d]:quality level[%d]\n", i, [Link][i]);
}
nTmp = GetIntInput("\t Select:", nError);
if (0 != nError || nTmp >= nRealNum)
{
printf("Input error!\n");
continue;
}

[Link][0].[Link] =
(CFG_IMAGE_QUALITY)[Link][nTmp];

// Set snapshot configuration of specified configuration


if (NULL == pszSnapAttr)
{
pszSnapAttr = new char[1024*100];
if (NULL == pszSnapAttr)

156
{
printf("pszSnapAttr new fail!\n");
return;
}
}

memset(pszSnapAttr, 0, 1024*100);
if (FALSE == CLIENT_PacketData(CFG_CMD_ENCODE, &stuEncodeInfo,
sizeof(CFG_ENCODE_INFO), pszSnapAttr, 1024*100))
{
printf("CLIENT_PacketData cmd[CFG_CMD_ENCODE] Failed!Last Error[%x]\n",
CLIENT_GetLastError());
delete []pszSnapAttr;
return;
}

int nRestart = 0;
if (FALSE == CLIENT_SetNewDevConfig(g_lLoginHandle, CFG_CMD_ENCODE, nSnapChannelId,
pszSnapAttr, 1024*100, &nError, &nRestart, 3000))
{
printf("CLIENT_SetNewDevConfig cmd[CFG_CMD_ENCODE] Failed!Last Error[%x]\n",
CLIENT_GetLastError());
delete []pszSnapAttr;
return;
}

delete []pszSnapAttr;
pszSnapAttr = NULL;

//Send snapshot command to the front-end device


SNAP_PARAMS stuSnapParams;
[Link] = nChannelId;
[Link] = nSnapType;
[Link] = ++g_nCmdSerial; // Ask for SN. The valid range is 0~65535, and
the over range part will be cut off as unsigned short.
if (FALSE == CLIENT_SnapPictureEx(g_lLoginHandle, &stuSnapParams))
{
printf("CLIENT_SnapPictureEx Failed!Last Error[%x]\n", CLIENT_GetLastError());
return;
}

157
else
{
printf("CLIENT_SnapPictureEx succ\n");
}

GetStringInput("'q': Exit; 'c': Continue \n", szUserChoose);


}while('q' != szUserChoose[0]);

return;
}

void EndTest()
{
printf("input any key to quit!\n");
getchar();

// Log ou t of device
if (0 != g_lLoginHandle)
{
if(FALSE == CLIENT_Logout(g_lLoginHandle))
{
printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_lLoginHandle = 0;
}
}
// Clean up initialization resources
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}

exit(0);
}

int main()
{

158
InitTest();

RunTest();

EndTest();

return 0;
}

//*********************************************************************************
// Commonly used callback set definition.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}

void CALLBACK SnapRev(LLONG lLoginID, BYTE *pBuf, UINT RevLen, UINT EncodeType, DWORD
CmdSerial, LDWORD dwUser)

159
{
printf("[SnapRev] -- receive data!\n");
if(lLoginID == g_lLoginHandle)
{
if (NULL != pBuf && RevLen > 0)
{
char szPicturePath[256] = "";
time_t stuTime;
time(&stuTime);
char szTmpTime[128] = "";
strftime(szTmpTime, sizeof(szTmpTime) - 1, "%y%m%d_%H%M%S", gmtime(&stuTime));
_snprintf(szPicturePath, sizeof(szPicturePath)-1, "%d_%[Link]", CmdSerial, szTmpTime);
FILE* pFile = fopen(szPicturePath, "wb");
if (NULL == pFile)
{
return;
}

int nWrite = 0;
while(nWrite != RevLen)
{
nWrite += fwrite(pBuf + nWrite, 1, RevLen - nWrite, pFile);
}

fclose(pFile);
}

}
}

//*********************************************************************************
// Commonly used callback function definition
int GetIntInput(char *szPromt, int& nError)
{
long int nGet = 0;
char* pError = NULL;
printf(szPromt);
char szUserInput[32] = "";
gets(szUserInput);
nGet = strtol(szUserInput, &pError, 10);

160
if ('\0' != *pError)
{
// Inpu t parameter error
nError = -1;
}
else
{
nError = 0;
}

return nGet;
}

void GetStringInput(const char *szPromt , char *szBuffer)


{
printf(szPromt);
gets(szBuffer);
}

Alarm Report

2.12.1 Introduction
Alarm report, is to send alarm to platform-end and notify the platform, when front-end device
detects special event set [Link] platform may receive external alarm, video signal lost
alarm, tampering alarm and motion detection alarm uploaded by device.
The method of alarm report is that SDK actively connects device and subscribes alarm function
from [Link] device detects alarm event, it will immediately send the event to SDK.

2.12.2 Interface Overview


Table 2-12 Interfaces of alarm listening
Interface Implication
CLIENT_Init Interface for initilization.
CLIENT_Cleanup Interface for cleaning up SDK resources.
CLIENT_LoginWithHighLevelSecurity Login with high level security.
CLIENT_SetDVRMessCallBack Interface for setting alarm callback function.
Extensive interface for subscribing alarm event from
CLIENT_StartListenEx
device.
CLIENT_StopListen Interface for stopping subscribing alarm.

161
Interface Implication
CLIENT_Logout Interface for logout device.
CLIENT_GetLastError Interface for getting error code after failed calling.

2.12.3 Process
Process of alarm report

Start

SDK Initialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Set alarm event callback Alarm event callback


CLIENT_SetDVRMessCallBack fMessCallBack

Subscribe alarms from device


CLIENT_StartListenEx

Stop subscribing
CLIENT_StopListen

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_SetDVRMessCallBack to set alarm callback function which should be
called before alarm subscription.
Call CLIENT_StartListenE to subscribe alarms fro mdevice. After susbcribtion, alarm
event reported by device is sent to user via callback function set in
CLIENT_SetDVRMessCallBack.
After using the function module, Call CLIENT_StopListen to stop susbscbing alarm
from device.
Call CLIENT_Logout to log out of the device.
After using all SDK functions, call CLIENT_Cleanup to release SDK resource.

162
2.12.4 Example Code
#include <windows.h>

#include <stdio.h>

#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;

static LLONG g_lLoginHandle = 0L;

static char g_szDevIp[32] = "[Link]";


static WORD g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port
of expected login device.

static char g_szUserName[64] = "admin";

static char g_szPasswd[64] = "admin";

static BOOL g_bStartListenFlag = FALSE;

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Alarm event callback function

// It is not recommended to call SDK interfaces in this callback function

// Set this callback function in CLIENT_SetDVRMessCallBack.When receiving alarm event reported by


device,SDK will call this function

BOOL CALLBACK MessCallBack(LONG lCommand, LLONG lLoginID, char *pBuf, DWORD dwBufLen, char
*pchDVRIP, LONG nDVRPort, LDWORD dwUser);

163
//*************************************************************************************

void InitTest()

// SDK initialization

g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);

if (FALSE == g_bNetSDKInitFlag)

printf("Initialize client SDK fail; \n");

return;

else

printf("Initialize client SDK done; \n");

}
// Get the SDK version information
// Optional operation

DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();

printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.

CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.

164
CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;

memset(&stInparam, 0, sizeof(stInparam));

[Link] = sizeof(stInparam);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

[Link] = sPort;

[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;

memset(&stOutparam, 0, sizeof(stOutparam));

[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)

// Log in to device

LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if(0 == g_lLoginHandle)

{
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.

printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,


g_nPort , CLIENT_GetLastError());

else

printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);

}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.

Sleep(1000);

printf("\n");

165
}

void RunTest()

if (FALSE == g_bNetSDKInitFlag)

return;

if (0 == g_lLoginHandle)

return;

// Set alarm event callback

CLIENT_SetDVRMessCallBack(MessCallBack , NULL);

// Subscribe alarm fro m device

if( TRUE == CLIENT_StartListenEx(g_lLoginHandle))

g_bStartListenFlag = TRUE;

printf("CLIENT_StartListenEx Success!\nJust Wait Event....\n");

else

printf("CLIENT_StartListenEx Failed!Last Error[%x]\n" , CLIENT_GetLastError());

void EndTest()

printf("input any key to quit!\n");

getchar();

// Stop subscribing alarm fro m device

166
if (TRUE == g_bStartListenFlag)

if (FALSE == CLIENT_StopListen(g_lLoginHandle))

printf("CLIENT_StopListen Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_bStartListenFlag = FALSE;

// Log ou t of device

if (0 != g_lLoginHandle)

if(FALSE == CLIENT_Logout(g_lLoginHandle))

printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lLoginHandle = 0;

// Clean up initialization resources

if (TRUE == g_bNetSDKInitFlag)

CLIENT_Cleanup();

g_bNetSDKInitFlag = FALSE;

return;

int main()

167
{

InitTest();

RunTest();

EndTest();

return 0;

//*********************************************************************************

// Commonly used callback set definition.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)

printf("Call DisConnectFunc\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Call HaveReConnect\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

168
}

BOOL CALLBACK MessCallBack(LONG lCommand, LLONG lLoginID, char *pBuf, DWORD dwBufLen, char
*pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("[MessCallBack] -- Get Event IP[%s] , port[%d]\n" , pchDVRIP , nDVRPort);

// Only part of alarm processing methods is listed in the demo, user can deal with corresponding
alarm event info accordingly, please refer to related event explanation in header file dhnetsdk.h for
details.

switch(lCommand)

case DH_ALARM_ALARM_EX:

printf("\n External alarm \n");

if (NULL != pBuf)

BYTE* pInfo = (BYTE*)pBuf;

for(unsigned int i = 0; i < dwBufLen/sizeof(BYTE); ++i)

printf("nChannelID = [%2d], state = [%d]\n", i, *(pInfo + i));

break;

case DH_MOTION_ALARM_EX:

printf("\n Motion detection alarm \n");

if (NULL != pBuf)

BYTE* pInfo = (BYTE*)pBuf;

for(unsigned int i = 0; i < dwBufLen/sizeof(BYTE); ++i)

printf("nChannelID = [%2d], state = [%d]\n", i, *(pInfo + i));

169
}

break;

case DH_ALARM_ALARM_EX_REMOTE:

printf("\n Remote external alarm \n");

if (NULL != pBuf)

ALARM_REMOTE_ALARM_INFO* pInfo = (ALARM_REMOTE_ALARM_INFO *)pBuf;

printf("nChannelID = %d\n" , pInfo->nChannelID);

printf("nState = %d\n" , pInfo->nState);

break;

case DH_ALARM_ACCESS_CTL_EVENT:

printf("\n Access control event \n");

if (NULL != pBuf)

ALARM_ACCESS_CTL_EVENT_INFO* pInfo = (ALARM_ACCESS_CTL_EVENT_INFO


*)pBuf;

printf("Unlock method = %d\n" , pInfo->emOpenMethod);

printf("Card number = [%s]\n" , pInfo->szCardNo);

break;

default:

printf("\n[MessCallBack] – Other alarms Get lCommand = 0x%x\n" , lCommand);

break;

return TRUE;

170
Device Search

2.13.1 Introduction
Device search is mainly used to help user to get device info from [Link] search can
work with login [Link] search interface can find relevant devices and login interface
can login these devices.
Device search is classified into the following two types by whether crossing segment or not:
⚫ Async same-segment device search: Search for device info within current segment.
⚫ Sync cross-segment device search: According to user-set segment info, searching for
device in corresponding segment.

2.13.2 Interface Overview


Table 2-13 Interfaces of device search
Interface Implication
CLIENT_Init Interface for initilization.
CLIENT_Cleanup Interface for cleaning up SDK resources.
Interface for async searching for devices within same
CLIENT_StartSearchDevicesEx
segment,such as IPC and NVS.
Interface for stopping async search for devices within
CLIENT_StopSearchDevices
same segment,such as IPC and NVS.
CLIENT_SearchDevicesByIPs Interface for sync searching cross-segment devices.
Interface for getting error code after failed calling
CLIENT_GetLastError
interface.

171
2.13.3 Process

[Link] Async Searching within Same Segment

Process of async searching within same segment

Start

SDK Initialization
CLIENT_Init

Search for devices asynchronously Get and save device info for
Within the same segment further using by callback
CLIENT_StartSearchDevicesEx fSearchDevicesCBEx

Search for devices synchronously


Within the same segment
CLIENT_StopSearchDevices

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_StartSearchDevicesEx to async search for devices within same segment.
Users get the obtained device info by fSearchDevicesCB which is set in this
[Link] search operation has no timeout, so usera need to stop searching by
calling interface CLIENT_StopSearchDevices.
Call CLIENT_StopSearchDevices to stop sync searchingfor devices within same
segment.
After using all SDK functions, call CLIENT_Cleanup to release SDK resource.

172
[Link] Sync Searching in Cross-segment

Process of sync searching in cross-segment

Start

SDK Initialization
CLIENT_Init

Synchronously search for corss- Get and save device info for
segment devices further using by callback
CLIENT_SearchDevicesByIPs fSearchDevicesCB

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_SearchDevicesByIPs to sync search for devices in cross-segment. Users
get the obtained device info by fSearchDevicesCB which is set in this interface. Only
when searching time is out or searching all the devices cross the segment, the interface
[Link] can decide the timeout as needed.
After using all SDK functions, call CLIENT_Cleanup to release SDK resources.

2.13.4 Example Code

[Link] Async Searching within Same Segment

#include <windows.h>
#include <stdio.h>

#include <vector>

#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

173
static BOOL g_bNetSDKInitFlag = FALSE;

static LLONG g_lSearchHandle = 0L;

static CRITICAL_SECTION g_mDeviceListLock; // Device list operation lock

static std::vector<DEVICE_NET_INFO_EX> g_lDeviceVec; // Device list

//*********************************************************************************
// Commonly used callback set.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Async search for device callback

// It is not recommended to call SDK interfaces in this callback function

// Set this callback function in CLIENT_StartSearchDevices/

CLIENT_StartSearchDevicesEx/CLIENT_SearchDevicesByIPs. SDK will call this function when device is


found.

void CALLBACK SearchDevicesCBEx(LLONG lSearchHandle,DEVICE_NET_INFO_EX2 *pDevNetInfo, void*


pUserData);

//*********************************************************************************

void InitTest()

// Initialization thread lock

InitializeCriticalSection(&g_mDeviceListLock);

// SDK initialization

g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);

if (FALSE == g_bNetSDKInitFlag)

174
{

printf("Initialize client SDK fail; \n");

return;

else

printf("Initialize client SDK done; \n");

}
// Get the SDK version information
// Optional operation

DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();

printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.

CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.

CLIENT_SetNetworkParam(&stuNetParm);

void RunTest()

if (FALSE == g_bNetSDKInitFlag)

175
return;

// Start async searching within same segment

NET_IN_STARTSERACH_DEVICE pInBuf = { 0 };

NET_OUT_STARTSERACH_DEVICE pOutBuf = { 0 };

LLONG seachHandle = 0;

[Link] = sizeof(NET_IN_STARTSERACH_DEVICE);

[Link] = cbSearchDevicesEx;

[Link] = this;

int nMaxCopyLen = MAX_LOCAL_IP_LEN - 1;

strncpy([Link], "[Link]", sizeof([Link]) - 1);

[Link] = sizeof(NET_OUT_STARTSERACH_DEVICE);

seachHandle = CLIENT_StartSearchDevicesEx(&pInBuf, &pOutBuf);

if (NULL == seachHandle)

printf("CLIENT_StartSearchDevicesEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

return;

int nIndex = 0;

int nSearchTime = 0;

int nSearchLimit = 10;// Search lasts for 10 seconds, and users can change the value according to
network condition

Sleep(nSearchLimit * 1000);

EnterCriticalSection(&g_mDeviceListLock);

for (std::vector<DEVICE_NET_INFO_EX>::iterator iter = g_lDeviceVec.begin(); iter !=


g_lDeviceVec.end(); ++iter)

printf("\n************** find device *************\n");

printf("nIndex[%d]\n", ++nIndex);

printf("iIPVersion[%d]\n", iter->iIPVersion);

printf("szIP[%s]\n", iter->szIP);

printf("nPort[%d]\n", iter->nPort);

g_lDeviceVec.clear();

176
LeaveCriticalSection(&g_mDeviceListLock);

void EndTest()

printf("input any key to quit!\n");

getchar();

// Cleanup thread lock resources

DeleteCriticalSection(&g_mDeviceListLock);

// Stop async searching within same segment

if (NULL != g_lSearchHandle)

if (FALSE == CLIENT_StopSearchDevices(g_lSearchHandle))

printf("CLIENT_StopSearchDevices Failed!Last Error[%x]\n", CLIENT_GetLastError());

// Clean up initialization resources

if (TRUE == g_bNetSDKInitFlag)

CLIENT_Cleanup();

g_bNetSDKInitFlag = FALSE;

int main()

InitTest();

RunTest();

EndTest();

177
return 0;

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)

printf("Call DisConnectFunc\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Call HaveReConnect\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK SearchDevicesCBEx(LLONG lSearchHandle,DEVICE_NET_INFO_EX2 *pDevNetInfo, void*


pUserData)

if ((NULL == pDevNetInfo) || (NULL == pUserData))

178
{

printf("warming param is null\n");

return;

std::vector<DEVICE_NET_INFO_EX>* pDeviceList = (std::vector<DEVICE_NET_INFO_EX>*)pUserData;

EnterCriticalSection(&g_mDeviceListLock);

pDeviceList->push_back(*pDevNetInfo);

LeaveCriticalSection(&g_mDeviceListLock);

return;
}

[Link] Sync Searching in Cross-segment

#include <windows.h>

#include <stdio.h>

#include <vector>

#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

BOOL g_bNetSDKInitFlag = FALSE;

std::vector<DEVICE_NET_INFO_EX> g_lDeviceVec; // Device list

// *************************************** Get local IP interface

std::string GetLocalIpAddress();

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.

void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully

179
// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Sync search for device callback

// It is not recommended to call SDK interfaces in this callback function.

// Set this callback function in CLIENT_StartSearchDevices/ CLIENT_StartSearchDevicesEx


/CLIENT_SearchDevicesByIPs. SDK will call this function when device is found.

void CALLBACK SearchDevicesCBEx(LLONG lSearchHandle,DEVICE_NET_INFO_EX2 *pDevNetInfo, void*


pUserData);

//*********************************************************************************

void InitTest()

// SDK initialization

g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);

if (FALSE == g_bNetSDKInitFlag)

printf("Initialize client SDK fail; \n");

return;

else

printf("Initialize client SDK done; \n");

// Get the SDK version information


// Optional operation

DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();

printf("NetSDK version is [%d]\n", dwNetSdkVersion);

// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.

CLIENT_SetAutoReconnect(&HaveReConnect, 0);

180
// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.

CLIENT_SetNetworkParam(&stuNetParm);

void RunTest()

if (FALSE == g_bNetSDKInitFlag)

return;

// Start sync searching in cross-segment

char szLocalIp[64] = "";

strncpy(szLocalIp, GetLocalIpAddress().c_str(), sizeof(szLocalIp) - 1);

DEVICE_IP_SEARCH_INFO stuTmp = {sizeof(stuTmp)};

[Link] = 256;// Number of valid searched IP address

for (unsigned int i = 0; i < [Link]; ++i)

// Users need to guarantee the validity of IP address

_snprintf([Link][i], sizeof([Link][i]) - 1, "172.11.1.%d", i);

DWORD dwWaitTime = 5000;

// Only when searching time is out, the interface [Link] can decide the timeout as needed.

181
if (FALSE == CLIENT_SearchDevicesByIPs(&stuTmp, SearchDevicesCB, (LDWORD)&g_lDeviceVec,
szLocalIp, dwWaitTime))

printf("CLIENT_SearchDevicesByIPs Failed!Last Error[%x]\n", CLIENT_GetLastError());

return;

int nIndex = 0;

for (std::vector<DEVICE_NET_INFO_EX>::iterator iter = g_lDeviceVec.begin(); iter !=


g_lDeviceVec.end(); ++iter)

printf("\n************** find device *************\n");

printf("nIndex[%d]\n", ++nIndex);

printf("iIPVersion[%d]\n", iter->iIPVersion);

printf("szIP[%s]\n", iter->szIP);

printf("nPort[%d]\n", iter->nPort);

g_lDeviceVec.clear();

void EndTest()

printf("input any key to quit!\n");

getchar();

// Clean up initialization resources

if (TRUE == g_bNetSDKInitFlag)

CLIENT_Cleanup();

g_bNetSDKInitFlag = FALSE;

int main()

182
InitTest();

RunTest();

EndTest();

return 0;

//*********************************************************************************

// Commonly used callback set definition

void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)

printf("Call DisConnectFunc\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Call HaveReConnect\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

183
printf("\n");

void CALLBACK SearchDevicesCBEx(LLONG lSearchHandle,DEVICE_NET_INFO_EX2 *pDevNetInfo, void*


pUserData)

if(pDevNetInfo != NULL)

CDevInitDlg *dlg = (CDevInitDlg *)pUserData;

DEVICE_NET_INFO_EX2 *pData = NEW DEVICE_NET_INFO_EX2;

memcpy(pData, pDevNetInfo, sizeof(DEVICE_NET_INFO_EX2));

LONG bIsUnicast = dlg->m_IsUnicast;

// *************************************** Get Local IP interface

std::string GetLocalIpAddress()

WSADATA wsaData;

if (0 != WSAStartup(MAKEWORD(2,2), &wsaData))

return "";

char local[255] = "";

gethostname(local, sizeof(local));

hostent* ph = gethostbyname(local);

if (NULL == ph)

return "";

in_addr addr;

memcpy(&addr, ph->h_addr_list[0], sizeof(in_addr));

184
std::string localIP(inet_ntoa(addr));

WSACleanup();

return localIP;

Smart Event Report and Snapshot

2.14.1 Introduction
Smart event report: Devices make smart analysis by real-time stream. Devices judge whether to
report events and to send pictures to users according to event trigger rules configured by users.
Smart events include scene change, cross picket line, enter picket zone, leave picket zone, in
picket zone, across enclosure, straggle detection, carry-over detection, move detection, goods
protection, illegal parking, fast moving, go in the wrong direction and so on.
Smar tevent snapshot: Users manually send a command to device after subscribing event
successfully. Device snapshots pictute of current scene and reports it to users by smart event.

2.14.2 Interface Overview


Table 2-14 Interfaces of smart event report and snapshot
Interface Implication
CLIENT_Init Interface for initilization.
CLIENT_Cleanup Interface for cleaning up SDK resources.
CLIENT_LoginWithHighLevelSecurity Extensive interface 2 for sync login.
CLIENT_RealLoadPictureEx Interface for smart snapshot alarm subscription.
CLIENT_ControlDeviceEx Extensive interface for device control.
CLIENT_Logout Interface for logout device.
Interface for getting error code after failed calling
CLIENT_GetLastError
interface.

185
2.14.3 Process
Process of smart event report and snapshot

Start

SDK Intialization
CLIENT_Init

Log in to device
CLIENT_LoginWithHighLevelSecurity

Get and save smart alarm info


Subscribe smart image alarm from device
and image info for further using
CLIENT_RealLoadPictureEx
by fAnalyzerDataCallBack

Call CLIENT_ControlDeviceEx to
trigger smart image alarm manually, and
set the emType parameter as
DH_MANUAL_SNAP

Stop subscribing smart image alarm from


device
CLIENT_StopLoadPic

Log out of device


CLIENT_Logout

Release SDK resource


CLIENT_Cleanup

Stop

Process Description
Call CLIENT_Init to initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_RealLoadPictureEx to subscribe smart snapshot alarm from device. After
successful subscription, the smart snapshot alarm event reported by device will be sent
to users by [Link] callback function, users should converts input
character to corresponding structyure according to the instructions in SDK header files,
and then display and save event as needed. Due to SDK receving buffer is 2M by
default, when callback picture info exceed 2M, users need to call
CLIENT_SetNetworkParam to set receiving buffer again, otherwise SDK will abandon
data pack over 2M.

186
If users want to manually trigger smart snapshot alarm, call CLIENT_ControlDeviceEx
with parameter emType DH_MANUAL_SNAP. SDK will send command to device, and
then device snapshots current monitoring video and reports it to users.
Call CLIENT_StopLoadPic to to stop subscribing smart snapshot alarm from device.
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.

2.14.4 Example Code


#include <windows.h>
#include <stdio.h>

#include <list>

#include <time.h>

#include "dhnetsdk.h"

#pragma comment(lib , "[Link]")

static BOOL g_bNetSDKInitFlag = FALSE;

static LLONG g_lLoginHandle = 0L;

static LLONG g_lRealLoadHandle = 0L;

static char g_szDevIp[32] = "[Link]";


static int g_nPort = 37777; // Tcp connection port, which should be the same as tcp connection port of
expected login device.

static char g_szUserName[64] = "admin";

static char g_szPasswd[64] = "admin";

//*********************************************************************************
// Commonly used callback set declaration.

// Callback function used when device disconnected.


// It is not recommended to call SDK interface in the SDK callback function.
// The callback is set by CLIENT_Init. When the device is offline, SDK will call this callback function.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser);

// Callback function is set after the device reconnected successfully


// It is not recommended to call SDK interface in this function.
// Set the callback function by CLIENT_SetAutoReconnect. When offline device is reconnected
successfully, SDK will call the function.

187
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);

// Smart analyzing data callback


// It is not recommended to call SDK interfaces in this callback function.
// Set this callback function in CLIENT_RealLoadPictureEx/CLIENT_RealLoadPicture, and SDK will call this
function when device-end has smart snapshot event to report.
// nSequence is used when uploading the same picture. 0 means it is the first time to appear; 2 means it
is the last time to appear or only appear once; 1 means it will appear again later.
// int nState =* (int*) reserved means current callback data status.0 means real-time data; 1 means offline
data; 2 means offline transmission done.
// Return value is abolished, without special meaning.
// Due to SDK receving buffer is 2M by default, when callback snapshot info exceeds 2M, users need to
call CLIENT_SetNetworkParam interface to set receiving buffer again, otherwise SDK will abandon data
pack over 2M.

int CALLBACK AnalyzerDataCallBack(LLONG lAnalyzerHandle, DWORD dwAlarmType, void* pAlarmInfo,


BYTE *pBuffer, DWORD dwBufSize, LDWORD dwUser, int nSequence, void *reserved);

//*********************************************************************************

void InitTest()

// SDK initialization

g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);

if (FALSE == g_bNetSDKInitFlag)

printf("Initialize client SDK fail; \n");

return;

else

printf("Initialize client SDK done; \n");

// Get the SDK version information


// Optional operation

DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();

printf("NetSDK version is [%d]\n", dwNetSdkVersion);

188
// Set reconnection callback. Internal SDK auto connects when the device disconnected.
// This operation is optional but recommended.

CLIENT_SetAutoReconnect(&HaveReConnect, 0);

// Set device connection timeout and trial times.

// Optional operation

int nWaitTime = 5000; // Timeout is 5 seconds.

int nTryTimes = 3; // If timeout, it will try to log in three times.

CLIENT_SetConnectTime(nWaitTime, nTryTimes);

// Set more network parameters. The nWaittime and nConnectTryNum of NET_PARAM have the
same meaning with the timeout and trial time set in interface CLIENT_SetConnectTime.

// Optional operation

NET_PARAM stuNetParm = {0};

[Link] = 3000; // The timeout of connection when login.

CLIENT_SetNetworkParam(&stuNetParm);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;

memset(&stInparam, 0, sizeof(stInparam));

[Link] = sizeof(stInparam);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

strncpy([Link], [Link](0), sizeof([Link]) - 1);

[Link] = sPort;

[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;

memset(&stOutparam, 0, sizeof(stOutparam));

[Link] = sizeof(stOutparam);

while(0 == g_lLoginHandle)

// Log in to device

LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

if (0 == g_lLoginHandle)

189
// Find the meanings of error codes in dhnetsdk.h. Here the print is hexadecimal and the
header file is decimal. Take care of conversion.
// For example:
// #define NET_NOT_SUPPORTED_EC(23) // Do not support this function. The
corresponding error code is 0x80000017, and the corresponding hexadecimal is 0x17.

printf("CLIENT_LoginWithHighLevelSecurity %s[%d]Failed!Last Error[%x]\n" , g_szDevIp ,


g_nPort , CLIENT_GetLastError());

else

printf("CLIENT_LoginWithHighLevelSecurity %s[%d] Success\n" , g_szDevIp , g_nPort);

}
// When first time logging in, some data is needed to be initialized to enable normal business
function. It is recommended to wait for a while after login, and the waiting time varies by devices.

Sleep(1000);

printf("\n");

void RunTest()

if (FALSE == g_bNetSDKInitFlag)

return;

if (0 == g_lLoginHandle)

return;

// Subscribe smart snapshot alarm

LDWORD dwUser = 0;

int nChannel = 0;

// Each setup corresponds to one channel, and corresponds to event of a certain type.

190
// If a user wants to set all types of event for one channel, the parameter dwAlarmType should be set
to EVENT_IVS_ALL.

// If you want to set that one channel uploads two events, call CLIENT_RealLoadPictureEx twice and
set different event type.

g_lRealLoadHandle = CLIENT_RealLoadPictureEx(g_lLoginHandle, nChannel, EVENT_IVS_ALL, TRUE,


AnalyzerDataCallBack, dwUser, NULL);

if (0 == g_lRealLoadHandle)

printf("CLIENT_RealLoadPictureEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

return;

// Manually snapshot to trigger smart snapshot alarm

while(1)

char szGetBuf[64] = "";

printf("manual snap, \'q\': quit, other: yes\n");

gets(szGetBuf);

// Input 'q' to exit manually snapshot trigger alarm, others mean to trigger alarm

if (0 == strncmp(szGetBuf, "q", sizeof(szGetBuf) - 1))

break;

MANUAL_SNAP_PARAMETER stuSanpParam = {0};

[Link] = 0;

memcpy([Link], "just for test", sizeof([Link]) - 1);

// Manually snapshot trigger alarm function, and this function is only valid for ITC device.

if (FALSE == CLIENT_ControlDeviceEx(g_lLoginHandle, DH_MANUAL_SNAP, &stuSanpParam))

printf("CLIENT_ControlDeviceEx Failed!Last Error[%x]\n", CLIENT_GetLastError());

break;

191
void EndTest()

printf("input any key to quit!\n");

getchar();

// Stop subscribing snapshot alarm.

if (0 != g_lRealLoadHandle)

if (FALSE == CLIENT_StopLoadPic(g_lRealLoadHandle))

printf("CLIENT_StopLoadPic Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lRealLoadHandle = 0;

// Log ou t of device

if (0 != g_lLoginHandle)

if (FALSE == CLIENT_Logout(g_lLoginHandle))

printf("CLIENT_Logout Failed!Last Error[%x]\n", CLIENT_GetLastError());

else

g_lLoginHandle = 0;

// Clean up initialization resources

if (TRUE == g_bNetSDKInitFlag)

192
{

CLIENT_Cleanup();

g_bNetSDKInitFlag = FALSE;

return;

int main()

InitTest();

RunTest();

EndTest();

return 0;

//*********************************************************************************

// Commonly used callback set definition.

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser)

printf("Call DisConnectFunc\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Call HaveReConnect\n");

printf("lLoginID[0x%x]", lLoginID);

if (NULL != pchDVRIP)

193
{

printf("pchDVRIP[%s]\n", pchDVRIP);

printf("nDVRPort[%d]\n", nDVRPort);

printf("dwUser[%p]\n", dwUser);

printf("\n");

int CALLBACK AnalyzerDataCallBack(LLONG lAnalyzerHandle, DWORD dwAlarmType, void* pAlarmInfo,


BYTE *pBuffer, DWORD dwBufSize, LDWORD dwUser, int nSequence, void *reserved)

if (lAnalyzerHandle != g_lRealLoadHandle)

return 0;

int nAlarmChn = 0;

switch(dwAlarmType)

case EVENT_IVS_TRAFFIC_OVERLINE:

printf("EVENT_IVS_TRAFFIC_OVERLINE event\n");

DEV_EVENT_TRAFFIC_OVERLINE_INFO* pStuInfo =
(DEV_EVENT_TRAFFIC_OVERLINE_INFO*)pAlarmInfo;

nAlarmChn = pStuInfo->nChannelID;

printf("nChannelID[%d]\n", pStuInfo->nChannelID);

break;

case EVENT_IVS_PARKINGDETECTION:

printf("EVENT_IVS_PARKINGDETECTION event\n");

DEV_EVENT_PARKINGDETECTION_INFO* pStuInfo =
(DEV_EVENT_PARKINGDETECTION_INFO*)pAlarmInfo;

nAlarmChn = pStuInfo->nChannelID;

printf("nChannelID[%d]\n", pStuInfo->nChannelID);

194
}

break;

case EVENT_IVS_TRAFFIC_MANUALSNAP:

printf("EVENT_IVS_TRAFFIC_MANUALSNAP event\n");

DEV_EVENT_TRAFFIC_MANUALSNAP_INFO* pStuInfo =
(DEV_EVENT_TRAFFIC_MANUALSNAP_INFO*)pAlarmInfo;

nAlarmChn = pStuInfo->nChannelID;

// pStuInfo->szManualSnapNo should be "just for test"

printf("nChannelID[%d]\n", pStuInfo->nChannelID);

break;

default:

printf("other event type[%d]\n", dwAlarmType);

break;

if (dwBufSize > 0 && NULL != pBuffer)

// In case of too many snapshots being received at the same time, mark with i than saving
snapshots by receiving time which may cause overlapping.

static int i;

char szPicturePath[256] = "";

time_t stuTime;

time(&stuTime);

char szTmpTime[128] = "";

strftime(szTmpTime, sizeof(szTmpTime) - 1, "%y%m%d_%H%M%S", gmtime(&stuTime));

_snprintf(szPicturePath, sizeof(szPicturePath)-1, "%d_%[Link]", ++i, szTmpTime);

FILE* pFile = fopen(szPicturePath, "wb");

if (NULL == pFile)

return 0;

195
int nWrite = 0;

while(nWrite != dwBufSize)

nWrite += fwrite(pBuffer + nWrite, 1, dwBufSize - nWrite, pFile);

fclose(pFile);

return 1;
}

App Management

2.15.1 Introduction
App management includes obtaining device status and the list of device applications, as well as
updating and installing (which includes preparation for updates, pushing update data, and
executing updates). It also involves starting, stopping, and deleting programs.

2.15.2 Interface Overview


Table 2-15 Interfaces of app management
Interface Implication
CLIENT_Init SDK initialization.
CLIENT_Cleanup SDK cleaning up.
Log in with high level security.

CLIENT_LoginEx2 can still be used, but there


CLIENT_LoginWithHighLevelSecurity are security risks, so it is highly
recommended to use the interface
CLIENT_LoginWithHighLevelSecurity to log in
to the device.
CLIENT_StartApp Run the program.
CLIENT_StopApp Stop the program.
CLIENT_RemoveApp Delete the program.
CLIENT_GetNewDevConfig +
Get configuration files.
CFG_CMD_DEV_GENERRAL
CLIENT_GetInstalledAppInfo Get the list of installed apps.
CLIENT_QueryDevState Search for the device status.

196
Interface Implication
CLIENT_UpgraderInstall Update related interfaces.
CLIENT_UpgraderInstall +
Prepare for the update.
EM_UPGRADER_INSTALL_PREPAREEX
CLIENT_UpgraderInstall +
Push update data.
EM_UPGRADER_INSTALL_APPEND_DATA
CLIENT_UpgraderInstall +
Execute the update.
EM_UPGRADER_INSTALL_EXECUTE
CLIENT_Logout Log out of the interface.
Get error codes of interfaces that fail to be
CLIENT_GetLastError
called.

2.15.3 Process
The process of app management is shown as the figure below.

Process Description
Initialize SDK.
Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
Call CLIENT_StartApp to send a request to the device to start the app. After the app
starts successfully, you need to check the device information. Use interfaces
CLIENT_GetNewDevConfig and CFG_CMD_DEV_GENERRAL to get the configuration
files, and use interface CLIENT_QueryDevState to check the device status.
If the user needs to update the app, call CLIENT_GetInstalledAppInfo to get the list of
installed apps. Use the interface CLIENT_UpgraderInstall and enumerate the emType to
update.
When emType is EM_UPGRADER_INSTALL_PREPAREEX, the SDK sends an update
preparation command to the device. If the device returns a success response, it means
it is ready for the update.
When emType is EM_UPGRADER_INSTALL_APPEND_DATA, the SDK sends the update
data to the device. The device will wait for the update after receiving the data.
When emType is EM_UPGRADER_INSTALL_EXECUTE, the SDK sends a command to
execute the update to the device. If the device returns a success response, it means the
update is being executed.
When emType is EM_UPGRADER_INSTALL_GETSTATE, the SDK sends a command to the
device to get the update status. The device will respond the update status.
When emType is EM_UPGRADER_INSTALL_CANCEL, the SDK sends a command to the
device to cancel the update. If the device returns a success response, it means the
update is canceled.
When emType is EM_UPGRADER_INSTALL_FIRMWAREEX, SDK sends a command to the
device with the specified update package address. The device will receive this
command and use the designated package to perform the update.
Call CLIENT_StopApp to stop the program. If the user wants to delete the app, call
CLIENT_RemoveApp.
After using the service, call CLIENT_Logout to log out of the device.
After using all SDK functions, call CLIENT_Cleanup to release SDK resources.

197
Process of app management

Start

Initialize SDK

Log in to device
CLIENT_LoginWithHighLevelSecurity Search for configuration information
Device information:
CLIENT_GetNewDevConfig
Call CLIENT_StartApp to start the app Device status: CLIENT_QueryDevState

Get the list of installed apps through Call CLIENT_UpgraderInstall to update


CLIENT_GetInstalledAppInfo

Call CLIENT_StopApp to stop the


program Call CLIENT_RemoveApp to delete the
program
Log out of device
CLIENT_Logout

Release SDK resources


CLIENT_Cleanup

Stop

2.15.4 Example Code


#include "stdafx.h"

#include <iostream>

#include <cstring>

#include "dhnetsdk.h"

#include "dhconfigsdk.h"

#include "testUtil.h"

#ifdef _WIN64

#pragma comment(lib, "./lib/win64/[Link]")

#pragma comment(lib, "./lib/win64/[Link]")

198
#else

#pragma comment(lib, "./lib/win32/[Link]")

#pragma comment(lib, "./lib/win32/[Link]")

#endif

LLONG g_lHandle = 0;

LLONG g_lFindID = 0;

LLONG lRealloadHandle = 0;

LLONG g_lFindHandle = 0;

void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Device is DisConnected\n");

void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)

printf("Device is Reconnecting!\n");

void TestStartApp(void* data)

LLONG lLoginID = *(LLONG*)data;

NET_IN_START_APP stuIn = {sizeof(NET_IN_START_APP)};;

memset(&stuIn, 0, sizeof(NET_IN_START_APP));

[Link] = sizeof(NET_IN_START_APP);

NET_OUT_START_APP stuOut = {sizeof(NET_OUT_START_APP)};;

memset(&stuOut, 0, sizeof(NET_OUT_START_APP));

[Link] = sizeof(NET_OUT_START_APP);

[Link] = 3214;

strncpy([Link], "TestAppCheck", sizeof([Link]) - 1);

BOOL bRet = CLIENT_StartApp(lLoginID, &stuIn,&stuOut,5000);

if(bRet)

printf("CLIENT_StartApp success\r\n");

199
}

else

printf("CLIENT_StartApp fail, error:%0x\n", CLIENT_GetLastError());

void TestQueryDevState(void* data)

LLONG lLoginID = *(LLONG*)data;

DHDEV_UPGRADE_STATE_INFO *pstInfo = new DHDEV_UPGRADE_STATE_INFO;

int nRetLen = sizeof(DHDEV_UPGRADE_STATE_INFO);

BOOL bRet = CLIENT_QueryDevState(lLoginID, DH_DEVSTATE_GET_UPGRADE_STATE, (char *)pstInfo,


sizeof(DHDEV_UPGRADE_STATE_INFO), &nRetLen, 1000);

if(bRet)

printf("CLIENT_QueryDevState success\r\n");

else

printf("CLIENT_QueryDevState fail, error:%0x\n", CLIENT_GetLastError());

delete pstInfo;

pstInfo = NULL;

void TestGetNewDevConfig(void* data)

LLONG lLoginID = *(LLONG*)data;

int nChannel = -1;

int nBufLen = 1024*1024*20;

char *pbufsize = new char[nBufLen];

memset(pbufsize, 0, nBufLen);

int nError = 0;

int nRetlen = 0;

CFG_DEV_DISPOSITION_INFO *pstinfo = new CFG_DEV_DISPOSITION_INFO;

200
memset(pstinfo, 0, sizeof(CFG_DEV_DISPOSITION_INFO));

BOOL bRet = CLIENT_GetNewDevConfig(lLoginID, CFG_CMD_DEV_GENERRAL, nChannel, pbufsize,


nBufLen, &nError, 5000);

if (bRet)

printf("GetNewDevConfig success\n");

bRet = CLIENT_ParseData(CFG_CMD_DEV_GENERRAL, pbufsize, pstinfo,


sizeof(CFG_DEV_DISPOSITION_INFO), NULL);

if (bRet)

printf("ParseData success\n");

printf("pstinfo->nLocalNo :%d\n",pstinfo->nLocalNo);

printf("pstinfo->szMachineID :%s\n",pstinfo->szMachineID);

else

printf("ParseData Failed, error is %d\n", CLIENT_GetLastError()&0x7fffffff);

else

printf("GetNewDevConfig Failed, error is %d\n", CLIENT_GetLastError()&0x7fffffff);

delete[] pbufsize;

pbufsize = NULL;

delete pstinfo;

pstinfo = NULL;

void TestGetInstalledAppInfo(void* data)

LLONG lLoginID = *(LLONG*)data;

NET_IN_GET_INSTALLED_APP_INFO stuIn = {sizeof(NET_IN_GET_INSTALLED_APP_INFO)};;

memset(&stuIn, 0, sizeof(NET_IN_GET_INSTALLED_APP_INFO));

201
[Link] = sizeof(NET_IN_GET_INSTALLED_APP_INFO);

NET_OUT_GET_INSTALLED_APP_INFO stuOut = {sizeof(NET_OUT_GET_INSTALLED_APP_INFO)};;

memset(&stuOut, 0, sizeof(NET_OUT_GET_INSTALLED_APP_INFO));

[Link] = sizeof(NET_OUT_GET_INSTALLED_APP_INFO);

BOOL bRet = CLIENT_GetInstalledAppInfo(lLoginID, &stuIn,&stuOut,5000);

if(bRet)

printf("CLIENT_GetInstalledAppInfo success\r\n");

printf("[Link] :%d\n",[Link]);

for(int i = 0;i<[Link];i++)

printf("[Link][%d].szAppName :%s\n",i,[Link][i].szAppName);

else

printf("CLIENT_GetInstalledAppInfo fail, error:%0x\n", CLIENT_GetLastError());

void TestUpgraderInstallPrepare(void* data)

LLONG lLoginID = *(LLONG*)data;

EM_NET_UPGRADE_INSTALL_TYPE emType = EM_UPGRADER_INSTALL_PREPAREEX;

NET_IN_INSTALL_PREPAREEX stuIn = {sizeof(NET_IN_INSTALL_PREPAREEX)};

memset(&stuIn, 0, sizeof(NET_IN_INSTALL_PREPAREEX));

[Link] = sizeof(NET_IN_INSTALL_PREPAREEX);

NET_OUT_INSTALL_PREPAREEX stuOut = {sizeof(NET_OUT_INSTALL_PREPAREEX)};

memset(&stuOut, 0, sizeof(NET_OUT_INSTALL_PREPAREEX));

[Link] = sizeof(NET_OUT_INSTALL_PREPAREEX);

[Link] = true;

[Link] = EM_NET_NEXT_OPERATE_INSTALL;

202
[Link] = 1024;

strncpy([Link], "TestAppCheck", sizeof([Link]) - 1);

BOOL bRet = CLIENT_UpgraderInstall(lLoginID, emType,&stuIn,&stuOut,5000);

if(bRet)

printf("TestUpgraderInstallPrepare success\r\n");

else

printf("TestUpgraderInstallPrepare fail, error:%0x\n", CLIENT_GetLastError());

void TestUpgraderInstallAppend(void* data)

LLONG lLoginID = *(LLONG*)data;

EM_NET_UPGRADE_INSTALL_TYPE emType = EM_UPGRADER_INSTALL_APPEND_DATA;

NET_IN_INSTALL_APPEND_DATA stuIn = {sizeof(NET_IN_INSTALL_APPEND_DATA)};

memset(&stuIn, 0, sizeof(NET_IN_INSTALL_APPEND_DATA));

[Link] = sizeof(NET_IN_INSTALL_APPEND_DATA);

NET_OUT_INSTALL_APPEND_DATA stuOut = {sizeof(NET_OUT_INSTALL_APPEND_DATA)};

memset(&stuOut, 0, sizeof(NET_OUT_INSTALL_APPEND_DATA));

[Link] = sizeof(NET_OUT_INSTALL_APPEND_DATA);

[Link] = 1024;

[Link] = 32;

[Link] = new unsigned char[[Link]];

for(int i = 0;i<[Link];i++)

[Link][i] = (unsigned char)(i+1);

BOOL bRet = CLIENT_UpgraderInstall(lLoginID, emType,&stuIn,&stuOut,5000);

if(bRet)

203
printf("TestUpgraderInstallAppend success\r\n");

else

printf("TestUpgraderInstallAppend fail, error:%0x\n", CLIENT_GetLastError());

delete[] [Link];

[Link] = NULL;

void TestUpgraderInstallExecute(void* data)

LLONG lLoginID = *(LLONG*)data;

EM_NET_UPGRADE_INSTALL_TYPE emType = EM_UPGRADER_INSTALL_EXECUTE;

NET_IN_INSTALL_EXECUTE stuIn = {sizeof(NET_IN_INSTALL_EXECUTE)};

memset(&stuIn, 0, sizeof(NET_IN_INSTALL_EXECUTE));

[Link] = sizeof(NET_IN_INSTALL_EXECUTE);

NET_OUT_INSTALL_EXECUTE stuOut = {sizeof(NET_OUT_INSTALL_EXECUTE)};

memset(&stuOut, 0, sizeof(NET_OUT_INSTALL_EXECUTE));

[Link] = sizeof(NET_OUT_INSTALL_EXECUTE);

[Link] = false;

BOOL bRet = CLIENT_UpgraderInstall(lLoginID, emType,&stuIn,&stuOut,5000);

if(bRet)

printf("TestUpgraderInstallExecute success\r\n");

else

printf("TestUpgraderInstallExecute fail, error:%0x\n", CLIENT_GetLastError());

void TestStopApp(void* data)

204
LLONG lLoginID = *(LLONG*)data;

NET_IN_STOP_APP stuIn = {sizeof(NET_IN_STOP_APP)};;

memset(&stuIn, 0, sizeof(NET_IN_STOP_APP));

[Link] = sizeof(NET_IN_STOP_APP);

NET_OUT_STOP_APP stuOut = {sizeof(NET_OUT_STOP_APP)};;

memset(&stuOut, 0, sizeof(NET_OUT_STOP_APP));

[Link] = sizeof(NET_OUT_STOP_APP);

[Link] = 3214;

strncpy([Link], "TestAppCheck", sizeof([Link]) - 1);

BOOL bRet = CLIENT_StopApp(lLoginID, &stuIn,&stuOut,5000);

if(bRet)

printf("CLIENT_StopApp success\r\n");

else

printf("CLIENT_StopApp fail, error:%0x\n", CLIENT_GetLastError());

void TestRemoveApp(void* data)

LLONG lLoginID = *(LLONG*)data;

NET_IN_REMOVE_APP stuIn = {sizeof(NET_IN_REMOVE_APP)};;

memset(&stuIn, 0, sizeof(NET_IN_REMOVE_APP));

[Link] = sizeof(NET_IN_REMOVE_APP);

NET_OUT_REMOVE_APP stuOut = {sizeof(NET_OUT_REMOVE_APP)};;

memset(&stuOut, 0, sizeof(NET_OUT_REMOVE_APP));

[Link] = sizeof(NET_OUT_REMOVE_APP);

[Link] = 3214;

strncpy([Link], "TestAppCheck", sizeof([Link]) - 1);

BOOL bRet = CLIENT_RemoveApp(lLoginID, &stuIn,&stuOut,5000);

205
if(bRet)

printf("CLIENT_RemoveApp success\r\n");

else

printf("CLIENT_RemoveApp fail, error:%0x\n", CLIENT_GetLastError());

int main()

SetConsoleOutputCP(CP_UTF8);

CLIENT_Init(DisConnectFunc, 0);

CLIENT_SetAutoReconnect(HaveReConnect, NULL);

LOG_SET_PRINT_INFO stLogPrintInfo = {sizeof(stLogPrintInfo)};

CLIENT_LogOpen(&stLogPrintInfo);

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;

memset(&stInparam, 0, sizeof(stInparam));

[Link] = sizeof(stInparam);

strncpy([Link], "[Link]", sizeof([Link]) - 1);

strncpy([Link], "admin123", sizeof([Link]) - 1);

strncpy([Link], "admin", sizeof([Link]) - 1);

[Link] = 37777;

[Link] = EM_LOGIN_SPEC_CAP_TCP;

printf("[Link]: %s, [Link]: %d\n", [Link],[Link]);

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;

memset(&stOutparam, 0, sizeof(stOutparam));

[Link] = sizeof(stOutparam);

LLONG lLoginID = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);

206
if (0 == lLoginID)

printf("CLIENT_LoginWithHighLevelSecurity fail,error:%d\n", [Link]);

printf("Enter any key to exit\n");

getchar();

CLIENT_Cleanup();

return 0;

else

CTestMenu menu(&lLoginID);

[Link]("case: CLIENT_StartApp.", TestStartApp);

[Link]("case: CLIENT_QueryDevState.", TestQueryDevState);

[Link]("case: CLIENT_GetNewDevConfig + CFG_CMD_DEV_GENERRAL.",


TestGetNewDevConfig);

[Link]("case: CLIENT_GetInstalledAppInfo.", TestGetInstalledAppInfo);

[Link]("case: CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_PREPAREEX.",


TestUpgraderInstallPrepare);

[Link]("case: CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_APPEND_DATA.",


TestUpgraderInstallAppend);

[Link]("case: CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_EXECUTE.",


TestUpgraderInstallExecute);

[Link]("case: CLIENT_StopApp.", TestStopApp);

[Link]("case: CLIENT_RemoveApp.", TestRemoveApp);

[Link]();

CLIENT_Logout(lLoginID);

CLIENT_Cleanup();

return 0;

207
3 Callback Function

fDisConnect
Table 3-1 fDisConnect
Item Description
Disconnection callback [Link] users by this callback when logined
Name
device gets disconnected.
Precondition None.
typedef void(CALLBACK *fDisConnect)(
LLONG lLoginID,
char *pchDVRIP,
Function
LONG nDVRPort,
LDWORD dwUser
);
Logined device [Link] value of interface
lLoginID
CLIENT_LoginWithHighLevelSecurity.
Device [Link] device IP which is the input IP
pchDVRIP
of login interface.
Parameter
Device [Link] device port which is the
nDVRPort
input port of login interface.
User data which should be the same with the
dwUser
imported value when setting fDisConnect.
Return value None.
Set this callback in interface CLIENT_Init. Users can identify which device gets
Note
disconnected by parameters lLoginID, pchDVRIP and nDVRPort.

fHaveReConnect
Table 3-2 fHaveReConnect
Item Description
Successful reconnection callback function. When the disconnected device gets
Name
reconnected, call this interface to inform users.
Precondition None.
typedef void (CALLBACK *fHaveReConnect)( LLONG lLoginID,
Function char *pchDVRIP, LONG nDVRPort, LDWORD dwUser
);
Logined device [Link] value of interface
lLoginID
CLIENT_LoginWithHighLevelSecurity.
Parameter
Device [Link] device IP which is the input IP
pchDVRIP
of login interface.

208
Item Description
Device [Link] device port which is the
nDVRPort
input port of login interface.
User data which should be the same with the
dwUser
imported value when setting fDisConnect.
Return value None.
Set this callback in interface CLIENT_SetAutoReconnect.
Note Users can identify which device gets reconnected by parameters lLoginID,
hDVRIP and nDVRPort.

fRealDataCallBackEx
Table 3-3 fRealDataCallBackEx
Item Description
Name Real-time monitoring data callback function prototype extension
Precondition None.
typedef void (CALLBACK *fRealDataCallBackEx)(
LLONG lRealHandle,
DWORD dwDataType,
BYTE *pBuffer,
Function
DWORD dwBufSize,
LONG param,
LDWORD dwUser
);
Real-time monitoring handle. Return value of interfaces
lRealHandle pulling real-time monitoring bitstream, such as
CLIENT_RealPlayEx.
Data type call backed by mark. It is determined by
dwFlag of CLIENT_SetRealDataCallBackEx.
0: Original data which is consistent with data saved by
dwDataType SaveRealData.
1: Frame data.
Parameter 2: Yuv data.
3: Pcm audio data.
Buffer for callback data. Data of different length will be
called back according to different data type. The data
pBuffer
are called back by frame for every type but type 0, and
each time one frame is called back.
Callback data length.
dwBufSize The data buffers are diffreent for different types. The
unit is byte.

209
Item Description
Callback parameter structure. Different type value
corresponds to different parameter structure.
The structure is 0 when type is 0 or 2.
When dwDataType is 1, param is a pointer of structure
param tagVideoFrameParam. For details, see
tagVideoFrameParam.
When dwDataType is 3, param is a pointer of structure
tagCBPCMDataParam. For details, see
tagCBPCMDataParam.
User data which should be the same with the imported
dwUserData
value when setting fRealDataCallBackEx.
Return value None.
Set this callback in interface CLIENT_SetRealDataCallBackEx.
Note In this callback, users can indentify which callback data is monitored in real
time by lRealHandle.

fRealDataCallBackEx2
Table 3-4 fRealDataCallBackEx2
Item Implication
Description Real-time monitoring data callback function prototype extension 2
Pre-conditions None.
typedef void (CALLBACK *fRealDataCallBackEx2)(
LLONG lRealHandle,
DWORD dwDataType,
BYTE *pBuffer,
Function
DWORD dwBufSize,
LONG param,
LDWORD dwUser
);

210
Item Implication
lRealHandle
Live video handles. The return values from interfaces like
CLIENT_RealPlayEx used for getting real-time live video streams.
dwDataType
Identifies the data type returned by the callback.
Determined by the dwFlag of the CLIENT_SetRealDataCallBackEx
interface. The specific data type definition of dwDataType is as
follows:
 0: Original data (Same as the data saved by SaveRealData).
 1: Frame data.
 2: yuv data.
 3: pcm audio data.
pBuffer
Callback data. Depending on the data type, each callback returns
data of varying lengths. Apart from the original data, all other data
types are returned in frame format, with each callback providing
Parameter one frame of data.
dwBufSize
The length of the callback data. Different data types have different
lengths. The unit is bytes.
param
Callback data parameter structure.
The parameter structure varies depending on the data type.
 When type is 0 (original data) and 2 (YUV data), param is 0.
 When the callback data type is frame data, param is a
tagVideoFrameParam structure pointer. For details, see 4.8
tagVideoFrameParam.
 When the data type is PCM data, param is a
tagCBPCMDataParam structure pointer. For details, see 4.9
tagCBPCMDataParam.
dwUserData
User data is consistent with the user data input when setting the
fRealDataCallBackEx callback function.
Return value None.
Remarks None.

fDataCallBackEx
Table 3-5 fDataCallBackEx
Item Implication
Description Real-time monitoring transcoding data callback function extension 2
Pre-conditions None.

211
Item Implication
typedef void (CALLBACK *fDataCallBackEx)(
LLONG lRealHandle,
Function NET_DATA_CALL_BACK_INFO *pDataCallBack,
LDWORD dwUser
);
lRealHandle
Live video handles. The return values from interfaces like
CLIENT_RealPlayEx used for getting real-time live video streams.
pDataCallBack
Parameter
The callback data. See structure NET_DATA_CALL_BACK_INFO
dwUserData
User data is consistent with the user data input when setting the
fRealDataCallBackEx callback function.
Return value None.
Remarks None.

fDownLoadPosCallBack
Table 3-6 fDownLoadPosCallBack
Item Description
Name Playback progress callback function
Precondition None.
typedef int (CALLBACK *fDataCallBack)(
LLONG lRealHandle,
DWORD dwDataType,
Function BYTE *pBuffer,
DWORD dwBufSize,
LDWORD dwUser
);
Playback handle. Return value of playback interfaces
lPlayHandle
such as CLIENT_PlayBackByTimeEx.
dwTotalSize Total size of the current play. The unit is KB.
The size that has been played. The unit is KB.
Parameter
dwDownLoadSize When the value is -1, it means the end of the
playback; and -2 means it failed to write the file.
User data which should be the same with the
dwUser
imported value when setting fDownLoadPosCallBack.
Return value None.
Set this callback in record palyback interfaces, such as
CLIENT_PlayBackByTimeEx.
Note
In this callback, users can indentify which progress callback corresponding to
the current stream by lRealHandle.

212
fDataCallBack
Table 3-7 fDataCallBack
Item Description
Name Playback data callback function
Precondition None.
typedef int (CALLBACK *fDataCallBack)(
LLONG lRealHandle,
DWORD dwDataType,
Function BYTE *pBuffer,
DWORD dwBufSize,
LDWORD dwUser
);
Playback handle. Return value of playback interfaces
lPlayHandle
such as CLIENT_PlayBackByTimeEx.
Data [Link] value remains 0, which means data of
dwDataType
original type.
Parameter Data buffer which is used to store video data of this
pBuffer
callback.
dwBufSize Data stored buffer length. The unit is byte.
User data which should be the same with the imported
dwUser
value when setting fDataCallBackEx.
Return value None.
Set the callback function in record playback interfaces such as
CLIENT_PlayBackByTimeEx.
If parameter, if hWnd is not NULL, no matter what value returns, the callback is
Note
being considered successful and next callback will return follow-up data.
In this callback, users can indentify which progress callback corresponding to the
current stream by lRealHandle.

fTimeDownLoadPosCallBack
Table 3-8 fTimeDownLoadPosCallBack
Item Description
Name Callback of download by time.
Precondition None.
typedef void (CALLBACK *fTimeDownLoadPosCallBack) (
LLONG lPlayHandle,
DWORD dwTotalSize,
DWORD dwDownLoadSize,
Function
int index,
NET_RECORDFILE_INFO recordfileinfo,
LDWORD dwUser
);

213
Item Description
Download handle. Return value of playback
lPlayHandle
interfaces such as CLIENT_DownloadByTimeEx.
dwTotalSize Total size of playback. The unit is KB.
dwDownLoadSize The size that has been played. The unit is KB.
Sequence number of the currently downloaded
index
Parameter video file, starting from 0.
Current downloaded files information. For details,
recordfileinfo
see structure NET_RECORDFILE_INFO.
User data which should be the same with the
dwUser imported value when setting
fTimeDownLoadPosCallBack.
Return value None.
Set the callback function in interfaces downloading by time, such as
CLIENT_PlayBackByTimeEx.
Note
In this callback, users can indentify which progress callback corresponding to the
record download by lRealHandle.

fMessCallBack
Table 3-9 fMessCallBack
Item Description
Name Alarm report callback function prototype
Precondition None.
typedef BOOL (CALLBACK *fMessCallBack)(
LONG lCommand,
LLONG lLoginID,
char *pBuf,
Function DWORD dwBufLen,
char *pchDVRIP,
LONG nDVRPort,
LDWORD dwUser
);
Alarm event type of callback which is matched with pBuf
lCommand for usage. Different lCommands have different types of
pBuf. For details, see the following descriptions.
Device login ID. Return value of device login interfaces
lLoginID
such as CLIENT_LoginWithHighLevelSecurity.
Parameter Alarm data received buffer.
pBuf pBuf points to different data type according to different
listen interface and different lCommand.
dwBufLen Length of alarm data received buffer. The unit is byte.
pchDVRIP Device IP which reports alarm.
nDVRPort Device port which reports alarm.

214
Item Description
User data which should be the same with the imported
dwUser
value when setting fMessCallBack.
Return value None.
All the logined device use the same alarm report callback function.
Users indentify which login report the alarm by parameter lLoginID.
pBuf points to different data type according to different listen interface and
different lCommand.
Note As there are too many alarm events, here does not introduce them all, and
users can search the following key section in dhnetsdk.h:
// Extensive alarm type, corresponding to CLIENT_StartListenEx
#define DH_ALARM_ALARM_EX 0x2101 // External alarm
To find the corresponding descriptions.

fSearchDevicesCB
Table 3-10 fSearchDevicesCB
Item Description
Name Device search callback prototype
Precondition None.
typedef void (CALLBACK *fSearchDevicesCB)(
DEVICE_NET_INFO_EX *pDevNetInfo,
Function
void* pUserData
);
pDevNetInfo Device info structure. For details, see structure
DEVICE_NET_INFO_EX.
Parameter
pUserData User data which should be the same with the
imported value when setting fSearchDevicesCB.
Return value None.
Device search callback function.
It is not recommended to call SDK interfaces in this callback function.
Note Set the callback function by CLIENT_StartSearchDevices/
CLIENT_SearchDevicesByIPs. When device is searched out, SDK will call this
function.

fSearchDevicesCBEx
Table 3-11 fSearchDevicesCBEx
Item Description
Name Device search callback prototype
Precondition None.

215
Item Description
typedef void(CALLBACK * fSearchDevicesCBEx)(
LLONG lSearchHandle,
Function DEVICE_NET_INFO_EX2 *pDevNetInfo,
void* pUserData
);
lSearchHandle Returned serach handle of CLIENT_StartSearchDevicesEx.
Device inforamtion structure. For details, see structure
pDevNetInfo
Parameter definition of DEVICE_NET_INFO_EX2.
User data which should be the same with the imported
pUserData
value when setting fSearchDevicesCBEx.
Return value None.
Device search callback function.
It is not recommended to call SDK interfaces in this callback function.
Note
Set the callback function by CLIENT_StartSearchDevicesEx. When device is
searched out, SDK will call this function.

fAnalyzerDataCallBack
Table 3-12 fAnalyzerDataCallBack
Item Description
Name Smart snapshot alarm callback function prototype
Precondition None.
typedef int (CALLBACK *fAnalyzerDataCallBack)(
LLONG lAnalyzerHandle,
DWORD dwAlarmType,
void* pAlarmInfo,
BYTE *pBuffer,
Function
DWORD dwBufSize,
LDWORD dwUser,
int nSequence,
void *reserved
);
Smart snapshot alarm subscription handle. When
multiple samrt snapshot alarm subscriptions use the
lAnalyzerHandle same callback function, users can find the
corresponding subscription operation by
lAnalyzerHandle.
Smart snapshot alarm type which is mathed with
Parameter
pAlarmInfo to use. pAlarmInfo points to different
dwAlarmType
data type according to different dwAlarmType
value.
Structure pointer which is mathed with
pAlarmInfo dwAlarmType to use. pAlarmInfo points to different
data type according to different dwAlarmType

216
Item Description
value.
pBuffer Smart snapshot info buffer.

dwBufSize Smart snapshot info size.


User data which should be the same with the
dwUser
imported value when setting fSearchDevicesCB.
Whether the sanpshot is repeated
0: It is the first time that the picture shows up, and
the follow-up alarms may use the picture.
1: This picture is the same as the one shown in the
last alarm, and the follow-up alarms may use the
nSequence picture.
2: This picture is the same as the one shown in the
last alarm. It will never show up again or it is the
only time that the picture shows up. (Most of the
alarms have an unique snapshot ,and nSequence
valus is 2 generally.)
Satatus of the current callback. Reserved is the int
pointer.
*(int *)reserved value:
0: Current data is real-time data.
reserved
1: Current data is off-line data.
2: Off-line transfer is finished. (Most of the smart
snapshot alarm data is real-time data, and the value
of *(int *)reserved is 0 generally.)
Return value The return value has no meaning. Users can return 0.
Smart snapshot alarm callback function.
It is not recommended to call SDK interfaces in this callback function.
Set the callback function by CLIENT_RealLoadPictureEx/ CLIENT_RealLoadPicture.
When smart snapshot alarm is reported by device, SDK will call this function.
SDK receving buffer is 2M by default, so that users need to call
CLIENT_SetNetworkParam to set receiving buffer again when callback snapshot
Note info exceeds 2M; otherwise SDK will abandon data pack over 2M.
Different dwAlarmType matches with different pointer.
As there are too many alarm events, here does not introduce them all, and users
can search the following key section in dhnetsdk.h:
// Smart analysis event type
#define EVENT_IVS_ALL 0x00000001// Subscribe all events
To find the corresponding descriptions.

fSnapRev
Table 3-13 fSnapRev
Item Description
Name Front-end video snapshot callback function prototype

217
Item Description
Precondition None.
typedef void (CALLBACK *fSnapRev)(
LLONG lLoginID,
BYTE *pBuf,
UINT RevLen,
Function
UINT EncodeType,
DWORD CmdSerial,
LDWORD dwUser
);
Device login ID. When multiple front-end video
lLoginID snapshots use the same callback function, users can
indentify which snapshot is by this parameter.
Sanpshot info buffer. Used to store the sanpshot info
pBuf
returned by storage device.
RevLen Snapshot info buffer size.
Parameter Encode type
EncodeType 10: jpeg picture
0: i frame of mpeg4
Serial number of snapshot.
CmdSerial
It is input by CLIENT_SnapPictureEx input parameter
User data which should be the same with the imported
dwUser
value when setting fSnapRev.
Return value None.
Snapshot callback function.
It is not recommended to call SDK interfaces in this callback function.
Set the callback function by CLIENT_SetSnapRevCallBack. When there are
Note snapshot data sent by device, SDK will call this function.
SDK receving buffer is 2M by default, so that users need to call
CLIENT_SetNetworkParam to set receiving buffer again when callback snapshot
info exceeds 2M; otherwise SDK will abandon data pack over 2M.

fRealPlayDisConnect
Table 3-14 fRealPlayDisConnect
Item Description
Name Real-time monitoring disconnection callback function prototype
Precondition None.
typedef void (CALLBACK *fRealPlayDisConnect)(
LLONG lOperateHandle,
EM_REALPLAY_DISCONNECT_EVENT_TYPE dwEventType,
Function
void* param,
LDWORD dwUser
);

218
Item Description
Real-time monitoring handle. When multiple real-time
lOperateHandle monitoring devices use the same callback function, users
can identify the cprresonding operation by this parameter.
Event which causes disconnection. For details, see enum
Parameter dwEventType
description of EM_REALPLAY_DISCONNECT_EVENT_TYPE.
param Reserved paramerer, and the default value is NULL.
User data which should be the same with the imported
dwUser
value when setting fRealPlayDisConnect.
Return value None.
Real-time monitoring disconnection callback function.
It is not recommended to call SDK interfaces in this callback function.
Note
Set the callback function by CLIENT_StartRealPlay. When eal-time monitoring
isdisconnected, SDK will call this function.

pfAudioDataCallBack
Table 3-15 pfAudioDataCallBack
Item Description
Name Audion data callback function protptype
Precondition None.
typedef void (CALLBACK *pfAudioDataCallBack)(
LLONG lTalkHandle,
char *pDataBuf,
Function DWORD dwBufSize,
BYTE byAudioFlag,
LDWORD dwUser
);
Voice talk handle. Return value of voice talk interfaces such
lTalkHandle
as CLIENT_StartTalkEx.
Audio data being called back
pDataBuf
Where the data from is decided by parameter byAudioFlag
dwBufSize Length of audio data being called back. The unit is byte.
Flag indicates where the audio data from.
Parameter
0: Receive PC audio data collected by local audio library.
byAudioFlag Only CLIENT_RecordStartEx is called, can the data be called
back.
1: Receive audio data sent by device.
User data which should be the same with the imported
dwUser
value when setting pfAudioDataCallBack.
Return value None.
Note Set the callback function in interfaces voice talk, such as CLIENT_StartTalkE.

219
4 Structure Definition

NET_DEVICEINFO
Table 4-1 NET_DEVICEINFO
Option Instruction
Struct description Device info
typedef struct
{
BYTE sSerialNumber[DH_SERIALNO_LEN];
BYTE byAlarmInPortNum;
BYTE byAlarmOutPortNum;
BYTE byDiskNum;
Structure BYTE byDVRType;
union
{
BYTE byChanNum;
BYTE byLeftLogTimes;
};
} NET_DEVICEINFO, *LPNET_DEVICEINFO;
sSerialNumber
SN
byAlarmInPortNum
DVR alarm input amount
byAlarmOutPortNum
DVR alarm output amount
byDiskNum
DVR HDD amount
Members
byDVRType
DVR [Link] to NET_DEVICE_TYPE.
byChanNum
DVR channel amount. It is valid after user logged in.
byLeftLogTimes
When login failed due to password error, prompt user by
this parameter.
Remaining login times 0 means this parameter is invalid.

NET_PARAM
Table 4-2 NET_PARAM
Option Instruction
Struct description Relevant parameters of login
typedef struct
{
int nWaittime;
Struct
int nConnectTime;
int nConnectTryNum;
int nSubConnectSpaceTime;

220
Option Instruction
int nGetDevInfoTime;
int nConnectBufSize;
int nGetConnInfoTime;
int nSearchRecordTime;
int nsubDisconnetTime;
BYTE byNetType;
BYTE byPlaybackBufSize;
BYTE bDetectDisconnTime;
BYTE bKeepLifeInterval;
int nPicBufSize;
BYTE bReserved[4];
} NET_PARAM;
nWaittime
Waiting time(unit is ms), 0:default 5000ms.
nConnectTime
Connection timeout value (Unit is ms), 0:default 1500ms.
nConnectTryNum
Connection trial times, 0:default 1.
nSubConnectSpaceTime
Sub-connection waiting time(Unit is ms), 0:default 10ms.
nGetDevInfoTime
Get device information timeout, 0:default 1000ms.
nConnectBufSize
Receiving data buffer size of each connection(Bytes), 0:default
250*1024
nGetConnInfoTime
Getting sub-connect information timeout(Unit is ms), 0:default
1000ms.
nSearchRecordTime
Members Timeout value of search video (unit ms), default 3000ms
nsubDisconnetTime
Waiting time of sub-link offline detection (unit ms), default 6000ms
byNetType
Network type,0-LAN,1-WAN.
byPlaybackBufSize
Playback data receiving buffer size(Unit;M). 0: default 4M.
bDetectDisconnTime
Pulse detection offline time(second) .When it is 0, the default setup is
60s, and the min time is 2s.
bKeepLifeInterval
Pulse sending out interval(second).When it is 0, the default setup is 10s,
the min internal is 2s.
nPicBufSize
Receiving buffer size of real-time piciture(Unit: byte). 0: default
2*1024*1024.
bReserved
Reserved byte

221
NET_DEVICEINFO_Ex
Table 4-3 NET_DEVICEINFO_Ex
Option Instruction
Struct description Device info extension
typedef struct
{
BYTE sSerialNumber[DH_SERIALNO_LEN];
int nAlarmInPortNum;
int nAlarmOutPortNum;
int nDiskNum;
int nDVRType;
Struct
int nChanNum;
BYTE byLimitLoginTime;
BYTE byLeftLogTimes;
BYTE bReserved[2];
int nLockLeftTime;
char Reserved[24];
} NET_DEVICEINFO_Ex, *LPNET_DEVICEINFO_Ex;
sSerialNumber
Device SN
nAlarmInPortNum
DVR alarm input amount
nAlarmOutPortNum
DVR alarm output amount
nDiskNum
DVR HDD amount
nDVRType
DVR [Link] to NET_DEVICE_TYPE.
nChanNum
DVR channel amount. It is valid after user logged in.
Members byLimitLoginTime
Online timeout. 0: no login limit. If it is not 0,it means the login limit
time (Unit: Minute).
byLeftLogTimes
When login failed due to password error, prompt user
by this parameter.
bReserved
Reserved byte. Byte alignment.
nLockLeftTime
Once login failed, it means the user unlock remaining time (Unit:
second). -1: Current parameter is null.
Reserved
Reserved byte

NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY
Table 4-4 NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY
Option Instruction
Struct description CLIENT_LoginWithHighLevelSecurity input parameters
Struct typedef struct tag NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY

222
Option Instruction
{
DWORD dwSize; // Structure size
char szIP[64]; // IP
int nPort; // Port
char szUserName[64]; // User name
char szPassword[64]; // Password
EM_LOGIN_SPAC_CAP_TYPE emSpecCap; // Login
mode
BYTE byReserved[4]; // Byte alignment
void* pCapParam; //A complementary
function of emSpecCap
} NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY;
dwSize
Structure size. Assign a value when using
sizeof(NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY).
szIp
Device IP
nPort
Login port
szUserName
User name
szPassword
Members
Password
emSpecCap
Login mode. The capabilities the device supports. Refer to
enumeration note of EM_LOGIN_SPAC_CAP_TYPE
byReserved
Byte alignment
pCapParam
The complementary function of emSpecCap, working with
emSpecCap. Refer to enumeration note of EM_LOGIN_SPAC_CAP_TYPE.
Input NULL if the value of pCapParam has no corresponding note.

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY
Table 4-5 NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY
Item Description
Struct description Output parameters of CLIENT_LoginWithHighLevelSecurity
typedef struct tagNET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY
{
DWORD dwSize; // Structure size
NET_DEVICEINFO_Ex stuDeviceInfo; // Device
Struct information
int nError; // error code.
Refer to error code of CLIENT_Login
BYTE byReserved[132]; // Reserved field
}NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY;
dwSize
Members Structure size. Assign a value when using
sizeof(NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY).

223
stuDeviceInfo
When the device successfully logged in, it saves the some information
of the logged in device. When the device failed to login, it saves the
information about the login such as remaining login attempts. Refer to
structure note of NET_DEVICEINFO.
nError
(It is null if the function returned successfully), return login error
code. Refer to the following contents.
1-Incorrect password
2 - User name does not exist
3 - Login timeout.
4 - Already logged in to this account.
5 - Account locked.
6 - The account is blocklisted
7 - System is busy. Resources are insufficient
8 - Sub-connection failed.
9 - Main connection failed.
10 - Exceeded maximum connections.
byReserved
Reserved field

NET_IN_STARTSERACH_DEVICE
Table 4-6 NET_IN_STARTSERACH_DEVICE
Option Instruction
Struct description Input parameters of CLIENT_StartSearchDevicesEx
typedef struct tagNET_IN_STARTSERACH_DEVICE
{
DWORD dwSize; // Structure size
char szLocalIp[MAX_LOCAL_IP_LEN]; // The local IP that
starts searching
fSearchDevicesCBEx cbSearchDevices; // Device
Struct
information
void* pUserData; // User
self-defined data
EM_SEND_SEARCH_TYPE emSendType; // Sending out
search type
}NET_IN_STARTSERACH_DEVICE;
dwSize
Structure size. Assign a value when using
sizeof(NET_IN_STARTSERACH_DEVICE).
szLocalIp
The local IP that starts searching
Do not need to input. The default value is NULL.
Members cbSearchDevices
Device info callback function
When there is corresponding package from the device, NetSDK parses
the package to valid information. And then use callback function to
notify the user. Refer to the callback function note of
fSearchDevicesCBEx.
Callback address cannot be null.

224
Option Instruction
pUserData
User self-defined data
NetSDK searches device callback function fSearchDevicesCB to return
the data to user so that the user can continue the following operations.
emSendType
Search type enumeration including multicast and broadcast. Refer to
the enumeration definition of EM_SEND_SEARCH_TYPE

NET_OUT_STARTSERACH_DEVICE
Table 4-7 NET_OUT_STARTSERACH_DEVICE
Item Description
Struct description Output parameters of CLIENT_StartSearchDevicesEx
typedef struct tagNET_OUT_STARTSERACH_DEVICE
{
Struct
DWORD dwSize; // Structure size
}NET_OUT_STARTSERACH_DEVICE;
dwSize
Members Structure size. Assign a value when using
sizeof(NET_OUT_STARTSERACH_DEVICE).

tagVideoFrameParam
Table 4-8 tagVideoFrameParam
Item Description
Struct description Frame structure of calling video data frame
typedef struct _tagVideoFrameParam
{
BYTE encode;
BYTE frametype;
BYTE format;
Struct BYTE size;
DWORD fourcc;
WORD width;
WORD height;
NET_TIME struTime;
} tagVideoFrameParam;
encode
Encode Type
Different values have different encode types. As follows:
MPEG4 encode – 1
Dahua H.264 encode -2
ADI H.264 encode – 3
Members Standard H.264 encode - 4
frametype
Frame type
Different values have different frame types. As follows:
I frame - 0
P frame - 1
B frame - 2

225
Item Description
format
Video format
Different values have different video formats. As follows:
RAID 0
RAID 1
size
Resolution
Different values have different resolutions. As follows:
RAID 0
HD1 – 1
2CIF2
D1 – 3
VGA – 4
QCIF – 5
QVGA – 6
SVCD – 7
QQVGA – 8
SVGA – 9
XVGA – 10
WXGA – 11
SXGA – 12
WSXGA – 13
UXGA – 14
WUXGA – 15
LFT – 16
720 – 17
1080 - 18
fourcc
If it is H.264 encode, the total amount is 0. Otherwise the value is
*( DWORD*)"DIVX",it is 0x58564944.
width
Width, unit is pixel. It is valid when size =255.
height
Height, unit is pixel. It is valid when size =255.
struTime
Time info
Refer to the structure note of the NET_TIME

tagCBPCMDataParam
Table 4-9 tagCBPCMDataParam
Item Description
Struct description Frame structure of callback audio data
typedef struct _tagCBPCMDataParam
{
BYTE channels;
BYTE samples;
Struct
BYTE depth;
BYTE param1;
DWORD reserved;
} tagCBPCMDataParam;
Members channels

226
Item Description
Sound track amount
samples
Sampling rate
Different values have different sampling rates. As follows:
0 – 8000
1 – 11025
2 - 16000
3 - 22050
4 - 32000
5 - 44100
6 - 48000
depth
Sampling depth
Value is 8,16 and so on.
param1
Audio data type
0 - Indication without icon
1 - Indication with icon
reserved
Reserve

NET_TIME
Table 4-10 NET_TIME
Item Description
Struct description Time structure. Unit is second.
typedef struct
{
DWORD dwYear;
DWORD dwMonth;
Struct DWORD dwDay;
DWORD dwHour;
DWORD dwMinute;
DWORD dwSecond;
} NET_TIME,*LPNET_TIME;
dwYear
Year
dwMonth
Month
dwDay
Day
Members
dwHour
Hour
dwMinute
Minute
dwSecond
Second

NET_RECORDFILE_INFO
Table 4-11 NET_RECORDFILE_INFO

227
Item Description
Struct description Structure description
typedef struct
{
unsigned int ch;
char filename[124];
unsigned int framenum;
unsigned int size;
NET_TIME starttime;
Struct NET_TIME endtime;
unsigned int driveno;
unsigned int startcluster;
BYTE nRecordFileType;
BYTE bImportantRecID;
BYTE bHint;
BYTE bRecType;
} NET_RECORDFILE_INFO, *LPNET_RECORDFILE_INFO;
ch
Channel number
filename
File name
framenum
File total frame amount
size
File length
starttime
Start time
endtime
End time
driveno
Disk No.
(Distinguishes network record file and local record file,0~127:local
record file, 64 means disc 1,128 means network record file.)
startcluster
Members Begin cluster No.
nRecordFileType
Record file types
0:General record;1:Alarm record;2:Motion detection;
3:Card number record;4:picture;5:IVS record
bImportantRecID
The flag to be the important record or not
0:General record;1:Important record
bHint
File positioning index
(When nRecordFileType==4<picture>,bImportantRecID<<8
+bHint ,creating picture positioning index)
bRecType
Device record stream type
0 - Main stream record
1 - Sub stream 1 Record
2 - Sub stream 2 Record
3 - Sub stream 3 Record

228
CFG_PTZ_PROTOCOL_CAPS_INFO
Table 4-12 CFG_PTZ_PROTOCOL_CAPS_INFO
Item Description
Struct description PTZ capability set information structure
typedef struct tagCFG_PTZ_PROTOCOL_CAPS_INFO
{
int nStructSize;
BOOL bPan;
BOOL bTile;
BOOL bZoom;
BOOL bIris;
BOOL bPreset;
BOOL bRemovePreset;
BOOL bTour;
BOOL bRemoveTour;
BOOL bPattern;
BOOL bAutoPan;
BOOL bAutoScan;
BOOL bAux;
BOOL bAlarm;
BOOL bLight;
BOOL bWiper;
BOOL bFlip;
BOOL bMenu;
BOOL bMoveRelatively;
BOOL bMoveAbsolutely;
BOOL bReset;
BOOL bGetStatus;
Struct BOOL bSupportLimit;
BOOL bPtzDevice;
BOOL bIsSupportViewRange;

WORD wCamAddrMin;
WORD wCamAddrMax;
WORD wMonAddrMin;
WORD wMonAddrMax;
WORD wPresetMin;
WORD wPresetMax;
WORD wTourMin;
WORD wTourMax;
WORD wPatternMin;
WORD wPatternMax;
WORD wTileSpeedMin;
WORD wTileSpeedMax;
WORD wPanSpeedMin;
WORD wPanSpeedMax;
WORD wAutoScanMin;
WORD wAutoScanMax;
WORD wAuxMin;
WORD wAuxMax;
DWORD dwInterval;
DWORD dwType;
DWORD dwAlarmLen;

229
Item Description
DWORD dwNearLightNumber;
DWORD dwFarLightNumber;
DWORD dwSupportViewRangeType;
DWORD dwSupportFocusMode;
char szName[MAX_PROTOCOL_NAME_LEN];
char szAuxs[CFG_COMMON_STRING_32][CFG_COMMON_STRING_32];
CFG_PTZ_MOTION_RANGE stuPtzMotionRange;
CFG_PTZ_LIGHTING_CONTROL stuPtzLightingControl;
BOOL bSupportPresetTimeSection;
BOOL bFocus;
}CFG_PTZ_PROTOCOL_CAPS_INFO;
nStructSize
Assign value as sizeof(CFG_PTZ_PROTOCOL_CAPS_INFO)
bPan
Supports PTZ horizontal movement or not.
bTile
Supports PTZ vertical movement or not.
bZoom
Supports PTZ zoom or not
bIris
Supports PTZ iris adjustment or not.
bPreset
Supports preset or not
bRemovePreset
Supports to delete preset or not
bTour
Supports tour or not
bRemoveTour
Supports to delete tour or not
bPattern
Support pattern or not
bAutoPan
Members Supports auto horizontal movement or not.
bAutoScan
Supports auto scan or not
bAux
Supports AUX function or not
bAlarm
Supports alarm or not
bLight
Supports light or not. Refer to the "stuPtzLightingControl” member
listed below.
bWiper
Supports wiper or not
bFlip
Supports lens flip or not
bMenu
Supports PTZ built-in menu or not
bMoveRelatively
Supports to positioning PTZ according to the relative coordinates
bMoveAbsolutely
Supports to positioning PTZ according to the absolute coordinates
bReset
Supports reset PTZ or not

230
Item Description
bGetStatus
Supports to get PTZ moving status and directional coordinates
bSupportLimit
Supports PTZ limit or not
bPtzDevice
Supports PTZ device or not.
bIsSupportViewRange
Supports PTZ visual range
wCamAddrMin
The min. value of the channel address
wCamAddrMax
The max. value of the channel address
wMonAddrMin
The min. value of the monitor address
wMonAddrMax
The max. value of the monitor address
wPresetMin
The min. value of preset
wPresetMax
The max. value of preset
wTourMin
The min. value of auto tour
wTourMax
The max. value of auto tour
wPatternMin
The min. value of pattern
wPatternMax
The max. value of pattern
wTileSpeedMin
The min. value of vertical speed
wTileSpeedMax
The max. value of vertical speed
wPanSpeedMin
The min. value of horizontal speed
wPanSpeedMax
The max. value of horizontal speed
wAutoScanMin
The min. value of auto scan
wAutoScanMax
The max. value of auto scan
wAuxMin
The min. value of aux function
wAuxMax
The max. value of aux function
dwInterval
Time interval of sending command.
dwType
Protocol type,0-Local PTZ,1-Remote PTZ
dwAlarmLen
Protocol alarm length
dwNearLightNumber
Near light groups amount,0~4,0: does not support this function
dwFarLightNumber
Far light groups amount,0~4,0: does not support this function

231
Item Description
dwSupportViewRangeType
The submask of getting the supported visual range type. From low bit
to high bit. Right now supports
The 1st bit:1: supports ‘’ElectronicCompass”
dwSupportFocusMode
The submask of supported focus mode. From low bit to high bit. Refer
to the enumeration note of EM_SUPPORT_FOCUS_MODE
szName
Operation protocol name
szAuxs
PTZ AUX function list
stuPtzMotionRange
PTZ movement angles range. The unit is degree. Refer to the structure
note of CFG_PTZ_MOTION_RANGE
stuPtzLightingControl
Light control contents. Refer to the structure note of
CFG_PTZ_LIGHTING_CONTROL
bSupportPresetTimeSection
Supports preset period setup or not
bFocus
Supports PTZ focus or not

CFG_PTZ_MOTION_RANGE
Table 4-13 CFG_PTZ_MOTION_RANGE
Item Description
Struct description PTZ movement angles range structure
typedef struct tagCFG_PTZ_MOTION_RANGE
{
int nHorizontalAngleMin;
Struct int nHorizontalAngleMax;
int nVerticalAngleMin;
int nVerticalAngleMax;
}CFG_PTZ_MOTION_RANGE;
nHorizontalAngleMin
Min. horizontal angle value. The unit : degree
nHorizontalAngleMax
Max. horizontal angle value. The unit : degree
Members
nVerticalAngleMin
Min. vertical angle value. The unit : degree
nVerticalAngleMax
Max. vertically angle value. The unit : degree

CFG_PTZ_LIGHTING_CONTROL
Table 4-14 CFG_PTZ_LIGHTING_CONTROL
Item Description
Struct description Light control contents structure
typedef struct tagCFG_PTZ_LIGHTING_CONTROL
Struct {
char szMode[CFG_COMMON_STRING_32];

232
Item Description
DWORD dwNearLightNumber;
DWORD dwFarLightNumber;
}CFG_PTZ_LIGHTING_CONTROL;
szMode
Manual light control mode
"on-off": on-off mode
"adjustLight": Manually adjusting light
Members
dwNearLightNumber
NearLight group amount
dwFarLightNumber
FarLight group amount

DHDEV_TALKFORMAT_LIST
Table 4-15 DHDEV_TALKFORMAT_LIST
Item Description
Struct description The audio talk type supported by the device
typedef struct
{
Int nSupportNum;
Struct
DHDEV_TALKDECODE_INFO type[64];
Char reserved[64];
} DHDEV_TALKFORMAT_LIST;
nSupportNum
Supported amount
type
Members Encode type
Refer to the structure note of DHDEV_TALKDECODE_INFO
reserved
Reserved byte

DHDEV_TALKDECODE_INFO
Table 4-16 DHDEV_TALKDECODE_INFO
Item Description
Struct description Audio encode information
typedef struct
{
DH_TALK_CODING_TYPE encodeType;
int nAudioBit;
Struct
DWORD dwSampleRate;
int nPacketPeriod;
char reserved[60];
} DHDEV_TALKDECODE_INFO;
encodeType
Encode type
Refer to the enumeration note of DH_TALK_CODING_TYPE
Members nAudioBit
Bit such as 8, 16.
dwSampleRate
Sampling rate such as 8000,16000

233
Item Description
nPacketPeriod
Packet interval. The unit. ms
reserved
Reserved byte

DHDEV_SYSTEM_ATTR_CFG
Table 4-17 DHDEV_SYSTEM_ATTR_CFG
Item Description
Struct description System Information
typedef struct
{
DWORD dwSize;
/* The following contents are the read-only part of the device */
DH_VERSION_INFO stVersion;
DH_DSP_ENCODECAP stDspEncodeCap;
BYTE szDevSerialNo[DH_DEV_SERIALNO_LEN];
BYTE byDevType;
BYTE szDevType[DH_DEV_TYPE_LEN];
BYTE byVideoCaptureNum;
BYTE byAudioCaptureNum;
BYTE byTalkInChanNum;
BYTE byTalkOutChanNum;
BYTE byDecodeChanNum;
BYTE byAlarmInNum;
BYTE byAlarmOutNum;
BYTE byNetIONum;
BYTE byUsbIONum;
Struct BYTE byIdeIONum;
BYTE byComIONum;
BYTE byLPTIONum;
BYTE byVgaIONum;
BYTE byIdeControlNum;
BYTE byIdeControlType;
BYTE byCapability;
BYTE byMatrixOutNum;
/* The following contents are the writable part of the device */
BYTE byOverWrite;
BYTE byRecordLen;
BYTE byDSTEnable;
WORD wDevNo;
BYTE byVideoStandard;
BYTE byDateFormat;
BYTE byDateSprtr;
BYTE byTimeFmt;
BYTE byLanguage;
} DHDEV_SYSTEM_ATTR_CFG, *LPDHDEV_SYSTEM_ATTR_CFG;
dwSize
Structure size. Assign a value sizeof(DHDEV_SYSTEM_ATTR_CFG)
Members /* The following contents are the read-only part of the device */
stVersion
Device version information. Refer to the structure note of

234
Item Description
DH_VERSION_INFO
stDspEncodeCap
DSP capability description. Refer to the structure note of
DH_DSP_ENCODECAP
szDevSerialNo
Device serial number
byDevType
Device type. Refer to the enumeration of NET_DEVICE_TYPE
szDevType
Device detailed model,. String format. It can be null sometimes.
byVideoCaptureNum
Video port amount
byAudioCaptureNum
Audio port amount
byTalkInChanNum
Audio talk input port amount
byTalkOutChanNum
Audio talk output port amount
byDecodeChanNum
Decode port amount
byAlarmInNum
Alarm input port amount
byAlarmOutNum
Alarm output port amount
byNetIONum
Network port amount
byUsbIONum
USB port amount
byIdeIONum
IDE amount
byComIONum
Serial port amount
byLPTIONum
LPT port amount
byVgaIONum
VGA port amount
byIdeControlNum
IDE control amount
byIdeControlType
IDE control type
byCapability
Device capabilities, extension description
byMatrixOutNum
Video matrix output port
/* The following contents are the writable part of the device */
byOverWrite
When HDD is full (1: Stop. 0: Overwrite)
byRecordLen
Record file pack duration
byDSTEnable
Enable DST or not. 1: enable. 0: disable.
wDevNo
Device SN. For remote control.
byVideoStandard

235
Item Description
Video format :0-PAL,1-NTSC
byDateFormat
Date format
byDateSprtr
Date separator (0:".",1:"-",2:"/")
byTimeFmt
Time format ((0~24H,1~12H)
byLanguage
Language type. Refer to the enumeration of DH_LANGUAGE_TYPE.

NET_SPEAK_PARAM
Table 4-18 NET_SPEAK_PARAM
Item Description
Struct description Audio parameter structure
typedef struct __NET_SPEAK_PARAM
{
DWORD dwSize;
Struct int nMode;
int nSpeakerChannel;
BOOL bEnableWait;
} NET_SPEAK_PARAM;
dwSize
Structure size. The assign value is sizeof(NET_SPEAK_PARAM)
nMode
Mode type, 0: audio talk (default), 1: broadcast; resetting required if
switching from broadcast to audio talk.
nSpeakerChannel
Members
Speaker channel number. It is valid in broadcast mode.
bEnableWait
Waiting for device to respond or not when enabling the audio talk. The
default value is FALSE. TRUE:Wait;FALSE:Do not wait. The timeout time
is set by CLIENT_SetNetworkParam,corresponding to nWaittime of
NET_PARAM.

NET_TALK_TRANSFER_PARAM
Table 4-19 NET_TALK_TRANSFER_PARAM
Item Description
Struct description Enable the transfer mode of the audio talk.
typedef struct tagNET_TALK_TRANSFER_PARAM
{
Struct DWORD dwSize;
BOOL bTransfer;
}NET_TALK_TRANSFER_PARAM;
dwSize
Structure the size. The assign value is
sizeof(NET_TALK_TRANSFER_PARAM)
Members
bTransfer
Enable audio talk transfer mode or not. TRUE:Enable transfer,FALSE:
Disable transfer

236
DEVICE_NET_INFO_EX
Table 4-20 DEVICE_NET_INFO_EX
Item Description
Struct description Device search callback message structure
typedef struct
{
int iIPVersion;
char szIP[64];
int nPort;
char szSubmask[64];
char szGateway[64];
char szMac[DH_MACADDR_LEN];
char szDeviceType[DH_DEV_TYPE_LEN];
BYTE byManuFactory;
BYTE byDefinition;
bool bDhcpEn;
BYTE byReserved1;
char verifyData[88];
Struct char szSerialNo[DH_DEV_SERIALNO_LEN];
char szDevSoftVersion[DH_MAX_URL_LEN];
char szDetailType[DH_DEV_TYPE_LEN];
char szVendor[DH_MAX_STRING_LEN];
char szDevName[DH_MACHINE_NAME_NUM];
char szUserName[DH_USER_NAME_LENGTH_EX];
char szPassWord[DH_USER_NAME_LENGTH_EX];
unsigned short nHttpPort;
WORD wVideoInputCh;
WORD wRemoteVideoInputCh;
WORD wVideoOutputCh;
WORD wAlarmInputCh;
WORD wAlarmOutputCh;
char cReserved[244];
}DEVICE_NET_INFO_EX;
iIPVersion
IP protocol,4 for IPV4, 6 for IPV6
szIP
IP string format,IP IPV4 such as "[Link]" IPV6 such as "2008::1/64"
nPort
TCP Port
szSubmask
Subnet mask. IPV6 has no subnet mask
szGateway
Device gateway
Members
szMac
Device MAC address
szDeviceType
Device type
byManuFactory
The manufacturer of the target device. Refer to EM_IPC_TYPE
byDefinition
1-Standard definition 2-High definition
bDhcpEn
DCHP enable status, true-Enable,false-Disable

237
Item Description
byReserved1
Byte alignment
verifyData
Verify data. Asynchronously search callback to get. (Uses the
information to verify when modifying device IP.)
szSerialNo
Serial number
szDevSoftVersion
Device software version
szDetailType
Device model
szVendor
OEM customer type
szDevName
Device name
szUserName
Logged in device user name (Input when modifying device IP)
szPassWord
Logged in device password (Input when modifying device IP)
nHttpPort
HTTP service port number.
wVideoInputCh
Video input channel amount
wRemoteVideoInputCh
Remote video input channel amount
wVideoOutputCh
Video output channel amount
wAlarmInputCh
Alarm input channel amount
wAlarmOutputCh
Alarm output channel amount
cReserved
Reserved byte

MANUAL_SNAP_PARAMETER
Table 4-21 MANUAL_SNAP_PARAMETER
Item Description
Struct description Manual Snapshot Structure
typedef struct _MANUAL_SNAP_PARAMETER{
int nChannel;
Struct BYTE bySequence[64];
BYTE byReserved[60];
}MANUAL_SNAP_PARAMETER;
nChannel
Snapshot channel. Start from 0.
bySequence
Snapshot SN string. Returns current field when uploading corresponding
Members
intelligent picture alarm.
Uses this string to check one by one when there are several manual
snapshot events at the same time.
byReserved

238
Item Description
Reserved field

OPR_RIGHT_EX
Table 4-22 OPR_RIGHT_EX
Item Description
Struct description Rights info structure
typedef struct _OPR_RIGHT_EX
{
DWORD dwID;
Struct
char name[DH_RIGHT_NAME_LENGTH];
char memo[DH_MEMO_LENGTH];
} OPR_RIGHT_EX;
dwID
Right ID
Each right has its own ID
Members name
Right name
memo
Right note

OPR_RIGHT_NEW
Table 4-23 OPR_RIGHT_NEW
Item Description
Struct description Rights info structure
typedef struct _OPR_RIGHT_NEW
{
DWORD dwSize;
Struct DWORD dwID;
char name[DH_RIGHT_NAME_LENGTH];
char memo[DH_MEMO_LENGTH];
} OPR_RIGHT_NEW;
dwSize
Structure size. The assign value is sizeof(OPR_RIGHT_NEW)
dwID
Right ID
Members Each right has its own ID
name
Right name
memo
Right note

NET_DEV_CHN_COUNT_INFO
Table 4-24 NET_DEV_CHN_COUNT_INFO
Item Description
Struct description Device channel amount information structure
Struct typedef struct tagNET_DEV_CHN_COUNT_INFO

239
Item Description
{
DWORD dwSize;
NET_CHN_COUNT_INFO stuVideoIn;
NET_CHN_COUNT_INFO stuVideoOut;
} NET_DEV_CHN_COUNT_INFO;
dwSize
Structure size. The assign value is sizeof(NET_DEV_CHN_COUNT_INFO)
stuVideoIn
Video input channel
Members
Refer to the structure note of NET_CHN_COUNT_INFO
stuVideoOut
Video output channel
Refer to the structure note of NET_CHN_COUNT_INFO

NET_CHN_COUNT_INFO
Table 4-25 NET_CHN_COUNT_INFO
Item Description
Struct description Channel amount information structure
typedef struct tagNET_CHN_COUNT_INFO
{
DWORD dwSize;
int nMaxTotal;
int nCurTotal;
Struct
int nMaxLocal;
int nCurLocal;
int nMaxRemote;
int nCurRemote;
} NET_CHN_COUNT_INFO;
dwSize
Structure size. The assign value is sizeof(NET_CHN_COUNT_INFO)
nMaxTotal
Device total channel amount (The total quantity of the valid channels)
nCurTotal
Configured channel amount
nMaxLocal
Members Max. local channel amount. It includes the main board and then
removable sub-card channel.
nCurLocal
Configured local channel amount
nMaxRemote
Max. remote channel amount
nCurRemote
Configured remote channel amount

NET_IN_SNAP_CFG_CAPS
Table 4-26 NET_IN_SNAP_CFG_CAPS
Item Description
Struct description Gets input parameter structure of the snapshot configuration
Struct typedef struct tagNET_IN_SNAP_CFG_CAPS

240
Item Description
{
int nChannelId;
BYTE bReserved[1024];
}NET_IN_SNAP_CFG_CAPS;
nChannelId
Channel number
Members
bReserved
Reserved byte

NET_OUT_SNAP_CFG_CAPS
Table 4-27 NET_OUT_SNAP_CFG_CAPS
Item Description
Struct description Gets output parameter structure of the snapshot configuration
typedef struct tagNET_OUT_SNAP_CFG_CAPS
{
int nResolutionTypeNum;
DH_RESOLUTION_INFO stuResolutionTypes[DH_MAX_CAPTURE_SIZE_NU
M];
DWORD dwFramesPerSecNum;
Struct int nFramesPerSecList[DH_MAX_FPS_NUM];
DWORD dwQualityMun;
DWORD nQualityList[DH_MAX_QUALITY_NUM];
DWORD dwMode;
DWORD dwFormat;
BYTE bReserved[2048];
} NET_OUT_SNAP_CFG_CAPS;
nResolutionTypeNum
Supported video resolution information
Works with stuResolutionTypes
stuResolutionTypes
Video resolution information structure
Works with nResolutionTypeNum
dwFramesPerSecNum
Supported frame rate information
Works with nFramesPerSecList
nFramesPerSecList
Supported frame rate list
Works with dwFramesPerSecNum
Members
dwQualityMun
Supported video quality
Works with nQualityList
nQualityList
Supported video quality List
Works with dwQualityMun
dwMode
Mode. By bit:The 1st bit:schedule. The 2nd bit:manual
dwFormat
Picture format mode. By bit:The 1st bit:BMP. The 2nd bit:JPG
bReserved
Reserved byte

241
DH_RESOLUTION_INFO
Table 4-28 DH_RESOLUTION_INFO
Item Description
Struct description Picture resolution structure
typedef struct
{
Struct unsigned short snWidth;
unsigned short snHight;
}DH_RESOLUTION_INFO;
snWidth
Width
Members
snHight
Height

CFG_VIDEOENC_OPT
Table 4-29 CFG_VIDEOENC_OPT
Item Description
Struct
Video encode parameter structure
description
typedef struct tagCFG_VIDEOENC_OPT
{
bool abVideoEnable;
bool abAudioEnable;
bool abSnapEnable;
bool abAudioAdd;
bool abAudioFormat;
Struct
BOOL bVideoEnable;
CFG_VIDEO_FORMAT stuVideoFormat;
BOOL bAudioEnable;
BOOL bSnapEnable;
BOOL bAudioAddEnable;
CFG_AUDIO_ENCODE_FORMAT stuAudioFormat;
} CFG_VIDEOENC_OPT;
abVideoEnable
Indicate the bVideoEnable is valid or not
When getting, indicates support enable video or not
When setting, indicates support modify video or not
abAudioEnable
Indicate the bAudioEnable is valid or not
When getting, indicates support enable audio or not
When setting, indicates support modify audio or not
Members abSnapEnable
Indicate the bSnapEnable is valid or not
When getting, indicates support schedule snapshot or not
When setting, indicates support modify schedule snapshot or not
abAudioAdd
Indicate the bAudioAddEnable is valid or not
When getting, indicates support overlay audio or not
When setting, indicates support modify overlay audio or not
abAudioFormat

242
Item Description
Indicate the stuAudioFormat is valid or not
When getting, indicates support audio format or not
When setting, indicates support modify audio format or not
bVideoEnable
Enable video
Works with abVideoEnable
stuVideoFormat
Video file format
Refer to the structure note of NET_CHN_COUNT_INFO
bAudioEnable
Enable audio
Works with abAudioEnable
bSnapEnable
Enable scheduled snapshot
Works with abSnapEnable
bAudioAddEnable
Enable audio overlay
Works with abAudioAdd
stuAudioFormat
Audio format
Works with abAudioFormat
Refer to the structure note of CFG_AUDIO_ENCODE_FORMAT

CFG_VIDEO_FORMAT
Table 4-30 CFG_VIDEO_FORMAT
Item Description
Struct description Struct
typedef struct tagCFG_VIDEO_FORMAT
{
bool abCompression;
bool abWidth;
bool abHeight;
bool abBitRateControl;
bool abBitRate;
bool abFrameRate;
bool abIFrameInterval;
bool abImageQuality;
bool abFrameType;
Struct bool abProfile;
CFG_VIDEO_COMPRESSION emCompression;
int nWidth;
int nHeight;
CFG_BITRATE_CONTROL emBitRateControl;
int nBitRate;
float nFrameRate;
int nIFrameInterval;
CFG_IMAGE_QUALITY emImageQuality;
int nFrameType;
CFG_H264_PROFILE_RANK emProfile;
} CFG_VIDEO_FORMAT;
Members abCompression

243
Item Description
TRUE:emCompression is valid;FALSE:emCompression is null
The string is read-only. Uses the getting value. Do not change.
abWidth
TRUE:nWidth is valid;FALSE:nWidth is null
The string is read-only. Uses the getting value. Do not change.
abHeight
TRUE:nHeight 字 is valid;FALSE:nHeight 字 is null
The string is read-only. Uses the getting value. Do not change.
abBitRateControl
TRUE:emBitRateControl is valid;FALSE:emBitRateControl is null
The string is read-only. Uses the getting value. Do not change.
abBitRate
TRUE:nBitRateis valid;FALSE:nBitRate is null
The string is read-only. Uses the getting value. Do not change.
abFrameRate
TRUE:nFrameRate is valid;FALSE:nFrameRate is null
The string is read-only. Uses the getting value. Do not change.
abIFrameInterval
TRUE:nIFrameIntervalis valid;FALSE:nIFrameInterval is null
The string is read-only. Uses the getting value. Do not change.
abImageQuality
TRUE:emImageQuality is valid;FALSE:emImageQuality is null
The string is read-only. Uses the getting value. Do not change.
abFrameType
TRUE:nFrameTypeis valid;FALSE:nFrameType is null
The string is read-only. Uses the getting value. Do not change.
abProfile
TRUE:emProfile is valid;FALSE:emProfile is null
The string is read-only. Uses the getting value. Do not change.
emCompression
Video compression format
The string is valid or not depending on abCompression
Refer to the enumeration note of CFG_VIDEO_COMPRESSION
nWidth
Video Width
The string is valid or not depending on abWidth
nHeight
Video Height
The string is valid or not depending on abHeight
emBitRateControl
Bit Rate Control Mode
The string is valid or not depending on abBitRateControl
Refer to the enumeration note of CFG_BITRATE_CONTROL
nBitRate
Video bit stream (kbps)
The string is valid or not depending on abBitRate
nFrameRate
Video Frame Rate
The string is valid or not depending on abFrameRate
nIFrameInterval
I frame interval (1-100). For example, 50 means there is one I frame
each 49 B frames or P frames.
The string is valid or not depending on abIFrameInterval
emImageQuality

244
Item Description
Image Quality
The string is valid or not depending on abImageQuality
Refer to the enumeration note of CFG_IMAGE_QUALITY
nFrameType
Packet mode. 0-DHAV,1-"PS"
The string is valid or not depending on abFrameType
emProfile
H.264 encode mode
The string is valid or not depending on abProfile
Refer to the enumeration note of CFG_H264_PROFILE_RANK

CFG_AUDIO_ENCODE_FORMAT
Table 4-31 CFG_AUDIO_ENCODE_FORMAT
Item Description
Struct description Audio format structure
typedef struct tagCFG_AUDIO_FORMAT
{
bool abCompression;
bool abDepth;
bool abFrequency;
bool abMode;
bool abFrameType;
Struct bool abPacketPeriod;
CFG_AUDIO_FORMAT emCompression;
AV_int32 nDepth;
AV_int32 nFrequency;
AV_int32 nMode;
AV_int32 nFrameType;
AV_int32 nPacketPeriod;
} CFG_AUDIO_ENCODE_FORMAT;
abCompression
TRUE:emCompression is valid;FALSE:emCompression is null
The string is read-only. Uses the getting value. Do not change.
abDepth
TRUE:nDepthis valid;FALSE:nDepth is null
The string is read-only. Uses the getting value. Do not change.
abFrequency
TRUE:nFrequency is valid;FALSE:nFrequency is null
The string is read-only. Uses the getting value. Do not change.
abMode
Members TRUE:nMode is valid;FALSE:nMode is null
The string is read-only. Uses the getting value. Do not change.
abFrameType
TRUE:nFrameType is valid;FALSE:nFrameType is null
The string is read-only. Uses the getting value. Do not change.
abPacketPeriod
TRUE:nPacketPeriod is valid;FALSE:nPacketPeriod is null
The string is read-only. Uses the getting value. Do not change.
emCompression
Audio Compression Mode
The string is valid or not depending on abCompression

245
Item Description
Refer to the enumeration note of CFG_AUDIO_FORMAT
nDepth
Audio Sampling Depth
The string is valid or not depending on abDepth
nFrequency
Audio Sampling Frequency
The string is valid or not depending on abFrequency
nMode
Audio Encode Mode
The string is valid or not depending on abMode
nFrameType
Audio package mode. 0-DHAV, 1-PS
The string is valid or not depending on abFrameType
nPacketPeriod
Audio Packet Period (ms)
The string is valid or not depending on abPacketPeriod

CFG_VIDEO_COVER
Table 4-32 CFG_VIDEO_COVER
Item Description
Struct description Multiple-zone Tampering Configuration Structure
typedef struct tagCFG_VIDEO_COVER
{
int nTotalBlocks;
Struct
int nCurBlocks;
CFG_COVER_INFO stuCoverBlock[MAX_VIDEO_COVER_NUM];
} CFG_VIDEO_COVER;
nTotalBlocks
Supported tampering block amount
nCurBlocks
Members Configured block amount
stuCoverBlock
Tampering zone
Refer to the structure note of CFG_COVER_INFO

CFG_COVER_INFO
Table 4-33 CFG_COVER_INFO
Item Description
Struct description Tampering Info Structure
typedef struct tagCFG_COVER_INFO
{
bool abBlockType;
bool abEncodeBlend;
bool abPreviewBlend;
Struct
CFG_RECT stuRect;
CFG_RGBA stuColor;
int nBlockType;
int nEncodeBlend;
int nPreviewBlend;

246
Item Description
} CFG_COVER_INFO;
abBlockType
TRUE:nBlockType is valid;FALSE:nBlockType is null
The string is read-only. Uses the getting value. Do not change.
abEncodeBlend
TRUE:nEncodeBlend is valid;FALSE:nEncodeBlend is null
The string is read-only. Uses the getting value. Do not change.
abPreviewBlend
TRUE:nPreviewBlend is valid;FALSE:nPreviewBlend is null
The string is read-only. Uses the getting value. Do not change.
stuRect
Tampering zone coordinates
Refer to the structure note of CFG_RECT
Members
stuColor
Tampering color
Refer to the structure note of CFG_RGBA
nBlockType
Tampering mode. 0-Black-black block,1-mosaic
The string is valid or not depending on abBlockType
nEncodeBlend
Encoding-level tampering. 1-valid,0-null
The string is valid or not depending on abEncodeBlend
nPreviewBlend
Tampering when previewing. 1-valid,0-null
The string is valid or not depending on abPreviewBlend

CFG_RECT
Table 4-34 CFG_RECT
Item Description
Struct description Area information structure
typedef struct tagCFG_RECT
{
int nLeft;
Struct int nTop;
int nRight;
int nBottom;
} CFG_RECT;
nLeft
Left Area
nTop
Top Area
Members
nRight
Right Area
nBottom
Bottom Area
Struct description RGBA information structure
typedef struct tagCFG_RGBA
{
Struct int nRed;
int nGreen;
int nBlue;

247
Item Description
int nAlpha;
} CFG_RGBA;
nRed
Red
nGreen
Green
Members
nBlue
Blue
nAlpha
Transparency

CFG_ENCODE_INFO
Table 4-35 CFG_ENCODE_INFO
Item Description
Struct description Image channel attribute information structure
typedef struct tagCFG_ENCODE_INFO
{
int nChannelID;
char szChnName[MAX_CHANNELNAME_LEN];
CFG_VIDEOENC_OPT stuMainStream[MAX_VIDEOSTREAM_NUM];
CFG_VIDEOENC_OPT stuExtraStream[MAX_VIDEOSTREAM_NUM];
CFG_VIDEOENC_OPT stuSnapFormat[MAX_VIDEOSTREAM_NUM];
DWORD dwCoverAbilityMask;
Struct
DWORD dwCoverEnableMask;
CFG_VIDEO_COVER stuVideoCover;
CFG_OSD_INFO stuChnTitle;
CFG_OSD_INFO stuTimeTitle;
CFG_COLOR_INFO stuVideoColor;
CFG_AUDIO_FORMAT emAudioFormat;
int nProtocolVer;
} CFG_ENCODE_INFO;
nChannelID
Channel number, starting from 0
When getting the value, current field is valid. When setting, current field
is null.
szChnName
Invalid field
stuMainStream
Main Stream Attribute Information
stuMainStream[0]-Main stream general record attribute information
stuMainStream[1] - Main stream motion detection record attribute
Members
information
stuMainStream[2]-Main stream alarm record attribute information
Refer to the structure note of CFG_VIDEOENC_OPT
stuExtraStream
Sub Stream Attribute Information
stuMainStream[0]-Sub stream general record attribute information
stuMainStream[1]-Sub stream general record attribute information
stuMainStream[2] - Sub stream tampered alarm record attribute
information
Refer to the structure note of CFG_VIDEOENC_OPT

248
Item Description
stuSnapFormat
Snapshot Attribute Information
stuSnapFormat[0]-General snapshot attribute information
stuSnapFormat[1]-Motion detection snapshot attribute information
stuSnapFormat[2]-Alarm snapshot attribute information
Refer to the structure note of CFG_VIDEOENC_OPT
dwCoverAbilityMask
Invalid Field
dwCoverEnableMask
Invalid Field
stuVideoCover
Invalid Field
stuChnTitle
Invalid Field
stuTimeTitle
Invalid Field
stuVideoColor
Invalid Field
emAudioFormat
Invalid Field
nProtocolVer
Protocol version number. Read-only.
When getting the value, current field is valid. When setting, current field
is null.

SNAP_PARAMS
Table 4-36 SNAP_PARAMS
Item Description
Struct description Snapshot parameters structure
typedef struct _snap_param
{
unsigned int Channel;
unsigned int Quality;
unsigned int ImageSize;
Struct
unsigned int mode;
unsigned int InterSnap;
unsigned int CmdSerial;
unsigned int Reserved[4];
} SNAP_PARAMS, *LPSNAP_PARAMS;
Channel
Snapshot channel
Quality
Image quality. Value range 1-6. The larger the value is, the better the
image quality is.
ImageSize
Members
Image size;0:QCIF,1:CIF,2:D1
mode
Snapshot Mode
-1: stop timing snapshot;0: require one frame; 1: timing send request.
2:Continuous request
InterSnap

249
Item Description
Time interval. The unit: second;if mode=1, device sends out timing
request. It is for some special devices such as (mobile device) to use this
field to set schedule snapshot interval. We recommend the user uses
stuSnapFormat[nSnapMode].[Link] of
CFG_CMD_ENCODE to realize this function.
CmdSerial
Snapshot request SN. The value ranges from 0 to 65535. Once the
value is out of range, it is unsigned short.
Reserved
Reserved byte

DH_VERSION_INFO
Table 4-37 DH_VERSION_INFO
Item Description
Device software version information. The higher 16-bit is main version
Struct description
number and then lower 16-bit is the minor version number.
typedef struct
{
DWORD dwSoftwareVersion;
DWORD dwSoftwareBuildDate;
DWORD dwDspSoftwareVersion;
DWORD dwDspSoftwareBuildDate;
Struct DWORD dwPanelVersion;
DWORD dwPanelSoftwareBuildDate;
DWORD dwHardwareVersion;
DWORD dwHardwareDate;
DWORD dwWebVersion;
DWORD dwWebBuildDate;
} DH_VERSION_INFO, *LPDH_VERSION_INFO;
dwSoftwareVersion
Software Version No.
dwSoftwareBuildDate
Software Built Version No.
dwDspSoftwareVersion
DSP Software Version
dwDspSoftwareBuildDate
DSP Software Built Version
dwPanelVersion
It is null right now
Members
dwPanelSoftwareBuildDate
It is null right now
dwHardwareVersion
Hardware Version
dwHardwareDate
It is null right now
dwWebVersion
Web Version
dwWebBuildDate
Web Built Version No.

250
NET_IN_REALPLAY_BY_DATA_TYPE
Table 4-38 NET_IN_REALPLAY_BY_DATA_TYPE
Item Implication
Structure
CLIENT_RealPlayByDataType input parameter
Description
typedef struct tagNET_IN_REALPLAY_BY_DATA_TYPE
{
DWORD dwSize;
int nChannelID;
HWND hWnd;
DH_RealPlayType rType;
fRealDataCallBackEx cbRealData;
Structure
EM_REAL_DATA_TYPE emDataType;
LDWORD dwUser;
const char* szSaveFileName;
fRealDataCallBackEx2 cbRealDataEx;
EM_AUDIO_DATA_TYPE emAudioType;
fDataCallBackEx cbRealDataEx2;
}NET_IN_REALPLAY_BY_DATA_TYPE;
dwSize
Structure size.
nChannelID
Channel No.
hWnd
Window handle.
rType
Stream type.
cbRealData
Data callback function.
Member
emDataType
The callback data type.
szSaveFileName
Converted file name.
cbRealDataEx
Data callback function: Extension.
emAudioType
Audio format.
cbRealDataEx2
Data callback (extended with timestamp and frame type)

NET_OUT_REALPLAY_BY_DATA_TYPE
Table 4-39 NET_OUT_REALPLAY_BY_DATA_TYPE
Item Implication
Structure
CLIENT_RealPlayByDataType output parameter.
Description

251
Item Implication
typedef struct tagNET_OUT_REALPLAY_BY_DATA_TYPE
{
Structure
DWORD dwSize;
}NET_OUT_REALPLAY_BY_DATA_TYPE;
dwSize: Structure size. When used, it must be assigned the value
Member
sizeof(NET_OUT_REALPLAY_BY_DATA_TYPE).

NET_IN_PLAYBACK_BY_DATA_TYPE
Table 4-40 NET_IN_PLAYBACK_BY_DATA_TYPE
Item Implication
Structure
CLIENT_PlayBackByDataType input parameter
Description
typedef struct tagNET_IN_PLAYBACK_BY_DATA_TYPE
{
DWORD dwSize;
int nChannelID;
NET_TIME stStartTime;
NET_TIME stStopTime;
HWND hWnd;
fDownLoadPosCallBack cbDownLoadPos;
Structure
LDWORD dwPosUser;
fDataCallBack fDownLoadDataCallBack;
EM_REAL_DATA_TYPE emDataType;
LDWORD dwDataUser;
int nPlayDirection;
EM_AUDIO_DATA_TYPE emAudioType;
fDataCallBackEx fDownLoadDataCallBackEx;
}NET_IN_PLAYBACK_BY_DATA_TYPE;

252
Item Implication
dwSize
Structure size.
nChannelID
Channel No.
stStartTime
Start time.
stStopTime
End time.
hWnd
Window handle.
cbDownLoadPos
Progress callback.
dwPosUser
Member
Progress callback user information.
fDownLoadDataCallBack
Data callback.
emDataType
Callback data type.
dwDataUser
Data callback user information.
nPlayDirection
Play mode. 0: forward playing. 1: backward playing.
emAudioType
Audio Type
fDownLoadDataCallBackEx
Data callback (extended with timestamp and frame type)

NET_OUT_PLAYBACK_BY_DATA_TYPE
Table 4-41 NET_OUT_PLAYBACK_BY_DATA_TYPE
Item Implication
Structure
CLIENT_PlayBackByDataType output parameters.
Description
typedef struct tagNET_OUT_PLAYBACK_BY_DATA_TYPE
{
Structure
DWORD dwSize;
}NET_OUT_PLAYBACK_BY_DATA_TYPE;
dwSize: Structure size. When used, it must be assigned the value
Member
sizeof(NET_OUT_PLAYBACK_BY_DATA_TYPE).

NET_IN_DOWNLOAD_BY_DATA_TYPE
Table 4-42 NET_IN_DOWNLOAD_BY_DATA_TYPE
Item Implication
Structure
CLIENT_DownloadByDataType input parameters.
Description

253
Item Implication
typedef struct tagNET_IN_DOWNLOAD_BY_DATA_TYPE
{
DWORD dwSize;
int nChannelID;
EM_QUERY_RECORD_TYPE emRecordType;
char* szSavedFileName;
NET_TIME stStartTime;
Structure NET_TIME stStopTime;
fTimeDownLoadPosCallBack cbDownLoadPos;
LDWORD dwPosUser;
fDataCallBack fDownLoadDataCallBack;
EM_REAL_DATA_TYPE emDataType;
LDWORD dwDataUser;
EM_AUDIO_DATA_TYPE emAudioType;
}NET_IN_DOWNLOAD_BY_DATA_TYPE;
dwSize
Structure size.
nChannelID
Channel No.
emRecordType
Video type.
szSavedFileName
The path to download and save the file.
stStartTime
Start time.
stStopTime
End time.
Member
cbDownLoadPos
Progress callback.
dwPosUser
Progress callback user information.
fDownLoadDataCallBack
Data callback.
emDataType
The callback data type.
dwDataUser
Data callback user information.
emAudioType
Audio type.

NET_OUT_DOWNLOAD_BY_DATA_TYPE
Table 4-43 NET_OUT_DOWNLOAD_BY_DATA_TYPE
Item Implication
Structure
CLIENT_DownloadByDataType output parameters.
Description
typedef struct tagNET_OUT_DOWNLOAD_BY_DATA_TYPE
{
Structure
DWORD dwSize;
}NET_OUT_DOWNLOAD_BY_DATA_TYPE;

254
Item Implication
dwSize: Structure size. When used, it needs to be assigned the value
Member
sizeof(NET_OUT_DOWNLOAD_BY_DATA_TYPE).

DH_DSP_ENCODECAP
Table 4-44 DH_DSP_ENCODECAP
Item Description
Struct description DSP capability description
typedef struct
{
DWORD dwVideoStandardMask;
DWORD dwImageSizeMask;
DWORD dwEncodeModeMask;
Struct DWORD dwStreamCap;
DWORD dwImageSizeMask_Assi[8];
DWORD dwMaxEncodePower;
WORD wMaxSupportChannel;
WORD wChannelMaxSetSync;
} DH_DSP_ENCODECAP, *LPDH_DSP_ENCODECAP;
dwVideoStandardMask
Video format mask. Uses bit to indicate the video format device
supported.
dwImageSizeMask
Resolution mask Uses bit to indicate the resolution device
supported. Refer to the following list.
0 704*576(PAL) 704*480(NTSC)
1 352*576(PAL) 352*480(NTSC)
2 704*288(PAL) 704*240(NTSC)
3 352*288(PAL) 352*240(NTSC)
4 176*144(PAL) 176*120(NTSC)
5 640*480
6 320*240
7 480*480
Members 8 160*128
9 800*592
10 1024*768
11 1280*800
12 1600*1024
13 1600*1200
14 1920*1200
15 240*192
16 1280*720
17 1920*1080
18 1280*960
19 1872*1408
20 3744*1408
21 2048*1536

255
Item Description
22 2432*2050
23 1216*1024
24 1408*1024
25 3296*2472
26 2560*1920(5M)
27 The region setting interface is
divided to 960×576(PAL)(NTSC)
28 960 (H) × 720 (V)
dwEncodeModeMask
Compression mode mask bit. Uses bit to indicate the compression
mode device supported.
dwStreamCap
Uses bit to indicate the multi-media function devices supported ,
The 1st bit :supports main stream,
The 2nd bit: supports sub stream1,
The 3rd bit: supports sub stream2,
The 5th bit : supports snapshot(.JPG)
dwImageSizeMask_Assi
For main stream resolution, it is the supported mask bit of sub
stream resolution
dwMaxEncodePower
DSP max. supports encode capability
wMaxSupportChannel
The max. input video channel amount of each DSP
wChannelMaxSetSync
The max. encode setting of each DSP is synchronized or not. 0: No.
1: Yes

DHDEV_UPGRADE_STATE_INFO
Table 4-45 DHDEV_UPGRADE_STATE_INFO
Item Description
Struct
Gets the device update status.
description
typedef struct tagDHDEV_UPGRADE_STATE_INFO
{
int nState; /// 0:None-No updates were detected. Default status.
/// 1:Regular-General update;
/// 2:Emergency-Forced update;
Struct /// 3:Upgrading-Updating.
char szOldVersion[UPDATE_VERSION_LEN]; /// Old version
char szNewVersion[UPDATE_VERSION_LEN]; /// New version
DWORD dwProgress; /// Update progess
int reserved[256]; /// Reserved field
}DHDEV_UPGRADE_STATE_INFO;

256
Item Description
nState
Update status. 0: None-No updates were detected. Default status. 1:
Regular-General update; 2:Emergency-Forced updates; 3:
Upgrading-Updating.
szOldVersion
Members
Old version
szNewVersion
New version
dwProgress
Update progress

NET_IN_START_APP
Table 4-46 NET_IN_START_APP
Item Description
Struct
CLIENT_StartApp input parameters
description
typedef struct tagNET_IN_START_APP
{
DWORD dwSize; /// Structure size
Struct
UINT nAppID; /// App ID
char szAppName[128]; /// App name
} NET_IN_START_APP;
dwSize
Structure size
nAppID
Members
App ID.
szAppName
App name.

NET_OUT_START_APP
Table 4-47 NET_OUT_START_APP
Item Description
Struct
CLIENT_StartApp output parameters
description
typedef struct tagNET_OUT_START_APP
{
Struct
DWORD dwSize; /// Structure size
} NET_OUT_START_APP;
dwSize
Members
Structure size

257
CFG_DEV_DISPOSITION_INFO
Table 4-48 CFG_DEV_DISPOSITION_INFO
Item Description
Struct
CLIENT_GetNewDevConfig output parameters
description
typedef struct tagCFG_DEV_DISPOSITION_INFO
{
int nLocalNo; // Device number. It is being used for the remote
control to identify devices. The value is between 0–998
char szMachineName[256]; // Device name or number
char szMachineAddress[256]; // Device deployment location (that is, the
road number)
char szMachineGroup[256]; // Device group or device organization. It
is empty by default. User can group different devices together for easier
management, and these groups can be reused
char szMachineID[64]; // Device ID. This is unique within the
connected platform
int nLockLoginTimes; // The number of login attempts after
login failure
Struct
int nLoginFailLockTime; // Lock duration after a failed login
attempt
BOOL bLockLoginEnable; // Enable the number of login
attempts after login failure
CFG_DATA_TIME stuActivationTime; // Startup time
UINT nCheckDuration; // Reset period. If the
number of login attempts does not exceed the allowed limit within the
specified time, the attempt count will be reset to zero.
BOOL bUseLocalPolicy; // Use the local GUI lock policy or
not
CFG_LOCAL_POLICY_INFO stuLocalPolicy; // Local GUI lock policy
char szMachineName1[256]; // Device name or number
BYTE bReserved[508]; // Reserved bytes
}CFG_DEV_DISPOSITION_INFO;

258
Item Description
nLocalNo
Device number.
szMachineName
Device name or number
szMachineAddress
Device deployment location (that is, the road number)
szMachineGroup
Device group
szMachineID
Device number
nLockLoginTimes
Number of login attempts after login failure
nLoginFailLockTime
Members
Lock duration after a failed login attempt
bLockLoginEnable
Enable the number of login attempts after login failure
stuActivationTime
Startup time
nCheckDuration
Reset period
bUseLocalPolicy
Use the local GUI lock policy or not
stuLocalPolicy
Local GUI lock policy
szMachineName1
Device name or number

NET_IN_GET_INSTALLED_APP_INFO
Table 4-49 NET_IN_GET_INSTALLED_APP_INFO
Item Description
Struct
CLIENT_GetInstalledAppInfo input parameters
description
typedef struct tagNET_IN_GET_INSTALLED_APP_INFO
{
Struct
DWORD dwSize; /// Structure size
} NET_IN_GET_INSTALLED_APP_INFO;
dwSize
Members
Structure size

NET_OUT_GET_INSTALLED_APP_INFO
Table 4-50 NET_OUT_GET_INSTALLED_APP_INFO
Item Description
Struct
CLIENT_GetInstalledAppInfo output parameters
description

259
Item Description
typedef struct tagNET_OUT_GET_INSTALLED_APP_INFO
{
DWORD dwSize; /// Structure size
UINT nListCount; /// Return the number of lists of installed
Struct
apps
NET_INSTALLED_APP_INFO stuAppInfoList[16]; /// Information on the
list of installed apps
} NET_OUT_GET_INSTALLED_APP_INFO;
dwSize
Structure size
nListCount
The number of lists of installed apps
stuAppInfoList
List of installed apps
///@brief Information on the installed apps
typedef struct tagNET_INSTALLED_APP_INFO
{
char szAppName[128]; /// App name
Members char szVersion[64]; /// App version
char szExtend[64]; /// Extended information
UINT nAppID; /// App ID
EM_APP_DEBUG_STATE emAppDebugState; /// App debugging
status
EM_APP_RUNNING_STATE emAppRunningState; ///App running status
EM_APP_LICENSE_STATE emAppLicenseState;/// App license status
NET_APP_CAPS stuAppCaps; /// App capability
information
BYTE byReserved[256]; /// Reserved bytes
} NET_INSTALLED_APP_INFO;

NET_IN_INSTALL_PREPAREEX
Table 4-51 NET_IN_INSTALL_PREPAREEX
Item Description
Struct CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_PREPAREEX Input
description parameters
typedef struct tagNET_IN_INSTALL_PREPAREEX
{
DWORD dwSize; /// Structure size
char szAppName[32]; /// The name of the app to be
Struct updated
EM_NET_NEXT_OPERATE emNextOperate; /// Next operation
UINT nTotalLength; /// Update package size
BOOL bReliable; /// Update reliability
}NET_IN_INSTALL_PREPAREEX;

260
Item Description
dwSize
Structure size
szAppName
The name of the app to be updated
emNextOperate
Members
Next operation
nTotalLength
Update package size
bReliable
Update reliability

NET_OUT_INSTALL_PREPAREEX
Table 4-52 NET_OUT_INSTALL_PREPAREEX
Item Description
Struct CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_PREPAREEX output
description parameters
typedef struct tagNET_OUT_INSTALL_PREPAREEX
{
Struct
DWORD dwSize; /// Structure size
}NET_OUT_INSTALL_PREPAREEX;
dwSize
Members
Structure size

NET_IN_INSTALL_APPEND_DATA
Table 4-53 NET_IN_INSTALL_APPEND_DATA
Item Description
Struct CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_APPEND_DATA input
description parameters
typedef struct tagNET_IN_INSTALL_APPEND_DATA
{
DWORD dwSize; /// Structure size
UINT nTotalLen; /// Total size of the update file
Struct
UINT nAppendLen; /// Length of the binary data sent this time
BYTE* pAppendData; /// The binary data sent this time. The user
requests the release
}NET_IN_INSTALL_APPEND_DATA;
dwSize
Structure size
nTotalLen
Total size of the update file
Members
nAppendLen
Length of the binary data sent this time
pAppendData
The binary data sent this time

261
NET_OUT_INSTALL_APPEND_DATA
Table 4-54 NET_OUT_INSTALL_APPEND_DATA
Item Description
Struct CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_APPEND_DATA output
description parameters
typedef struct tagNET_OUT_INSTALL_APPEND_DATA
{
Struct
DWORD dwSize; /// Structure size
}NET_OUT_INSTALL_APPEND_DATA;
dwSize
Members
Structure size

NET_IN_INSTALL_EXECUTE
Table 4-55 NET_IN_INSTALL_EXECUTE
Item Description
Struct CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_EXECUTE input
description parameters
typedef struct tagNET_IN_INSTALL_EXECUTE
{
DWORD dwSize; /// Structure size
Struct
BOOL bAutoReboot; /// The system automatically restarts
after the update or not
}NET_IN_INSTALL_EXECUTE;
dwSize
Structure size
Members
bAutoReboot
The system automatically restarts after the update or not

NET_OUT_INSTALL_EXECUTE
Table 4-56 NET_OUT_INSTALL_EXECUTE
Item Description
Struct CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_EXECUTE output
description parameters
typedef struct tagNET_OUT_INSTALL_EXECUTE
{
Struct
DWORD dwSize; /// Structure size
}NET_OUT_INSTALL_EXECUTE;
dwSize
Members
Structure size

262
NET_IN_STOP_APP
Table 4-57 NET_IN_STOP_APP
Item Description
Struct
CLIENT_StopApp input parameters
description
typedef struct tagNET_IN_STOP_APP
{
DWORD dwSize; /// Structure size
Struct
UINT nAppID; /// App ID
char szAppName[128]; /// App name
} NET_IN_STOP_APP;
dwSize
Structure size
nAppID
Members
App ID
szAppName
App name

NET_OUT_STOP_APP
Table 4-58 NET_OUT_STOP_APP
Item Description
Struct
CLIENT_StopApp output parameters
description
typedef struct tagNET_OUT_STOP_APP
{
Struct
DWORD dwSize; /// Structure size
} NET_OUT_STOP_APP;
dwSize
Members
Structure size

NET_IN_INSTALL_EXECUTE
Table 4-59 NET_IN_INSTALL_EXECUTE
Item Description
Struct
CLIENT_RemoveApp input parameters
description
typedef struct tagNET_IN_REMOVE_APP
{
DWORD dwSize; /// Structure size
Struct
UINT nAppID; /// App ID
char szAppName[128]; /// App name
} NET_IN_REMOVE_APP;

263
Item Description
dwSize
Structure size
nAppID
Members
App ID
szAppName
App name

NET_OUT_INSTALL_EXECUTE
Table 4-60 NET_OUT_INSTALL_EXECUTE
Item Description
Struct
CLIENT_RemoveApp output parameters
description
typedef struct tagNET_OUT_REMOVE_APP
{
Struct
DWORD dwSize; /// Structure size
} NET_OUT_REMOVE_APP;
dwSize
Members
Structure size

264
5 Enumeration Definition

NET_DEVICE_TYPE
Table 5-1 NET_DEVICE_TYPE
Item Description
Enumeration
Device type enumeration. For different device types.
Description
typedef enum tagNET_DEVICE_TYPE
{
NET_PRODUCT_NONE = 0,
NET_DVR_NONREALTIME_MACE, // Non-real time MACE
NET_DVR_NONREALTIME, // Non-real time
NET_NVS_MPEG1, // Network Video Server
NET_DVR_MPEG1_2, // MPEG1 2-channel DVR
NET_DVR_MPEG1_8, // MPEG1 8-channel DVR
NET_DVR_MPEG4_8, // MPEG4 8-channel DVR
NET_DVR_MPEG4_16, // MPEG4 16-channel DVR
NET_DVR_MPEG4_SX2, // LB series DVR
NET_DVR_MEPG4_ST2, // GB series DVR
NET_DVR_MEPG4_SH2, // HB series DVR
NET_DVR_MPEG4_GBE, // GBE series DVR
NET_DVR_MPEG4_NVSII, // The 2nd Network Video Server
NET_DVR_STD_NEW, // New standard configuration protocol
NET_DVR_DDNS, // DDNS server
NET_DVR_ATM, // ATM
NET_NB_SERIAL, // The 2nd non-real time NB series DVR
NET_LN_SERIAL, // LN series DVR
NET_BAV_SERIAL, // BAV series DVR
Enumeration NET_SDIP_SERIAL, // SDIP series products
Definition NET_IPC_SERIAL, // IPC series products
NET_NVS_B, // NVS B series
NET_NVS_C, // NVS H series
NET_NVS_S, // NVS S series
NET_NVS_E, // NVS E series
NET_DVR_NEW_PROTOCOL,
// Search device type from QueryDevState by string mode
NET_NVD_SERIAL, // Network video decoder
NET_DVR_N5, // N5
NET_DVR_MIX_DVR, // Hybrid DVR
NET_SVR_SERIAL, // SVR series
NET_SVR_BS, // SVR-BS
NET_NVR_SERIAL, // NVR series
NET_DVR_N51, // N51
NET_ITSE_SERIAL, // ITSE intelligent analytics box
NET_ITC_SERIAL, // ITC (Intelligent Traffic Camera)
NET_HWS_SERIAL, // HWS (Radar Speed Measurement Device)
NET_PVR_SERIAL, // Portable video recorder
NET_IVS_SERIAL, // IVS(Intelligent Video Server)
NET_IVS_B, // General intelligent video analytics server
NET_IVS_F, // Human recognition device
NET_NVS_MPEG1, // Video Quality Diagnosis Server

265
Item Description
NET_MATRIX_SERIAL, // Matrix
NET_DVR_N52, // N52
NET_DVR_N56, // N56
NET_ESS_SERIAL, // ESS
NET_IVS_PC, // People Counting Server
NET_PC_NVR, // pc-nvr
NET_DSCON, // Video wall controller
NET_EVS, // Embedded video storage server
NET_EIVS, // Embedded intelligent video server
NET_DVR_N6, // DVR-N6
NET_UDS, // Universal decoder
NET_AF6016, // Bank alarm host
NET_AS5008, // Video network alarm server
NET_AH2008, // Network alarm server
NET_A_SERIAL, // Alarm host series
NET_BSC_SERIAL, // Access control series products
NET_NVS_SERIAL, // NVS
NET_VTO_SERIAL, // VTO
NET_VTNC_SERIAL, // VTNC
NET_TPC_SERIAL, // TPC (Thermal devices)
}NET_DEVICE_TYPE ;

EM_OPTIMIZE_TYPE
Table 5-2 EM_OPTIMIZE_TYPE
Item Description
Enumeration Set up internal optimization options to choose different optimization
Description methods.
typedef enum tagEmOptimizeType
{
EM_OPT_TYPE_DEFAULT = 0, /// Not optimized by
default
EM_OPT_TYPE_MOBILE_V1 = 1, /// Conflicts with
EM_OPT_TYPE_MOBILE_OPTION; only one can be used. Asynchronous
login optimization is not supported. When mobile optimization is
enabled, it will filter device attributes and hard disk information by
default.
EM_OPT_TYPE_P2P_NETPARAM_V1 = 2, /// Configure P2P
Enumeration
network parameters. pParam is NET_PARAM*
Definition
EM_OPT_TYPE_MOBILE_OPTION = 3, /// Conflicts with
EM_OPT_TYPE_MOBILE_V1; only one can be used. Asynchronous login
optimization is supported. It is a mobile optimization option with
parameter int, specified as a bitmask ranging from low to high. The
input values come from the enumeration type
EM_OPTTYPE_MOBILE_TYPE.
EM_OPT_TYPE_LOGIN_GET_ENCRYPT = 4, /// Get key information
during login to reduce stream loading time. pParam is int*. Use 1 to
enable optimization.
}EM_OPTIMIZE_TYPE;

266
EM_LOGIN_SPAC_CAP_TYPE
Table 5-3 EM_LOGIN_SPAC_CAP_TYPE
Item Description
Enumeration
Login mode enumeration description. To select different login mode.
Description
typedef enum tagEM_LOGIN_SPAC_CAP_TYPE
{
EM_LOGIN_SPEC_CAP_TCP= 0, // TCP, default mode
EM_LOGIN_SPEC_CAP_ANY = 1, // Login unconditionally
EM_LOGIN_SPEC_CAP_SERVER_CONN = 2, // Login of auto registration
EM_LOGIN_SPEC_CAP_MULTICAST = 3, // Multicast login, default
EM_LOGIN_SPEC_CAP_UDP= 4, // UDP login
EM_LOGIN_SPEC_CAP_MAIN_CONN_ONLY= 6,
// Only main connection
EM_LOGIN_SPEC_CAP_SSL= 7, // SSL encryption mode login
EM_LOGIN_SPEC_CAP_INTELLIGENT_BOX= 9,
// Log in to the smart box device
Enumeration EM_LOGIN_SPEC_CAP_NO_CONFIG= 10,
Definition // Do not get configuration after login device
EM_LOGIN_SPEC_CAP_U_LOGIN= 11, // Login by USB key
EM_LOGIN_SPEC_CAP_LDAP= 12, // Login by LDAP
EM_LOGIN_SPEC_CAP_AD= 13, // AD(ActiveDirectory)login
EM_LOGIN_SPEC_CAP_RADIUS = 14, // Radius login
EM_LOGIN_SPEC_CAP_SOCKET_5 = 15, // Socks5 login
EM_LOGIN_SPEC_CAP_CLOUD= 16, // Cloud login
EM_LOGIN_SPEC_CAP_AUTH_TWICE= 17, // The 2nd verification login
EM_LOGIN_SPEC_CAP_TS = 18, // TS bit stream client login
EM_LOGIN_SPEC_CAP_P2P = 19, // P2P login
EM_LOGIN_SPEC_CAP_MOBILE= 20, // Cellphone client login
EM_LOGIN_SPEC_CAP_INVALID// Invalid login
}EM_LOGIN_SPAC_CAP_TYPE;

DH_RealPlayType
Table 5-4 DH_RealPlayType
Item Description
Enumeration
Live view type. Corresponding value of CLIENT_RealPlayEx
Description
typedef enum _RealPlayType
{
DH_RType_Realplay = 0, // real-time live view
DH_RType_Multiplay,, //Multi-screen Preview
DH_RType_Realplay_0 , / / Real-time monitoring—main stream,
equivalent to DH_RType_Realplay
Enumeration DH_RType_Realplay_1 , / / Real-time monitoring—sub stream 1
Definition 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 view—1-window
DH_RType_Multiplay_4 , / / Multi-picture live view—4-window
DH_RType_Multiplay_8 , / / Multi-picture live view—8-window
DH_RType_Multiplay_9 , / / Multi-picture live view—9-window
DH_RType_Multiplay_16 , / / Multi-picture live view—16-window

267
Item Description
DH_RType_Multiplay_6 , / / Multi-picture live view—6-window
DH_RType_Multiplay_12 , / / Multi-picture live view—12-window
DH_RType_Multiplay_25 , / / Multi-picture live view—25-window
DH_RType_Multiplay_36 , / / Multi-picture live view—36-window
} DH_RealPlayType;

EM_QUERY_RECORD_TYPE
Table 5-5 EM_QUERY_RECORD_TYPE
Item Description
Enumeration
Record search type
Description
typedef enum tagEmQueryRecordType
{
EM_RECORD_TYPE_ALL = 0, // All records
EM_RECORD_TYPE_ALARM = 1, // External alarm record
DPSDK_RECORD_TYPE_ALARM = 2, // Motion detect alarm record
EM_RECORD_TYPE_ALARM_ALL = 3, // All alarm records
EM_RECORD_TYPE_CARD = 4, // Search card number
EM_RECORD_TYPE_CONDITION = 5, // Search by criteria
EM_RECORD_TYPE_JOIN = 6, // Combined search
EM_RECORD_TYPE_CARD_PICTURE = 8,
Enumeration
// Search picture by card number. For HB-U, NVS and so on.
Definition
EM_RECORD_TYPE_PICTURE = 9, // Search picture. For HB-U, NVS
and so on.
EM_RECORD_TYPE_FIELD = 10, // Search by field.
EM_RECORD_TYPE_INTELLI_VIDEO = 11, // Search IVS record
EM_RECORD_TYPE_TRANS_DATA = 16, // Search transparent serial
port record
EM_RECORD_TYPE_IMPORTANT = 17,,// Search important record files
EM_RECORD_TYPE_TALK_DATA = 18, // Search audio file
EM_RECORD_TYPE_INVALID = 256, // Invalid search type
}EM_QUERY_RECORD_TYPE;

EM_USEDEV_MODE
Table 5-6 EM_USEDEV_MODE
Item Description
Enumeration Device working mode type (Some modes are not included in this manual so there
Description is no corresponding note about the extension data type )
typedef enum __EM_USEDEV_MODE
{
DH_TALK_CLIENT_MODE,
// Set to use client-end mode to begin audio talk (The extension data is NULL)
DH_TALK_SERVER_MODE,
Enumeration
// Set to use server mode to begin audio talk (The extension data is NULL)
Definition
DH_TALK_ENCODE_TYPE,
/ / Configure the encode format of audio talk (The extension data is
DHDEV_TALKDECODE_INFO* )
DH_ALARM_LISTEN_MODE,
// Set alarm subscription mode (The extension data is NULL))

268
Item Description
DH_CONFIG_AUTHORITY_MODE,
// Set to use right to realize configuration management(The extension data is
NULL)
DH_TALK_TALK_CHANNEL,
// Set audio talk channel. (The extension data is int*, pointer address is
0~MaxChannel-1)
DH_RECORD_STREAM_TYPE,
// Set the record bit stream type of the file to be searched and file searching by
time (The extension data is int*,pointer address is 0-main stream/sub
stream,1-main stream,2-sub stream)
DH_TALK_SPEAK_PARAM,
/ / Set broadcast parameters of audio talk
DH_RECORD_TYPE,
// Set record file type of the file play and download by time (Refer to
NET_RECORD_TYPE)
DH_TALK_MODE3
/ / Set audio talk parameters of the third-generation devices(The extension data
is ???)
DH_PLAYBACK_REALTIME_MODE ,
// Set real-time playback function ( The extension data is int*,pointer
address :0-Disable,1-Enable)
DH_TALK_TRANSFER_MODE,
// Set audio talk is transfer mode or not (The extension data is
NET_TALK_TRANSFER_PARAM*)
DH_TALK_VT_PARAM,
//Set VT audio talk parameters, corresponding structure is NET_VT_TALK_PARAM
DH_TARGET_DEV_ID,
//Set object device identifier,to search new system capability (Not 0-Transfer
system capability message)
} EM_USEDEV_MODE;

EM_SUPPORT_FOCUS_MODE
Table 5-7 EM_SUPPORT_FOCUS_MODE
Item Description
Enumeration
The enumeration of the supported focus mode
Description
typedef enum tagSUPPORT_FOCUS_MODE
{
ENUM_SUPPORT_FOCUS_CAR= 1,// Focus on card mode
Enumeration
ENUM_SUPPORT_FOCUS_PLATE= 2,// Focus on plate number mode
Definition
ENUM_SUPPORT_FOCUS_PEOPLE= 3,// Focus on human mode
ENUM_SUPPORT_FOCUS_FACE= 4,// Focus on human face
}EM_SUPPORT_FOCUS_MODE;

DH_PTZ_ControlType
Table 5-8 DH_PTZ_ControlType
Item Description
Enumeration
General PTZ control commands enumeration
Description

269
Item Description
typedef enum _PTZ_ControlType
{
DH_PTZ_UP_CONTROL = 0, // Up,lParam2:pan/tilt movement speed. Valid
range (1-8)
DH_PTZ_DOWN_CONTROL, // Down,lParam2:pan/tilt movement speed. Valid
range(1-8)
DH_PTZ_LEFT_CONTROL, // Left,lParam2:pan/tilt movement speed. Valid
range (1-8)
DH_PTZ_RIGHT_CONTROL, // Right,lParam2:pan/tilt movement speed. Valid
range(1-8)
DH_PTZ_ZOOM_ADD_CONTROL, // Zoom+,lParam2:speed,Valid range(1-8)
Enumeration DH_PTZ_ZOOM_DEC_CONTROL, // Zoom-,lParam2:speed,Valid range(1-8)
Definition DH_PTZ_FOCUS_ADD_CONTROL, // Focus+,lParam2:speed,Valid range(1-8)
DH_PTZ_FOCUS_DEC_CONTROL, // Focus-,lParam2:speed,Valid range(1-8)
DH_PTZ_APERTURE_ADD_CONTROL, // Iris +,lParam2:speed,Valid range(1-8)
DH_PTZ_APERTURE_DEC_CONTROL, // Iris-,lParam2:speed,Valid range(1-8)
DH_PTZ_POINT_MOVE_CONTROL, // Go to preset,lParam2:Preset No.
DH_PTZ_POINT_SET_CONTROL, // Set,lParam2:Preset No.
DH_PTZ_POINT_DEL_CONTROL, // Delete,lParam2:Preset No.
DH_PTZ_POINT_LOOP_CONTROL, // Tour,lParam1:Tour path,lParam3:76
start;96 stop
DH_PTZ_LAMP_CONTROL// Light and wiper,lParam1:On-off
control,1:Enable,0:Disable
} DH_PTZ_ControlType;

DH_EXTPTZ_ControlType
Table 5-9 DH_EXTPTZ_ControlType
Item Description
Enumeration
PTZ control extension commands
Description
typedef enum _EXTPTZ_ControlType
{
DH_EXTPTZ_LEFTTOP = 0x20,// Upper left
DH_EXTPTZ_RIGHTTOP,// Upper right
DH_EXTPTZ_LEFTDOWN,// Down left
DH_EXTPTZ_RIGHTDOWN,// Down right
DH_EXTPTZ_ADDTOLOOP,// Adds a preset to tour, lParam1: tour No.;lParam2:
preset No.
DH_EXTPTZ_DELFROMLOOP,// Deletes a preset from the tour,lParam1:tour
Enumera No.;lParam2: preset No.
tion DH_EXTPTZ_CLOSELOOP,// Delete a tour. lParam1: tour No.
Definition DH_EXTPTZ_STARTPANCRUISE,//Begin pan rotation
DH_EXTPTZ_STOPPANCRUISE,// Stop pan rotation
DH_EXTPTZ_SETLEFTBORDER,// Set left limit
DH_EXTPTZ_SETRIGHTBORDER,// Set right limit
DH_EXTPTZ_STARTLINESCAN,// Start scanning
DH_EXTPTZ_CLOSELINESCAN,// Stop scanning
DH_EXTPTZ_SETMODESTART,// Start mode Mode line
DH_EXTPTZ_SETMODESTOP,// Stop mode Mode line
DH_EXTPTZ_RUNMODE,// Running mode Mode line
DH_EXTPTZ_STOPMODE,// Stop mode Mode line

270
Item Description
DH_EXTPTZ_DELETEMODE,// Clear mode Mode line
DH_EXTPTZ_REVERSECOMM,// Flip command
DH_EXTPTZ_FASTGOTO,// Fast positioning lParam1:Horizontal
coordinates,valid range(-8191 ~ 8191);lParam2:vertical coordinates,valid range
(-8191 ~ 8191);lParam3:zoom,valid range(-16 ~ 16)
DH_EXTPTZ_AUXIOPEN,// Auxiliary open Auxiliary point
DH_EXTPTZ_AUXICLOSE, // Auxiliary close Auxiliary point
DH_EXTPTZ_OPENMENU = 0x36, // Open dome menu
DH_EXTPTZ_CLOSEMENU, // Close menu
DH_EXTPTZ_MENUOK, // Confirm menu
DH_EXTPTZ_MENUCANCEL, // Cancel menu
DH_EXTPTZ_MENUUP, // Menu up
DH_EXTPTZ_MENUDOWN, // Menu down
DH_EXTPTZ_MENULEFT, // Menu left
DH_EXTPTZ_MENURIGHT, // Menu right
DH_EXTPTZ_ALARMHANDLE = 0x40,
// Alarm triggers PTZ parm1:Alarm input channel;parm2:Alarm trigger type
1-preset 2-scan 3-tour;parm3:trigger value,such as preset value
DH_EXTPTZ_MATRIXSWITCH = 0x41,
// Matrix switch parm1:monitor number(video output number);parm2:video
input number;parm3:matrix number

DH_EXTPTZ_LIGHTCONTROL, // Light controller


DH_EXTPTZ_EXACTGOTO,
// 3D accurate positioning parm1:Pan degree(0~3600);parm2:tilt coordinates
(0~900);parm3:zoom(1~128)
DH_EXTPTZ_RESETZERO, // Reset 3D positioning as zero
DH_EXTPTZ_MOVE_ABSOLUTELY,
// Absolute motion control commands,param4 corresponding structure
PTZ_CONTROL_ABSOLUTELY
DH_EXTPTZ_MOVE_CONTINUOUSLY,
// Continuous motion control commands,param4 corresponding structure
PTZ_CONTROL_CONTINUOUSLY
DH_EXTPTZ_GOTOPRESET,
// PTZ control commands, at a certain speed to go to a preset ,parm4
corresponding structure //PTZ_CONTROL_GOTOPRESET
DH_EXTPTZ_SET_VIEW_RANGE = 0x49,
// Set visual field (param4 corresponding structure PTZ_VIEW_RANGE_INFO)
DH_EXTPTZ_FOCUS_ABSOLUTELY = 0x4A,
// Absolute focus (param4 corresponding structure PTZ_FOCUS_ABSOLUTELY)
DH_EXTPTZ_HORSECTORSCAN = 0x4B,
// Horizontal scan (param4 corresponding structure
PTZ_CONTROL_SECTORSCAN,param1, param2, param3 are null)
DH_EXTPTZ_VERSECTORSCAN = 0x4C,
// Vertical scan (param4 corresponding structure
PTZ_CONTROL_SECTORSCAN,param1, param2, param3 are null)
DH_EXTPTZ_SET_ABS_ZOOMFOCUS = 0x4D,
// Set absolute focus distance, focus value,param1 is focus
distance,range:[0,255],param2 is focus,range :[0,255],param3, param4 are null.
DH_EXTPTZ_SET_FISHEYE_EPTZ = 0x4E,
// Control fish eye e-PTZ,param4 corresponding structure
PTZ_CONTROL_SET_FISHEYE_EPTZ
DH_EXTPTZ_UP_TELE = 0x70,// up + TELE param1=step (1-8). similarly
hereinafter

271
Item Description
DH_EXTPTZ_DOWN_TELE,// Down + TELE
DH_EXTPTZ_LEFT_TELE,// Left + TELE
DH_EXTPTZ_RIGHT_TELE,// Right + TELE
DH_EXTPTZ_LEFTUP_TELE,// Upper left + TELE
DH_EXTPTZ_LEFTDOWN_TELE, // Down left + TELE
DH_EXTPTZ_TIGHTUP_TELE,// Upper right + TELE
DH_EXTPTZ_RIGHTDOWN_TELE, // Down right + TELE
DH_EXTPTZ_UP_WIDE, // Up + WIDE param1=step (1-8). similarly hereinafter
DH_EXTPTZ_DOWN_WIDE,// Down + WIDE
DH_EXTPTZ_LEFT_WIDE,//Left + WIDE
DH_EXTPTZ_RIGHT_WIDE,// Right + WIDE
DH_EXTPTZ_LEFTUP_WIDE,// Upper left + WIDE
DH_EXTPTZ_LEFTDOWN_WIDE, // Down left + WIDE
DH_EXTPTZ_TIGHTUP_WIDE, // Upper right + WIDE
DH_EXTPTZ_RIGHTDOWN_WIDE, // Down right + WIDE
DH_EXTPTZ_TOTAL,// Max command value
} DH_EXTPTZ_ControlType;

DH_TALK_CODING_TYPE
Table 5-10 DH_TALK_CODING_TYPE
Item Description
Enumeration
Audio Encode Type
Description
typedef enum __TALK_CODING_TYPE
{
DH_TALK_DEFAULT = 0,// No-head PCM
DH_TALK_PCM = 1,// PCM with head
DH_TALK_G711a,// G711a
DH_TALK_AMR, // AMR
DH_TALK_G711u,// G711u
DH_TALK_G726, // G726
DH_TALK_G723_53,// G723_53
Enumeration
DH_TALK_G723_63,// G723_63
Definition
DH_TALK_AAC,// AAC
DH_TALK_OGG,// OGG
DH_TALK_G729 = 10,// G729
DH_TALK_MPEG2,// MPEG2
DH_TALK_MPEG2_Layer2,// MPEG2-Layer2
DH_TALK_G722_1,// G.722.1
DH_TALK_ADPCM= 21,// ADPCM
DH_TALK_MP3 = 22,// MP3
} DH_TALK_CODING_TYPE;

CtrlType
Table 5-11 CtrlType
Item Description
Enumeration
Device control type. Corresponding to interface CLIENT_ControlDeviceEx
Description
Enumeration typedef enum _CtrlType

272
Item Description
Definition {
DH_CTRL_REBOOT = 0, // Reboot device
DH_CTRL_SHUTDOWN, // Shut down device
DH_CTRL_DISK, // HDD management
DH_KEYBOARD_POWER = 3, // Network keyboard
DH_KEYBOARD_ENTER,
DH_KEYBOARD_ESC,
DH_KEYBOARD_UP,
DH_KEYBOARD_DOWN,
DH_KEYBOARD_LEFT,
DH_KEYBOARD_RIGHT,
DH_KEYBOARD_BTN0,
DH_KEYBOARD_BTN1,
DH_KEYBOARD_BTN2,
DH_KEYBOARD_BTN3,
DH_KEYBOARD_BTN4,
DH_KEYBOARD_BTN5,
DH_KEYBOARD_BTN6,
DH_KEYBOARD_BTN7,
DH_KEYBOARD_BTN8,
DH_KEYBOARD_BTN9,
DH_KEYBOARD_BTN10,
DH_KEYBOARD_BTN11,
DH_KEYBOARD_BTN12,
DH_KEYBOARD_BTN13,
DH_KEYBOARD_BTN14,
DH_KEYBOARD_BTN15,
DH_KEYBOARD_BTN16,
DH_KEYBOARD_SPLIT,
DH_KEYBOARD_ONE,
DH_KEYBOARD_NINE,
DH_KEYBOARD_ADDR,
DH_KEYBOARD_INFO,
DH_KEYBOARD_REC,
DH_KEYBOARD_FN1,
DH_KEYBOARD_FN2,
DH_KEYBOARD_PLAY,
DH_KEYBOARD_STOP,
DH_KEYBOARD_SLOW,
DH_KEYBOARD_FAST,
DH_KEYBOARD_PREW,
DH_KEYBOARD_NEXT,
DH_KEYBOARD_JMPDOWN,
DH_KEYBOARD_JMPUP,
DH_KEYBOARD_10PLUS,
DH_KEYBOARD_SHIFT,
DH_KEYBOARD_BACK,
DH_KEYBOARD_LOGIN , // New network keyboard functions
DH_KEYBOARD_CHNNEL , // Switch video channel
DH_TRIGGER_ALARM_IN = 100, // Trigger alarm input
DH_TRIGGER_ALARM_OUT, // Trigger alarm output
DH_CTRL_MATRIX, // Matrix control
DH_CTRL_SDCARD, // SD card control (IPC products)
Parameters are the same as that of the HDD control.

273
Item Description
DH_BURNING_START, // Burner control, start burning
DH_BURNING_STOP, // Burner control, stop burning
DH_BURNING_ADDPWD, // Burner control, overlay password
(String ended with '\0'. Max length is 8-bit )
DH_BURNING_ADDHEAD, // Burner control, overlay title
(String ended with '\0'. Max length is 1024-bit. Use '\n' to Enter. )
DH_BURNING_ADDSIGN, // Burner control:overlay dot to the
burned information(No parameter)
DH_BURNING_ADDCURSTOMINFO, // Burner
control:self-defined overlay (The string ended with '\0'. Max length is 1024
[Link] '\n' to Enter)
DH_CTRL_RESTOREDEFAULT, // Restore device default setup
DH_CTRL_CAPTURE_START, //Trigger device to snapshot
DH_CTRL_CLEARLOG, // Clear log
DH_TRIGGER_ALARM_WIRELESS = 200, // Trigger wireless
alarm (IPC series)
DH_MARK_IMPORTANT_RECORD, // Mark important record
DH_CTRL_DISK_SUBAREA, // Network hard disk partition
DH_BURNING_ATTACH, // Burner control, burn the
attachment
DH_BURNING_PAUSE, // Pause burn
DH_BURNING_CONTINUE, // Resume burn
DH_BURNING_POSTPONE, //Postpone burn
DH_CTRL_OEMCTRL, // OEM control
DH_BACKUP_START, // Device starts backing up
DH_BACKUP_STOP, // Device stops backing up
DH_VIHICLE_WIFI_ADD, // Manually adds Wi-Fi configuration
for mobile devices
DH_VIHICLE_WIFI_DEC, // Manually deletes Wi-Fi
configuration for mobile devices
DH_BUZZER_START, // Start to buzzer control
DH_BUZZER_STOP, // Stop to buzzer control
DH_REJECT_USER, // Reject user
DH_SHIELD_USER, // Shield user
DH_RAINBRUSH, // Intelligent traffic,wiper control
DH_MANUAL_SNAP, // Intelligent traffic, manual snapshot
(MANUAL_SNAP_PARAMETER)
DH_MANUAL_NTP_TIMEADJUST, // Manual NTP
DH_NAVIGATION_SMS, // Navigation info and message
DH_CTRL_ROUTE_CROSSING, // Route info
DH_BACKUP_FORMAT, // Format backup device
DH_DEVICE_LOCALPREVIEW_SLIPT, // Control local live view split
(DEVICE_LOCALPREVIEW_SLIPT_PARAMETER)
DH_CTRL_INIT_RAID, // RAID initialization
DH_CTRL_RAID, // RAID operation
DH_CTRL_SAPREDISK, // Hotspare operation
DH_WIFI_CONNECT, // Manually start Wi-Fi connection
(WIFI_CONNECT)
DH_WIFI_DISCONNECT, // Manually stop Wi-Fi connection
(WIFI_CONNECT)
DH_CTRL_ARMED, //Arm and disarm operation
DH_CTRL_IP_MODIFY, // Modify front-end IP
(DHCTRL_IPMODIFY_PARAM)
DH_CTRL_WIFI_BY_WPS, // wps connects Wi-Fi

274
Item Description
(DHCTRL_CONNECT_WIFI_BYWPS)
DH_CTRL_FORMAT_PATITION, // Format
partition(DH_FORMAT_PATITION)
DH_CTRL_EJECT_STORAGE, // Manually eject device
(DH_EJECT_STORAGE_DEVICE)
DH_CTRL_LOAD_STORAGE, // Manually load
device(DH_LOAD_STORAGE_DEVICE)
DH_CTRL_CLOSE_BURNER, // Close
burner( NET_CTRL_BURNERDOOR) Usually waits for 6 seconds.
DH_CTRL_EJECT_BURNER, // Eject
burner( NET_CTRL_BURNERDOOR) Usually waits for 4 seconds.
DH_CTRL_CLEAR_ALARM, // Clear alarm
(NET_CTRL_CLEAR_ALARM)
DH_CTRL_MONITORWALL_TVINFO, // TV wall information
display(NET_CTRL_MONITORWALL_TVINFO)
DH_CTRL_START_VIDEO_ANALYSE, // Start intelligent video
analytics(NET_CTRL_START_VIDEO_ANALYSE)
DH_CTRL_STOP_VIDEO_ANALYSE, // Stop intelligent video
analytics(NET_CTRL_STOP_VIDEO_ANALYSE)
DH_CTRL_UPGRADE_DEVICE, // Control and start device
upgrade. Device completes upgrade independently. No need to transmit upgrade
file.
DH_CTRL_MULTIPLAYBACK_CHANNALES, // Switch the playback
channel of the multi-channel live view (NET_CTRL_MULTIPLAYBACK_CHANNALES)
DH_CTRL_SEQPOWER_OPEN, // Power sequencer enables
on-off output port (NET_CTRL_SEQPOWER_PARAM)
DH_CTRL_SEQPOWER_CLOSE, // Power sequencer disables
on-off output port( NET_CTRL_SEQPOWER_PARAM)
DH_CTRL_SEQPOWER_OPEN_ALL, // Power sequencer enables
on-off output group port (NET_CTRL_SEQPOWER_PARAM)
DH_CTRL_SEQPOWER_CLOSE_ALL, // Power sequencer disables
on-off output group port (NET_CTRL_SEQPOWER_PARAM)
DH_CTRL_PROJECTOR_RISE, // Project
up( NET_CTRL_PROJECTOR_PARAM)
DH_CTRL_PROJECTOR_FALL, // Project down
( NET_CTRL_PROJECTOR_PARAM)
DH_CTRL_PROJECTOR_STOP, // Project
stop( NET_CTRL_PROJECTOR_PARAM)
DH_CTRL_INFRARED_KEY, // IR button
(NET_CTRL_INFRARED_KEY_PARAM)
DH_CTRL_START_PLAYAUDIO, // Device starts playing audio file
(NET_CTRL_START_PLAYAUDIO)
DH_CTRL_STOP_PLAYAUDIO, // Device stops playing audio file
DH_CTRL_START_ALARMBELL, // Enable siren (Corresponding
structure NET_CTRL_ALARMBELL)
DH_CTRL_STOP_ALARMBELL, // Disable siren (Corresponding
structure NET_CTRL_ALARMBELL)
DH_CTRL_ACCESS_OPEN, // A&C control-open door
(Corresponding structure NET_CTRL_ACCESS_OPEN)
DH_CTRL_SET_BYPASS, // Set bypass function( Corresponding
structure NET_CTRL_SET_BYPASS)
DH_CTRL_RECORDSET_INSERT, // Add records, get record set
number (Corresponding structureNET_CTRL_RECORDSET_INSERT_PARAM)
DH_CTRL_RECORDSET_UPDATE, // Update a record of the

275
Item Description
number set (Corresponding structure NET_CTRL_RECORDSET_PARAM)
DH_CTRL_RECORDSET_REMOVE, // According to the record set
number to delete a record (Corresponding structure
NET_CTRL_RECORDSET_PARAM)
DH_CTRL_RECORDSET_CLEAR, // Remove all record set
information(Corresponding structure NET_CTRL_RECORDSET_PARAM)
DH_CTRL_ACCESS_CLOSE, // A&C control-close door
(Corresponding structure NET_CTRL_ACCESS_CLOSE)
DH_CTRL_ALARM_SUBSYSTEM_ACTIVE_SET, // Alarm sub system
activation setup (Corresponding
structureNET_CTRL_ALARM_SUBSYSTEM_SETACTIVE)
DH_CTRL_FORBID_OPEN_STROBE, // Disable device open
gateway(Corresponding structure NET_CTRL_FORBID_OPEN_STROBE)
DH_CTRL_OPEN_STROBE, // Enable gateway (Corresponding
structure NET_CTRL_OPEN_STROBE)
DH_CTRL_TALKING_REFUSE, // The audio talk rejects to
answer(Corresponding structure NET_CTRL_TALKING_REFUSE)
DH_CTRL_ARMED_EX, // Arm/disarm
operation(Corresponding structure CTRL_ARM_DISARM_PARAM_EX),upgrade
CTRL_ARM_DISARM_PARAM. Recommended.
DH_CTRL_NET_KEYBOARD = 400, // Net keyboard
control(Corresponding structure DHCTRL_NET_KEYBOARD)
DH_CTRL_AIRCONDITION_OPEN, // Open air conditioner
(Corresponding structure NET_CTRL_OPEN_AIRCONDITION)
DH_CTRL_AIRCONDITION_CLOSE, // Close air-conditioner
(Corresponding structureNET_CTRL_CLOSE_AIRCONDITION)
DH_CTRL_AIRCONDITION_SET_TEMPERATURE, // Set air-conditioner
temperature(Corresponding structureNET_CTRL_SET_TEMPERATURE)
DH_CTRL_AIRCONDITION_ADJUST_TEMPERATURE, // Adjust
air-conditioner temperature(Corresponding structure
NET_CTRL_ADJUST_TEMPERATURE)
DH_CTRL_AIRCONDITION_SETMODE, // Set air-conditioner work
mode (Corresponding structure NET_CTRL_ADJUST_TEMPERATURE)
DH_CTRL_AIRCONDITION_SETWINDMODE, // Set air-conditioner
blow-in mode(Corresponding structure NET_CTRL_AIRCONDITION_SETMODE)
DH_CTRL_RESTOREDEFAULT_EX , // New protocol to reset device
default setup (Corresponding structure NET_CTRL_RESTORE_DEFAULT)
// If port failed,first use this enumeration to
recover setup.
// CLIENT_GetLastError returns
NET_UNSUPPORTED, and then try to use DH_CTRL_RESTOREDEFAULT to reover
setup.
DH_CTRL_NOTIFY_EVENT, // Sends event to
device(Corresponding structure NET_NOTIFY_EVENT_DATA)
DH_CTRL_SILENT_ALARM_SET, // Mute alarm setup
DH_CTRL_START_PLAYAUDIOEX, // Device starts audio broadcast
(Corresponding structure NET_CTRL_START_PLAYAUDIOEX)
DH_CTRL_STOP_PLAYAUDIOEX, // Device stops audio broadcast
DH_CTRL_CLOSE_STROBE, // Close gateway (Corresponding
structure NET_CTRL_CLOSE_STROBE)
DH_CTRL_SET_ORDER_STATE, // Set parking reservation status
(Corresponding structure NET_CTRL_SET_ORDER_STATE)
DH_CTRL_RECORDSET_INSERTEX, // Add record,get record set
number (Corresponding structure NET_CTRL_RECORDSET_INSERT_PARAM)

276
Item Description
DH_CTRL_RECORDSET_UPDATEEX, // Upgrade the record of one
record set number (Corresponding structure NET_CTRL_RECORDSET_PARAM)
DH_CTRL_CAPTURE_FINGER_PRINT, // Fingerprint collection
(Corresponding structure NET_CTRL_CAPTURE_FINGER_PRINT)
DH_CTRL_ECK_LED_SET, // Parking lot entrance/exit controller
LED setup(Corresponding structure NET_CTRL_ECK_LED_SET_PARAM)
DH_CTRL_ECK_IC_CARD_IMPORT, // Intelligent parking system
in/out device IC card info import(Corresponding structure
NET_CTRL_ECK_IC_CARD_IMPORT_PARAM)
DH_CTRL_ECK_SYNC_IC_CARD, // Intelligent parking system
in/out device IC card info sync command. After received this command, device
will delete original IC card info (Corresponding structure
NET_CTRL_ECK_SYNC_IC_CARD_PARAM)
DH_CTRL_LOWRATEWPAN_REMOVE, // Delete specific wireless
device(Corresponding structure NET_CTRL_LOWRATEWPAN_REMOVE)
DH_CTRL_LOWRATEWPAN_MODIFY, // Modify wireless device info
(Corresponding structure NET_CTRL_LOWRATEWPAN_MODIFY)
DH_CTRL_ECK_SET_PARK_INFO, // Set up the vehicle spot
information of the machine at the passageway of the intelligent parking system
(Corresponding structure NET_CTRL_ECK_SET_PARK_INFO_PARAM)
DH_CTRL_VTP_DISCONNECT, // Hang up the video phone
(Corresponding structure NET_CTRL_VTP_DISCONNECT)
DH_CTRL_UPDATE_FILES, // Update the multimedia files
remotely (Corresponding structure NET_CTRL_UPDATE_FILES)
DH_CTRL_MATRIX_SAVE_SWITCH, // Saves up the relationship
between the hyponymy matrices (Corresponding structure
NET_CTRL_MATRIX_SAVE_SWITCH)
DH_CTRL_MATRIX_RESTORE_SWITCH, // Recover the relationship
between the hyponymy matrices (Corresponding structure
NET_CTRL_MATRIX_RESTORE_SWITCH)
DH_CTRL_VTP_DIVERTACK, // Calls and transfers respond
(Corresponding structure NET_CTRL_VTP_DIVERTACK)
DH_CTRL_RAINBRUSH_MOVEONCE, // Wiper moves back and
forth for once . It is valid when wiper is in manual mode. (Corresponding structure
NET_CTRL_RAINBRUSH_MOVEONCE)
DH_CTRL_RAINBRUSH_MOVECONTINUOUSLY, // Wiper moves back
and forth continuously. It is valid when wiper is in manual mode. (Corresponding
structure NET_CTRL_RAINBRUSH_MOVECONTINUOUSLY)
DH_CTRL_RAINBRUSH_STOPMOVE, // Wiper stops. It is valid when
wiper is in manual mode (Corresponding structure
NET_CTRL_RAINBRUSH_STOPMOVE)
DH_CTRL_ALARM_ACK, // Confirm alarm event
(Corresponding structure NET_CTRL_ALARM_ACK)
// DH_CTRL_ALARM_ACK DO NOT call this
function in alarm callback interface
DH_CTRL_RECORDSET_IMPORT, // Batch import record set info
(Corresponding structure NET_CTRL_RECORDSET_PARAM)
DH_CTRL_ACCESS_USE_DOOR, // Disable and enable door
(Corresponding structure NET_CTRL_ACCESS_USE_DOOR)
DH_CTRL_ACCESS_SHUT_LOCK, // The latch and the cancellation
of the lock, can not pass through the door (Corresponding structure
NET_CTRL_ACCESS_SHUT_LOCK)
DH_CTRL_OPEN_DOOR_CONTINUE, // Continuous unlocking
instruction(Corresponding structure NET_CTRL_OPEN_DOOR_CONTINUE)

277
Item Description
// The following commands are only for
CLIENT_ControlDeviceEx
DH_CTRL_THERMO_GRAPHY_ENSHUTTER = 0x10000, // Set to enable or
disable thermal shutter,, pInBuf= NET_IN_THERMO_EN_SHUTTER*, pOutBuf=
NET_OUT_THERMO_EN_SHUTTER *
DH_CTRL_RADIOMETRY_SETOSDMARK, // Set the OSD of the
detected object as highlighted, pInBuf= NET_IN_RADIOMETRY_SETOSDMARK*,
pOutBuf= NET_OUT_RADIOMETRY_SETOSDMARK *
DH_CTRL_AUDIO_REC_START_NAME, // Enable audio record and get
audio name,, pInBuf = NET_IN_AUDIO_REC_MNG_NAME *, pOutBuf =
NET_OUT_AUDIO_REC_MNG_NAME *
DH_CTRL_AUDIO_REC_STOP_NAME, // Close audio file and return
file name, pInBuf = NET_IN_AUDIO_REC_MNG_NAME *, pOutBuf =
NET_OUT_AUDIO_REC_MNG_NAME *
DH_CTRL_SNAP_MNG_SNAP_SHOT, // Instant snapshot(Manual
snapshot), pInBuf = NET_IN_SNAP_MNG_SHOT *, pOutBuf =
NET_OUT_SNAP_MNG_SHOT *
DH_CTRL_LOG_STOP, // Forcedly sync buffer data to the
database and close the database, pInBuf = NET_IN_LOG_MNG_CTRL *, pOutBuf =
NET_OUT_LOG_MNG_CTRL *
DH_CTRL_LOG_RESUME, // Recover database, pInBuf =
NET_IN_LOG_MNG_CTRL *, pOutBuf = NET_OUT_LOG_MNG_CTRL *
DH_CTRL_POS_ADD, // Add a POS device, pInBuf =
NET_IN_POS_ADD *, pOutBuf = NET_OUT_POS_ADD *
DH_CTRL_POS_REMOVE, // Delete a POS device, pInBuf =
NET_IN_POS_REMOVE *, pOutBuf = NET_OUT_POS_REMOVE *
DH_CTRL_POS_REMOVE_MULTI, // Batch deletes POS devices,
pInBuf = NET_IN_POS_REMOVE_MULTI *, pOutBuf =
NET_OUT_POS_REMOVE_MULTI *
DH_CTRL_POS_MODIFY, // Modify a POS device, pInBuf =
NET_IN_POS_ADD *, pOutBuf = NET_OUT_POS_ADD *
DH_CTRL_SET_SOUND_ALARM, // /Trigger an alarm with sound,
pInBuf = NET_IN_SOUND_ALARM *, pOutBuf = NET_OUT_SOUND_ALARM *
DH_CTRL_AUDIO_MATRIX_SILENCE, // Audio deposition
and one-click mute control (Corresponding pInBuf =
NET_IN_AUDIO_MATRIX_SILENCE, pOutBuf =
NET_OUT_AUDIO_MATRIX_SILENCE)
DH_CTRL_MANUAL_UPLOAD_PICTURE, // Set manual
upload, pInBuf = NET_IN_MANUAL_UPLOAD_PICTURE *, pOutBUf =
NET_OUT_MANUAL_UPLOAD_PICTURE *
DH_CTRL_REBOOT_NET_DECODING_DEV, // Reboot
network decoding device,, pInBuf = NET_IN_REBOOT_NET_DECODING_DEV *,
pOutBuf = NET_OUT_REBOOT_NET_DECODING_DEV *
} CtrlType;

CFG_VIDEO_COMPRESSION
Table 5-12 CFG_VIDEO_COMPRESSION
Item Description
Enumeration
Video compression format description
Description
Enumeration typedef enum tagCFG_VIDEO_COMPRESSION

278
Item Description
Definition {
VIDEO_FORMAT_MPEG4, // MPEG4
VIDEO_FORMAT_MS_MPEG4, // MS-MPEG4
VIDEO_FORMAT_MPEG2, // MPEG2
VIDEO_FORMAT_MPEG1, // MPEG1
VIDEO_FORMAT_H263, // H.263
VIDEO_FORMAT_MJPG, // MJPG
VIDEO_FORMAT_FCC_MPEG4, // FCC-MPEG4
VIDEO_FORMAT_H264, // H.264
VIDEO_FORMAT_H265, // H.265
} CFG_VIDEO_COMPRESSION;

CFG_BITRATE_CONTROL
Table 5-13 CFG_BITRATE_CONTROL
Item Description
Enumeration
Bit rate control mode
Description
typedef enum tagCFG_BITRATE_CONTROL
{
Enumeration
BITRATE_CBR, // constant bit stream
Definition
BITRATE_VBR, // Variable bit stream
} CFG_BITRATE_CONTROL;

CFG_IMAGE_QUALITY
Table 5-14 CFG_IMAGE_QUALITY
Item Description
Enumeration
Quality type
Description
typedef enum tagCFG_IMAGE_QUALITY
{
IMAGE_QUALITY_Q10 = 1, // Picture quality 10%
IMAGE_QUALITY_Q30, // Picture quality 30%
Enumeration
IMAGE_QUALITY_Q50, // Picture quality 50%
Definition
IMAGE_QUALITY_Q60, // Picture quality 60%
IMAGE_QUALITY_Q80, // Picture quality 80%
IMAGE_QUALITY_Q100, // Picture quality 100%
} CFG_IMAGE_QUALITY;

CFG_H264_PROFILE_RANK
Table 5-15 CFG_H264_PROFILE_RANK
Item Description
Enumeration
H.264 encode level
Description
typedef enum tagCFG_H264_PROFILE_RANK
Enumeration
{
Definition
PROFILE_BASELINE = 1, // Provides I/P Frame,only support

279
Item Description
progressive scanning and CAVLC
PROFILE_MAIN, // Provides I/P/B Frame,support
progressive and interlaced,provide CAVLC and CABAC
PROFILE_EXTENDED, // Provide I/P/B/SP/SI Frame, only
support progressive scanning and CAVLC
PROFILE_HIGH, // /Based on FRExt,Main_Profile, new
add:8x8 intra prediction(8x8 intra-frame prediction), custom quant(customized
quantization), lossless video coding(No-loss video encode), more yuv format
}CFG_H264_PROFILE_RANK;

CFG_AUDIO_FORMAT
Table 5-16 CFG_AUDIO_FORMAT
Item Description
Enumeration
Audio encode mode
Description
typedef enum tatCFG_AUDIO_FORAMT
{
AUDIO_FORMAT_G711A, // G711a
Enumeration AUDIO_FORMAT_PCM, // PCM
Definition AUDIO_FORMAT_G711U, // G711u
AUDIO_FORMAT_AMR, // AMR
AUDIO_FORMAT_AAC, // AAC
} CFG_AUDIO_FORMAT;

EM_SEND_SEARCH_TYPE
Table 5-17 EM_SEND_SEARCH_TYPE
Item Description
Enumeration
Send search type
Description
typedef enum tagEM_SEND_SEARCH_TYPE
{
EM_SEND_SEARCH_TYPE_MULTICAST_AND_BROADCAST, // Search by
multicast and broadcast.
Enumeration
EM_SEND_SEARCH_TYPE_MULTICAST, // Multicast
Definition
search
EM_SEND_SEARCH_TYPE_BROADCAST, // Broadcast.
search
}EM_SEND_SEARCH_TYPE;

EM_REALPLAY_DISCONNECT_EVENT_TYPE
Table 5-18 EM_REALPLAY_DISCONNECT_EVENT_TYPE
Item Description
Enumeration
Video monitor offline event type
Description
Enumeration typedef enum _EM_REALPLAY_DISCONNECT_EVENT_TYPE
Definition {

280
Item Description
DISCONNECT_EVENT_REAVE, // The user of the high-level takes the
resources of the user of the low-level.
DISCONNECT_EVENT_NETFORBID, // Forbid connection
DISCONNECT_EVENT_SUBCONNECT, // Dynamic sub-connection offline
}EM_REALPLAY_DISCONNECT_EVENT_TYPE;

EM_NET_UPGRADE_INSTALL_TYPE
Table 5-19 EM_NET_UPGRADE_INSTALL_TYPE
Item Description
Enumerati
on
Operate for update and installation
Descriptio
n
typedef enum tag_EM_NET_UPGRADE_INSTALL_TYPE
{
EM_UPGRADER_INSTALL_PREPAREEX, ///Update preparation
EM_UPGRADER_INSTALL_APPEND_DATA, ///Update data
Enumerati
EM_UPGRADER_INSTALL_EXECUTE, ///Update
on
EM_UPGRADER_INSTALL_GETSTATE, ///Get update status
Definition
EM_UPGRADER_INSTALL_CANCEL, ///Cancel update
EM_UPGRADER_INSTALL_FIRMWAREEX, ///Use the designated
package to update
}EM_NET_UPGRADE_INSTALL_TYPE;

EM_APP_RUNNING_STATE
Table 5-20 EM_APP_RUNNING_STATE
Item Description
Enumerati
on
App running status
Descriptio
n
typedef enum tagEM_APP_RUNNING_STATE
{
Enumerati EM_APP_RUNNING_STATE_UNKNOWN, /// Unknown
on EM_APP_RUNNING_STATE_RUNNING, /// Running
Definition EM_APP_RUNNING_STATE_STOP, /// Stopped
EM_APP_RUNNING_STATE_ERROR, /// Error
} EM_APP_RUNNING_STATE;

EM_APP_LICENSE_STATE
Table 5-21 EM_APP_LICENSE_STATE
Item Description
Enumerati
on
App license status
Descriptio
n

281
Item Description
typedef enum tagEM_APP_LICENSE_STATE
{
EM_APP_LICENSE_STATE_UNKNOEN, /// Unknown
Enumerati
EM_APP_LICENSE_STATE_IN_TRAL, /// License trial period
on
EM_APP_LICENSE_STATE_IN_LICENSE, /// The license is official and
Definition
valid
EM_APP_LICENSE_STATE_EXPIRED, /// License expired
}EM_APP_LICENSE_STATE;

EM_APP_DEBUG_STATE
Table 5-22 EM_APP_DEBUG_STATE
Item Description
Enumerati
on
App debugging status
Descriptio
n
typedef enum tagEM_APP_DEBUG_STATE
{
Enumerati
EM_APP_DEBUG_STATE_UNKNOWN, /// Unknown
on
EM_APP_DEBUG_STATE_ENABLE, /// Enable debugging
Definition
EM_APP_DEBUG_STATE_DISABLE, /// Disable debugging
}EM_APP_DEBUG_STATE;

EM_NET_NEXT_OPERATE
Table 5-23 EM_NET_NEXT_OPERATE
Item Description
Enumerati
on
Preparaton for installing update
Descriptio
n
typedef enum tagEM_NET_NEXT_OPERATE
{
Enumerati
EM_NET_NEXT_OPERATE_UNKNOWN = 0, /// Unknown operation
on
EM_NET_NEXT_OPERATE_INSTALL, ///Install app;
Definition
EM_NET_NEXT_OPERATE_UPDATE, /// Update app;
}EM_NET_NEXT_OPERATE;

EM_NET_UPGRADE_INSTALL_TYPE
Table 5-24 EM_NET_UPGRADE_INSTALL_TYPE
Item Description
Enumerati
on
Update and install
Descriptio
n

282
Item Description
typedef enum tag_EM_NET_UPGRADE_INSTALL_TYPE
{
EM_UPGRADER_INSTALL_PREPAREEX, ///Update preparation
EM_UPGRADER_INSTALL_APPEND_DATA, ///Update data
Enumerati
EM_UPGRADER_INSTALL_EXECUTE, ///Update
on
EM_UPGRADER_INSTALL_GETSTATE, ///Get update status
Definition
EM_UPGRADER_INSTALL_CANCEL, ///Cancel update
EM_UPGRADER_INSTALL_FIRMWAREEX, ///Use the designated
package to update
}EM_NET_UPGRADE_INSTALL_TYPE;

283
6 Interface Function Definition

CLIENT_Init
Table 6-1 CLIENT_Init
Item Description
Interface description SDK initialization interface. Call it when initializing program.
Pre-condition None
BOOL CLIENT_Init(
fDisConnect cbDisConnect,
Function
LDWORD dwUser
);
cbDisConnect
[In] Offline callback function. When the on line device gets
disconnected,SDK will notify user by call this function. The callback
info includes login ID,device IP,login port etc,please refer to
Parameter “3.1fDisConnect”for details When function is set to 0,it means to
prohibit the callback.
dwUser
[in] User data,when callback function is not 0,SDK will call fDisConnect
to return the data to user for following operation.
Return value Return TRUE for success, and return FALSE for failure.
It’s not recommended to call SDK interface in callback function, unless
call CLIENT_GetLastError to get error code of current process.
//Device disconnection callback function
// When the device gets offline,SDK will call this callback function. Go
to CLINET_Init to set the callback function.
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP,
LONG nDVRPort, DWORD dwUser)
{
printf("Call DisConnectFunc\n");
printf("lLoginID[0x%x]", lLoginID);
Use examples
if (NULL != pchDVRIP)
{
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
************Above are callback function definition, the underneath are
interface using examples*************

284
Item Description
//Initialize SDK
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
{
printf("Initialize client SDK failed; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}
Before call other SDK interface, call this interface first.
Note
If call this interface repeatedly,the first time is valid.

CLIENT_Cleanup
Table 6-2 CLIENT_Cleanup
Item Description
Interface description SDK cleaning up interface
Already called initialization interface
Pre-condition
CLIENT_Init
void CLIENT_Cleanup(
Function
);
Parameter None
Return value None
// Clean initialization resources
Use examples printf("CLIENT_Cleanup!\n");
CLIENT_Cleanup();
When application program is closed, call this interface to release
Note
resources at last.

CLIENT_GetSDKVersion
Table 6-3 CLIENT_GetSDKVersion
Item Description
Interface description The interface to get the version information of SDK
Already called initialization interface
Pre-condition
CLIENT_Init
DWORD CLIENT_GetSDKVersion(
Function
);
Parameter None
Return value Return value is version,for example 34219000 corresponding to

285
Item Description
version 3.42 19000.
/ /Get SDK version info
Use examples DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);
Note None

CLIENT_GetLastError
Table 6-4 CLIENT_GetLastError
Item Description
Interface description Interface to get error code,get current thread error code.
Already called initialization interface
Pre-condition
CLIENT_Init
DWORD CLIENT_GetLastError(
Function void
);
Parameter None
Return value Current thread error code
Solution 1:
Print the error code in hexadecimal format. Search for the hexadecimal
value in dhnetsdk.h to find the corresponding explanation.
// For example,
printf("Last Error[%x]\n" , CLIENT_GetLastError());
The error code is 0x80000017. Search for corresponding
NET_NOT_SUPPORTED in the dhnetsdk.h header file.
Solution 2:
Use examples
// According to error code, user can find corresponding explanation in
[Link] is to print hexadecimal here, not decimal shows in header
file, be careful with conversion.
For example:
// #define NET_NOT_SUPPORTED_EC(23)
// Now SDK does not support this function, error code is 0x80000017,
Decimal number 23 is hexadecimal 0x17.
printf("Last Error[%x]\n" , CLIENT_GetLastError());
Call this interface after failed to call thread SDK interface.
There is too much error code, so it is impossible to illustrate one by one
here. User can search the following fields in dhnetsdk.h:
Note // Error type code, corresponds with return value of CLIENT_GetLastError
interface.
#define _EC(x) (0x80000000|x)
To find instruction of corresponding error code.

286
CLIENT_SetAutoReconnect
Table 6-5 CLIENT_SetAutoReconnect
Item Description
Interface for successful callback function after disconnection. Once
Interface description
device gets offline, SDK will reconnect automatically.
Already called initialization interface
Pre-condition
CLIENT_Init
void CLIENT_SetAutoReconnect(
HaveReConnect cbAutoConnect,
Function
DWORD dwUser
);

[in] cbAutoConnect
Successful reconnection function after offline. After device reconnects
Parameter successfully, SDK call this interface to note the user.
[in] dwUser
User data, set by [Link] to user for further use by callback
successful reconnection function after offline
Return value None
// Not recommended to call SDK interface in SDK callback
function,unless get current thread error code by CLIENT_GetLastError.
// Successful reconnection function after offline
// When offline device is reconnected successfully, SDK will call this
function, set the callback function in CLIENT_SetAutoReconnect.
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG
nDVRPort, LDWORD dwUser)
{
printf("Call HaveReConnect\n");
printf("lLoginID[0x%x]", lLoginID);
if (NULL != pchDVRIP)
{
Use examples
printf("pchDVRIP[%s]\n", pchDVRIP);
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
************Above are callback function definition, the underneath
are interface using examples.**************
// Set reconnection call interface after offline. After set successful
reconnection function, when device gets offline, SDK will reconnect
automatically.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);
Note After set successful reconnection function when calling this interface,

287
Item Description
once device gets disconnected, SDK will try to reconnect to device
[Link] reconnection is successful, SDK will inform user by
successful reconnection function after offline .
If the interface is not called or successful reconnection function is NULL,
when device gets disconnected, SDK will not try to reconnect to device.

CLIENT_SetConnectTime
Table 6-6 CLIENT_SetConnectTime
Item Description
Interface description Sets device connection timeout value and trial times.
Already called initialization interface
Pre-condition
CLIENT_Init
void CLIENT_SetConnectTime(
int nWaitTime,
Function
int nTryTimes
);
nWaitTime

[in]The timeout time means waiting time for device’s answer in every
login.
Parameter
nTryTimes

[in]The trial time means the times of trying to connect device in every
login.
Return value None
// Set device connection timeout time and trial times.
// This operation is optional.
Use examples int nWaitTime = 5000; // timeout time is 5 seconds
int nTryTimes = 3; // If timeout,it will try to log in three times
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
If do not call CLIENT_SetConnectTime interface, the device response
Note
timeout is 5 seconds. The try to login device attempt is 1 by default.

CLIENT_SetNetworkParam
Table 6-7 CLIENT_SetNetworkParam
Item Description
Interface description Sets login network environment interface
Already called initialization interface
Pre-condition
CLIENT_Init
Function void CLIENT_SetNetworkParam(

288
Item Description
NET_PARAM *pNetParam
);
pNetParam
Parameter
[in]To provide network parameter. Refer to NET_PARAM
Return value None
// Set the network login parameters,including login attempts and
timeout time.
NET_PARAM stuNetParm = {0};
Use examples
[Link] = 10000; // Change login timeout value to
10s,other parameters still use default setup.
CLIENT_SetNetworkParam(&stuNetParm);
Note None

CLIENT_SetOptimizeMode
Table 6-8 CLIENT_SetOptimizeMode
Item Description
Interface
Optimize obtaining hard disk information
description
Pre-condition CLIENT_Init initialization interface is already called.
BOOL CLIENT_SetOptimizeMode(EM_OPTIMIZE_TYPE emType, void
Function
*pParam);
pstInParam
[in]Input parameter, plan type emType.
Parameter Refer to EM_OPTIMIZE_TYPE for the enumerated definition.
[In]Input parameter, memory for pParam should be freed by the user.
Refer to the size of the structure corresponding to emType.
Return value If succeeded, return True. If failed, return False.
int opt = OPTTYPE_MOBILE_DISK_INFO;
Use examples
CLIENT_SetOptimizeMode(EM_OPT_TYPE_MOBILE_OPTION, &opt);
Note Not optimized by default.

CLIENT_LoginWithHighLevelSecurity
Table 6-9 CLIENT_LoginWithHighLevelSecurity
Item Description
High level login interface. To register user to device. It defines the device
Interface description
capabilities the user supported.
Pre-condition Already called initialization interface CLIENT_Init
LLONG CLIENT_LoginWithHighLevelSecurity (
Function NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY* pstInParam,
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY* pstOutParam

289
Item Description
);
pstInParam
[in]Input parameter
Refer to the structure definition of
NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY
Parameter
pstOutParam
[out]Output parameter
Refer to the structure definition of
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY
Return the device ID for success, and return 0 for failure
Return value Uses this value (device ID) to operate the device after successfully
logged in by working with interface of SDK.
// Log in to the device
NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
memset(&stInparam, 0, sizeof(stInparam));
[Link] = sizeof(stInparam);
strncpy([Link], “[Link]”, sizeof([Link]) - 1);
strncpy([Link], “123456”, sizeof([Link]) -
1);
strncpy([Link], “admin”, sizeof([Link])
Use examples - 1);
[Link] = 37777;
[Link] = EM_LOGIN_SPEC_CAP_TCP;

NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
memset(&stOutparam, 0, sizeof(stOutparam));
[Link] = sizeof(stOutparam);
LLONG lLoginID =
CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);
Call this interface to register to the specified device after initialization.
Return device ID for other functions to callback if successful.
Note
Recommended to login by TCP mode of emSpecCap =
EM_LOGIN_SPEC_CAP_TCP

CLIENT_Logout
Table 6-10 CLIENT_Logout
Item Description
Interface description Logout interface.
BOOL CLIENT_Logout(
Function LLONG lLoginID
);
lLoginID
Parameter
[in] Device login handle

290
Item Description
Return value of CLIENT_LoginWithHighLevelSecurity
Return value Return TRUE for success, and return FALSE for failure.
printf("CLIENT_Logout!\n");
if(!CLIENT_Logout(g_lLoginHandle))
{
Use examples
printf("CLIENT_Logout Failed!Last Error[%x]\n" , CLIENT_GetLastError());
}
Refer to the synchronization login code of the device registration
When logout device, the related businesses will stop ,such as real-time
Note
live view and so on.

CLIENT_RealPlayEx
Table 6-11 CLIENT_RealPlayEx
Item Description
Begin live view extension interface. It is to get real-time monitoring data
Interface description
stream from logged in device.
Pre-condition Call CLIENT_LoginWithHighLevelSecurity to log in to the device.
LLONG CLIENT_RealPlayEx(
LLONG lLoginID,
int nChannelID,
Function
HWND hWnd,
DH_RealPlayType rType = DH_RType_Realplay
);
lLoginID
[In] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
nChannelID
[in] Real-time monitoring channel number which starts from 0.
Parameter hWnd
[in] Window handle,when value is 0, data is not decoded and image is
not displayed.
rType
[in] Real-time monitoring type.
Default type is DH_RType_Realplay, Refer to enumeration definition of
DH_RealPlayType
Return 0 when failed,otherwise return real-time monitoring ID(real-time
Return value
monitoring handle) and used as parameters of related function.
typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)();
PROCGETCONSOLEWINDOW GetConsoleWindow;
Use examples
// Gets the console window handle.
HMODULE hKernel32 = GetModuleHandle("kernel32");

291
Item Description
GetConsoleWindow =
(PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsole
Window");
HWND hWnd = GetConsoleWindow();
//Starts real-time monitoring.
int nChannelID = 0; // Live view channel
DH_RealPlayType emRealPlayType = DH_RType_Realplay;
g_lRealHandle = CLIENT_RealPlayEx(g_lLoginHandle, nChannelID, hWnd,
emRealPlayType);
if (g_lRealHandle == 0)
{
printf("CLIENT_RealPlayEx: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
For NVR device, fills nChannelID as video output channel number in
multi-play livew preview mode.
According to information when device logged in, user can open a valid
Note
real-time monitoring channel and display it in any designated window
by calling this interface. If succeeded, real-time monitoring ID is returned
for more operation and control.

CLIENT_RealPlayByDataType
Table 6-12 CLIENT_RealPlayByDataType
Item Implication
Description Enable the real-time monitoring transcoding interface.
Pre-conditions Already called CLIENT_LoginWithHighLevelSecurity to log in to the device
LLON G CLIENT_RealPlayByDataType(
LLONG lLoginID,
const NET_IN_REALPLAY_BY_DATA_TYPE* pstInParam,
Function
NET_OUT_REALPLAY_BY_DATA_TYPE* pstOutParam,
DWORD dwWaitTime
);

292
Item Implication
lLoginID
[in] Device login ID
Corresponding to the return value of the
CLIENT_LoginWithHighLevelSecurity device login interface.
pstInParam
[in] Input parameter, please refer to the
NET_IN_REALPLAY_BY_DATA_TYPE structure definition for details.
Parameter pstOutParam
[out] Output parameter. For details, see the definition of the
NET_OUT_REALPLAY_BY_DATA_TYPE structure.
dwWaitTime
[in] User expected search time.
Users can set this parameter based on their needs. Since this interface
is a synchronous interface, it will not return from the interface until the
search time is reached.
Return Returns 0 if failed, and returns the real-time preview ID (real-time preview
value handle) if successful, and will be used as a parameter of related functions.
NET_IN_REALPLAY_BY_DATA_TYPE stIn = {sizeof(stIn)};
NET_OUT_REALPLAY_BY_DATA_TYPE stOut = {sizeof(stOut)};
[Link] = EM_REAL_DATA_TYPE_H264;
[Link] = DH_RType_Realplay;
[Link] = 0;
[Link] = NULL;
[Link] = NULL;
Use stIn.cbRealDataEx2 = OnDataCallBackEx;
examples
g_lRealHandle = CLIENT_RealPlayByDataType(g_lLoginHandle, &stIn,
&stOut, 5000);
if (0 == g_lRealHandle)
{
printf("CLIENT_RealPlayByDataType: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
Remarks None.

CLIENT_SetRealDataCallBackEx
Table 6-13 CLIENT_SetRealDataCallBackEx
Item Implication
Description Set the real-time monitoring data callback function extension interface.
CLIENT_Init initialization interface is already called.
Already called CLIENT_LoginWithHighLevelSecurity to log in to the device
Pre-conditions
The CLIENT_RealPlayEx interface has been called to pull the real-time live
video stream.

293
Item Implication
BOOL CLIENT_SetRealDataCallBackEx(
LLONG lRealHandle,
fRealDataCallBackEx cbRealData,
Function
LDWORD dwUser,
DWORD dwFlag
);
lRealHandle
[in] Live video handle
The return values from interfaces like CLIENT_RealPlayEx used for
getting real-time live video streams.
cbRealData
[in] Real-time monitoring data callback function
 When cbRealData is 0, it means that real-time live video data will
not be called back.
 When cbRealData is not 0, the real-time live video data is called
back to the user through the cbRealData callback function. For
details, see the fRealDataCallBackEx callback function description.
dwUser
[in] User data. The SDK returns this data to the user through the
Parameter
real-time live video data callback function fRealDataCallBackEx for
subsequent operations.
dwFlag
[in] The selection flag for callback data.
You can selectively call back the required data. For data types that do
not have a callback set, no callback will be made. Different values
correspond to different data types, as follows:
 0x00000001: Equivalent to the original data.
 0x00000002: MPEG4/H264 standard data.
 0x00000004: YUV data.
 0x00000008: PCM data.
 0x00000010: Original audio data.
 0x0000001f: The data types above.
Return value If succeeded, return True. If failed, return False.

294
Item Implication
// We do not recommend you call SDK interfaces in SDK callback
functions, unless you call CLIENT_GetLastError to get the error code of the
current thread.
// Real-time monitoring data callback function prototype: Extension.
// When receiving real-time monitoring data, the SDK will call this
function. Set the callback function in CLIENT_SetRealDataCallBackEx
// We recommend you only save data in this callback function, that is,
copy the corresponding data to your own storage space, and then perform
encoding and decoding on the data after leaving the callback function.
// We do not recommend you directly encode and decode data in the
callback function
void CALLBACK RealDataCallBackEx(LLONG lRealHandle, DWORD
dwDataType, BYTE *pBuffer, DWORD dwBufSize, LONG param, LDWORD
dwUser)
{
if (lRealHandle == g_lRealHandle)
{
switch(dwDataType)
{
case 0:
// Original audio and video mixed data.
printf("receive real data, param: lRealHandle[%p],
dwDataType[%d], pBuffer[%p], dwBufSize[%d], param[%p], dwUser[%p]\n",
lRealHandle, dwDataType, pBuffer, dwBufSize,
param, dwUser);
break;
Use examples
case 1:
// Standard video data.
break;
case 2:
// yuv data.
break;
case 3:
//pcm audio data.
break;
case 4:
//Original audio data.
break;
default:
break;
}
}
}
************The above is the callback function definition, and the following
is an example of interface usage.**************
DWORD dwFlag = 0x00000001;
if (!CLIENT_SetRealDataCallBackEx(g_lRealHandle, &RealDataCallBackEx,
NULL, dwFlag))
295
{
Item Implication
Add a callback data type flag dwFlag parameter, which can selectively call
Remarks back the required data. No callback is required for data types that do not have
a callback set.

CLIENT_StopRealPlayEx
Table 6-14 CLIENT_StopRealPlayEx
Item Description
Stop real-time monitor extension interface, stop pulling real-time
Interface description
monitor bit stream from the logged in device.
Already called CLIENT_RealPlayEx to pluu the real-time monitor bit
Pre-condition
stream
BOOL CLIENT_StopRealPlayEx (
Function LLONG lRealHandle
);
lRealHandle
[In] Real-time monitor handle
Parameter
The return value of pulling real-time monitor bit stream interface such as
CLIENT_RealPlayEx
Return value Return TRUE for success, and return FALSE for failure
if (!CLIENT_StopRealPlayEx(g_lRealHandle))

Use examples
printf("CLIENT_StopRealPlayEx Failed, g_lRealHandle[%x]!Last
Error[%x]\n" , g_lRealHandle, CLIENT_GetLastError());

}
Note None

CLIENT_FindFile
Table 6-15 CLIENT_FindFile
Item Description
Interface description Open the record search handle
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLONG CLIENT_FindFile(
LLONG lLoginID,
int nChannelId,
Function
int nRecordFileType,
char* cardid,
LPNET_TIME time_start,

296
Item Description
LPNET_TIME time_end,
BOOL bTime,
int waittime
);
lLoginID
[In] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
nChannelId
[in] Channel ID, starting from 0
nRecordFileType
[in] Record file type
The different record types have different values. Refer to the
enumeration note of EM_QUERY_RECORD_TYPE.
cardid
[in] Extension parameter,working with nRecordFileType.
nRecordFileType cardid
EM_RECORD_TYPE_CARD Card No.
EM_RECORD_TYPE_CONDI Card number &&transaction
TION type&&transaction amount (Set as null if
Parameter want to skip a specified field)
EM_RECORD_TYPE_CARD_ Card No.
PICTURE
EM_RECORD_TYPE_FIELD FELD1&&FELD2&&FELD3&&(Set as null
if want to skip a specified field)
The cardid value is NULL except the above conditions.
tmStart
[in] Start time of searching record
Refer to the structure description of NET_TIME
tmEnd
[in] Stop time of searching record
Refer to the structure description of NET_TIME
bTime
[in] Search by time or not
This parameter is invalid now. Transmit FALSE.
waittime
[in] Waiting time
Return value Return record search handle for success, and return 0 for failure
NET_TIME StartTime = {0};
NET_TIME StopTime = {0};
[Link] = 2015;
Use examples
[Link] = 9;
[Link] = 20;
[Link] = 0;

297
Item Description
[Link] = 0;
[Link] = 2015;
[Link] = 9;
[Link] = 21;
[Link] = 15;
NET_RECORDFILE_INFO netFileInfo[30] = {0};
int nFileCount = 0;
// Get record search handle
if(!CLIENT_FindFile (lLoginHandle, nChannelID,
(int)EM_RECORD_TYPE_ALL, NULL, &StartTime, &StopTime, FALSE,
5000))
{
printf("CLIENT_FindFile: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
Call this interface to search video record before playback,then call
CLIENT_FindNextFile function to return a detailed video record for
Note
playing. After search is finished,call CLIENT_FindClose close query
handle.

CLIENT_FindNextFile
Table 6-16 CLIENT_FindNextFile
Item Description
Interface description Search
Pre-condition Already called CLIENT_FindFile to get search record handle
int CLIENT_FindNextFile(
LLONG lFindHandle,
Function
LPNET_RECORDFILE_INFO lpFindData
);
lFindHandle
[in] Record search handle
Corresponding return value of device login interface of
CLIENT_FindFile
Parameter
lpFindData
[out] Record file butter
To output searched record file information. Refer to
NET_RECORDFILE_INFO
Return value 1: Successfully got one record, 0: Got all records, -1: Parameter error.
NET_RECORDFILE_INFO struFileData = {0};
int result = CLIENT_FindNextFile(lFindHandle, & struFileData);
Use examples if(result == 1)//Get a video record file
{
// Storage record file

298
Item Description
}
elseif(result == 0)//Got all record file info data
{
;
}
else//Parameter error
{
printf("CLIENT_FindNextFile: failed! Error code:0x%x.\n",
CLIENT_GetLastError());
}
Before calling this interface, call CLIENT_FindFile first to open the
Note search handle
One call returns one video record.

CLIENT_FindClose
Table 6-17 CLIENT_FindClose
Item Description
Interface description Close the record search handle
Pre-condition Already called CLIENT_FindFile to get search record handle
BOOL CLIENT_FindClose(
Function LLONG lFindHandle
);
lFindHandle
Parameter [in] Record search handle
Corresponding return value of CLIENT_FindFile
Return value Return TRUE for success, and return FALSE for failure
if(!CLIENT_FindClose (lFindHandle))
{
Use examples printf("CLIENT_FindNextFile: failed! Error code:0x%x.\n",
CLIENT_GetLastError());
}
Call CLIENT_FindFile to open the search handle; after the search is
Note
completed, call this function to close the search handle

CLIENT_PlayBackByDataType
Table 6-18 CLIENT_PlayBackByDataType
Item Implication
Description Start real-time monitoring transcoding interface.
Pre-conditions Already called CLIENT_LoginWithHighLevelSecurity to log in to the device

299
Item Implication
LLON G CLIENT_PlayBackByDataType(
LLONG lLoginID,
const NET_IN_PLAYBACK_BY_DATA_TYPE* pstInParam,
Function
NET_OUT_PLAYBACK_BY_DATA_TYPE* pstOutParam,
DWORD dwWaitTime
);
lLoginID
[in] Device login ID
Corresponding to the return value of the
CLIENT_LoginWithHighLevelSecurity device login interface.
pstInParam
[in] Input parameter. For details, please refer to the definition of the
NET_IN_PLAYBACK_BY_DATA_TYPE structure.
Parameter pstOutParam
[out] Output parameter. For details, see the
NET_OUT_PLAYBACK_BY_DATA_TYPE structure definition.
dwWaitTime
[in] User expected search time.
Users can set this parameter based on their needs. Since this interface
is a synchronous interface, it will not return from the interface until the
search time is reached.
Return
If successful, it returns the playback handle ID; if failed, it returns 0.
value

300
Item Implication
NET_IN_PLAYBACK_BY_DATA_TYPE stuIn = {sizeof(stuIn)};
[Link] = 0;
[Link] = EM_REAL_DATA_TYPE_MP4;
[Link] = EM_AUDIO_DATA_TYPE_G711A;
[Link] = 0;
[Link] = DownLoadPosCallBack;
[Link] = PlayBackDataCallBack;
[Link] = DataCallBackEx;
[Link] = NULL;
[Link] = 2023;
[Link] = 2;
[Link] = 1;
[Link] = 11;
[Link] = 10;
[Link] = 12;
Use
examples [Link] = 2023;
[Link] = 2;
[Link] = 1;
[Link] = 11;
[Link] = 11;
[Link] = 12;

NET_OUT_PLAYBACK_BY_DATA_TYPE stuOut = {sizeof(stuOut)};

g_lPlayHandle = CLIENT_PlayBackByDataType(g_lLoginHandle, &stuIn,


&stuOut, 5000);
if (0 == g_lPlayHandle)
{
printf("CLIENT_PlayBackByDataType fail,error:%X\n",
CLIENT_GetLastError());
}
Remarks None.

CLIENT_PlayBackByTimeEx
Table 6-19 CLIENT_PlayBackByTimeEx
Item Description
Interface description To playback by time.-- Extension interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLONG CLIENT_PlayBackByTimeEx(
Function LLONG lLoginID,
int nChannelID,

301
Item Description
LPNET_TIME lpStartTime,
LPNET_TIME lpStopTime,
HWND hWnd,
fDownLoadPosCallBack cbDownLoadPos,
LDWORD dwPosUser,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
nChannelID
[in] Channel ID, starting from 0
lpStartTime
[in] Playback start time
Refer to the structure description of NET_TIME
lpStopTime
[in] Playback end time
Refer to the structure description of NET_TIME
hWnd
[in] Playback window
cbDownLoadPos
[In] Progress callback user parameters
If cbDownLoadPos value is 0,do not callback playback data process;

Parameter If cbDownLoadPos value is not 0,callback playback data process by


cbDownLoadPos to user. Refer to callback function note of
fDownLoadPosCallBack

dwPosUser
[in] User data
SDK returns the data to user by playback data process callback function
fDownLoadPosCallBack so that the user can continue the following
operations
fDownLoadDataCallBack
[in] Record data callback function
If fDownLoadDataCallBack value is 0, do not callback playback data
process;

If fDownLoadDataCallBack value is not 0, callback playback data


process by cbDownLoadPos to user. Refer to callback function note of
fDataCallBack
dwDataUser
[in] User data

302
Item Description
SDK returns the data to user by playback data process callback
function fDownLoadPosCallBack so that the user can continue the
following operations.
Return value Return record playback handle for success, and return 0 for failure
// The following sample codes are based on playsdk library decode
when playback by time.
typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)();
PROCGETCONSOLEWINDOW GetConsoleWindow;
// Get the console window handle
HMODULE hKernel32 = GetModuleHandle("kernel32");
GetConsoleWindow =
(PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsole
Window");
HWND hWnd = GetConsoleWindow();
int nChannelID = 0; // Channel No.
NET_TIME stuStartTime = {0};
[Link] = 2015;
[Link] = 9;
Use examples [Link] = 3;

NET_TIME stuStopTime = {0};


[Link] = 2015;
[Link] = 9;
[Link] = 12;

g_lPlayHandle = CLIENT_PlayBackByTimeEx(g_lLoginHandle,
nChannelID, &stuStartTime, &stuStopTime, hWnd, NULL, NULL, NULL,
NULL);
if (g_lPlayHandle == 0)
{
printf("CLIENT_PlayBackByTimeEx: failed! Error code: 0x%x.\n",
CLIENT_GetLastError());
}
hWnd and fDownLoadDataCallBack can not be NULL at the same
Note
time,otherwise the interface callback may fail.

CLIENT_StopPlayBack
Table 6-20 CLIENT_StopPlayBack
Item Description
Interface description Stop record playback interface
Already called interfaces such as CLIENT_PlayBackByTimeEx to get
Pre-condition
record playback handle
Function BOOL CLIENT_StopPlayBack(

303
Item Description
LLONG lPlayHandle
);
lPlayHandle
Parameter [in] Record Playback handle
Corresponding return value of CLIENT_PlayBackByTimeEx
Return value Return TRUE for success, and return FALSE for failure
if (!CLIENT_StopPlayBack(g_lPlayHandle))
{
Use examples printf("CLIENT_StopPlayBack Failed, g_lPlayHandle[%x]!Last
Error[%x]\n" , g_lPlayHandle, CLIENT_GetLastError());
}
Call interface such as CLIENT_PlayBackByTimeEx to get record
Note playback handle,Call CLIENT_StopPlayBack to close record playback
handle.

CLIENT_GetPlayBackOsdTime
Table 6-21 CLIENT_GetPlayBackOsdTime
Item Description
Get playback OSD time interface
Interface description The parameters of this interface is valid only when parameter hWnd of
opening file playback interface is valid. Otherwise it is invalid.
Already called interfaces such as CLIENT_PlayBackByTimeEx to get
Pre-condition
record playback handle
BOOL CLIENT_GetPlayBackOsdTime(
LLONG lPlayHandle,
LPNET_TIME lpOsdTime,
Function
LPNET_TIME lpStartTime,
LPNET_TIME lpEndTime
);
lPlayHandle
[in] Record playback handle
Corresponding return value of CLIENT_PlayBackByTimeEx
lpOsdTime
[out] OSD time
Refer to the structure note of NET_TIME
Parameter
lpStartTime
[in] Playback start time
Refer to the structure note of NET_TIME
lpEndTime
[in] Playback end time
Refer to the structure note of NET_TIME
Return value Return TRUE for success, and return FALSE for failure

304
Item Description
NET_TIME stuOsdTime = {0};
NET_TIME stuStartTime = {0};
NET_TIME stuEndTime = {0};

if (!CLIENT_GetPlayBackOsdTime (g_lPlayHandle, &stuOsdTime,


Use examples
&stuStartTime, &stuEndTime))
{
printf("CLIENT_ GetPlayBackOsdTime Failed, g_lPlayHandle[%x]!Last
Error[%x]\n" , g_lPlayHandle, CLIENT_GetLastError());
}
The parameters of this interface is valid only when parameter hWnd of
Note
opening file playback interface is valid. Otherwise it is invalid.

CLIENT_QueryRecordFile
Table 6-22 CLIENT_QueryRecordFile
Item Description
Interface description Search the interfaces of all record files in this period.
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_QueryRecordFile(
LLONG lLoginID,
int nChannelId,
int nRecordFileType,
LPNET_TIME tmStart,
LPNET_TIME tmEnd,
Function char* pchCardid,
LPNET_RECORDFILE_INFO nriFileinfo,
int maxlen,
int *filecount,
int waittime=1000,
BOOL bTime = FALSE
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
nChannelId
Parameter [in] Channel ID, starting from 0
nRecordFileType
[in] Record file type
The different record types have different values. Refer to the
enumeration note of EM_QUERY_RECORD_TYPE .
tmStart

305
Item Description
[in] Start time of searching record
Refer to the structure description of NET_TIME
tmEnd
[in] End time of searching record
Refer to the structure description of NET_TIME
pchCardid
[in] Extension parameter,working with nRecordFileType.
nRecordFileType pchCardid
EM_RECORD_TYPE_CARD Card No.
EM_RECORD_TYPE_CONDITION Card number &&transaction
type&&transaction amount (Set
as null if want to skip a specifed
field)
EM_RECORD_TYPE_CARD_PICTURE Card No.
EM_RECORD_TYPE_FIELD FELD1&&FELD2&&FELD3&&(Set
as null if want to skip a specified
field)
pchCardid value is NULL except the above conditions.
nriFileinfo
[out] Info of the returned record file
The pointer of the structure array NET_RECORDFILE_INFO. Refer to
structure note of NET_RECORDFILE_INFO
maxlen
[in] nriFileinfo butter max. length
Unit:byte. Recommended length:(100~200)
*sizeof(NET_RECORDFILE_INFO)
filecount
[out] Returned file amount
Get the max. output parameter when buffer is full.
waittime
[In] Waiting time
bTime
[in] Search by time or not
This parameter is invalid now. Transmit FALSE.
Return value Return TRUE for success, and return FALSE for failure
NET_TIME StartTime = {0};
NET_TIME StopTime = {0};
[Link] = 2015;
[Link] = 9;
Use examples [Link] = 20;
[Link] = 0;
[Link] = 0;
[Link] = 2015;
[Link] = 9;

306
Item Description
[Link] = 21;
[Link] = 15;
NET_RECORDFILE_INFO netFileInfo[30] = {0};
int nFileCount = 0;
//Search record file
if(!CLIENT_QueryRecordFile(lLoginHandle, nChannelID,
(int)EM_RECORD_TYPE_ALL, &StartTime, &StopTime, NULL,
&netFileInfo[0], sizeof(netFileInfo), &nFileCount,5000, FALSE))
{
printf("CLIENT_QueryRecordFile: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
Before playback by file,call this interface to search video [Link]
searched video record info of input period is larger than defined
Note
buffer size, SDK returns video record that buffer can storage,and can
continue search as needed.

CLIENT_DownloadByTimeEx
Table 6-23 CLIENT_DownloadByTimeEx
Item Description
Interface description Extension interface of download the recorded video by time.
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLONG CLIENT_DownloadByTimeEx(
LLONG lLoginID,
int nChannelId,
int nRecordFileType,
LPNET_TIME tmStart,
LPNET_TIME tmEnd,
Function char *sSavedFileName,
fTimeDownLoadPosCallBack cbTimeDownLoadPos,
LDWORD dwUserData,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser,
void* pReserved = NULL
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
Parameter CLIENT_LoginWithHighLevelSecurity
nChannelId
[in] Channel number, starting from 0
nRecordFileType

307
Item Description
[in] Record file type
Refer to enumeration note of EM_QUERY_RECORD_TYPE
tmStart
[in] Start time of downloading record
Refer to the structure note of NET_TIME
tmEnd
[in] End time of downloading record
Refer to the structure note of NET_TIME
sSavedFileName
[In] Video file name user wants to save
Full path is recommended
cbTimeDownLoadPos
[in]Download process callback function
Refer to callback function note of fTimeDownLoadPosCallBack
dwUserData
[In] User data of download progress callback functions
SDK returns the data to user by download progress function
fTimeDownLoadPosCallBack so that the user can continue the
following operations
fDownLoadDataCallBack
[in] Download data callback function
Refer to callback function note of fDataCallBack
dwDataUser
[in] User data of download callback functions
SDK returns the data to user by playback data process callback
function fDataCallBack so that the user can continue the following
operations
pReserved
[In] Reserved parameter
For future development. It is invalid now. Default value is NULL.
Return value Return the download ID for success, and return 0 for failure
int nChannelID = 0; // Channel No.
NET_TIME stuStartTime = {0};
[Link] = 2015;
[Link] = 9;
[Link] = 17;

NET_TIME stuStopTime = {0};


Use examples
[Link] = 2015;
[Link] = 9;
[Link] = 18;
// Start download records
// At least one value of formal parameter sSavedFileName or
fDownLoadDataCallBack is valid.
g_lDownloadHandle =

308
Item Description
CLIENT_DownloadByTimeEx(g_lLoginHandle, nChannelID,
EM_RECORD_TYPE_ALL, &stuStartTime, &stuStopTime, "[Link]",
TimeDownLoadPosCallBack, NULL, DataCallBack, NULL);
if (g_lDownloadHandle == 0)
{
printf("CLIENT_DownloadByTimeEx: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
sSavedFileName is not null, write the record data to the file of the
corresponding path;
fDownLoadDataCallBack is not null, return record data by callback
Note
function
After download is complete, call CLIENT_StopDownload to close
download handle.

CLIENT_DownloadByDataType
Table 6-24 CLIENT_DownloadByDataType
Item Description
Interface description Extension interface of download the recorded video by data type.
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLON G CLIENT_DownloadByDataType(
LLONG lLoginID,
const NET_IN_DOWNLOAD_BY_DATA_TYPE* pstInParam,
Function
NET_OUT_DOWNLOAD_BY_DATA_TYPE* pstOutParam,
DWORD dwWaitTime
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
pstInParam
[in] Input parameter, please refer to the
NET_IN_DOWNLOAD_BY_DATA_TYPE structure definition for
details.
Parameter
pstOutParam
[out] Output parameter, please refer to the
NET_OUT_DOWNLOAD_BY_DATA_TYPE structure definition for
details.
dwWaitTime
[in] User expected search time
Users should set this parameter reasonably according to their
needs. Since this is a synchronous interface, the function will only

309
Item Description
return after the specified search time has elapsed.
Return value Return the download ID for success, and return 0 for failure
NET_IN_DOWNLOAD_BY_DATA_TYPE stuIn = {sizeof(stuIn)};
[Link] = 0;
[Link] = EM_REAL_DATA_TYPE_MP4;
[Link] = EM_AUDIO_DATA_TYPE_G711A;
[Link] = TimeDownLoadPosCallBack;
[Link] = DataCallBack;
[Link] = NULL;
[Link] = 2023;
[Link] = 2;
[Link] = 1;
[Link] = 11;
[Link] = 10;
[Link] = 12;

[Link] = 2023;
[Link] = 2;
Use examples [Link] = 1;
[Link] = 11;
[Link] = 11;
[Link] = 12;

strncpy(g_szFileName, "D:\\file.mp4", sizeof(g_szFileName) - 1);


[Link] = g_szFileName;

NET_OUT_DOWNLOAD_BY_DATA_TYPE stuOut = {sizeof(stuOut)};


g_lDownloadHandle =
CLIENT_DownloadByDataType(g_lLoginHandle, &stuIn, &stuOut,
5000);
if (0 == g_lDownloadHandle)
{
printf("CLIENT_DownloadByDataType fail,error:%X\n",
CLIENT_GetLastError());
}
Note None

CLIENT_StopDownload
Table 6-25 CLIENT_StopDownload
Item Description
Interface description Stop downloading record interface
Already called record download interface such as
Pre-condition
CLIENT_DownloadByTimeEx

310
Item Description
BOOL CLIENT_StopDownload(
Function LLONG lFileHandle
);
lFileHandle
[in] Download handle
Parameter
Corresponding return value of record download interface such as
CLIENT_DownloadByTimeEx
Return value Return TRUE for success, and return FALSE for failure
// Close download. Call after download is complete or call during
the download.
if (g_lDownloadHandle)
{
if (!CLIENT_StopDownload(g_lDownloadHandle))
Use examples {
printf("CLIENT_StopDownload Failed,
g_lDownloadHandle[%x]!Last Error[%x]\n" , g_lDownloadHandle,
CLIENT_GetLastError());
}
}
Close download when all files are downloaded or stop download
Note
during the downloading process.

CLIENT_PlayBackByRecordFileEx
Table 6-26 CLIENT_PlayBackByRecordFileEx
Item Description
Interface description Playback by file extension interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLONG CLIENT_PlayBackByRecordFileEx(
LLONG lLoginID,
LPNET_RECORDFILE_INFO lpRecordFile,
HWND hWnd,
Function fDownLoadPosCallBack cbDownLoadPos,
LDWORD dwPosUser,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
Parameter
CLIENT_LoginWithHighLevelSecurity
lpRecordFile
[In] Record file information

311
Item Description
Get by record information search interface such as
CLIENT_FindNextFile. Refer to structure note of
NET_RECORDFILE_INFO
Refer to the structure note of NET_TIME
hWnd
[In] Playback window
cbDownLoadPos
[in] Record process callback function
If cbDownLoadPos value is 0,do not callback playback data
process;

If cbDownLoadPos value is not 0,callback playback data process by


cbDownLoadPos to user. Refer to callback function note of
fDownLoadPosCallBack
dwPosUser
[in] User data
SDK returns the data to user by playback data process callback
function fDownLoadPosCallBack so that the user can continue the
following operations
fDownLoadDataCallBack
[in] Record data callback function
If fDownLoadDataCallBack value is 0, do not callback playback data
process;

If fDownLoadDataCallBack value is not 0, callback playback data


process by cbDownLoadPos to user. Refer to callback function
note of fDataCallBack
dwDataUser
[in] User data
SDK returns the data to user by playback data process callback
function fDownLoadPosCallBack so that the user can continue the
following operations
Return value Return record playback handle for success, and return 0 for failure
// Function formal parameter pa hWnd need to be valid.
// stuNetFileInfo is the record file info of three interfaces:
CLIENT_FindFile,CLIENT_FindNextFile,CLIENT_FindClose
g_lPlayHandle = CLIENT_PlayBackByRecordFileEx(g_lLoginHandle,
&stuNetFileInfo, hWnd, NULL, NULL, NULL, NULL);
Use examples
if (g_lPlayHandle == 0)
{
printf("CLIENT_PlayBackByRecordFileEx: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
The hWnd and fDownLoadDataCallBack can not be NULL at the
Note
same time,otherwise the function callback may fail.

312
CLIENT_PausePlayBack
Table 6-27 CLIENT_PausePlayBack
Item Description
Pause or resume record playback
Interface description The parameters of this interface is valid only when parameter hWnd of
opening file playback interface is valid. Otherwise it is invalid.
Already called interfaces such as CLIENT_PlayBackByTimeEx to get
Pre-condition
record playback handle
Function BOOL CLIENT_PausePlayBack(LLONG lPlayHandle, BOOL bPause);
lPlayHandle
[in] Record playback handle
Corresponding return value of CLIENT_PlayBackByTimeEx
Parameter
bPause
[in] The tag of the playback pause and resume playback control
TRUE: Pause, FALSE: Resume
Return value Return TRUE for success, and return FALSE for failure
if (!CLIENT_ PausePlayBack (g_lPlayHandle))
{
Use examples printf("CLIENT_ PausePlayBack Failed, g_lPlayHandle[%x]!Last
Error[%x]\n" , g_lPlayHandle, CLIENT_GetLastError());
}
The parameters of this interface is valid only when parameter hWnd of
Note
opening file playback interface is valid. Otherwise it is invalid.

CLIENT_SeekPlayBack
Table 6-28 CLIENT_SeekPlayBack
Item Description
Interface description Locate the start position of record playback
Already called interfaces such as CLIENT_PlayBackByTimeEx to get
Pre-condition
record playback handle
BOOL CLIENT_SeekPlayBack(
LLONG lPlayHandle,
Function unsigned int offsettime,
unsigned int offsetbyte
);
lPlayHandle
[in] Record playback handle
Corresponding return value of CLIENT_PlayBackByTimeEx
Parameter offsettime
[in] Relative offset of start time(unit : s)
offsetbyte
[in] This parameter is deleted

313
Item Description
Set value as 0xffffffff.
Return value Return TRUE for success, and return FALSE for failure
int nOffsetSeconds = 2 * 60 * 60; // drag to 2*60*60s after
stuStartTime to start play.
if (FALSE == CLIENT_SeekPlayBack (g_lPlayHandle, nOffsetSeconds,
0xffffffff))
Use examples
{
printf("CLIENT_SeekPlayBack Failed, g_lPlayHandle[%x]!Last
Error[%x]\n" , g_lPlayHandle, CLIENT_GetLastError());
}
Note None

CLIENT_FastPlayBack
Table 6-29 CLIENT_FastPlayBack
Item Description
Fast play [Link] frame rate by 1x
Interface description The parameters of this interface is valid only when parameter hWnd of
opening file playback interface is valid. Otherwise it is invalid.
Already called interfaces such as CLIENT_PlayBackByTimeEx to get
Pre-condition
record playback handle
BOOL CLIENT_FastPlayBack(
Function LLONG lPlayHandle
);
lPlayHandle
Parameter [in] Record playback handle
Corresponding return value of CLIENT_PlayBackByTimeEx
Return value Return TRUE for success, and return FALSE for failure
if (!CLIENT_ FastPlayBack (g_lPlayHandle))
{
Use examples printf("CLIENT_ FastPlayBack Failed, g_lPlayHandle[%x]!Last
Error[%x]\n" , g_lPlayHandle, CLIENT_GetLastError());
}
Can not fast forward without limit, currently the max frame is 200.
Return FALSE if the value is bigger than 200 [Link] forward is null
Note if there is audio.
The parameters of this interface is valid only when parameter hWnd of
opening file playback interface is valid. Otherwise it is invalid.

CLIENT_SlowPlayBack
Table 6-30 CLIENT_SlowPlayBack

314
Item Description
Interface description Slow play [Link] frame rate by 1/2
Already called interfaces such as CLIENT_PlayBackByTimeEx to get
Pre-condition
record playback handle
BOOL CLIENT_SlowPlayBack (
Function LLONG lPlayHandle
);
lPlayHandle
Parameter [in] Record playback handle
Corresponding return value of CLIENT_PlayBackByTimeEx
Return value Return TRUE for success, and return FALSE for failure
if (!CLIENT_SlowPlayBack (g_lPlayHandle))
{
Use examples printf("CLIENT_SlowPlayBack Failed, g_lPlayHandle[%x]!Last
Error[%x]\n" , g_lPlayHandle, CLIENT_GetLastError());
}
The min frame is 1. Return FALSE if the value is less than 1.
When the parameter hWnd of opening record playback interface is 0
and device supports playback speed control, SDK can send speed
control command to device.
Note
When the parameter hWnd of opening record playback interface is a
valid value and device supports playback speed control, SDK can send
speed control command to device and call the speed control
command of playsdk library displayed on the window.

CLIENT_NormalPlayBack
Table 6-31 CLIENT_NormalPlayBack
Item Description
Interface description Resume normal playback speed interface
Already called interfaces such as CLIENT_PlayBackByTimeEx to get
Pre-condition
record playback handle
BOOL CLIENT_NormalPlayBack(
Function LLONG lPlayHandle
);
lPlayHandle
Parameter [in] Record playback handle
Corresponding return value of CLIENT_PlayBackByTimeEx
Return value Return TRUE for success, and return FALSE for failure
if (!CLIENT_NormalPlayBack (g_lPlayHandle))
{
Use examples printf("CLIENT_NormalPlayBack Failed, g_lPlayHandle[%x]!Last
Error[%x]\n" , g_lPlayHandle, CLIENT_GetLastError());
}

315
Item Description
When the parameter hWnd of opening record playback interface is 0
and device supports playback speed control, SDK can send speed
control command to device.
Note When the parameter hWnd of opening record playback interface is a
valid value and device supports playback speed control, SDK can send
speed control command to device and call the speed control
command of playsdk library displayed on the window.

CLIENT_DownloadByRecordFileEx
Table 6-32 CLIENT_DownloadByRecordFileEx
Item Description
Interface description Download by time extension interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLONG CLIENT_DownloadByRecordFileEx(
LLONG lLoginID,
LPNET_RECORDFILE_INFO lpRecordFile,
char *sSavedFileName,
fDownLoadPosCallBack cbDownLoadPos,
Function
LDWORD dwUserData,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser,
void* pReserved = NULL
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
lpRecordFile
[in] Record file information pointer
Obtained by record search interface. Refer to NET_RECORDFILE_INFO
sSavedFileName
[In] Video file name user wants to save
Parameter Full path is recommended
cbDownLoadPos
[in] Download process callback function
Refer to callback function fDownLoadPosCallBack
dwUserData
[in] User data of download process callback function
SDK returns the data to user by download progress function
fTimeDownLoadPosCallBack so that the user can continue the
following operations
fDownLoadDataCallBack

316
Item Description
[in] Download process callback function
Refer to callback function fDataCallBack
dwUserData
[in] User data of download callback function
SDK returns the data to user by playback data process callback
function fDataCallBack so that the user can continue the following
operations
pReserved
[in] Reserved parameter
For future development. It is invalid now. Default value is NULL.
Return value Return the download ID for success, and return 0 for failure
// At least one value of formal parameter sSavedFileName or
fDownLoadDataCallBack is valid.
g_lDownloadHandle = CLIENT_DownloadByRecordFileEx(g_lLoginHandle,
&stuNetFileInfo, "[Link]", DownLoadPosCallBack, NULL, DataCallBack,
NULL);
Use examples if (g_lDownloadHandle == 0)
{
printf("CLIENT_DownloadByRecordFileEx: failed! Error code: %x.\n",
CLIENT_GetLastError());

}
sSavedFileName is not null, write the record data to the file of the
corresponding path;
fDownLoadDataCallBack is not null, return record data by callback
Note
function.
After download is complete, call CLIENT_StopDownload to close
download handle..

CLIENT_ParseData
Table 6-33 CLIENT_ParseData
Item Description
Interface description Parse the searched configuration information
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_ParseData(
char* szCommand,
char* szInBuffer,
Function LPVOID lpOutBuffer,
DWORD dwOutBufferSize,
void* pReserved
);
Parameter szCommand

317
Item Description
[in] Command parameter
Refer to the following notes for details.
szInBuffer
[in] Input buffer
Input the json string contents for the buffer internal storage to parse
lpOutBuffer
[out] Output buffer
Different commands are corresponding to different structure types.
Refer to the following notes for detail.
dwOutBufferSize
[in] Output buffer size
pReserved
[in] Reserved parameter
Return value Return TRUE for success, and return FALSE for failure
CFG_PTZ_PROTOCOL_CAPS_INFO stuPtzCapsInfo =
{sizeof(stuPtzCapsInfo)};
if (FALSE == CLIENT_ParseData(CFG_CAP_CMD_PTZ, pBuffer,
&stuPtzCapsInfo, sizeof(stuPtzCapsInfo), NULL))
Use examples
{
printf("CLIENT_ParseData Failed, cmd[CFG_CAP_CMD_PTZ], Last
Error[%x]\n" , CLIENT_GetLastError());
}
Command Parameters:
#define CFG_CAP_CMD_PTZ "[Link]"
// Get PTZ capability set(CFG_PTZ_PROTOCOL_CAPS_INFO)
Note
#define CFG_CMD_ENCODE "Encode" // Video
channel properties setup ( CFG_ENCODE_INFO)
Refer to dhconfigsdk.h for more command parameters

CLIENT_DHPTZControlEx2
Table 6-34 CLIENT_DHPTZControlEx2
Item Description
Private PTZ control extension port Support 3D fast positioning,
Interface description
fisheye
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_DHPTZControlEx2(
LLONG lLoginID,
int nChannelID,
Function DWORD dwPTZCommand,
LONG lParam1,
LONG lParam2,
LONG lParam3,

318
Item Description
BOOL dwStop ,
void* param4 = NULL
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
nChannelID
[in] Operation channel No.
Channel number starting from 0
dwPTZCommand
[in] Speed dome control commands
Refer to enumeration note of DH_PTZ_ControlType and
DH_EXTPTZ_ControlType
lParam1
[in] Aux parameter 1
Working with other parameters. Different control commands have
different parameter combination:groups.
Parameter lParam2
[in] Aux parameter 2
Working with other parameters. Different control commands have
different parameter combination:groups.
lParam3
[in] Aux parameter 3
Working with other parameters. Different control commands have
different parameter combination:groups.
dwStop
[in] Stop or not
It is valid when operating PTZ eight directions and lens, otherwise fill
in FALSE when operating others functions.
lParam4
[in] Aux parameter 4. Default value is NULL.
Working with other parameters. Different control commands have
different parameter combination:groups.
Return value Return TRUE for success, and return FALSE for failure
if (!CLIENT_DHPTZControlEx2(g_lLoginHandle, nChannelId,
DH_PTZ_UP_CONTROL, 0, 0, 0, FALSE, NULL))
{
Use examples printf("CLIENT_DHPTZControlEx2 Failed,
nChoose[DH_PTZ_UP_CONTROL]!Last Error[%x]\n" ,
CLIENT_GetLastError());
}
Refer to CLIENT_DHPTZControlEx2 on Network SDK development
Note
manual for lParam1-4 information.

319
CLIENT_QueryNewSystemInfo
Table 6-35 CLIENT_QueryNewSystemInfo
Item Description
New system capability search interface. Search system capability
Interface description
information(Json format. Refer to configuration SDK)
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_QueryNewSystemInfo(
LLONG lLoginID,
char* szCommand,
int nChannelID,
Function char* szOutBuffer,
DWORD dwOutBufferSize,
int *error,
int waittime=1000
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
szCommand
[in] Corresponding search command
Refer to notes.
nChannelID
[in] Corresponding search channel.
Channel begins with 0. When it is -1, search all channels. Some
commands do not support channel number as -1.
Parameter szOutBuffer
[in]Storage data buffer
To save the searched json data
dwOutBufferSize
[in] Buffer size
error
[out] Return error code
Netsdk fills in the corresponding error code on the pointer address if
failed to get.
waittime
[in]Timeout period
Wait for the returned command timeout . 1000ms by defaults
Return value Return TRUE for success, and return FALSE for failure
char* pBuffer = new char[2048];
if (NULL == pBuffer)
Use examples
{
return;

320
Item Description
}

int nError = 0;
if (FALSE == CLIENT_QueryNewSystemInfo(g_lLoginHandle,
CFG_CAP_CMD_PTZ, 0, pBuffer, 2048, &nError))
{
printf("CLIENT_QueryNewSystemInfo Failed,
cmd[CFG_CAP_CMD_PTZ], Last Error[%x]\n" , CLIENT_GetLastError());
if (pBuffer)
{
delete [] pBuffer;
pBuffer = NULL;
}
return;
}
Uses CLIENT_ParseData to analyze json got by this interface,
otherwise, it can not be used. The capability set command of
CLIENT_QueryNewSystemInfo is:
Note
#define CFG_CAP_CMD_PTZ "[Link]" //
Get PTZ capability set (CFG_PTZ_PROTOCOL_CAPS_INFO)
Refer to dhconfigsdk.h for more commands.

CLIENT_SetDeviceMode
Table 6-36 CLIENT_SetDeviceMode
Item Description
Interface description Set working mode interface of device audio talk, playback and rights
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_SetDeviceMode(
LLONG lLoginID,
Function EM_USEDEV_MODE emType,
void* pValue
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
emType
Parameter
[in] Work mode type
Refer to enumeration note of EM_USEDEV_MODE
pValue
[in] Extension parameter
The different emType values have different extension parameters.

321
Item Description
Refer to the enumeration note of EM_QUERY_RECORD_TYPE.
Return value Return TRUE for success, and return FALSE for failure
// Set bit stream type when playback
int nStreamType = 0; // 0-main and sub stream, 1-main stream,
2-sub stream
if(!CLIENT_SetDeviceMode(g_lLoginHandle,
Use examples DH_RECORD_STREAM_TYPE, &nStreamType))
{
printf("CLIENT_ SetDeviceMode: failed! Error code: 0x%x.\n",
CLIENT_GetLastError());
}
Note None

CLIENT_StartSearchDevicesEx
Table 6-37 CLIENT_StartSearchDevicesEx
Item Description
Interface description Asynchronously search the IPC, NVS device in the same IP segment
Already called initialization interface
Pre-condition
CLIENT_Init
LLONG CLIENT_StartSearchDevicesEx (
NET_IN_STARTSERACH_DEVICE* pInBuf,
Function
NET_OUT_STARTSERACH_DEVICE* pOutBuf
);
pInBuf
[in] Input parameter for searching device asynchronously. Refer to the
definition of NET_IN_STARTSERACH_DEVICE
Parameter
pOutBuf
[out] Output parameter for searching device asynchronously. Refer to
the definition of NET_OUT_STARTSERACH_DEVICE
Return value Return handle for success, and return 0 for failure
// Start Asynchronously search the IPC, NVS device in the same IP
segment
NET_IN_STARTSERACH_DEVICE stuInParam = {sizeof(stuInParam)};
[Link] = EM_SEND_SEARCH_TYPE_BROADCAST;
[Link] = SearchDevicesCBEx;
NET_OUT_STARTSERACH_DEVICE stuOutParam =
Use examples
{sizeof(stuOutParam)};
LLONG g_lSearchHandle =
CLIENT_StartSearchDevicesEx(SearchDevicesCB, &g_lDeviceList);
if (NULL == g_lSearchHandle)
{
printf("CLIENT_StartSearchDevicesEx Failed!Last

322
Item Description
Error[%x]\n", CLIENT_GetLastError());
return;
}
The interface searches the device in the same IP segment. Call
Note CLIENT_SearchDevicesByIPs to search in different IP segments at the
same time.

CLIENT_QueryDevState
Table 6-38 CLIENT_QueryDevState
Item Description
Interface description Search device status
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_QueryDevState(
LLONG lLoginID,
int nType,
char *pBuf,
Function
int nBufLen,
int *pRetLen,
int waittime=1000
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity.
nType
[In] Search type
Refer to the following notes for details.
pBuf
Parameter [out] Output buffer
To save the searched result information, working with search
matching type. Refer to the following notes.
nBufLen
[in] Buffer zone size
pRetLen
[out] Actually searched data length. The unit is byte
waittime
[In] Search waiting time,1000ms by default
Return value Return TRUE for success, and return FALSE for failure
// To get the encode type of audio talk supported by the front-end
device
Use examples
DHDEV_TALKFORMAT_LIST stulstTalkEncode;
int retlen = 0;

323
Item Description
bSuccess = CLIENT_QueryDevState(g_lLoginHandle,
DH_DEVSTATE_TALK_ECTYPE, (char*)&stulstTalkEncode,
sizeof(stulstTalkEncode), &retlen, 3000);
if (!(bSuccess && retlen == sizeof(stulstTalkEncode)))
{
printf("CLIENT_QueryDevState cmd[%d] Failed!Last Error[%x]\n" ,
DH_DEVSTATE_TALK_ECTYPE, CLIENT_GetLastError());
}
Supported search types
#define DH_DEVSTATE_TALK_ECTYPE 0x0009 // Search the audio
Note
talk format list device supported. Refer to DHDEV_TALKFORMAT_LIST
Refer to dhnetsdk.h for more commands.

CLIENT_StartTalkEx
Table 6-39 CLIENT_StartTalkEx
Item Description
Interface description Extension interface of starting the audio talk
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLONG CLIENT_StartTalkEx(
LLONG lLoginID,
Function pfAudioDataCallBack pfcb,
LDWORD dwUser
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
pfcb
[In] Audio data callback function of audio talk
Parameter
Refer to callback function of pfAudioDataCallBack
dwUser
In] User data of audio data callback function of audio talk
SDK returns the data to user by download progress function
pfAudioDataCallBack so that the user can continue the following
operations
Return value Return handle of audio talk for success, and return 0 for failure
g_lTalkHandle = CLIENT_StartTalkEx(g_lLoginHandle,
AudioDataCallBack, (DWORD)NULL);
if(0 == g_lTalkHandle)
Use examples
{
printf("CLIENT_StartTalkEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());

324
Item Description
}
Note None

CLIENT_StopTalkEx
Table 6-40 CLIENT_StopTalkEx
Item Description
Interface
Stop audio talk extension interface
description
Pre-condition Already called audio talk interface such as CLIENT_StartTalkEx
BOOL CLIENT_StopTalkEx(
Function LLONG lTalkHandle
);
lTalkHandle
[in] Handle ID of audio talk
Parameter
Corresponding return value of opening audio talk interface such as
CLIENT_StartTalkEx
Return value Return TRUE for success, and return FALSE for failure
if(!CLIENT_StopTalkEx(g_lTalkHandle))
{
printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());
Use examples }
else
{
g_lTalkHandle = 0;
}
Note None

CLIENT_RecordStartEx
Table 6-41 CLIENT_RecordStartEx
Item Description
Start audio extension interface on PC (Extension of
Interface description
CLIENT_RecordStart())
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_RecordStartEx(
Function LLONG lLoginID
);
lLoginID
Parameter
[in] Device login ID

325
Item Description
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
Return value Return TRUE for success, and return FALSE for failure
BOOL bSuccess = CLIENT_RecordStartEx(g_lLoginHandle);
if(!bSuccess)
{
Use examples
printf("CLIENT_RecordStartEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());
}
Note None

CLIENT_RecordStopEx
Table 6-42 CLIENT_RecordStopEx
Item Description
Stop audio extension interface on PC (Extension of
Interface description
CLIENT_RecordStart())
Already called CLIENT_RecordStartEx to enable local audio collection
Pre-condition
interface
BOOL CLIENT_RecordStopEx(
Function LLONG lLoginID
);
lLoginID
[in] Device login ID
Parameter
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
Return value Return TRUE for success, and return FALSE for failure
//Stop local audio record
if (g_RecordFlag)
{
if (!CLIENT_RecordStopEx(g_lLoginHandle))
{
printf("CLIENT_RecordStop Failed!Last Error[%x]\n",
Use examples CLIENT_GetLastError());
}
else
{
g_RecordFlag = FALSE;
}
}
Note CLIENT_RecordStopEx needs to work with CLIENT_RecordStartEx

326
CLIENT_TalkSendData
Table 6-43 CLIENT_TalkSendData
Item Description
Interface description Send audio data to the device
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LONG CLIENT_TalkSendData(
LLONG lTalkHandle,
Function char *pSendBuf,
DWORD dwBufSize
);
lTalkHandle
[in] Audio talk handle ID
Corresponding return value of opening audio talk such as
CLIENT_StartTalkEx
pSendBuf
Parameter
[In] Send buffer zone
Save audio data to be sent
dwBufSize
[in] Buffer size,
Length of audio data to be sent. Unit is byte
Return the transmits locations device length of data for success, and
Return value
return -1 for failure
LONG lSendLen = CLIENT_TalkSendData(lTalkHandle, pDataBuf,
dwBufSize);
if(lSendLen != (long)dwBufSize)
Use examples {
printf("CLIENT_TalkSendData Failed!Last Error[%x]\n" ,
CLIENT_GetLastError());
}
After receiving the audio data from CLIENT_StartTalkEx, use this
Note
interface to send to device.

CLIENT_AudioDecEx
Table 6-44 CLIENT_AudioDecEx
Item Description
Interface description Decode audio data extension interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_AudioDecEx(
Function LLONG lTalkHandle,
char *pAudioDataBuf,

327
Item Description
DWORD dwBufSize
);
lTalkHandle
[in] Audio talk handle ID
Corresponding return value of opening audio talk interface such as
CLIENT_PlayBackByTimeEx
pAudioDataBuf
Parameter
[In] Audio buffer zone
Audio data to be decoded
dwBufSize
[in] Buffer size
Length of audio data to be decoded. Unit is byte
Return value Return TRUE for success, and return FALSE for failure
//Pass the audio data sent from the device to SDK for decoding play
if (!CLIENT_AudioDecEx(lTalkHandle, pDataBuf, dwBufSize))
{
Use examples
printf("CLIENT_AudioDecEx Failed!Last Error[%x]\n" ,
CLIENT_GetLastError());
}
Note Decode the data from the audio talk device

CLIENT_SetDVRMessCallBack
Table 6-45 CLIENT_SetDVRMessCallBack
Item Description
Interface description Set alarm callback function interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
void CLIENT_SetDVRMessCallBack(
fMessCallBack cbMessage,
Function
LDWORD dwUser
);
cbMessage
[in] Alarm callback function
Refer to callback function fMessCallBack
Parameter
dwUser
[in] User data. SDK sends the data to user for further use by
callback function fMessCallBack
Return value None
/ / Set alarm event callback function
Use examples
CLIENT_SetDVRMessCallBack(MessCallBack , NULL);
Call CLIENT_SetDVRMessCallBack before alarm subscription. The
Note
event of the configured callback function do not contain the event

328
Item Description
picture.

CLIENT_StartListenEx
Table 6-46 CLIENT_StartListenEx
Item Description
Interface description Alarm subscription extension interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_StartListenEx(
Function LLONG lLoginID
);
lLoginID
[in] Device login ID
Parameter
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
Return value Return TRUE for success, and return FALSE for failure
/ / Subscribe alarm from the device
if( CLIENT_StartListenEx(g_lLoginHandle))
{
g_bStartListenFlag = TRUE;
printf("Listen Success!\nJust Wait Event....\n");
Use examples }
else
{
printf("CLIENT_StartListenEx Failed!Last Error[%x]\n" ,
CLIENT_GetLastError());
}
Alarm events of all devices returned to the user are by callback
Note
function of CLIENT_SetDVRMessCallBack

CLIENT_StopListen
Table 6-47 CLIENT_StopListen
Item Description
Interface description Stop subscribing alarm
Pre-condition Already called alarm reporting interface such as CLIENT_StartListenEx
BOOL CLIENT_StopListen(
Function LLONG lLoginID
);
lLoginID
Parameter
[in] Device login ID

329
Item Description
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
Return value Return TRUE for success, and return FALSE for failure
/ / Stop subscribing alarm from the device
if (g_bStartListenFlag)
{
if (!CLIENT_StopListen(g_lLoginHandle))
{
printf("CLIENT_StopListen Failed!Last Error[%x]\n",
Use examples CLIENT_GetLastError());
}
else
{
g_bStartListenFlag = FALSE;
}
}
Note None

CLIENT_StopSearchDevices
Table 6-48 CLIENT_StopSearchDevices
Item Description
Stop asynchronously search the IPC, NVS device in the same IP
Interface description
segment
Already called asynchronously search device interface such as
Pre-condition
CLIENT_StartSearchDevicesEx
BOOL CLIENT_StopSearchDevices(
Function LLONG lSearchHandle
);
lSearchHandle
[in] Asynchronously search device ID
Parameter
Corresponding return value of asynchronously search device interface
such as CLIENT_StartSearchDevicesEx
Return value Return TRUE for success, and return FALSE for failure
// Stop asynchronously search device in the same IP segment
if (NULL != g_lSearchHandle)
{
if (FALSE == CLIENT_StopSearchDevices(g_lSearchHandle))
Use examples {
printf("CLIENT_StopSearchDevices Failed!Last Error[%x]\n",
CLIENT_GetLastError());
}
}

330
Item Description
Note The interface needs to work with CLIENT_StartSearchDevicesEx

CLIENT_SearchDevicesByIPs
Table 6-49 CLIENT_SearchDevicesByIPs
Item Description
Synchronously search device cross different IP segments at the same
Interface description
time
Already called initialization interface
Pre-condition
CLIENT_Init
BOOL CLIENT_SearchDevicesByIPs(
DEVICE_IP_SEARCH_INFO* pIpSearchInfo,
fSearchDevicesCB cbSearchDevices,
Function LDWORD dwUserData,
char* szLocalIp,
DWORD dwWaitTime
);
pIpSearchInfo
[in] Search device information
Save the device IP to be searched. DEVICE_IP_SEARCH_INFO refer to
dhnetsdk.h
cbSearchDevices
[In] Callback function for searching device
When there is device response packet, SDK parses the response
packet to valid information and then notify the user by callback
function. Refer to callback function note of fSearchDevicesCB for
details.
Callback address cannot be null.
dwUserData
Parameter
[in] User data
NetSDK searches device callback function fSearchDevicesCB to return
the data to user so that the user can continue the following
operations.
szLocalIp
[in] Local IP
Do not need to input. The default value is NULL
dwWaitTime
[in] User expected search time
User sets the parameter according to actual requirements. Since it is
the synchronization interface, it returns the value when the search
time is finish.
Return value Return TRUE for success, and return FALSE for failure
DWORD dwWaitTime = 5000;
Use examples
// Please note the interface only returns when time is out. Set the

331
Item Description
timeout period according to network environment.
if (FALSE == CLIENT_SearchDevicesByIPs(&stuTmp, SearchDevicesCB,
(LDWORD)&g_lDeviceList, szLocalIp, dwWaitTime))
{
printf("CLIENT_SearchDevicesByIPs Failed!Last Error[%x]\n",
CLIENT_GetLastError());
sreturn;
}
It is the synchronization interface. The interface only returns when
Note search time starts . Set the search period according to network
environment.

CLIENT_RealLoadPictureEx
Table 6-50 CLIENT_RealLoadPictureEx
Item Description
Interface description Intelligent picture alarm subscription interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
LLONG CLIENT_RealLoadPictureEx(
LLONG lLoginID,
int nChannelID,
DWORD dwAlarmType,
Function BOOL bNeedPicFile,
fAnalyzerDataCallBack cbAnalyzerData,
LDWORD dwUser,
void* Reserved
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
nChannelID
[in] Intelligent picture alarm subscription interface channel No.
Channel No. begins with 0
dwAlarmType
Parameter
[in] The alarm type to be subscripted
Such as:EVENT_IVS_ALL //Upload all alarm info
Refer to dhnetsdk.h for more types.
bNeedPicFile
[in] Subscribe picture file or not
TRUE: subscribe picture file. The callback function returns the
intelligent picture information.
FALSE:Do not subscribe picture file. The callback function does not

332
Item Description
return the intelligent picture info (It reduces the network flows when
there is no picture information.)
cbAnalyzerData
[in] Intelligent picture alarm callback function
SDK calls the return value of the function to user when there is
uploaded intelligent picture alarm from the device.
dwUser
[in] User data. SDK sends the data to user for further use by
callback fAnalyzerDataCallBack
Reserved
[in] Reserved parameter
Fill in NULL in the field.
Return 0 for failure, return intelligent pictures alarm subscription ID as
Return value
the parameter of CLIENT_StopLoadPic
// Intelligent picture alarm subscription
LDWORD dwUser = 0;
g_lRealLoadHandle = CLIENT_RealLoadPictureEx(g_lLoginHandle, 0,
EVENT_IVS_ALL, TRUE, AnalyzerDataCallBack, dwUser, NULL);
if (0 == g_lRealLoadHandle)
Use examples
{
printf("CLIENT_RealLoadPictureEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());
return;
}
Each interface is corresponding to one channel and one event type
at each time.
Set dwAlarmType as EVENT_IVS_ALL if user wants to subscribe all
Note event types of current channel.
If user wants to subscribe one channel to upload two event types, call
CLIENT_RealLoadPictureEx twice and then input different types.
Call CLIENT_StopLoadPic to cancel subscription

CLIENT_ControlDeviceEx
Table 6-51 CLIENT_ControlDeviceEx
Item Description
Interface description Device control extension interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_ControlDeviceEx(
LLONG lLoginID,
Function CtrlType emType,
void* pInBuf,
void* pOutBuf = NULL,

333
Item Description
int nWaitTime = 1000
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
emType
[in] Control type
Working with pInBuf and pOutBuf,different emType,pInBuf
and pOutBuf point to different structures. Refer to enumeration note
of CtrlType.
pInBuf
[in] Input parameter of device control
Working with emType. Different emType and pInBuf point to different
Parameter
structures. Refer to enumeration note of enum CtrlType for [Link]
in NULL if the value of emType did not indicate what structure pInBuf
is.
pOutBuf
[out] Output parameter of device control. It is NULL by default.
Working with emType,different emType and pInBuf point to different
structures. Refer to enumeration note of CtrlType for [Link] in
NULL if the value of emType not indicate what struct pOutBuf is.
Do not need to fill in pOutBuf if emType is less than 0x10000
nWaitTime
[in] Timeout when waiting for device to return. Unit is ms
It is 1000 by default.
Return value Return TRUE for success, and return FALSE for failure
MANUAL_SNAP_PARAMETER stuSanpParam = {0};
[Link] = 0;
memcpy([Link], "just for test",
sizeof([Link]) - 1);
// Manual snapshot triggers alarm function. For ITC only.
if (FALSE == CLIENT_ControlDeviceEx(g_lLoginHandle,
Use examples
DH_MANUAL_SNAP, &stuSanpParam))
{
printf("CLIENT_ControlDeviceEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());
break;
}
Note None

CLIENT_StopLoadPic
Table 6-52 CLIENT_StopLoadPic

334
Item Description
Interface description Cancel intelligent picture alarm subscription interface
Already called intelligent picture alarm subscription interface such as
Pre-condition
CLIENT_RealLoadPictureEx
BOOL CLIENT_StopLoadPic(
Function LLONG lAnalyzerHandle
);
lAnalyzerHandle
[in] Intelligent picture alarm subscription ID
Parameter
Corresponding intelligent picture alarm subscription interface such as
Return value of CLIENT_RealLoadPictureEx
Return value Return TRUE for success, and return FALSE for failure
/ / Cancel intelligent picture alarm subscription
if (0 != g_lRealLoadHandle)
{
if (FALSE == CLIENT_StopLoadPic(g_lRealLoadHandle))
{
printf("CLIENT_StopLoadPic Failed!Last Error[%x]\n",
Use examples CLIENT_GetLastError());
}
else
{
g_lRealLoadHandle = 0;
}
}
Note None

CLIENT_GetDownloadPos
Table 6-53 CLIENT_GetDownloadPos
Item Description
Interface description Search download process. The unit is KB.
Already called record download interface such as
Pre-condition
CLIENT_DownloadByTimeEx
BOOL CLIENT_GetDownloadPos(
LLONG lFileHandle,
Function int *nTotalSize,
int *nDownLoadSize
);
lFileHandle
[in] Download handle
Parameter Corresponding return value of record download interface such as
CLIENT_DownloadByTimeEx
nTotalSize

335
Item Description
[out] Downloaded total size. The unit is KB
nDownLoadSize
[out] Downloaded total length. The unit is KB
Return value Return TRUE for success, and return FALSE for failure
int nTotal = 0;
int nDownLoad = 0;
if (FALSE == CLIENT_GetDownloadPos(g_lDownloadHandle, &nTotal,
&nDownLoad))
Use examples
{
printf("CLIENT_GetDownloadPos Failed!Last Error[%x]\n",
CLIENT_GetLastError());
}
Note None

CLIENT_SetSnapRevCallBack
Table 6-54 CLIENT_SetSnapRevCallBack
Item Description
Interface description Set front-end video snapshot callback function interface
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
void CLIENT_SetSnapRevCallBack(
fSnapRev OnSnapRevMessage,
Function
LDWORD dwUser
);
OnSnapRevMessage
[In] Front-end video snapshot callback function
Refer to callback function note of fSnapRev
Parameter
dwUser
[in] User data. SDK sends the data to user for further use by callback
function fSnapRev.
Return value None
In] Set front-end video snapshot callback function
Use examples
CLIENT_SetSnapRevCallBack(SnapRev, NULL);
Call CLIENT_SetSnapRevCallBack before calling front-end video
Note
snapshot interface

CLIENT_SnapPictureEx
Table 6-55 CLIENT_SnapPictureEx
Item Description
Interface description Snapshot request extension interface

336
Item Description
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device.
BOOL CLIENT_SnapPictureEx(
LLONG lLoginID,
Function SNAP_PARAMS *par,
int *reserved = 0
);
lLoginID
[in] Device login ID
Corresponding return value of device login interface of
CLIENT_LoginWithHighLevelSecurity
Parameter par
[in] Snapshot parameters
Refer to the structure note of SNAP_PARAMS
reserved
[in] Reserved field
Return value Return TRUE for success, and return FALSE for failure
// Send out snapshot command to front-end device
SNAP_PARAMS stuSnapParams;
[Link] = nChannelId;
[Link] = nSnapType;
[Link] = ++g_nCmdSerial; // Snapshot request
SN. The value ranges from 0 to 65535. Once the value is out of
range, it is unsigned short.
if (FALSE == CLIENT_SnapPictureEx(g_lLoginHandle,
&stuSnapParams))
Use examples
{
printf("CLIENT_SnapPictureEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());
return;
}
else
{
printf("CLIENT_SnapPictureEx succ\n");
}
Note None

CLIENT_StartApp
Table 6-56 CLIENT_StartApp
Item Implication
Interface description Start the app
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device

337
Item Implication
BOOL CLIENT_StartApp(LLONG lLoginID, const NET_IN_START_APP*
Function
pInParam, NET_OUT_START_APP* pOutParam, int nWaitTime);

[in] lLoginID The login handle


[in] pInParam Input parameters for the interface. Memory
resources are requested and released by the user
Parameter
[out] pOutParam Output parameters for the interface. Memory
resources are requested and released by the user
[in] nWaitTime Timeout period for the interface, in milliseconds
return TRUE: Success
Return value
FALSE: Failure
//Start the program
NET_IN_START_APP stuIn = {sizeof(NET_IN_START_APP)};
memset(&stuIn, 0, sizeof(NET_IN_START_APP));
[Link] = sizeof(NET_IN_START_APP);
NET_OUT_START_APP stuOut = {sizeof(NET_OUT_START_APP)};
Use examples memset(&stuOut, 0, sizeof(NET_OUT_START_APP));
[Link] = sizeof(NET_OUT_START_APP);
[Link] = 3214;
strncpy([Link], "TestAppCheck", sizeof([Link])
- 1);
BOOL bRet = CLIENT_StartApp(lLoginID, &stuIn,&stuOut,5000);
Note None

CLIENT_GetNewDevConfig

Table 6-57 CLIENT_GetNewDevConfig


Item Implication
Interface description Query config information
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device
BOOL CLIENT_GetNewDevConfig(LLONG lLoginID, char*
szCommand, int nChannelID, char* szOutBuffer, DWORD
Function
dwOutBufferSize, int *error, int waittime=500, void* pReserved =
NULL);

338
Item Implication
[in] lLoginID The login handle
[in] szCommand Configuration name
[in] nChannelID Channel ID
[out] szOutBuffer Configuration information in JSON format
[in] dwOutBufferSize Original validity level of the configuration
Parameter
information
[out] error Error code
[in] waittime Timeout period for the interface, in milliseconds
[in] pReserved Its type is a pointer of
NET_CONFIG_RESERVED_PARA
return TRUE: Success
Return value
FALSE: Failure
LLONG lLoginID = *(LLONG*)data;
int nChannel = -1;
int nBufLen = 1024*1024*20;
char *pbufsize = new char[nBufLen];
memset(pbufsize, 0, nBufLen);
int nError = 0;
Use examples int nRetlen = 0;
CFG_DEV_DISPOSITION_INFO *pstinfo = new
CFG_DEV_DISPOSITION_INFO;
memset(pstinfo, 0, sizeof(CFG_DEV_DISPOSITION_INFO));
BOOL bRet = CLIENT_GetNewDevConfig(lLoginID,
CFG_CMD_DEV_GENERRAL, nChannel, pbufsize, nBufLen, &nError,
5000);
Note None

CLIENT_GetInstalledAppInfo
Table 6-58 CLIENT_GetInstalledAppInfo
Item Implication
Interface description Get the list of installed apps
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device
BOOL CLIENT_GetInstalledAppInfo(LLONG lLoginID, const
Function NET_IN_GET_INSTALLED_APP_INFO* pInParam,
NET_OUT_GET_INSTALLED_APP_INFO* pOutParam, int nWaitTime);
[in] lLoginID The login handle
[in] pInParam Input parameters for the interface. Memory
resources are requested and released by the user
Parameter
[out] pOutParam Output parameters for the interface. Memory
resources are requested and released by the user
[in] nWaitTime Timeout period for the interface, in milliseconds

339
Item Implication
return TRUE: Success
Return value
FALSE: Failure
LLONG lLoginID = *(LLONG*)data;
NET_IN_GET_INSTALLED_APP_INFO stuIn =
{sizeof(NET_IN_GET_INSTALLED_APP_INFO)};;
memset(&stuIn, 0, sizeof(NET_IN_GET_INSTALLED_APP_INFO));
[Link] = sizeof(NET_IN_GET_INSTALLED_APP_INFO);
Use examples NET_OUT_GET_INSTALLED_APP_INFO stuOut =
{sizeof(NET_OUT_GET_INSTALLED_APP_INFO)};;
memset(&stuOut, 0, sizeof(NET_OUT_GET_INSTALLED_APP_INFO));
[Link] = sizeof(NET_OUT_GET_INSTALLED_APP_INFO);
BOOL bRet = CLIENT_GetInstalledAppInfo(lLoginID,
&stuIn,&stuOut,5000);
Note None

CLIENT_UpgraderInstall
Table 6-59 CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_PREPAREEX
Item Implication
Interface description Update preparations
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device
BOOL CLIENT_UpgraderInstall(LLONG lLoginID,
Function EM_NET_UPGRADE_INSTALL_TYPE emType, void* pInBuf, void*
pOutBuf, int nWaittime);
[in] lLoginID The login handle
[in] emType Operation type
[in] pInBuf The user can request to release the memory.
Parameter emType corresponds to its respective structure
[out] pOutBuf The user can request to release the memory.
emType corresponds to its respective structure
[in] nWaittime Timeout period for the interface, in milliseconds
return TRUE: Success
Return value
FALSE: Failure

340
Item Implication
LLONG lLoginID = *(LLONG*)data;
EM_NET_UPGRADE_INSTALL_TYPE emType =
EM_UPGRADER_INSTALL_PREPAREEX;
NET_IN_INSTALL_PREPAREEX stuIn =
{sizeof(NET_IN_INSTALL_PREPAREEX)};
memset(&stuIn, 0, sizeof(NET_IN_INSTALL_PREPAREEX));
[Link] = sizeof(NET_IN_INSTALL_PREPAREEX);
NET_OUT_INSTALL_PREPAREEX stuOut =
{sizeof(NET_OUT_INSTALL_PREPAREEX)};
Use examples
memset(&stuOut, 0, sizeof(NET_OUT_INSTALL_PREPAREEX));
[Link] = sizeof(NET_OUT_INSTALL_PREPAREEX);
[Link] = true;
[Link] = EM_NET_NEXT_OPERATE_INSTALL;
[Link] = 1024;
strncpy([Link], "TestAppCheck", sizeof([Link])
- 1);
BOOL bRet = CLIENT_UpgraderInstall(lLoginID,
emType,&stuIn,&stuOut,5000);
Note None

CLIENT_UpgraderInstall
Table 6-60 CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_APPEND_DATA
Item Implication
Interface description Push update data
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device
BOOL CLIENT_UpgraderInstall(LLONG lLoginID,
Function EM_NET_UPGRADE_INSTALL_TYPE emType, void* pInBuf, void*
pOutBuf, int nWaittime);
[in] lLoginID The login handle
[in] emType Operation type
[in] pInBuf The user can request to release the memory.
Parameter emType corresponds to its respective structure
[out] pOutBuf The user can request to release the memory.
emType corresponds to its respective structure
[in] nWaittime Timeout period for the interface, in milliseconds
return TRUE: Success
Return value
FALSE: Failure

341
Item Implication
LLONG lLoginID = *(LLONG*)data;
EM_NET_UPGRADE_INSTALL_TYPE emType =
EM_UPGRADER_INSTALL_APPEND_DATA;
NET_IN_INSTALL_APPEND_DATA stuIn =
{sizeof(NET_IN_INSTALL_APPEND_DATA)};
memset(&stuIn, 0, sizeof(NET_IN_INSTALL_APPEND_DATA));
[Link] = sizeof(NET_IN_INSTALL_APPEND_DATA);
NET_OUT_INSTALL_APPEND_DATA stuOut =
{sizeof(NET_OUT_INSTALL_APPEND_DATA)};
memset(&stuOut, 0, sizeof(NET_OUT_INSTALL_APPEND_DATA));
Use examples
[Link] = sizeof(NET_OUT_INSTALL_APPEND_DATA);
[Link] = 1024;
[Link] = 32;
[Link] = new unsigned char[[Link]];
for(int i = 0;i<[Link];i++)
{
[Link][i] = (unsigned char)(i+1);
}
BOOL bRet = CLIENT_UpgraderInstall(lLoginID,
emType,&stuIn,&stuOut,5000);
Note None

CLIENT_UpgraderInstall
Table 6-61 CLIENT_UpgraderInstall + EM_UPGRADER_INSTALL_EXECUTE
Item Implication
Interface description Upgrade
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device
BOOL CLIENT_UpgraderInstall(LLONG lLoginID,
Function EM_NET_UPGRADE_INSTALL_TYPE emType, void* pInBuf, void*
pOutBuf, int nWaittime);
[in] lLoginID The login handle
[in] emType Operation type
[in] pInBuf The user can request to release the memory.
Parameter emType corresponds to its respective structure
[out] pOutBuf The user can request to release the memory.
emType corresponds to its respective structure
[in] nWaittime Timeout period for the interface, in milliseconds
return TRUE: Success
Return value
FALSE: Failure

342
Item Implication
LLONG lLoginID = *(LLONG*)data;
EM_NET_UPGRADE_INSTALL_TYPE emType =
EM_UPGRADER_INSTALL_EXECUTE;
NET_IN_INSTALL_EXECUTE stuIn =
{sizeof(NET_IN_INSTALL_EXECUTE)};
memset(&stuIn, 0, sizeof(NET_IN_INSTALL_EXECUTE));
[Link] = sizeof(NET_IN_INSTALL_EXECUTE);
Use examples
NET_OUT_INSTALL_EXECUTE stuOut =
{sizeof(NET_OUT_INSTALL_EXECUTE)};
memset(&stuOut, 0, sizeof(NET_OUT_INSTALL_EXECUTE));
[Link] = sizeof(NET_OUT_INSTALL_EXECUTE);
[Link] = false;
BOOL bRet = CLIENT_UpgraderInstall(lLoginID,
emType,&stuIn,&stuOut,5000);
Note None

CLIENT_StopApp
Table 6-62 CLIENT_StopApp
Item Implication
Interface description Stop the program
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device

BOOL CLIENT_StopApp(LLONG lLoginID, const NET_IN_STOP_APP*


Function
pInParam, NET_OUT_STOP_APP* pOutParam, int nWaitTime);

[in] lLoginID The login handle


[in] pInParam Input parameters for the interface. Memory
resources are requested and released by the user
Parameter
[out] pOutParam Output parameters for the interface. Memory
resources are requested and released by the user
[in] nWaitTime Timeout period for the interface, in milliseconds
return TRUE: Success
Return value
FALSE: Failure

343
Item Implication
LLONG lLoginID = *(LLONG*)data;
NET_IN_STOP_APP stuIn = {sizeof(NET_IN_STOP_APP)};;
memset(&stuIn, 0, sizeof(NET_IN_STOP_APP));
[Link] = sizeof(NET_IN_STOP_APP);
NET_OUT_STOP_APP stuOut = {sizeof(NET_OUT_STOP_APP)};;
Use examples memset(&stuOut, 0, sizeof(NET_OUT_STOP_APP));
[Link] = sizeof(NET_OUT_STOP_APP);
[Link] = 3214;
strncpy([Link], "TestAppCheck", sizeof([Link])
- 1);
BOOL bRet = CLIENT_StopApp(lLoginID, &stuIn,&stuOut,5000);
Note None

CLIENT_RemoveApp
Table 6-63 CLIENT_RemoveApp
Item Implication
Interface description Uninstall the program
Already called CLIENT_LoginWithHighLevelSecurity to log in to the
Pre-condition
device
BOOL CLIENT_RemoveApp(LLONG lLoginID, const
Function NET_IN_REMOVE_APP* pInParam, NET_OUT_REMOVE_APP*
pOutParam, int nWaitTime);
[in] lLoginID The login handle
[in] pInParam Input parameters for the interface. Memory
resources are requested and released by the user
Parameter
[out] pOutParam Output parameters for the interface. Memory
resources are requested and released by the user
[in] nWaitTime Timeout period for the interface, in milliseconds
return TRUE: Success
Return value
FALSE: Failure
LLONG lLoginID = *(LLONG*)data;
NET_IN_REMOVE_APP stuIn = {sizeof(NET_IN_REMOVE_APP)};;
memset(&stuIn, 0, sizeof(NET_IN_REMOVE_APP));
[Link] = sizeof(NET_IN_REMOVE_APP);
NET_OUT_REMOVE_APP stuOut = {sizeof(NET_OUT_REMOVE_APP)};;
Use examples memset(&stuOut, 0, sizeof(NET_OUT_REMOVE_APP));
[Link] = sizeof(NET_OUT_REMOVE_APP);
[Link] = 3214;
strncpy([Link], "TestAppCheck", sizeof([Link])
- 1);
BOOL bRet = CLIENT_RemoveApp(lLoginID, &stuIn,&stuOut,5000);
Note None

344
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

345
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.

346
⚫ 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.
⚫ It is recommended that you enable your device's firewall or blocklsit and allowlist
feature to reduce the risk that your device might be attacked.

347

You might also like