DAHUA Camera NetSDK Programming Guide
DAHUA Camera NetSDK Programming Guide
V3.4.7
Preface
Purpose
SDK is the software development kit used by software developer when developing DVR(digital
video recorder), DVS(digital video server), IPC(IP camere), SD(speed dome), intelligent devices to
monitor network application.
This document has described functions, interfaces and calling relationship between functions
Target reader
Symbols
The symbols shown in the sheet below may appear in the document, their meanings are shown
below.
Symbol Instruction
Revise history
2016-01-15 Create
2016-08-16 Revise
Catalogue
PREFACE ................................................................................................................................2
CATALOGUE ...........................................................................................................................3
1 INTRODUCTION ........................................................................................................... 10
3/339
2.5 RECORD DOWNLOAD............................................................................................................................................ 59
4/339
2.11 I NTELLIGENT EVENT R EPORT AND SNAPSHOT.................................................................................................. 162
NET_DEVICEINFO....................................................................................................................................................... 189
NET_IN_STARTLOGINEX............................................................................................................................................ 190
5/339
CFG_PTZ_MOTION_RANGE ..................................................................................................................................... 207
CFG_PTZ_LIGHTING_CONTROL............................................................................................................................... 208
NET_SPEAK_PARAM.................................................................................................................................................. 213
NET_TALK_TRANSFER_PARAM................................................................................................................................ 214
CFG_VIDEO_COVER................................................................................................................................................... 231
CFG_RECT.................................................................................................................................................................... 233
SNAP_PARAMS........................................................................................................................................................... 237
DH_DSP_ENCODECAP............................................................................................................................................... 239
EM_LOGIN_SPAC_CAP_TYPE................................................................................................................................... 245
6/339
DH_R EAL PLAYTYPE ........................................................................................................................................................ 246
EM_SUPPORT_FOCUS_MODE................................................................................................................................. 250
DH_TALK_CODING_TYPE.......................................................................................................................................... 254
CFG_AUDIO_FORMAT............................................................................................................................................... 269
CLIENT_GETSDKVERSION............................................................................................................................................. 273
CLIENT_FINDFILE.......................................................................................................................................................... 286
7/339
CLIENT_PLAYBACKBYTIMEEX ........................................................................................................................................ 291
CLIENT_DOWNLOADBYTIMEEX..................................................................................................................................... 299
CLIENT_STOPDOWNLOAD............................................................................................................................................. 301
CLIENT_PLAYBACKBYRECORDFILEEX............................................................................................................................. 302
CLIENT_SLOWPLAYBACK............................................................................................................................................... 307
CLIENT_DOWNLOADBYRECORDFILEEX.......................................................................................................................... 309
CLIENT_RECORDSTARTEX.............................................................................................................................................. 322
CLIENT_RECORDSTOPEX............................................................................................................................................... 323
CLIENT_AUDIODECEX................................................................................................................................................... 325
8/339
CLIENT_REALLOADPICTUREEX ...................................................................................................................................... 331
9/339
1 Introduction
1.1Abstract
SDK is the software development kit used by software developer when developing DVR(digital
video recorder), DVS(digital video server), IPC(IP camere), SD(speed dome), intelligent devices to
monitor network application.
The kit mainly includes the following functions:
Device login, real-time monitoring, record playback and playback control, record download, PTZ
control, audio intercom, video snapshpot, alarm report, device search, intelligent event report and
picture snapshot, user management and some other functions (device restart, device upgrade, video
image parameter setup, channel name setup, device network parameter setup and etc.) .
Files in development kit are shown below:
10/339
mpeg4enc.dll Decoding aux library
1.2Applicability
Recommended memory: unused menory should not below 256M.
Windows
Linux
CentOS/Red Hat/SUSE and other general Linux OS. GCC version not below 4.1.2.
Record Playback and Playback Control storage device as DVR and NVR
PTZ Control SD
11/339
2 Major Functions
Initialization is the first step of SDK business. The module itself does not include surveillance
business, interfaces in this chapter will not make any interaction with Dahua device, but the module
is responsible for SDK initialization, and setting properties which influence business.
Warnings:
3. You need to call cleanup interface to release resources after using SDK completely.
12/339
2.1.3 SDK Initialization Instruction
Start
Initialization
CLIENT_Init
Optional
Clean up SDK resources
CLIENT_Cleanup
Mandatory
End
Process description:
1. Call CLIENT_Init to initialize SDK.
optional,suggest calling, Internal SDK auto connect again when the device disconnect.
4. Call CLIENT_SetConnectTime to set device connection timeout value and trial times
13/339
optional.
//************************************************************************** *******
// commonly used callback set declaration.
14/339
}
else
{
printf("Initialize client SDK done; \n");
}
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
// The first time logining to device, some data is needed to be initialized to enable normal
business function. It is recommended to wait for a while after login, the waiting time varies by
devices.
Sleep(1000);
printf("\n");
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
15/339
}
// task realizing operation
}
void EndTest()
{
printf("input any key to quit! \n");
getchar();
16/339
{
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");
}
2.2Device Login
2.2.1 Intro
Precondition
Overview
When SDK initialization is complete, user 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.
Login Method
It has three login methods according to function and use scene: sync login, async login and auto
registration login. Please refer to Ch 2.2.3.1, 2.2.3.2 and 2.2.3.3 to learn about them.
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
Among the three login methods, auto registration login dont support reconnection.
User can call SDK self-carried reconnection function, as well as can call login and logout
17/339
NOTE
1. The provided login operation is for Dahua devices only, not for other manufuature s devices.
Please use the login operation carefully, otherwise the device will not be able to login successfully.
2. Login and logout should be used as a pair. In case of resource leak, you must call logout
CLIENT_GetLastError Interface for getting error code after failed calling interface
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.
18/339
Start
SDK initialization
ClIENT_Ini()
NO
Successfully register user to device? Get the error code and
CLIENT_LoginEx2 analyze the failure reason
YES
Logout user
CLIENT_Logout
END
Process description:
1. SDK initialization.
5. Last but not the least, call CLIENT_Cleanup to release SDK resource.
19/339
#pragma comment(lib , " dhnetsdk.h ")
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD 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");
}
20/339
printf("NetSDK version is [%d]\n", dwNetSdkVersion);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
CLIENT_SetNetworkParam(&stuNetParm);
if (0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
//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("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
21/339
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time va ries
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
// business realization
}
void EndTest()
{
printf("input any key to quit! \n");
getchar();
// logout 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 resource
if (TRUE == g_bSDKInitFlag)
{
CLIENT_Cleanup();
g_bSDKInitFlag = FALSE;
}
return;
}
int main()
{
22/339
InitTest();
RunTest();
EndTest();
return 0;
}
//*********************************************************************************
// commonly used callback set definition
2.3.1 Intro
Real-time monitoring which is to get real time stream from storage device or front-end device is
After login to device, SDK can obtain main stream, aux stream and the third stream from device.
Support: Config front-end device bit stream resolution, encode, bit rate and etc.
Support: User conveys window handle, SDK analyzes stream and play directly.
Support: Callback real-time stream data to user, let user process by himself.
Support: Save real-time record to specific folder, user can save callback stream to achieve
23/339
Interface Interface Description
SDK only callback real-time monitoring data stream to user, user decodes and plays with a
third-party library.
SDK decoding and playing process flow sheet is shown below in Figure 2-3.
24/339
Start
SDK initialization
Login device
CLIENT_LoginEx2
Logout user
CLIENT_Logout
End
Process description:
1. SDK initialization
monitoring.
6. Last but not the least, call CLIENT_Cleanup to release SDK resources.
25/339
2.3.3.2 The third Party Decoding and Playing Process
The third party decoding and playing process is shown below in Figure 2-4.
Start
SDK initialization
Login device
CLIENT_LoginEx2
Logout user
CLIENT_Logout
End
Process description:
1. SDK initialization.
26/339
valid window handle.
5. Save real-time data in callback function for further use. It is not recommended to do any
work but data stored and data delivered, or the performance will be affected when there are too
monitoring.
8. Last but not the least, call CLIENT_Cleanup to release SDK resources.
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
27/339
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
28/339
NET_PARAM stuNetParm = {0};
if(0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
//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("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
// judge whether initialization is successful or not
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
//judge whether login device or not
29/339
if (0 == g_lLoginHandle)
{
return;
}
printf("user can input any key to quit during real play! \n");
Sleep(1000);
void EndTest()
{
printf("input any key to quit! \n");
getchar();
// Close preview
if (0 != g_lRealHandle)
{
if(FALSE == CLIENT_StopRealPlayEx(g_lRealHandle))
{
printf("CLIENT_StopRealPlayEx Failed!Last Error[%x]\n" ,
CLIENT_GetLastError());
}
else
{
g_lRealHandle = 0;
}
}
30/339
//Exit 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 functions 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");
}
31/339
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");
}
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
32/339
// callback function used after device is reconnected successfully
// Its not recommended to call SDK interfaces in this callback function
// Set the callback function in 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");
}
33/339
//This operation is optional
int nWaitTime = 5000; // timeout value is 5 seconds
int nTryTimes = 3; //If timeout,it will try to log in three times.
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
CLIENT_SetNetworkParam(&stuNetParm);
if (0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
//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("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
34/339
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
{
return;
}
void EndTest()
{
printf("input any key to quit! \n");
35/339
getchar();
//Close preview
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;
}
}
//Exit 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;
}
//*********************************************************************************
36/339
//commonly used callback functions 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");
}
37/339
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;
}
}
}
2.4Record Playback
2.4.1 Intro
Overview
Record playback is to playback record of certain channels during specific periods,in order to
Playback function includes several operations, such as play, pause, quick play,slow play,
According to the different decoding method selected by users, record playback have two
methods: SDK decoding playback and third-party decoding playback.please refer to Ch 2.4.3 for
details.
38/339
2.4.2 Interface Overview
According to the different decoding method selected by users, r ecord playback have the
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.
39/339
The third-party decoding and playing back
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 record. After SDK re ceives playback
stream data, the data is called back to user for saving by playback stream callback function. After
leaving callback function, user calls a third-party library to analyze and display the saved stream
data.
SDK Decoding and Playing back process flow sheet is shown below in Figure 2-5.
40/339
START
SDK initialization
Login to device
CLIENT_LoginEx2
Start playback
Parameter hWind is a valid window handle value
CLIENT_PlayBackByTimeEx
Stop playback
CLIENT_StopPlayBack
Logout user
CLIENT_Logout
END
Figure 2-5 SDK Decoding and Playing back process flow sheet
41/339
Process description:
1. SDK initialization.
handle value.
8. Last but not the least, call CLIENT_Cleanup to release SDK resource.
The third-party library decoding and playing back flow sheet is shown in Figure 2-6.
42/339
START
SDK initialization
Login to device
CLIENT_LoginEx2
Start playback
Parameter hWind is set to NULL Callback function
Parameter fDownLoadDataCallBack is valid pointer pointing to callback function fDataCallBack
CLIENT_PlayBackByTimeEx
Stop playback
CLIENT_StopPlayBack
Logout user
CLIENT_Logout
END
Figure 2-6 The third-party library decoding and playing back flow sheet
43/339
Process description:
1. SDK initialization.
5. 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.
9. Last but not the least, call CLIENT_Cleanup to release SDK resource.
44/339
static char g_szPasswd[64] = "admin";
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
45/339
//This operation is optional.
int nWaitTime = 5000; // timeout value is 5 seconds
int nTryTimes = 3; //if timeout,it will try to log in three times.
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
if(0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
//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("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
46/339
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
{
return;
}
47/339
}
48/339
/* example code
int nOffsetSeconds = 2 * 60 * 60; // drag to 2*60*60s after stuStartTime to start play
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;
}
}
// logout 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;
}
}
// cleanup initialization resource
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
49/339
g_bNetSDKInitFlag = FALSE;
}
return;
}
int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}
//*********************************************************************************
// commonly used callback set definition
50/339
2.4.4.2 The Third-party Decoding and Playing Back
#include <windows.h>
#include <stdio.h>
#include "dhnetsdk.h"
#pragma comment(lib , "dhnetsdk.lib")
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
51/339
// when parameter hWnd ist NULL, it will be treated as callback successful no matter what the
return value is, and next time callback will return follow-up data
// set this callback function in CLIENT_PlayBackByTimeEx. when playback data is received,
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");
}
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
52/339
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
if(0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
//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("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be in itialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
{
return;
53/339
}
54/339
if (FALSE == CLIENT_SlowPlayBack (g_lPlayHandle))
{
printf("CLIENT_SlowPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" ,
g_lPlayHandle, CLIENT_GetLastError());
}
//the third-party interface call
*/
*/
*/
*/
55/339
/* example code
int nOffsetSeconds = 2 * 60 * 60; // drag to 2*60*60s after stuStartTime to start play
if (FALSE == CLIENT_SeekPlayBack (g_lPlayHandle, nOffsetSeconds, 0))
{
printf("CLIENT_SeekPlayBack Failed, g_lPlayHandle[%x]!Last Error[%x]\n" ,
g_lPlayHandle, CLIENT_GetLastError());
}
//the third-party interface call
*/
}
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;
}
}
// logout 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;
}
}
// cleanup initialization resource
if (TRUE == g_bNetSDKInitFlag)
56/339
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}
int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}
//*********************************************************************************
// commonly used callback set definition
57/339
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
58/339
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;
}
2.5Record Download
2.5.1 Intro
Video monitoring system is widely used in safe city, airport, subway, bank, factory and etc.
When something happened, its needed to download records to leaderspolice and media as
evidence for further use. Therefore, record download is a commonly used application module.
Record download process is that users get the records from storage device and save them to
local. It allows user to download records in currently selected channel, and export the records to
59/339
Record Download Methods
Record download have two methods: download by file and download by time, please refer to Ch
2.5.3.
Download by file
Users need to point the downloaded record files 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 callback
60/339
function.
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 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
61/339
START
SDK initialization
ClIENT_Ini()
Login to device
CLIENT_LoginEx2
Download by file
CLIENT_DownByRecordFileEx
Stop download
CLIENT_StopDownload
Logout user
CLIENT_Logout optional
mandatory
Release SDK resource
CLIENT_Cleanup
END
62/339
Process description:
1. SDK initialization.
devices will not return a result. If you only need main stream record, you can filter out sub stream
4. You can search record file with the following two methods
Call CLIENT_FindFile to get record search handle, and then call CLIENT_FindNextFile to
progressively get record file info in cycle, finally call CLIENT_FindClose to close record search
handle.
5. After you get record file info, call CLIENT_DownloadByRecordFileEx to download record
file. At least one of the input parameters sSavedFileName and fDownLoadDataCallBack is valid.
as needed.
9. Last but not the least, call CLIENT_Cleanup to release SDK resource.
63/339
START
SDK initialization
CLIENT_init
Login to device
CLIENT_LoginEx2
Download by time
CLIENT_DownloadByTimeEx
Stop download
CLIENT_StopDownload
Logout user
CLIENT_Logout
END
Process description
1. SDK initialization
note.
64/339
4. Call CLIENT_DownloadByTimeEx to start to download by time. At least one input
7. Last but not the least, call CLIENT_Cleanup to release SDK resource.
65/339
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");
}
66/339
// set CLIENT_SetAutoReconnect interface.Once HaveReConnect is set, when device
gets offline, SDK will reconnect internally.
// this operation is optional, but recommended
CLIENT_SetAutoReconnect(&HaveReConnect, 0);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
if (0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
// example
// #define NET_NOT_SUPPORTED_EC(23)
// current SDK does not support the function, corresponding error code is
0x80000017. Decimal number 23 is hexadecimal 0x17.
printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
67/339
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
{
return;
}
// record file search
// set record stream type
int nStreamType = 0; // 0-main stream/sub stream,1-main stream,2-sub stream
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_STREAM_TYPE,
&nStreamType);
// there are two methods to search files: 1.take all record files in the specified time period
once2take all records in the specified time period in several times.
// here is the second method, the first method can refer to CLIENT_QueryRecordFile
interface
int nChannelID = 0; // channel no.
NET_TIME stuStartTime = {0};
stuStartTime.dwYear = 2015;
stuStartTime.dwMonth = 9;
stuStartTime.dwDay = 20;
68/339
}
// demo
std::vector<NET_RECORDFILE_INFO> bufFileInfo(g_nMaxRecordFileCount);
//stop search
if(0 != lFindHandle)
{
CLIENT_FindClose(lFindHandle);
}
// set the first file queried as download file
NET_RECORDFILE_INFO stuNetFileInfo;
if (nFileIndex > 0)
{
memcpy(&stuNetFileInfo, (void *)&bufFileInfo[0], sizeof(stuNetFileInfo));
}
else
{
printf("no record, return\n");
return;
}
69/339
{
printf("CLIENT_DownloadByRecordFileEx: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
}
void EndTest()
{
printf("input any key to quit! \n");
getchar();
// stop download,we 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;
}
}
// logout 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;
}
}
// cleanup initialization resource
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
70/339
}
int main()
{
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");
}
71/339
// If different playback/download uses the same process callback function, we can judge by
parameter 1PlayHandle
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");
}
}
break;
case 1:
//Standard video data
break;
case 2:
//yuv data
72/339
break;
case 3:
//pcm audio data
break;
case 4:
//Original audio data
break;
default:
break;
}
}
return nRet;
}
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
73/339
// Set the callback function in 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");
}
74/339
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
if (0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
// example
// #define NET_NOT_SUPPORTED_EC(23)
// current SDK does not support the function, corresponding error code is
0x80000017. Decimal number 23 is hexadecimal 0x17.
printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
75/339
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
{
return;
}
// record file search
// set record stream type
int nStreamType = 0; // 0-main/sub stream,1-main stream,2-sub stream
CLIENT_SetDeviceMode(g_lLoginHandle, DH_RECORD_STREAM_TYPE,
&nStreamType);
76/339
NULL, DataCallBack, NULL);
if (g_lDownloadHandle == 0)
{
printf("CLIENT_DownloadByTimeEx: failed! Error code: %x.\n",
CLIENT_GetLastError());
}
}
void EndTest()
{
printf("input any key to quit! \n");
getchar();
// stop download,we can call this interface after download end 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;
}
}
// logout 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;
}
}
// cleanup initialization resource
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
77/339
return;
}
int main()
{
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");
}
78/339
DWORD dwDownLoadSize, int index, NET_RECORDFILE_INFO recordfileinfo, LDWORD
dwUser)
{
// If different playback/download uses the same process callback function, we can judge by
parameter 1PlayHandle
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");
}
}
break;
case 1:
//Standard video data
break;
79/339
case 2:
//yuv data
break;
case 3:
//pcm audio data
break;
case 4:
//Original audio data
break;
default:
break;
}
}
return nRet;
}
2.6PTZ Control
2.6.1 Intro
PTZ is a mechanical platform which carries camera device and protective cover can remote
monitor and control in all directions. PTZ 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 system. Users have different demands for
suiveillance in different application scene. For example, users may want to track the surveillance
screen in a normal application scene. Users can control PTZ device via SDK, such as move
80/339
Interface Interface Description
CLIENT_GetLastError Interface for getting error code after failed calling interface
81/339
START
SDK initialization
CLIENT_init
Login to device
CLIENT_LoginEx2
Logout user
ClIENT_Logout
END
Process description
1. SDK initialization
82/339
CFG_CAP_CMD_PTZ to analyze the obtained capacity set.
Different PTZ command requires may have different parameters. For example some
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
83/339
// callback function used after device is reconnected successfully
// Its not recommended to call SDK interfaces in this callback function
// Set the callback function in 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");
}
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
84/339
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
if (0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhSDK.h. It is
to print hexadecimal here, not decimal showns in header file, please be careful with conversion
// example
// #define NET_NOT_SUPPORTED_EC(23)
// current SDK does not support the function, corresponding error code is 0x80000017.
Decimal number 23 is hexadecimal 0x17.
printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, t he waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
85/339
operation
}PtzControlInfo;
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
{
return;
}
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;
}
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 == stuPtzCapsInfo.bTile)
86/339
{
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_UP_CONTROL), "up", true));
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_DOWN_CONTROL), "down",
true));
}
if (TRUE == stuPtzCapsInfo.bPan)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_LEFT_CONTROL), "left",
true));
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_RIGHT_CONTROL), "right",
true));
}
if (TRUE == stuPtzCapsInfo.bZoom)
{
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 == stuPtzCapsInfo.bFocus)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_FOCUS_ADD_CONTROL),
"focus +", true));
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_FOCUS_DEC_CONTROL),
"focus -", true));
}
if (TRUE == stuPtzCapsInfo.bIris)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_APERTURE_ADD_CONTROL), "aperture
+", true));
if (TRUE == stuPtzCapsInfo.bPreset)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_MOVE_CONTROL),
87/339
"go to preset point", false));
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_SET_CONTROL), "set
preset point", false));
}
if (TRUE == stuPtzCapsInfo.bRemovePreset)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_DEL_CONTROL),
"delete preset point", false));
}
if (TRUE == stuPtzCapsInfo.bTour)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_LOOP_CONTROL),
"point-to-point tour", false));
vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_ADDTOLOOP), "add
preset point to tour", false));
vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_DELFROMLOOP), "delete
preset point in tour", false));
}
if (TRUE == stuPtzCapsInfo.bRemoveTour)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_CLOSELOOP), "clear
tour", false));
}
if (TRUE == stuPtzCapsInfo.bMoveRelatively)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_FASTGOTO), "quick
position", false));
88/339
}
if (TRUE == stuPtzCapsInfo.bMoveAbsolutely)
{
vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_EXACTGOTO), "3D
position precisely ", false));
}
if (iterFind == vecPtzControl.end())
{
printf("pleas input valid operation\n");
continue;
}
// stop the last opetation
int nChannelId = 0;
89/339
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;
}
if (iterFind->m_sDescription == "exit")
{
break;
}
// different PTZ commands correspond to different extra parameter setup plans .
Parameter 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 speedvalid 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)
{
90/339
// lParam2 means preset point NO.
printf("\t preset point NO.(%2d-%2d):",
stuPtzCapsInfo.wPresetMin,stuPtzCapsInfo.wPresetMax);
scanf("%d", &lParam2);
}
else if (DH_PTZ_POINT_LOOP_CONTROL == iterFind->m_iCmd)
{
// lParam1 means tour path, lParam376 start96 stop
printf("\t tour path(%2d-%2d):",
stuPtzCapsInfo.wTourMin,stuPtzCapsInfo.wTourMax);
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 means switch control
printf("\t1:enable\n\t0:disable\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 means tour path
printf("\t tour path (%2d-%2d):",
stuPtzCapsInfo.wTourMin,stuPtzCapsInfo.wTourMax);
91/339
scanf("%d", &lParam1);
// lParam2 means preset point NO.
printf("\t preset point NO. (%2d-%2d):",
stuPtzCapsInfo.wPresetMin,stuPtzCapsInfo.wPresetMax);
scanf("%d", &lParam2);
}
else if (DH_EXTPTZ_CLOSELOOP == iterFind->m_iCmd)
{
// lParam1 means tour path
printf("\t tour path(%2d-%2d):",
stuPtzCapsInfo.wTourMin,stuPtzCapsInfo.wTourMax);
scanf("%d", &lParam1);
}
else if (DH_EXTPTZ_FASTGOTO == iterFind->m_iCmd)
{
// horizontal coordinatevalid 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*stuPtzCapsInfo.stuPtzMotionRange.nHorizontalAngleMin,
10*stuPtzCapsInfo.stuPtzMotionRange.nHorizontalAngleMax);
scanf("%d", &lParam1);
// vertical coordinate, valid range, accuracy is 10x of capacity set acquisition
range
printf("\t vertical coordinate (%2d-%2d):",
10*stuPtzCapsInfo.stuPtzMotionRange.nVerticalAngleMin,
10*stuPtzCapsInfo.stuPtzMotionRange.nVerticalAngleMax);
scanf("%d", &lParam2);
// zoomvalid range 1 ~ 128
lParam3 = 2;
}
92/339
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();
// logout 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;
}
}
// cleanup initialization resource
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}
int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}
93/339
//*********************************************************************************
// 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");
}
94/339
else
{
nError = 0;
}
return nGet;
}
2.7Audio intercom
2.7.1 Intro
Audio intercom is mainly used for audio interacting between local platform and front -end device
located environment.
The chapter mainly tells users how to use SDK to audio intercoming with front-end device.
Audio intercom has two modes: client mode and server mode, please refer to Ch 2.7.3 for
details.
95/339
Interface Interface Description
CLIENT_GetLastError Interface for getting error code after failed calling interface
Client mode
SDK allows user to provide a callback function. The callback function is called when SDK
collects audio data from local sound card or receives data from the front-end. In callback function
user can not only send collected local audio data to front-end device but decode and play the
received front-end audio data. This mode is valid in Windows platform only.
Server mode
SDK allows user to provide one callback function. The callback function is called when SDK
receives audio data from front-end device. In 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 to
decode and play audio data and etc. For local audio data, user can collect it by calling a third-party
96/339
Start
SDK initialization
Login device
CLIENT_LoginEx2
Logout user
CLIENT_Logout
End
97/339
Process description:
1. SDK initialization
emType is DH_TALK_CLIENT_MODE.
emType is DH_TALK_ENCODE_TYPE.
DH_TALK_SPEAK_PARAM.
means audio intercom between local PC and logined device; and transfer mode means audio
intercom between local PC and front-end device connected with specific channel of the logined
device.
7. Call CLIENT_StartTalkEx to set callback function and start audio intercom.In callback
function, call CLIENT_AudioDec to decode audio data sent by device and call
8. Call CLIENT_RecordStartEx to start PC recording. Only after this interface is called, can
audio intercom callback function set by CLIENT_StartTalkEx will receive local audio data.
12. Last but not the least, call CLIENT_Cleanup to release SDK resources.
98/339
Start
SDK initialization
Login device
CLIENT_LoginEx2
Logout user
CLIENT_Logout
End
1. SDK initialization
99/339
3. Call CLIENT_SetDeviceMode to set server mode as audio intercom mode, Parameter
emType is DH_TALK_SERVER_MODE.
emType is DH_TALK_ENCODE_TYPE.
DH_TALK_SPEAK_PARAM.
means audio intercom between local PC and logined device; and transfer mode means audio
intercom between local PC and front-end device connected with specific channel of the logined
device.
7. Call CLIENT_StartTalkEx to set callback function and start audio intercom. In callback
function, the audio data sent by device can be dealt with by users with the methods as transfer or
8. At first user encodes original audio data to be the same type with intercom encode typ e,
then adds 8 corresponding private protocol bytes in front of encoded data, and finally calls
11. Last but not the least, call CLIENT_Cleanup to release SDK resources.
#include "dhnetsdk.h"
100/339
static BOOL g_bNetSDKInitFlag = FALSE;
//*********************************************************************************
//*********************************************************************************
void InitTest()
101/339
{
// SDK Initialization
if (FALSE == g_bNetSDKInitFlag)
return;
else
}
//Get the SDK version info
// This operation is optional.
CLIENT_SetAutoReconnect(&HaveReConnect, 0);
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
102/339
NET_DEVICEINFO_Ex stDevInfoEx = {0};
int nError = 0;
while(0 == g_lLoginHandle)
//Login device
if(0 == g_lLoginHandle)
else
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
void RunTest()
103/339
if (FALSE == g_bNetSDKInitFlag)
return;
if (0 == g_lLoginHandle)
return;
if (FALSE == bSuccess)
return;
DHDEV_TALKFORMAT_LIST stulstTalkEncode;
int retlen = 0;
return;
104/339
//Set audio intercom encode info.
DHDEV_TALKDECODE_INFO curTalkMode;
//Select the first encode method in the list, user can select other encode method as
needed.
curTalkMode = stulstTalkEncode.type[0];
if (FALSE == bSuccess)
return;
if (FALSE == bSuccess)
return;
stuTransfer.bTransfer = FALSE; //Close transfer mode because its intercom with login
device.
105/339
&stuTransfer);
if (FALSE == bSuccess)
return;
if(0 != g_lTalkHandle)
//Start local recording.Its no need to call this interface if it is one-way audio intercom
between DVR and PC.
if(TRUE == bSuccess)
g_bRecordFlag = TRUE;
else
if (FALSE == CLIENT_StopTalkEx(g_lTalkHandle))
else
g_lTalkHandle = 0;
106/339
else
void EndTest()
getchar();
if (TRUE == g_bRecordFlag)
{
if (!CLIENT_RecordStopEx(g_lLoginHandle))
else
g_bRecordFlag = FALSE;
if (0 != g_lTalkHandle)
if(FALSE == CLIENT_StopTalkEx(g_lTalkHandle))
else
107/339
g_lTalkHandle = 0;
//Exit device
if (0 != g_lLoginHandle)
if(FALSE == CLIENT_Logout(g_lLoginHandle))
else
{
g_lLoginHandle = 0;
if (TRUE == g_bNetSDKInitFlag)
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
return;
int main()
InitTest();
RunTest();
EndTest();
return 0;
108/339
}
//*********************************************************************************
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");
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");
109/339
void CALLBACK AudioDataCallBack(LLONG lTalkHandle, char *pDataBuf, DWORD
dwBufSize, BYTE byAudioFlag, DWORD dwUser)
//If different audio intercoms use the same data callback function, user can judge by
parameter 1TalkHandle.
if (g_lTalkHandle != lTalkHandle)
return;
if(0 == byAudioFlag)
//Send received sound card data which is detected by local PC to device. This
interface must follow the interface CLIENT_RecordStartEx.
if(lSendLen != (LONG)dwBufSize)
//Send received audio data sent by device to SDK for decoding and playing.
CLIENT_AudioDec(pDataBuf, dwBufSize);
#ifdef _DEBUG
FILE *stream;
fclose( stream );
110/339
}
#endif
#include "dhplay.h"
#include "Alaw_encoder.h"
#include "dhnetsdk.h"
//*********************************************************************************
111/339
// callback function used after device is reconnected successfully
// Its not recommended to call SDK interfaces in this callback function
// Set the callback function in CLIENT_SetAutoReconnect, when offline device is reconnected
successfully, SDK will call the function
void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort,
LDWORD dwUser);
//*********************************************************************************
// function declaration
BOOL StartAudioRecord();
BOOL StopAudioRecord();
//*********************************************************************************
void InitTest()
// SDK Initialization
if (FALSE == g_bNetSDKInitFlag)
112/339
{
return;
else
CLIENT_SetAutoReconnect(&HaveReConnect, 0);
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
int nError = 0;
while(0 == g_lLoginHandle)
113/339
{
//Login device
if(0 == g_lLoginHandle)
else
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
void RunTest()
if (FALSE == g_bNetSDKInitFlag)
return;
114/339
if (0 == g_lLoginHandle)
return;
if (FALSE == bSuccess)
return;
DHDEV_TALKFORMAT_LIST stulstTalkEncode;
int retlen = 0;
return;
g_curTalkMode = stulstTalkEncode.type[0];
if (FALSE == bSuccess)
115/339
{
return;
if (FALSE == bSuccess)
return;
stuTransfer.bTransfer = FALSE; //Close transfer mode because its intercom with login
device.
if (FALSE == bSuccess)
return;
116/339
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
void EndTest()
getchar();
if(TRUE == g_bOpenAudioRecord)
if (TRUE == StopAudioRecord())
117/339
g_bOpenAudioRecord = FALSE;
if (0 != g_lTalkHandle)
if(FALSE == CLIENT_StopTalkEx(g_lTalkHandle))
else
{
g_lTalkHandle = 0;
//Logout device
if (0 != g_lLoginHandle)
if(FALSE == CLIENT_Logout(g_lLoginHandle))
else
g_lLoginHandle = 0;
if (TRUE == g_bNetSDKInitFlag)
118/339
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
return;
int main()
InitTest();
RunTest();
EndTest();
return 0;
//*********************************************************************************
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");
119/339
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");
//If different audio intercoms use the same data callback function, user can judge by
parameter 1TalkHandle.
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
120/339
int nPort = 99;
if (g_curTalkMode.encodeType == DH_TALK_DEFAULT)
nPort = 100;
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(nPort,(BYTE *)pDataBuf,dwBufSize);
#ifdef _DEBUG
FILE *stream;
fclose( stream );
#endif
if (NULL == pCbData)
121/339
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 PCMg711a and g711u
encoding.
if (g_curTalkMode.nAudioBit == 8)
*(pDataBuffer + j) += 128;
pCbData[0]=0x00;
pCbData[1]=0x00;
pCbData[2]=0x01;
pCbData[3]=0xF0;
pCbData[4]=g_curTalkMode.nAudioBit==8?0x07:0x0C;
pCbData[5]=0x02;//8k
pCbData[5] = 0x04;
122/339
else if(48000 == g_curTalkMode.dwSampleRate)
pCbData[5] = 0x09;
*(DWORD*)(pCbData+6)=DataLength;
iCbLen = 8+DataLength;
{
//Encode the original audio data to g711a.
goto end;
pCbData[0]=0x00;
pCbData[1]=0x00;
pCbData[2]=0x01;
pCbData[3]=0xF0;
pCbData[4]=0x0E; //G711A
pCbData[5]=0x02;//8k
123/339
{
pCbData[5] = 0x04;
pCbData[5] = 0x09;
pCbData[6]=BYTE(iCbLen&0xff);
pCbData[7]=BYTE(iCbLen>>8);
iCbLen += 8;
}
goto end;
pCbData[0]=0x00;
pCbData[1]=0x00;
pCbData[2]=0x01;
pCbData[3]=0xF0;
pCbData[4]=0x0A; //G711u
pCbData[5]=0x02; //8k
124/339
}
pCbData[5] = 0x04;
pCbData[5] = 0x09;
pCbData[6]=BYTE(iCbLen&0xff);
pCbData[7]=BYTE(iCbLen>>8);
iCbLen += 8;
else
goto end;
end:
if (pCbData != NULL)
delete[] pCbData;
//*********************************************************************************
125/339
BOOL StartAudioRecord()
//First confirm decode port.DH_TALK_DEFAULT is 100 port number and then rest is 99
port number.
if (g_curTalkMode.encodeType == DH_TALK_DEFAULT)
nPort = 100;
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;
126/339
case DH_TALK_AAC:
nFrameLength = 1024;
default:
break;
if(bOpenRet)
if(bPlayRet)
PLAY_PlaySoundShare(nPort);
BOOL bSuccess =
PLAY_OpenAudioRecord(AudioCallFunction,g_curTalkMode.nAudioBi
t,
g_curTalkMode.dwSampleRate,nFrameLength,0,NULL);
if(bSuccess)
bRet = TRUE;
else
127/339
PLAY_StopSoundShare(nPort);
PLAY_Stop(nPort);
PLAY_CloseStream(nPort);
else
PLAY_CloseStream(nPort);
return bRet;
}
BOOL StopAudioRecord()
if(TRUE == bSuccess)
PLAY_Stop(100);
PLAY_Stop(99);
PLAY_StopSoundShare(100);
PLAY_StopSoundShare(99);
PLAY_CloseStream(100);
PLAY_CloseStream(99);
else
128/339
return bSuccess;
2.8Snapshot
2.8.1 Intro
Video snapshot,as to snapshot picture not only from video,but also from device, used by upper
Snapshot picture from device: User 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 user,user can configure interface by SDK to set some parameters, such as picture
CLIENT_GetLastError Interface for getting error code after failed calling interface.
129/339
Start
SDK initialization
Login device
CLIENT_LoginEx2
Logout user
CLIENT_Logout
End
Process discription
1. SDK initialization.
snapshot data sent from device,it will call fSnapRev callback function to recall picture informatio n
6. Last but not the least, call CLIENT_Cleanup to release SDK resources.
130/339
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include "dhnetsdk.h"
#include "dhconfigsdk.h"
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Init,when device gets offline,SDK will call this function
automatically
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
//*********************************************************************************
// commonly used function set declaration
131/339
//Get int input
int GetIntInput(char *szPromt, int& nError);
//*********************************************************************************
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");
}
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
132/339
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
if(0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal shows in header file, please be careful with conversion
//Example: #define NET_NOT_SUPPORTED_EC(23)
//Current SDK does not support this function, error code is 0x80000017, Decimal
number 23 is hexadecimal 0x17.
printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
133/339
if (0 == g_lLoginHandle)
{
return;
}
SNAP_PARAMS stuSnapParams;
stuSnapParams.Channel = nChannelId;
stuSnapParams.mode = nSnapType;
stuSnapParams.CmdSerial = ++g_nCmdSerial; //request SN, valid range
0~65535,over this range will be cut to unsigned short
if (FALSE == CLIENT_SnapPictureEx(g_lLoginHandle, &stuSnapParams))
{
printf("CLIENT_SnapPictureEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());
return;
}
else
{
printf("CLIENT_SnapPictureEx succ\n");
}
return;
}
void EndTest()
{
printf("input any key to quit! \n");
getchar();
//Logout device
if (0 != g_lLoginHandle)
134/339
{
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()
{
InitTest();
RunTest();
EndTest();
return 0;
}
//*********************************************************************************
// commonly used callback set declaration
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);
135/339
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
void CALLBACK SnapRev(LLONG lLoginID, BYTE *pBuf, UINT RevLen, UINT EncodeType,
DWORD CmdSerial, LDWORD dwUser)
{
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_%s.jpg", CmdSerial,
szTmpTime);
FILE* pFile = fopen(szPicturePath, "wb");
if (NULL == pFile)
{
return;
}
int nWrite = 0;
while(nWrite != RevLen)
{
136/339
nWrite += fwrite(pBuf + nWrite, 1, RevLen - nWrite, pFile);
}
fclose(pFile);
}
}
}
//*********************************************************************************
// commonly used function set declaration
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)
{
//input parameter error
nError = -1;
}
else
{
nError = 0;
}
return nGet;
}
137/339
2.9Report Alarm
2.9.1 Intro
Report alarm, when front-end device detects special event set previously, send alarm to
platform-end and notify the platform. The platform may receive external alarmvideo signal lost
The method of alarm report is that SDK actively connects device and subscribes alarm function
from device. When device detects alarm event, it will immediately send the event to SDK.
138/339
START
SDK initialization
CLIENT_init
Login to device
CLIENT_LoginEx2
Logout user
CLIENT_Logout
END
Process discription
1. SDK initialization
alarm event reported by device is sent to user via callback function set in
CLIENT_SetDVRMessCallBack.
5. After alarm report function is finished, call CLIENT_StopListen to stop device alarm
139/339
subscription.
7. Last but not the least, call CLIENT_Cleanup to release SDK resources.
#include<windows.h>
#include <stdio.h>
#include "dhnetsdk.h"
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
140/339
// Its not recommended to call SDK interfaces in this callback function
// set this callback function in CLIENT_SetDVRMessCallBack. When receiving alarm event
reported by deviceSDK will call this function
BOOL CALLBACK MessCallBack(LONG lCommand, LLONG lLoginID, char *pBuf, DWORD
dwBufLen, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser);
141/339
CLIENT_SetNetworkParam(&stuNetParm);
if (0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhnetsdk.h.
It is to print hexadecimal here, not decimal showns in header file, please be careful with conversion
// example
// #define NET_NOT_SUPPORTED_EC(23)
// current SDK does not support the function, corresponding error code is
0x80000017. Decimal number 23 is hexadecimal 0x17.
printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
142/339
{
return;
}
// set alarm event callback function
CLIENT_SetDVRMessCallBack(MessCallBack , NULL);
void EndTest()
{
printf("input any key to quit! \n");
getchar();
// stop subscribing alarm from device
if (TRUE == g_bStartListenFlag)
{
if (FALSE == CLIENT_StopListen(g_lLoginHandle))
{
printf("CLIENT_StopListen Failed!Last Error[%x]\n", CLIENT_GetLastError());
}
else
{
g_bStartListenFlag = FALSE;
}
}
143/339
// logout 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;
}
}
// cleanup initialization resource
if (TRUE == g_bNetSDKInitFlag)
{
CLIENT_Cleanup();
g_bNetSDKInitFlag = FALSE;
}
return;
}
int main()
{
InitTest();
RunTest();
EndTest();
return 0;
}
//*********************************************************************************
// commonly used callback definition set
void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser)
{
144/339
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");
}
// 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)
{
145/339
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));
}
}
}
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);
146/339
}
}
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 NO. = [%s]\n" , pInfo->szCardNo);
}
}
break;
default:
printf("\n[MessCallBack] other alarm Get lCommand = 0x%x\n" , lCommand);
break;
}
return TRUE;
}
2.10.1 Intro
Device search is mainly used to help user to get device info from network. Device search can
work with login function. Device search interface can find relevant devices and login interface can
147/339
login these devices.
Device search is classified into the following two types by whether crossing segment or not
Interface for async searching for IPC, NVS and etc. within
CLIENT_StartSearchDevices
same segment
Interface for stopping async search for IPC, NVS and etc.
CLIENT_StopSearchDevices
within same segment
CLIENT_GetLastError Interface for getting error code after failed calling interface
Async search for device within the same segment is shown in Figure 2-14.
148/339
START
SDK initialization
Async search devices within User obtains and saves relevant device info
the same segment for further use via async search device
CLIENT_StartSearchDevice callback fSearchDeviceCB
END
Figure 2-14 Async search for devices within the same segment
Process discription
1. SDK initialization
2. Call CLIENT_StartSearchDevices to async search for devices within the same segment.
User gets the obtained device info via callback function fSearchDevicesCB which is set in this
interface. The search operation has no timeout time, user needs to stop searching by calling
interface CLIENT_StopSearchDevices.
segment.
4. When SDK function use is done, call CLIENT_Cleanup to release SDK resourc e.
149/339
START
SDK initialization
Sync search cross-segment User obtains and saves relevant device info
device for further use via sync search device
CLIENT_SearchDevicesByIPS callback fSearchDeviceCB
END
Process description
1. SDK initialization.
2. Call CLIENT_SearchDevicesByIPs to sync search for device crossing segment. User gets
the obtained device info via callback function fSearchDevicesCB which is set in this interface. Only
when searching time is out or searching all the devices cross the segment , the interface return.
150/339
static BOOL g_bNetSDKInitFlag = FALSE;
static LLONG g_lSearchHandle = 0L;
static CRITICAL_SECTION g_mDeviceListLock; // device list operation lock
static std::list<DEVICE_NET_INFO_EX> g_lDeviceList; // device list
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
//*********************************************************************************
void InitTest()
{
// initialization thread lock
InitializeCriticalSection(&g_mDeviceListLock);
// initialization SDK
g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0);
if (FALSE == g_bNetSDKInitFlag)
151/339
{
printf("Initialize client SDK fail; \n");
return;
}
else
{
printf("Initialize client SDK done; \n");
}
// get SDK version info
// this operation is optional
DWORD dwNetSdkVersion = CLIENT_GetSDKVersion();
printf("NetSDK version is [%d]\n", dwNetSdkVersion);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
152/339
// start async search for same-segment device
g_lSearchHandle = CLIENT_StartSearchDevices(SearchDevicesCB, &g_lDeviceList);
if (NULL == g_lSearchHandle)
{
printf("CLIENT_StartSearchDevices Failed!Last Error[%x]\n",
CLIENT_GetLastError());
return;
}
int nIndex = 0;
int nSearchTime = 0;
int nSearchLimit = 10;// search lasts for 10s, user can modify this value according to
network condition
while (TRUE)
{
if (nSearchLimit == nSearchTime++)
{
break;
}
EnterCriticalSection(&g_mDeviceListLock);
for (std::list<DEVICE_NET_INFO_EX>::iterator iter = g_lDeviceList.begin(); iter !=
g_lDeviceList.end();)
{
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_lDeviceList.erase(iter);
iter = g_lDeviceList.begin();
}
LeaveCriticalSection(&g_mDeviceListLock);
Sleep(1000);
}
153/339
}
void EndTest()
{
printf("input any key to quit! \n");
getchar();
// cleanup thread lock resource
DeleteCriticalSection(&g_mDeviceListLock);
int main()
{
InitTest();
RunTest();
EndTest();
154/339
return 0;
}
155/339
printf("warming param is null\n");
return;
}
std::list<DEVICE_NET_INFO_EX>* pDeviceList =
(std::list<DEVICE_NET_INFO_EX>*)pUserData;
EnterCriticalSection(&g_mDeviceListLock);
pDeviceList->push_back(*pDevNetInfo);
LeaveCriticalSection(&g_mDeviceListLock);
return;
}
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD dwUser);
156/339
// Its not recommended to call SDK interfaces in this callback function
// Set the callback function in 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");
}
157/339
int nTryTimes = 3; // if timeout, you have 3 attempts
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
// start sync search for cross-segment device
char szLocalIp[64] = "";
strncpy(szLocalIp, GetLocalIpAddress().c_str(), sizeof(szLocalIp) - 1);
158/339
CLIENT_GetLastError());
return;
}
int nIndex = 0;
for (std::list<DEVICE_NET_INFO_EX>::iterator iter = g_lDeviceList.begin(); iter !=
g_lDeviceList.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);
}
}
void EndTest()
{
printf("input any key to quit! \n");
getchar();
int main()
{
InitTest();
RunTest();
159/339
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");
}
160/339
void CALLBACK SearchDevicesCB(DEVICE_NET_INFO_EX *pDevNetInfo, void* pUserData)
{
if ((NULL == pDevNetInfo) || (NULL == pUserData))
{
printf("warming param is null\n");
return;
}
std::list<DEVICE_NET_INFO_EX>* pDeviceList =
(std::list<DEVICE_NET_INFO_EX>*)pUserData;
pDeviceList->push_back(*pDevNetInfo);
return;
}
in_addr addr;
memcpy(&addr, ph->h_addr_list[0], sizeof(in_addr));
std::string localIP(inet_ntoa(addr));
161/339
WSACleanup();
return localIP;
}
2.11.1 Intro
Intelligent event report is that devices judge whether to report events and to send pictures to
users or not according to real-time stream intelligent analyzation and intelligent event tr igger rules
configured by users. Intelligent events are: 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 etc.
Intelligent snapshot event: user manually sends a command to device after subscribing event
successfully. Device snapshots pictute of current scene and reports it to user via intelligent event.
CLIENT_GetLastError Interface for getting error code after failed calling interface
Intelligent event report and snapshot process flow sheet is shown in Figure 2-16.
162/339
START
SDK initialization
Device login
CLIENT_LoginEx2
Logout user
CLIENT_Logout
END
Process discription
1. SDK initialization
successful subscription, the intelligent snapshot alarm event reported by device will be sent to user
character to corresponding struct according to the instruction in SDK header files, and then displays
163/339
and saves event as needed. Due to SDK receving buffer is 2M by default, when callback picture info
exceed 2M,user need to call CLIENT_SetNetworkParam interface to set receiving buffer again,
command to device, device then snapshots current monitoring video and reports it to user.
5. After intelligent picture alarm report function is done, call CLIENT_StopLoadPic to stop
7. After SDK function use is done, call CLIENT_Cleanup to release SDK resource.
#include<windows.h>
#include <stdio.h>
#include <list>
#include <time.h>
#include "dhnetsdk.h"
//*********************************************************************************
// commonly used callback set declaration
// callback function used when device gets offline
// Its not recommended to call SDK interfaces in this callback function
//Set the callback function in CLIENT_Initwhen device gets offlineSDK will call this function
164/339
automatically
void CALLBACK DisConnectFunc(LONG lLoginID, char *pchDVRIP, LONG nDVRPort,
DWORD 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");
165/339
}
//Set more network parameter, nWaittime and nConnectTryNum in NET_PARAM has the
same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.
//This operation is optional.
NET_PARAM stuNetParm = {0};
stuNetParm.nWaittime = 3000; // when login, connection timeout value is 3000ms.
CLIENT_SetNetworkParam(&stuNetParm);
if (0 == g_lLoginHandle)
{
// according to error code, you can find corresponding explanation in dhSDK.h. It is
to print hexadecimal here, not decimal showns in header file, please be careful with conversion
// example
// #define NET_NOT_SUPPORTED_EC(23)
// current SDK does not support the function, corresponding error code is 0x80000017.
Decimal number 23 is hexadecimal 0x17.
printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" , g_szDevIp , g_nPort ,
166/339
CLIENT_GetLastError());
}
else
{
printf("CLIENT_LoginEx2 %s[%d] Success\n" , g_szDevIp , g_nPort);
}
// The first time logining to device, some data is needed to be initialized to enable
normal business function. It is recommended to wait for a while after login, the waiting time varies
by devices.
Sleep(1000);
printf("\n");
}
}
void RunTest()
{
if (FALSE == g_bNetSDKInitFlag)
{
return;
}
if (0 == g_lLoginHandle)
{
return;
}
167/339
{
printf("CLIENT_RealLoadPictureEx Failed!Last Error[%x]\n",
CLIENT_GetLastError());
return;
}
void EndTest()
{
168/339
printf("input any key to quit! \n");
getchar();
// logout 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;
}
}
169/339
}
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");
}
170/339
}
printf("nDVRPort[%d]\n", nDVRPort);
printf("dwUser[%p]\n", dwUser);
printf("\n");
}
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_PARKINGDETECT ION_INFO*)pAlarmInfo;
nAlarmChn = pStuInfo->nChannelID;
printf("nChannelID[%d]\n", pStuInfo->nChannelID);
}
171/339
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;
}
172/339
int nWrite = 0;
while(nWrite != dwBufSize)
{
nWrite += fwrite(pBuffer + nWrite, 1, dwBufSize - nWrite, pFile);
}
fclose(pFile);
}
return 1;
}
173/339
3 Callback function definition
3.1fDisConnect
Option Instruction
Precondition none
LLONG lLoginID,
char *pchDVRIP,
Function
LONG nDVRPort,
LDWORD dwUser
);
lLoginID
pchDVRIP
Device IP.
nDVRPort
Device port.
dwUser
User data
Note User can identify which device gets disconnected via parameters
174/339
3.2fHaveReConnect
Option Instruction
Precondition None
LLONG lLoginID,
char *pchDVRIP,
Function
LONG nDVRPort,
LDWORD dwUser
);
lLoginID
pchDVRIP
Device IP.
nDVRPort
Device port.
dwUser
User data
Note User can identify which device gets reconnected via parameters lLoginID
175/339
3.3fRealDataCallBackEx
Option Instruction
Precondition None
LLONG lRealHandle,
DWORD dwDataType,
BYTE *pBuffer,
Function
DWORD dwBufSize,
LONG param,
LDWORD dwUser
);
lRealHandle
CLIENT_SetRealDataCallBackEx.
dwDataType description
stored by CLIENT_SaveRealData
1 Frame data
2 Yuv data
3 Pcm data
pBuffer
dwDataType value. The data are called back by frame for every
176/339
Option Instruction
dwBufSize
param
details.
details.
dwUserData
user data.
Note User can identify which real-time monitoring the callback data belongs
3.4fDownLoadPosCallBack
Option Instruction
Precondition None
LLONG lPlayHandle,
DWORD dwDownLoadSize,
LDWORD dwUser
177/339
Option Instruction
);
lPlayHandle
Playback handle
etc.
dwTotalSize
dwUser
User data
3.5fDataCallBack
Option Instruction
Precondition None
LLONG lRealHandle,
DWORD dwDataType,
DWORD dwBufSize,
LDWORD dwUser
);
Parameter lRealHandle
178/339
Option Instruction
Playback handle
etc.
dwDataType
Data type.
pBuffer
dwBufSize
dwUser
User data
0: means callback failed, and next time the same data will be returned.
Return value 1: means callback succeeded, and next time the follow-up data will be
returned.
etc.
3.6fTimeDownLoadPosCallBack
Option Instruction
Precondition None
179/339
Option Instruction
DWORD dwTotalSize,
DWORD dwDownLoadSize,
int index,
NET_RECORDFILE_INFO recordfileinfo,
LDWORD dwUser
);
lPlayHandle
Download handle
dwTotalSize
dwDownLoadSize
recordfileinfo
dwUser
User data
Note etc.
3.7fMessCallBack
Option Instruction
precondition None
180/339
Option Instruction
LONG lCommand,
LLONG lLoginID,
char *pBuf,
char *pchDVRIP,
LONG nDVRPort,
LDWORD dwUser
);
lCommand
lLoginID
pBuf
dwBufLen
pchDVRIP
nDVRPort
dwUser
User data
181/339
Option Instruction
All the logined device use the same alarm report callback function .
pBuf points to different data type according to different listen interface and
different lCommand.
Note As there are too many alarm events, here we dont introduce them all,
user can search the following key section in header file Eng_dhnetsdk.h
for details:
3.8fSearchDevicesCB
Option Instruction
Interface
Device search callback prototype
description
Precondition None
DEVICE_NET_INFO_EX *pDevNetInfo,
Function
void* pUserData
);
pDevNetInfo
pUserData
User data
182/339
Option Instruction
function.
3.9fAnalyzerDataCallBack
Option Instruction
Interface
Intellengent picture alarm callback function prototype
description
Precondition None
LLONG lAnalyzerHandle,
DWORD dwAlarmType,
void* pAlarmInfo,
BYTE *pBuffer,
Function
DWORD dwBufSize,
LDWORD dwUser,
int nSequence,
void *reserved
);
lAnalyzerHandle
When multiple intelligent picture alarm subscriptions use the same callback
dwAlarmType
Parameter
Intelligent picture alarm typethis parameter should be used matched with
parameter pBuffer.
As there are too many alarm events, here we dont introduce them all, user
can search the following key section in header file Eng_dhnetsdk.h for
details:
183/339
Option Instruction
pAlarmInfo
pBuffer
dwBufSize
dwUser
User data
nSequence
0:its the first time that the picture shows up, and the follow-up alarms may
1this picture is the same as the one shown in tha last alarm, and the
2this picture is the same as the one shown in tha last alarm,and it will never
show up again.or it is the only time that the picture shows up.
reserved
(as most of the intelligent picture alarm data is real-time data ,the value of
*(int *)reserved is 0)
184/339
Option Instruction
receiving buffer again, otherwise SDK will abandon data pack over 2M.
As there are too many alarm events, here we dont introduce them all, user
can search the following key section in header file Eng_dhnetsdk.h for details:
3.10 fSnapRev
Option Instruction
Interface
Front-end video snapshot callback function prototype
description
Precondition None
LLONG lLoginID,
BYTE *pBuf,
UINT RevLen,
Function
UINT EncodeType,
DWORD CmdSerial,
LDWORD dwUser
);
lLoginID
Parameter When multiple front-end video snapshots use the same callback function,
pBuf
185/339
Option Instruction
RevLen
EncodeType
Encode type
CmdSerial
dwUser
User data
Note snapshot picture data sent by device-end, SDK will call this function.
receiving buffer again, otherwise SDK will abandon data pack over 2M.
3.11 fRealPlayDisConnect
Option Instruction
Interface
Real-time monitoring disconnection callback function prototype
description
Precondition None
EM_REALPLAY_DISCONNECT_EVENT_TYPE dwEventType,
186/339
Option Instruction
void* param,
LDWORD dwUser
);
LOperateHandle
When multiple real-time monitoring device use the same callback function,
dwEventType
param
dwUser
User data
3.12 pfAudioDataCallBack
Option Instruction
Interface
Audion data callback function protptype
description
Precondition None
LLONG lTalkHandle,
Function
char *pDataBuf,
DWORD dwBufSize,
187/339
Option Instruction
BYTE byAudioFlag,
LDWORD dwUser
);
lTalkHandle
pDataBuf
dwBufSize
0 indicates that the audio data received is PC-end data collected by local
be called back.
dwUser
User data
Note Set the callback in audio intercom interface such as CLIENT_StartTalkEx etc.
188/339
Appendix 1 struct definition
NET_DEVICEINFO
Option Instruction
Struct
Device info
description
typedef struct
BYTE sSerialNumber[DH_SERIALNO_LEN];
BYTE byAlarmInPortNum;
BYTE byAlarmOutPortNum;
BYTE byDiskNum;
Union
BYTE byChanNum;
BYTE byLeftLogTimes;
};
} NET_DEVICEINFO, *LPNET_DEVICEINFO;
sSerialNumber
SN
byAlarmInPortNum
byAlarmOutPortNum
member
DVR alarm output amount
byDiskNum
byDVRType
189/339
Option Instruction
byChanNum
byLeftLogTimes
When login failed due to password error, notice user via this parameter,
NET_IN_STARTLOGINEX
Option Instruction
DWORD dwSize;
DWORD dwPort;
struct
const char* szName;
fHaveLogin cbLogin;
LDWORD dwUser;
}NET_IN_STARTLOGINEX;
dwSize
when used.
szIp
device ip
member
dwPort
login port
szName
username
szPwd
190/339
password
cbLogin
dwUser
NET_OUT_STARTLOGINEX
Option Instruction
{
Struct
DWORD dwSize;
}NET_OUT_STARTLOGINEX;
dwSize
sizeof(NET_OUT_STARTLOGINEX)when used.
NET_PARAM
Option Instruction
Struct
Relevant parameters of login
description
typedef struct
int nWaittime;
int nConnectTime;
int nSubConnectSpaceTime;
int nGetDevInfoTime;
int nConnectBufSize;
int nGetConnInfoTime;
191/339
int nSearchRecordTime;
int nsubDisconnetTime;
BYTE byNetType;
BYTE byPlaybackBufSize;
BYTE bDetectDisconnTime;
BYTE bKeepLifeInterval;
int nPicBufSize;
BYTE bReserved[4];
} NET_PARAM;
nWaittime
nConnectTime
nConnectTryNum
nSubConnectSpaceTime
nGetDevInfoTime
Member nConnectBufSize
nGetConnInfoTime
nSearchRecordTime
nsubDisconnetTime
byNetType
byPlaybackBufSize
192/339
playback data from the receive buffer size(m),when value = 0,default 4M
bDetectDisconnTime
Pulse detect offline time(second) .When it is 0, the default setup is 60s, and
bKeepLifeInterval
Pulse send out interval(second). When it is 0, the default setup is 10s, the min
internal is 2s.
nPicBufSize
2*1024*1024
bReserved
reserved
NET_DEVICEINFO_Ex
Option Instruction
Struct
device info extension
description
typedef struct
BYTE sSerialNumber[DH_SERIALNO_LEN];
int nAlarmInPortNum;
int nAlarmOutPortNum;
int nDiskNum;
int nChanNum;
BYTE byLimitLoginTime;
BYTE byLeftLogTimes;
BYTE bReserved[2];
int nLockLeftTime;
char Reserved[24];
193/339
} NET_DEVICEINFO_Ex, *LPNET_DEVICEINFO_Ex;
sSerialNumber
SN
nAlarmInPortNum
nAlarmOutPortNum
nDiskNum
nDVRType
nChanNum
byLeftLogTimes
When login failed due to password error, notice user via this parameter,
bReserved
nLockLeftTime
when log in failed, the left time for users to unlock (seconds), -1 indicate the
Reserved
reserved
tagVideoFrameParam
Option Instruction
Struct
Frame parameter struct of Callback video data frame
description
194/339
Option Instruction
BYTE encode;
BYTE frametype;
BYTE format;
Struct
BYTE size;
DWORD fourcc;
DWORD reserved;
NET_TIME struTime;
} tagVideoFrameParam;
encode
Encode type
MPEG4 encode: 1
frametype
frame type
I frame - 0
P frame - 1
B frame - 2
format
video format
PAL 0
NTSC - 1
size
195/339
Option Instruction
resolution ratio
CIF 0
HD1 1
2CIF 2
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
reserved
reserved
struTime
Time information
196/339
tagCBPCMDataParam
Option Instruction
Struct
Frame parameter struct of audio data callback
description
BYTE channels;
BYTE samples;
Struct
BYTE depth;
BYTE param1;
DWORD reserved;
} tagCBPCMDataParam;
channels
Track amount
samples
sample rate
0 8000
1 11025
2 - 16000
3 - 22050
Member
4 - 32000
5 - 44100
6 - 48000
depth
param1
0 - indication no symbol
197/339
Option Instruction
reserved
reserved
NET_TIME
Option Instruction
Struct
Time structexact to second
description
typedef struct
DWORD dwYear;
DWORD dwMonth;
DWORD dwHour;
DWORD dwMinute;
DWORD dwSecond;
} NET_TIME,*LPNET_TIME;
dwYear
year
dwMonth
month
dwDay
day
Member
dwHour
hour
dwMinute
minute
dwSecond
second
198/339
NET_RECORDFILE_INFO
Option Instruction
Struct
Record file info struct
description
typedef struct
char filename[124];
NET_TIME starttime;
BYTE nRecordFileType;
BYTE bImportantRecID;
BYTE bHint;
BYTE bRecType;
} NET_RECORDFILE_INFO, *LPNET_RECORDFILE_INFO;
ch
Channel number
filename
File name
framenum
size
File length
starttime
Start time
endtime
199/339
Option Instruction
End time
driveno
HDD number
1,128:net record)
startcluster
nRecordFileType
bImportantRecID
bHint
Document Indexing
bRecType
stream type
CFG_PTZ_PROTOCOL_CAPS_INFO
Option Instruction
200/339
Option Instruction
description
int nStructSize;
BOOL bPan;
BOOL bTile;
BOOL bZoom;
BOOL bIris;
BOOL bPreset;
BOOL bRemovePreset;
BOOL bTour;
BOOL bRemoveTour;
BOOL bPattern;
BOOL bAutoPan;
BOOL bAutoScan;
Struct
BOOL bAux;
BOOL bAlarm;
BOOL bLight;
BOOL bWiper;
BOOL bFlip;
BOOL bMenu;
BOOL bMoveRelatively;
BOOL bMoveAbsolutely;
BOOL bReset;
BOOL bGetStatus;
BOOL bSupportLimit;
BOOL bPtzDevice;
BOOL bIsSupportViewRange;
WORD wCamAddrMin;
201/339
Option Instruction
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;
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;
202/339
Option Instruction
BOOL bSupportPresetTimeSection;
BOOL bFocus;
}CFG_PTZ_PROTOCOL_CAPS_INFO;
nStructSize
bPan
bTile
bZoom
bIris
bPreset
bRemovePreset
Member
Whether to support removal of preset point
bTour
bRemoveTour
bPattern
bAutoPan
bAutoScan
bAux
203/339
Option Instruction
bAlarm
bLight
"stuPtzLightingControl".
bWiper
bFlip
bMenu
bMoveRelatively
bMoveAbsolutely
bReset
bGetStatus
Whether or not support Get the state of motion and orientation coordinates of
PTZ
bSupportLimit
bPtzDevice
bIsSupportViewRange
wCamAddrMin
wCamAddrMax
204/339
Option Instruction
wMonAddrMin
wMonAddrMax
wPresetMin
wPresetMax
wTourMin
wTourMax
wPatternMin
wPatternMax
wTileSpeedMin
wTileSpeedMax
wPanSpeedMin
wPanSpeedMax
wAutoScanMin
wAutoScanMax
205/339
Option Instruction
wAuxMin
wAuxMax
dwInterval
dwType
dwAlarmLen
dwNearLightNumber
dwFarLightNumber
dwSupportViewRangeType
Visual field data acquisition mode supported by the mask, from low to high
mode.
dwSupportFocusMode
Supported Focus mode mask, from low to high depending on the number,
szName
szAuxs
stuPtzMotionRange
CFG_PTZ_MOTION_RANGEfor details
206/339
Option Instruction
stuPtzLightingControl
details
bSupportPresetTimeSection
bFocus
CFG_PTZ_MOTION_RANGE
Option Instruction
Struct
PTZ rotation angle rang struct
description
int nHorizontalAngleMin;
int nVerticalAngleMin;
int nVerticalAngleMax;
}CFG_PTZ_MOTION_RANGE;
nHorizontalAngleMin
nHorizontalAngleMax
nVerticalAngleMax
207/339
CFG_PTZ_LIGHTING_CONTROL
Option Instruction
char szMode[CFG_COMMON_STRING_32];
Struct
DWORD dwNearLightNumber;
DWORD dwFarLightNumber;
}CFG_PTZ_LIGHTING_CONTROL;
szMode
dwFarLightNumber
DHDEV_TALKFORMAT_LIST
Option Instruction
typedef struct
Int nSupportNum;
Struct
DHDEV_TALKDECODE_INFO type[64];
Char reserved[64];
} DHDEV_TALKFORMAT_LIST;
nSupportNum
Member
amount
208/339
Option Instruction
type
Encode type
reserved
reserved
DHDEV_TALKDECODE_INFO
Option Instruction
typedef struct
DH_TALK_CODING_TYPE encodeType;
int nAudioBit;
Struct
DWORD dwSampleRate;
int nPacketPeriod;
char reserved[60];
} DHDEV_TALKDECODE_INFO;
encodeType
Encode type
nAudioBit
Bit:8/16
Member dwSampleRate
nPacketPeriod
Pack Period,Unit:ms
reserved
reserved
209/339
DHDEV_SYSTEM_ATTR_CFG
Option Instruction
typedef struct
DWORD dwSize;
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 byAlarmInNum;
BYTE byAlarmOutNum;
BYTE byNetIONum;
BYTE byUsbIONum;
BYTE byIdeIONum;
BYTE byComIONum;
BYTE byLPTIONum;
BYTE byVgaIONum;
BYTE byIdeControlNum;
BYTE byIdeControlType;
BYTE byCapability;
BYTE byMatrixOutNum;
210/339
Option Instruction
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
stVersion
stDspEncodeCap
szDevSerialNo
Member SN
ByDevType
szDevType
ByVideoCaptureNum
ByAudioCaptureNum
byTalkInChanNum
211/339
Option Instruction
NSP
ByTalkOutChanNum
NSP
byDecodeChanNum
NSP
ByAlarmInNum
ByAlarmOutNum
ByNetIONum
byUsbIONum
ByIdeIONum
IDE amount
ByComIONum
COM amount
ByLPTIONum
LPT amount
byVgaIONum
NSP
byIdeControlNum
NSP
byIdeControlType
NSP
byCapability
ByMatrixOutNum
212/339
Option Instruction
ByOverWrite
ByRecordLen
ByDSTEnable
WDevNo
ByVideoStandard
Video format
ByDateFormat
Date format
ByDateSprtr
Date separator(0:".",1:"-",2:"/")
ByTimeFmt
byLanguage
NET_SPEAK_PARAM
Option Instruction
DWORD dwSize;
Struct
int nMode;
int nSpeakerChannel;
BOOL bEnableWait;
213/339
Option Instruction
} NET_SPEAK_PARAM;
dwSize
nMode
mode type
afresh to configure
Member nSpeakerChannel
bEnableWait
Wait for device to responding or not when enable bidirectional talk. Default
NET_PARAM.
NET_TALK_TRANSFER_PARAM
Option Instruction
BOOL bTransfer;
}NET_TALK_TRANSFER_PARAM;
dwSize
214/339
DEVICE_NET_INFO_EX
Option Instruction
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 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 szPassWord[DH_USER_NAME_LENGTH_EX];
WORD wVideoInputCh;
WORD wRemoteVideoInputCh;
WORD wVideoOutputCh;
WORD wAlarmInputCh;
WORD wAlarmOutputCh;
215/339
Option Instruction
char cReserved[244];
}DEVICE_NET_INFO_EX;
iIPVersion
szIP
nPort
tcp port
szSubmask
szGateway
Gateway
szMac
MAC address
szDeviceType
byManuFactory
byDefinition
bDhcpEn
byReserved1
verifyData
szSerialNo
SN
216/339
Option Instruction
szDevSoftVersion
soft version
szDetailType
szVendor
OEM type
SzDevName
Device name
szUserName
user name for log in device(it need be filled when modify device ip)
szPassWord
pass word for log in device(it need be filled when modify device ip)
nHttpPort
wVideoInputCh
wRemoteVideoInputCh
wVideoOutputCh
wAlarmInputCh
wAlarmOutputCh
cReserved
reserved
217/339
MANUAL_SNAP_PARAMETER
Option Instruction
Struct
Manual snap parameter
description
int nChannel;
BYTE byReserved[60];
}MANUAL_SNAP_PARAMETER;
nChannel
bySequence
If triggering multiple manual snap events at the same time, user can identify
byReserved
reserved
OPR_RIGHT_EX
Option Instruction
Struct
Right information
description
DWORD dwID;
Struct
char name[DH_RIGHT_NAME_LENGT H];
char memo[DH_MEMO_LENGTH];
} OPR_RIGHT_EX;
218/339
Option Instruction
dwID
name
Member
right name
memo
right note
OPR_RIGHT_NEW
Option Instruction
DWORD dwSize;
char memo[DH_MEMO_LENGTH];
} OPR_RIGHT_NEW;
dwSize
dwID
Right name
memo
note
NET_DEV_CHN_COUNT_INFO
Option Instruction
219/339
Option Instruction
Struct
Device channel amount information struct
description
DWORD dwSize;
Struct
NET_CHN_COUNT_INFO stuVideoIn;
NET_CHN_COUNT_INFO stuVideoOut;
} NET_DEV_CHN_COUNT_INFO;
dwSize
stuVideoIn
Member
Video Input Channel, see struct NET_CHN_COUNT_INFO for details.
stuVideoOut
NET_CHN_COUNT_INFO
Option Instruction
Struct
Channel number information
description
DWORD dwSize;
int nMaxTotal;
int nCurTotal;
Struct
int nMaxLocal;
int nCurLocal;
int nMaxRemote;
int nCurRemote;
} NET_CHN_COUNT_INFO;
220/339
Option Instruction
dwSize
nMaxTotal
Equipment to the total number of channels (the sum of all valid channel
number
nCurTotal
nMaxLocal
Member
Maximum number of local channels, including motherboard and pluggable
cartoon
nCurLocal
nMaxRemote
nCurRemote
NET_IN_SNAP_CFG_CAPS
Option Instruction
Struct
Snap configure capacity input parameter
description
BYTE bReserved[1024];
}NET_IN_SNAP_CFG_CAPS;
nChannelId
bReserved
221/339
Option Instruction
reserved
NET_OUT_SNAP_CFG_CAPS
Option Instruction
Struct
Snap configure capacity output parameter
description
int nResolutionTypeNum;
NUM];
DWORD dwFramesPerSecNum;
DWORD dwQualityMun;
DWORD nQualityList[DH_MAX_QUALITY_NUM];
DWORD dwMode;
DWORD dwFormat;
BYTE bReserved[2048];
} NET_OUT_SNAP_CFG_CAPS;
nResolutionTypeNum
stuResolutionTypes
stuResolutionTypes
nResolutionTypeNum
dwFramesPerSecNum
nFramesPerSecLis
222/339
Option Instruction
nFramesPerSecList
dwQualityMun
nQualityList
dwMode
dwFormat
bReserved
reserved
DH_RESOLUTION_INFO
Option Instruction
Struct
Image resolution struct
description
typedef struct
}DH_RESOLUTION_INFO;
snWidth
width
Member
snHight
heigh
DEOENC_ VIDEOENC_OPT
Option Instruction
223/339
Option Instruction
Struct
Video encode parameter
description
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
abAudioEnable
abSnapEnable
abAudioAdd
224/339
Option Instruction
abAudioFormat
sbVideoEnable
stuVideoFormat
bAudioEnable
bSnapEnable
bAudioAddEnable
stuAudioFormat
CFG_VIDEO_FORMAT
Option Instruction
Struct
Video format struct
description
{
Struct
bool abCompression;
bool abWidth;
225/339
Option Instruction
bool abHeight;
bool abBitRateControl;
bool abBitRate;
bool abFrameRate;
bool abIFrameInterval;
bool abImageQuality;
bool abFrameType;
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;
abCompression
be modified.
abWidth
Member
TRUEnWidth is valid ; FALSEnWidth is invalid
be modified.
abHeight
226/339
Option Instruction
be modified.
abBitRateControl
be modified.
abBitRate
be modified.
abFrameRate
be modified.
abIFrameInterval
be modified.
abImageQuality
be modified.
abFrameType
be modified.
abProfile
227/339
Option Instruction
be modified.
emCompression
nWidth
video width
nHeight
video height
emBitRateControl
nBitRate
nFrameRate
nIFrameInterval
frame or P frame.
emImageQuality
Video quality
228/339
Option Instruction
nFrameType
Sniffer mode,0-DHAV,1-"PS"
emProfile
CFG_AUDIO_ENCODE_FORMAT
Option Instruction
Struct
Audion format
description
bool abCompression;
bool abDepth;
bool abFrequency;
bool abMode;
bool abFrameType;
CFG_AUDIO_FORMAT emCompression;
AV_int32 nDepth;
AV_int32 nFrequency;
AV_int32 nMode;
AV_int32 nFrameType;
AV_int32 nPacketPeriod;
} CFG_AUDIO_ENCODE_FORMAT;
abCompression
Member
TRUEemCompression is valid;FALSEemCompression is invalid
229/339
Option Instruction
be modified.
abDepth
be modified.
abFrequency
be modified.
abMode
be modified.
abFrameType
be modified.
abPacketPeriod
be modified.
emCompression
nDepth
230/339
Option Instruction
nFrequency
nMode
nFrameType
nPacketPeriod
CFG_VIDEO_COVER
Option Instruction
Struct
Multiple-zone mask configuration
description
int nTotalBlocks;
Struct
int nCurBlocks;
CFG_COVER_INFO stuCoverBlock[MAX_VIDEO_COVER_NUM];
} CFG_VIDEO_COVER;
nTotalBlocks
nCurBlocks
Member
The amount of zones already set.
stuCoverBlock
231/339
Option Instruction
CFG_COVER_INFO
Option Instruction
Struct
Privacy mask information
description
bool abBlockType;
bool abEncodeBlend;
bool abPreviewBlend;
CFG_RGBA stuColor;
int nBlockType;
int nEncodeBlend;
int nPreviewBlend;
} CFG_COVER_INFO;
abBlockType
be modified.
abEncodeBlend
be modified.
abPreviewBlend
232/339
Option Instruction
be modified.
stuRect
The position (coordinates) of the mask zone, see struct CFG_RECT for
details.
stuColor
nBlockType
nEncodeBlend
nPreviewBlend
Preview mask;1-enable,0-disable
CFG_RECT
Option Instruction
Struct
Zone information
description
int nLeft;
int nRight;
int nBottom;
} CFG_RECT;
nLeft
Member
left side of the zone
233/339
Option Instruction
nTop
nRight
nBottom
CFG_RGBA
Option Instruction
Struct
RGBA information
description
int nRed;
int nBlue;
int nAlpha;
} CFG_RGBA;
nRed
red
nGreen
green
member
nBlue
blue
nAlpha
pellucidity
CFG_ENCODE_INFO
Option Instruction
234/339
Option Instruction
Struct
Video channel property information
description
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
szChnName
invalid parameter
Member stuMainStream
235/339
Option Instruction
stuExtraStream
stuSnapFormat
dwCoverAbilityMask
invalid parameter
dwCoverEnableMask
invalid parameter
stuVideoCover
invalid parameter
stuChnTitle
invalid parameter
stuTimeTitle
invalid parameter
stuVideoColor
invalid parameter
emAudioFormat
invalid parameter
nProtocolVer
236/339
SNAP_PARAMS
Option Instruction
Struct
Snapshot parameter structure
description
} SNAP_PARAMS, *LPSNAP_PARAMS;
Channel
Snapshot channel
Quality
Image quality: evel 1 to level 6,the bigger the value is, the better quality the
image is
ImageSize
Invalide parameter
Member
Mode
Snapshot mode
-1:stop snapshotting
2: Request consecutively
InterSnap
237/339
Option Instruction
Snapshot interval(unit: s)
parameter tuSnapFormat[nSnapMode].stuVideoFormat.nFrameRate in
configure CFG_CMD_ENCODE
CmdSerial
Snapshot Request serial number, valid range 0~65535, over this range will be
Reserved
reserved
DH_VERSION_INFO
Option Instruction
Struct Device software version information. The higher 16-bit means the main version
typedef struct
DWORD dwSoftwareVersion;
DWORD dwSoftwareBuildDate;
DWORD dwDspSoftwareVersion;
DWORD dwDspSoftwareBuildDate;
Struct
DWORD dwPanelVersion;
DWORD dwPanelSoftwareBuildDate;
DWORD dwHardwareVersion;
DWORD dwHardwareDate;
DWORD dwWebVersion;
DWORD dwWebBuildDate;
238/339
Option Instruction
} DH_VERSION_INFO, *LPDH_VERSION_INFO;
dwSoftwareVersion
software version
dwSoftwareBuildDate
dwDspSoftwareVersion
dwDspSoftwareBuildDate
dwPanelVersion
not used
Member
dwPanelSoftwareBuildDate
not used
dwHardwareVersion
hardware version
dwHardwareDate
not used
dwWebVersion
web version
dwWebBuildDate
DH_DSP_ENCODECAP
Option Instruction
Struct
DSP capacity description
description
typedef struct
Struct {
DWORD dwVideoStandardMask;
239/339
Option Instruction
DWORD dwImageSizeMask;
DWORD dwEncodeModeMask;
DWORD dwStreamCap;
DWORD dwImageSizeMask_Assi[8];
DWORD dwMaxEncodePower;
WORD wMaxSupportChannel;
WORD wChannelMaxSetSync;
} DH_DSP_ENCODECAP, *LPDH_DSP_ENCODECAP;
dwVideoStandardMask
video format mask. Bit stands for the video format device supported.
dwImageSizeMask
Resolution mask, Bit stands for the resolution setup devices supported, see
below:
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)
Member
5 640*480
6 320*240
7 480*480
8 160*128
9 800*592
10 1024*768
11 1280*800
12 1600*1024
13 1600*1200
240/339
Option Instruction
14 1920*1200
15 240*192
16 1280*720
17 1920*1080
18 1280*960
19 1872*1408
20 3744*1408
21 2048*1536
22 2432*2050
23 1216*1024
24 1408*1024
25 3296*2472
26 2560*1920(5M)
27 960*576(PAL) 960*480(NTSC)
28 960*720
dwEncodeModeMask
Encode mode mask bit. Bit stands for the encode mode devices supported.
dwStreamCap
dwImageSizeMask_Assi
When the main stream is the corresponding resolution, the supported extra
dwMaxEncodePower
241/339
Option Instruction
wMaxSupportChannel
wChannelMaxSetSync
Max encode bit setup in each DSP channel are synchronized or not ;0:does
not synchronized,1:synchronized
242/339
Appendix 2 Enum definition
NET_DEVICE_TYPE
Option Instruction
NET_PRODUCT_NONE = 0,
NET_LN_SERIAL, // LN series
NET_IPC_SERIAL, //IPCseries
243/339
Option Instruction
it is in string format.
NET_NVD_SERIAL, // NVD
NET_DVR_N5, // N5
NET_DVR_MIX_DVR, // HDVR
NET_SVR_BS, //SVR-BS
NET_DVR_N51, // N51
camera equipment
server series)
NET_MATRIX_SERIAL, // matrix
NET_DVR_N52, // N52
NET_DVR_N56, // N56
NET_ESS_SERIAL, // ESS
NET_PC_NVR, // pc-nvr
244/339
Option Instruction
system
NET_DVR_N6, // DVR-N6
of products
}NET_DEVICE_TYPE ;
EM_LOGIN_SPAC_CAP_TYPE
Option Instruction
description
245/339
Option Instruction
login
device
not config
EM_LOGIN_SPEC_CAP_AD=13, //AD(ActiveDirectory)
login
}EM_LOGIN_SPAC_CAP_TYPE;
DH_RealPlayType
Option Instruction
CLIENT_StartRealPlay interfaces
246/339
Option Instruction
DH_RType_Realplay
DH_RType_Multiplay_1, //Multiple-channel
preview-- 1-window
} DH_RealPlayType;
EM_QUERY_RECORD_TYPE
Option Instruction
external alarm
detection alarm
247/339
Option Instruction
or NVS
serial data
}EM_QUERY_RECORD_TYPE;
EM_USEDEV_MODE
Option Instruction
Enum description Audio talk way(not describe some extensive data type)
talk
talk
audio talk
248/339
Option Instruction
configuration management
channel(0~MaxChannel-1)
extra stream)
parameter,corresponding to
NET_SPEAK_PARAM
RECORD TYPE)
EX
function(0-off,1-on)
NET_TALK_TRANSFER_PARAM)
corresponding to
NET_VT_TALK_PARAM structure
249/339
Option Instruction
} EM_USEDEV_MODE;
EM_SUPPORT_FOCUS_MODE
Option Instruction
number mode
}EM_SUPPORT_FOCUS_MODE;
DH_PTZ_ControlType
Option Instruction
DH_PTZ_UP_CONTROL = 0, // Up
DH_PTZ_DOWN_CONTROL, // Down
DH_PTZ_LEFT_CONTROL, // Left
DH_PTZ_RIGHT_CONTROL, // Right
DH_PTZ_ZOOM_ADD_CONTROL, // +Zoom in
DH_PTZ_FOCUS_ADD_CONTROL, // +Zoom in
DH_PTZ_APERTURE_ADD_CONTROL, // + Aperture
250/339
Option Instruction
DH_PTZ_APERTURE_DEC_CONTROL, // -Aperture
DH_PTZ_POINT_MOVE_CONTROL, // Go to preset
DH_PTZ_POINT_SET_CONTROL, // Set
DH_PTZ_POINT_DEL_CONTROL, // Delete
DH_PTZ_POINT_LOOP_CONTROL, // Tour
} DH_PTZ_ControlType;
DH_EXTPTZ_ControlType
Option Instruction
251/339
Option Instruction
DH_EXTPTZ_REVERSECOMM, // Flip
Y address(8192)zoom(4)
DH_EXTPTZ_MENUUP, // menu up
number
252/339
Option Instruction
PTZ_CONTROL_ABSOLUTELY
PTZ_CONTROL_CONTINUOUSLY
struct PTZ_CONTROL_GOTOPRESET
param1param2param3 is invalid)
(param4correspondingPTZ_CONTROL_SECTORSCAN,
param1param2param3 is invalid)
PTZ,param4corresponding to structure
PTZ_CONTROL_SET_FISHEYE_EPTZ
similarly hereinafter
253/339
Option Instruction
similarly hereinafter
} DH_EXTPTZ_ControlType;
DH_TALK_CODING_TYPE
Option Instruction
DH_TALK_G711a, // G711a
DH_TALK_AMR, // AMR
DH_TALK_G711u, // G711u
DH_TALK_G726, // G726
DH_TALK_G723_53, // G723_53
DH_TALK_G723_63, // G723_63
DH_TALK_AAC, // AAC
254/339
Option Instruction
DH_TALK_OGG, // OGG
DH_TALK_MPEG2, // MPEG2
DH_TALK_MPEG2_Layer2, // MPEG2-Layer2
DH_TALK_G722_1, // G.722.1
} DH_TALK_CODING_TYPE;
CtrlType
Option Instruction
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,
255/339
Option Instruction
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,
256/339
Option Instruction
DH_KEYBOARD_SHIFT,
DH_KEYBOARD_BACK,
information(No parameter)
257/339
Option Instruction
MANUAL_SNAP_PARAMETER)
DEVICE_LOCALPREVIEW_SLIPT_PARAMETER)
(struct WIFI_CONNECT)
258/339
Option Instruction
(struct WIFI_CONNECT)
DH_CTRL_IP_MODIFY, // IP modify
(struct DHCTRL_IPMODIFY_PARAM)
DHCTRL_CONNECT_WIFI_BYWPS)
(struct DH_FORMAT_PATITION)
(struct DH_EJECT_STORAGE_DEVICE)
(struct DH_LOAD_STORAGE_DEVICE)
MONITORWALL TVINFO)
(corresponding structure
VIDEO ANALYSE)
259/339
Option Instruction
MULTIPLAYBACK CHANNALES)
SEQPOWER PARAM)
DH_CTRL_PROJECTOR_RISE, // PROJECTOR up
file
260/339
Option Instruction
NET_CTRL_ALARM_SUBSYSTEM_SETACT IVE)
gateway(corresponding to structure
NET_CTRL_FORBID_OPEN_STROBE)
to structure NET_CTRL_OPEN_STROBE)
to structure NET_CTRL_TALKING_REFUSE)
261/339
Option Instruction
CTRL_ARM_DISARM_PARAM upgrade,recommended
(corresponding to structure
NET_CTRL_SET_TEMPERATURE)
temperature(corresponding to structure
NET_CTRL_ADJUST_TEMPERATURE)
(corresponding to structure
NET_CTRL_AIRCONDITION_SETMODE)
DH_CTRL_RESTOREDEFAULT_EX ,
structure NET_CTRL_RESTORE_DEFAULT)
to structure NET_NOTIFY_EVENT_DATA)
262/339
Option Instruction
report(corresponding to structure
NET_CTRL_START_PLAYAUDIOEX)
structure NET_CTRL_CLOSE_STROBE)
no.(corresponding to
NET_CTRL_RECORDSET_INSERT_PARAM)
record(corresponding to NET_CTRL_RECORDSET_PARAM)
NET_CTRL_ECK_LED_SET_PARAM)
NET_CTRL_ECK_IC_CARD_IMPORT_PARAM)
device IC card info sync command, receive this command, device will
NET_CTRL_ECK_SYNC_IC_CARD_PARAM)
device(corresponding structure
NET_CTRL_LOWRATEWPAN_REMOVE)
263/339
Option Instruction
info(corresponding structure
NET_CTRL_LOWRATEWPAN_MODIFY)
NET_CTRL_ECK_SET_PARK_INFO_PARAM)
(corresponding to NET_CTRL_VTP_DISCONNECT)
NET_CTRL_MATRIX_SAVE_SWITCH)
NET_CTRL_MATRIX_RESTORE_SWITCH)
(corresponding to NET_CTRL_VTP_DIVERTACK)
NET_CTRL_RAINBRUSH_MOVEONCE)
NET_CTRL_RAINBRUSH_MOVECONTINUOUSLY)
NET_CTRL_RAINBRUSH_STOPMOVE)
(corresponding to NET_CTRL_ALARM_ACK)
264/339
Option Instruction
callback interface
(Corresponding to NET_CTRL_RECORDSET_PARAM)
structure NET_CTRL_ACCESS_SHUT_LOCK)
NET_CTRL_OPEN_DOOR_CONTINUE)
CLIENT_ControlDeviceEx
DH_CTRL_THERMO_GRAPHY_ENSHUTTER = 0x10000,
//pInBuf= NET_IN_THERMO_EN_SHUTTER*,
//pOutBuf= NET_OUT_THERMO_EN_SHUTTER *
DH_CTRL_RADIOMETRY_SETOSDMARK,
// NET_IN_RADIOMETRY_SETOSDMARK*,
//pOutBuf= NET_OUT_RADIOMETRY_SETOSDMARK *
DH_CTRL_AUDIO_REC_START_NAME,
//pInBuf = NET_IN_AUDIO_REC_MNG_NAME *,
//pOutBuf = NET_OUT_AUDIO_REC_MNG_NAME *
DH_CTRL_AUDIO_REC_STOP_NAME,
//pInBuf ,NET_IN_AUDIO_REC_MNG_NAME *,
//pOutBuf = NET_OUT_AUDIO_REC_MNG_NAME *
265/339
Option Instruction
DH_CTRL_SNAP_MNG_SNAP_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,
// pOutBuf = NET_OUT_LOG_MNG_CTRL *
DH_CTRL_POS_ADD,
//pOutBuf = NET_OUT_POS_ADD *
DH_CTRL_POS_REMOVE,
//pOutBuf = NET_OUT_POS_REMOVE *
DH_CTRL_POS_REMOVE_MULTI,
//pInBuf = NET_IN_POS_REMOVE_MULT I *,
//pOutBuf = NET_OUT_POS_REMOVE_MULTI *
DH_CTRL_POS_MODIFY,
//pOutBuf = NET_OUT_POS_ADD *
DH_CTRL_SET_SOUND_ALARM,
//pInBuf = NET_IN_SOUND_ALARM *,
//pOutBuf = NET_OUT_SOUND_ALARM *
DH_CTRL_AUDIO_MATRIX_SILENCE,
//audiomatrix silence,
266/339
Option Instruction
//pInBuf = NET_IN_AUDIO_MATRIX_SILENCE*,
//pOutBuf = NET_OUT_AUDIO_MATRIX_SILENCE*
DH_CTRL_MANUAL_UPLOAD_PICT URE,
//pInBuf = NET_IN_MANUAL_UPLOAD_PICTURE *,
//pOutBUf = NET_OUT_MANUAL_UPLOAD_PICTURE *
DH_CTRL_REBOOT_NET_DECODING_DEV,
//pInBuf = NET_IN_REBOOT_NET_DECODING_DEV *,
//pOutBuf = NET_OUT_REBOOT_NET_DECODING_DEV *
} CtrlType;
CFG_VIDEO_COMPRESSION
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;
267/339
CFG_BITRATE_CONTROL
Option Instruction
} CFG_BITRATE_CONTROL;
CFG_IMAGE_QUALITY
Option Instruction
} CFG_IMAGE_QUALITY;
CFG_H264_PROFILE_RANK
Option Instruction
268/339
Option Instruction
formats.
}CFG_H264_PROFILE_RANK;
CFG_AUDIO_FORMAT
Option Instruction
AUDIO_FORMAT_G711A, // G711a
AUDIO_FORMAT_PCM, // PCM
AUDIO_FORMAT_G711U, // G711u
AUDIO_FORMAT_AMR, // AMR
AUDIO_FORMAT_AAC, // AAC
} CFG_AUDIO_FORMAT;
EM_REALPLAY_DISCONNECT_EVENT_TYPE
Option Instruction
269/339
Option Instruction
advanced user
DISCONNECT_EVENT_NETFORBID, //forbidden
}EM_REALPLAY_DISCONNECT_EVENT_TYPE;
270/339
Appendix 3 Interface definition
CLIENT_Init
Option Instruction
description initialized.
Precondition None
fDisConnect cbDisConnect,
LDWORD dwUser
);
Parameter cbDisConnect
device is offline,SDK will notify user by this callback, info includes login
dwUser
Example // Its not recommended to call SDK interface in callback function, unless call
//When online device gets offline,SDK will call this callback function set by
CLINET_Init.
printf("Call DisConnectFunc\n");
271/339
Option Instruction
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");
//SDK initialization
if (FALSE == g_bNetSDKInitFlag)
return;
else
Note Before call other SDK interface, call this interface firstly.
CLIENT_Cleanup
Option Instruction
description
272/339
Option Instruction
Parameter None
printf("CLIENT_Cleanup! \n");
CLIENT_Cleanup();
Note When application program is closed , call this interface to release resources at
last.
CLIENT_GetSDKVersion
Option Instruction
description
Parameter None
Return value Return value is version,for example 34219000 corresponding to version 3.42
19000.
Note None
CLIENT_GetLastError
Option Instruction
Interface Interface for getting error code after failed calling interface,get current thread
273/339
Function DWORD CLIENT_GetLastError(void);
Parameter None
//Now SDK does not support this function, error code is 0x80000017, Decimal
Because of too much error code, it is not illustrate here,user can search the
interface.
CLIENT_SetAutoReconnect
Option Instruction
HaveReConnect cbAutoConnect,
DWORD dwUser
);
274/339
Option Instruction
reconnection successful.
[in] dwUser
User data, set by user. Return to user for further use by callback function
cbAutoConnect.
Example //Not recommended to call SDK interface in SDK callback function,unless get
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");
CLIENT_SetAutoReconnect(&HaveReConnect, 0);
275/339
Option Instruction
interface is NULL , when device-end gets disconnected, SDK will not try to
reconnect to device.
CLIENT_SetConnectTime
Option Instruction
Interface Interface for setting device connection timeout value and trial times.
description
int nWaitTime,
int nTryTimes
);
Parameter nWaitTime
[in] The timeout time means waiting time for devices answer in every login.
nTryTimes
[in]The trial time means the times of trying to connect device in every login.
//This is optional.
CLIENT_SetConnectTime(nWaitTime, nTryTimes);
276/339
CLIENT_SetNetworkParam
Option Instruction
description
NET_PARAM *pNetParam
);
Parameter pNetParam
NET_TIME
Example //Set the network login parameters,include login timeout time and trial times.
CLIENT_SetNetworkParam(&stuNetParm);
Note None
CLIENT_LoginEx2
Option Instruction
Interface Extensive interface 2 for login, used to register user to device,could define
WORD wDVRPort,
277/339
Option Instruction
EM_LOGIN_SPAC_CAP_TYPE emSpecCap,
void* pCapParam,
LPNET_DEVICEINFO_Ex lpDeviceInfo,
int *error = 0
);
Parameter pchDVRIP
[in]device IP.
wDVRPort
pchUserName
pchPassword
emSpecCap
EM_LOGIN_SPAC_CAP_TYPE.
pCapParam
lpDeviceInfo
error
278/339
Option Instruction
For example
1- erroneous password
3-login timeout
4-account logged in
5- account locked
6- account is blacklisted
8-failed subconnection
equipment.
int nError = 0;
g_lLoginHandle=CLIENT_LoginEx2(g_szDevIp,g_nPort,g_szUserName,
g_szPasswd,EM_LOGIN_SPEC_CAP_TCP,NULL,&stDevInfoEx, &nError);
if(0 == g_lLoginHandle)
279/339
Option Instruction
//Now SDK does not support this function, error code is 0x80000017,
g_nPort , CLIENT_GetLastError());
else
CLIENT_Logout
Option Instruction
description
Parameter lLoginID
if(!CLIENT_Logout(g_lLoginHandle))
CLIENT_GetLastError());
280/339
//Please refer to example code of sync login in device login.
Note When logout device,related businesses will stop ,such as real-time preview
etc.
CLIENT_RealPlayEx
Option Instruction
LLONG lLoginID,
int nChannelID,
HWND hWnd,
);
Parameter lLoginID
nChannelID
hWnd
[in] window handle,when value is 0, data is not decoded and image is not
displayed.
rType
DH_RealPlayType.
Return value Failed return 0,otherwise return real-time monitoring ID(real-time monitoring
281/339
Option Instruction
PROCGETCONSOLEWINDOW GetConsoleWindow;
GetConsoleWindow =
(PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWi
ndow");
emRealPlayType);
if (g_lRealHandle == 0)
CLIENT_GetLastError());
Note NVR device fills nChannelID as video output channel number in multiplay
preview.
According to device information got when login, you can open any real-time
CLIENT_StopRealPlayEx
Option Instruction
Interface Extensive interface for stopping real-time monitoring , stop getting real-time
Precondition Have called interface for getting real-time monitoring data stream ,such as
CLIENT_RealPlayEx interface.
282/339
Option Instruction
LLONG lRealHandle
);
Parameter lRealHandle
CLIENT_RealPlayEx etc.
Example if (!CLIENT_StopRealPlayEx(g_lRealHandle))
Note None
CLIENT_SetRealDataCallBackEx
Option Instruction
Interface Extensive interface for setting real-time monitoring data callback function.
description
CLIENT_RealPlayEx etc.
LLONG lRealHandle,
fRealDataCallBackEx cbRealData,
LDWORD dwUser,
DWORD dwFlag
);
Parameter lRealHandle
283/339
Option Instruction
CLIENT_RealPlayEx etc.
cbRealData
If cbRealData value is not 0,call back real-time monitoring data via callback
dwUser
[in] User data,SDK sends the data to user for further use via callback
function fRealDataCallBackEx.
dwFlag
we can recall data selectively as needed, do not recall data type which is not
Example // Its not recommended to call SDK interface in callback function, unless call
284/339
Option Instruction
//Recommend users only save data in this callback, In the other word:copy
data to your storage, and encode or decode data after leaving callback.
dwUser)
if (lRealHandle == g_lRealHandle)
switch(dwDataType)
case 0:
dwDataType[%d],pBuffer[%p],dwBufSize[%d],
param[%p],dwUser[%p]\n",lRealHandle, dwDataType,
break;
case 1:
break;
case 2:
//yuv data
break;
case 3:
break;
case 4:
285/339
Option Instruction
break;
default:
break;
************ Above are callback function definition, the underneath are interface
if(!CLIENT_SetRealDataCallBackEx(g_lRealHandle,&RealDataCallBackEx,
NULL, dwFlag))
CLIENT_GetLastError());
Note Add a callback data type flag- dwFlag, we can recall data selectively as
CLIENT_FindFile
Option Instruction
description
LLONG lLoginID,
int nChannelId,
int nRecordFileType,
286/339
Option Instruction
char* cardid,
LPNET_TIME time_start,
LPNET_TIME time_end,
BOOL bTime,
int waittime
);
Parameter lLoginID
nChannelId
nRecordFileType
enum EM_QUERY_RECORD_TYPE
cardid
nRecordFileType cardid
empty word)
PICTURE
EM_RECORD_TYPE_FIELD FELD1&&FELD2&&
287/339
Option Instruction
is null)
tmStart
tmEnd
bTime
waittime
StartTime.dwYear = 2015;
StartTime.dwMonth = 9;
StartTime.dwDay = 20;
StartTime.dwHour = 0;
StartTime.dwMinute = 0;
StopTime.dwYear = 2015;
StopTime.dwMonth = 9;
StopTime.dwDay = 21;
StopTime.dwHour = 15;
int nFileCount = 0;
288/339
Option Instruction
CLIENT_GetLastError());
Note You can call this interface for querying video record before playback,then call
CLIENT_FindNextFile
Option Instruction
description
LLONG lFindHandle,
LPNET_RECORDFILE_INFO lpFindData
);
Parameter lFindHandle
lpFindData
NET_RECORDFILE_INFO.
-1:parameter error.
289/339
Option Instruction
CLIENT_GetLastError());
Note Call CLIENT_FindFile for opening query handle before call this interface.
CLIENT_FindClose
Option Instruction
description
LLONG lFindHandle
);
Parameter lFindHandle
290/339
Option Instruction
CLIENT_GetLastError());
CLIENT_PlayBackByTimeEx
Option Instruction
description
LLONG lLoginID,
int nChannelID,
LPNET_TIME lpStartTime,
LPNET_TIME lpStopTime,
HWND hWnd,
fDownLoadPosCallBack cbDownLoadPos,
LDWORD dwPosUser,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser
);
Parameter lLoginID
nChannelID
291/339
Option Instruction
lpStartTime
lpStopTime
hWnd
cbDownLoadPos
dwPosUser
SDK sends the data to user for further use via callback function
fDownLoadPosCallBack.
fDownLoadDataCallBack
details.
dwDataUser
SDK sends the data to user for further use via callback function
fDownLoadDataCallBack.
292/339
Option Instruction
PROCGETCONSOLEWINDOW GetConsoleWindow;
GetConsoleWindow =
(PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWi
ndow");
stuStartTime.dwYear = 2015;
stuStartTime.dwMonth = 9;
stuStartTime.dwDay = 3;
stuStopTime.dwYear = 2015;
stuStopTime.dwMonth = 9;
stuStopTime.dwDay = 12;
if (g_lPlayHandle == 0)
CLIENT_GetLastError());
Note Parameter hWnd and fDownLoadDataCallBack can not be NULL at the same
293/339
CLIENT_StopPlayBack
Option Instruction
description
CLIENT_PlayBackByTimeEx etc.
LLONG lPlayHandle
);
Parameter lPlayHandle
Example if (!CLIENT_StopPlayBack(g_lPlayHandle))
CLIENT_GetPlayBackOsdTime
Option Instruction
description Only when parameter hWnd in record playback interface is valid, can
CLIENT_PlayBackByTimeEx etc.
294/339
Option Instruction
LLONG lPlayHandle,
LPNET_TIME lpOsdTime,
LPNET_TIME lpStartTime,
LPNET_TIME lpEndTime
);
Parameter lPlayHandle
lpOsdTime
lpStartTime
lpEndTime
&stuStartTime, &stuEndTime))
Note Only when parameter hWnd in record playback interface is valid, can
295/339
CLIENT_QueryRecordFile
Option Instruction
description
LLONG lLoginID,
int nChannelId,
int nRecordFileType,
LPNET_TIME tmStart,
LPNET_TIME tmEnd,
char* pchCardid,
LPNET_RECORDFILE_INFO nriFileinfo,
int maxlen,
int *filecount,
int waittime=1000,
);
Parameter lLoginID
nChannelId
nRecordFileType
enum EM_QUERY_RECORD_TYPE.
tmStart
296/339
Option Instruction
tmEnd
pchCardid
nRecordFileType pchCardid
type&&transaction amount
word)
EM_RECORD_TYPE_FIELD FELD1&&FELD2&&FELD3
empty word,corresponding
position is null)
nriFileinfo
maxlen
(unit:byte,recommend length:
(100~200)*sizeof(NET_RECORDFILE_INFO)
filecount
297/339
Option Instruction
Output parameter only querys to the biggest video record which buffer is full.
waittime
bTime
StartTime.dwYear = 2015;
StartTime.dwMonth = 9;
StartTime.dwDay = 20;
StartTime.dwHour = 0;
StartTime.dwMinute = 0;
StopTime.dwYear = 2015;
StopTime.dwMonth = 9;
StopTime.dwDay = 21;
StopTime.dwHour = 15;
int nFileCount = 0;
if(!CLIENT_QueryRecordFile(lLoginHandle, nChannelID,
CLIENT_GetLastError());
Note Before playback by file,its needed to call this interface to query video record. If
298/339
Option Instruction
video record info of input time slot queried is greater than defined buffer size,
return video record which size is defined buffer size,and can continue querying
as needed.
CLIENT_DownloadByTimeEx
Option Instruction
Interface
Extensive interface for downloading record by time
description
LLONG CLIENT_DownloadByTimeEx(
LLONG lLoginID,
int nChannelId,
int nRecordFileType,
LPNET_TIME tmStart,
LPNET_TIME tmEnd,
fTimeDownLoadPosCallBack cbTimeDownLoadPos,
LDWORD dwUserData,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser,
);
lLoginID
Parameter nChannelId
nRecordFileType
299/339
Option Instruction
tmStart
tmEnd
sSavedFileName
cbTimeDownLoadPos
dwUserData
SDK send the data to user for further use via callback function
fTimeDownLoadPosCallBack
fDownLoadDataCallBack
dwDataUser
SDK send the data to user for further use via callback function
fDataCallBack
pReserved
[in]reserved parameter
Used for further extension, meaningless until now, default value is NULL.
300/339
Option Instruction
stuStartTime.dwYear = 2015;
stuStartTime.dwMonth = 9;
stuStartTime.dwDay = 17;
stuStopTime.dwYear = 2015;
stuStopTime.dwMonth = 9;
stuStopTime.dwDay = 18;
fDownLoadDataCallBack is valid.
g_lDownloadHandle = CLIENT_DownloadByTimeEx(g_lLoginHandle,
if (g_lDownloadHandle == 0)
CLIENT_GetLastError());
CLIENT_StopDownload
Option Instruction
Interface
Interface for stopping record download
description
301/339
Option Instruction
BOOL CLIENT_StopDownload(
);
lFileHandle
[in]download handle
Parameter
Return value of record download interface as
CLIENT_DownloadByTimeEx etc.
// stop download,we can call this interface after download end or during
download.
if (g_lDownloadHandle)
if (!CLIENT_StopDownload(g_lDownloadHandle))
Example {
printf("CLIENT_StopDownload
Failed, g_lDownloadHandle[%x]
Note We can stop download after download end or during download as needed.
CLIENT_PlayBackByRecordFileEx
Option Instruction
Interface
Extensive interface for playing back by file
description
LLONG CLIENT_PlayBackByRecordFileEx(
LPNET_RECORDFILE_INFO lpRecordFile,
302/339
Option Instruction
HWND hWnd,
fDownLoadPosCallBack cbDownLoadPos,
LDWORD dwPosUser,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser
);
lLoginID
lpRecordFile
hWnd
cbDownLoadPos
for details.
dwPosUser
SDK send the data to user for further use via callback function
fDownLoadPosCallBack
fDownLoadDataCallBack
303/339
Option Instruction
fDataCallBackfor details.
dwDataUser
SDK send the data to user for further use via callback function
fDownLoadDataCallBack
g_lPlayHandle = CLIENT_PlayBackByRecordFileEx(g_lLoginHandle,
CLIENT_GetLastError());
CLIENT_PausePlayBack
Option Instruction
Parameter lPlayHandle
304/339
Option Instruction
bPause
Only when the parameter hWnd in open record playback interface is valid,
Note
can parameters this interface obtained be valid, otherwise it is no meaning.
CLIENT_SeekPlayBack
Option Instruction
Interface
Interface for positioning record playback start point
description
BOOL CLIENT_SeekPlayBack(
LLONG lPlayHandle,
);
lPlayHandle
offsettime
305/339
Option Instruction
offsetbyte
Set to 0xffffffff.
play.
0xffffffff))
Example
{
Note None
CLIENT_FastPlayBack
Option Instruction
BOOL CLIENT_FastPlayBack(
);
lPlayHandle
306/339
Option Instruction
Can not fast forward without limit, currently the max frame is 200, greater than
this will return FALSE. if the record is with sound, fast forward is not
Note supported.
Only when the parameter hWnd in open record playback interface is valid, can
CLIENT_SlowPlayBack
Option Instruction
Interface
Interface for slow play. Decreasing frame rate by 1x
description
BOOL CLIENT_SlowPlayBack (
);
lPlayHandle
if (!CLIENT_SlowPlayBack (g_lPlayHandle))
Example {
307/339
Option Instruction
when the parameter hWnd in open record playback interface is 0 and device
supports playback speed control, SDK can send speed control command to
device.
Note
when the parameter hWnd in open record playback interface is a valid value
and device supports playback speed control, SDK can send speed control
command to device and call the command to playsdk library which display
records.
CLIENT_NormalPlayBack
Option Instruction
Interface
Interface for restoring normal play speed
description
BOOL CLIENT_NormalPlayBack(
);
lPlayHandle
if (!CLIENT_NormalPlayBack (g_lPlayHandle))
308/339
Option Instruction
when the parameter hWnd in open record playback interface is 0 and device
supports playback speed control, SDK can send speed control command to
device.
Note when the parameter hWnd in open record playback interface is a valid value
and device supports playback speed control, SDK can send speed control
command to device and call the command to playsdk library which display
records.
CLIENT_DownloadByRecordFileEx
Option Instruction
Interface
Extensive interface for downloading record by file
description
LLONG CLIENT_DownloadByRecordFileEx(
LLONG lLoginID,
LPNET_RECORDFILE_INFO lpRecordFile,
char *sSavedFileName,
fDownLoadPosCallBack cbDownLoadPos,
Function
LDWORD dwUserData,
fDataCallBack fDownLoadDataCallBack,
LDWORD dwDataUser,
);
lLoginID
309/339
Option Instruction
sSavedFileName
cbDownLoadPos
for details.
dwPosUser
SDK send the data to user for further use via callback function
fDownLoadPosCallBack
fDownLoadDataCallBack
fDataCallBackfor details.
dwDataUser
SDK send the data to user for further use via callback function
fDownLoadDataCallBack
pReserved
[in]reserved parameter
Used for further extension, invalid until now, default value is NULL.
310/339
Option Instruction
fDownLoadDataCallBack is valid.
g_lDownloadHandle = CLIENT_DownloadByRecordFileEx(g_lLoginHandle,
NULL);
if (g_lDownloadHandle == 0)
printf("CLIENT_DownloadByRecordFileEx: failed!
CLIENT_ParseData
Option Instruction
Interface
Interface for analyzing the obtained config info
description
BOOL CLIENT_ParseData(
char* szCommand,
char* szInBuffer,
DWORD dwOutBufferSize,
void* pReserved
);
szCommand
311/339
Option Instruction
szInBuffer
lpOutBuffer
dwOutBufferSize
pReserved
CFG_PTZ_PROTOCOL_CAPS_INFO stuPtzCapsInfo =
{sizeof(stuPtzCapsInfo)};
Command parameter
CLIENT_DHPTZControlEx2
Option Instruction
Interface Extensive interface for private PTZ control. Support 3-D quick positioning and
312/339
Option Instruction
description fish-eye.
BOOL CLIENT_DHPTZControlEx2(
LLONG lLoginID,
int nChannelID,
DWORD dwPTZCommand,
LONG lParam1,
Function
LONG lParam2,
LONG lParam3,
BOOL dwStop ,
);
lLoginID
nChannelId
dwPTZCommand
Parameter details.
lParam1
Used matched with other parameter, different control command has different
lParam1.
lParam2
Used matched with other parameter, different control command has different
lParam2
313/339
Option Instruction
lParam3
Used matched with other parameter, different control command has different
lParam3
dwStop
Valid when operating PTZ eight direction and lens, otherwise in when
lParam4
Used matched with other parameter, different control command has different
lParam4
if (!CLIENT_DHPTZControlEx2(g_lLoginHandle, nChannelId,
nChoose[DH_PTZ_UP_CONTROL]!Last Error[%x]\n" ,
CLIENT_GetLastError());
CLIENT_QueryNewSystemInfo
Option Description
Interface Interface for obtaining new system capacity set (take the form of Json, see
314/339
Option Description
BOOL CLIENT_QueryNewSystemInfo(
LLONG lLoginID,
char* szCommand,
int nChannelID,
DWORD dwOutBufferSize,
int *error,
int waittime=1000
);
lLoginID
szCommand
nChannelID
set to -1 means searching all the channels, partial commands not support
Parameter
setting to -1.
szOutBuffer
dwOutBufferSize
error
When failed obtaining, netsdk will write corresponding error code to this
pointer address.
315/339
Option Description
waittime
if (NULL == pBuffer)
return;
int nError = 0;
if (FALSE == CLIENT_QueryNewSystemInfo(g_lLoginHandle,
{
Example
printf("CLIENT_QueryNewSystemInfo
CLIENT_GetLastError());
if (pBuffer)
delete [] pBuffer;
pBuffer = NULL;
return;
follows:
316/339
Option Description
CLIENT_SetDeviceMode
Option Instruction
Interface Interface for setting work mode such as audio intercom, playback, right and
description etc.
BOOL CLIENT_SetDeviceMode(
LLONG lLoginID,
void* pValue
);
lLoginID
emType
pValue
Example if(!CLIENT_SetDeviceMode(g_lLoginHandle,
DH_RECORD_STREAM_TYPE, &nStreamType))
317/339
Option Instruction
CLIENT_GetLastError());
Note None
CLIENT_StartSearchDevices
Option Instruction
Interface
Interface for async searching for IPC, NVS and etc. within same segment
description
LLONG CLIENT_StartSearchDevices(
fSearchDevicesCB cbSearchDevices,
char* szLocalIp=NULL
);
cbSearchDevices
When there are response package returned from device-end, NetSDK will
analyze them to valid information and inform user via callback function, see
pUserData
Parameter
[in] user data
NetSDK will return the value to user for further user via callback function
fSearchDevicesCB.
szLocalIp
[in] local IP
318/339
Option Instruction
g_lSearchHandle = CLIENT_StartSearchDevices(SearchDevicesCB,
&g_lDeviceList);
if (NULL == g_lSearchHandle)
CLIENT_GetLastError());
return;
CLIENT_QueryDevState
Option Instruction
Interface
Interface for searching device status
description
BOOL CLIENT_QueryDevState(
LLONG lLoginID,
int nType,
char *pBuf,
Function
int nBufLen,
int *pRetLen,
int waittime=1000
);
lLoginID
nType
319/339
Option Instruction
pBuf
Used to store the queried device infor, used matched with nType, see
nBufLen
pRetLen
waittime
DHDEV_TALKFORMAT_LIST stulstTalkEncode;
int retlen = 0;
bSuccess = CLIENT_QueryDevState(g_lLoginHandle,
DH_DEVSTATE_TALK_ECTYPE, (char*)&stulstTalkEncode,
DH_DEVSTATE_TALK_ECTYPE, CLIENT_GetLastError());
320/339
CLIENT_StartTalkEx
Option Instruction
Interface
Extensive interface for opening audio intercom
description
LLONG CLIENT_StartTalkEx(
LLONG lLoginID,
LDWORD dwUser
);
lLoginID
pfcb
dwUser
SDK will call back the data to user for further use via callback function
pfAudioDataCallBack
Return value Succeed return audio intercom handle, failed return FALSE.
(DWORD)NULL);
if(0 == g_lTalkHandle)
Example {
CLIENT_GetLastError());
Note None
321/339
CLIENT_StopTalkEx
Option Instruction
Interface
Extensive interface for stopping audio intercom
description
BOOL CLIENT_StopTalkEx(
);
lTalkHandle
if(!CLIENT_StopTalkEx(g_lTalkHandle))
CLIENT_GetLastError());
Example }
else
g_lTalkHandle = 0;
Note None
CLIENT_RecordStartEx
Option Instruction
description CLIENT_RecordStart())
322/339
Option Instruction
LLONG lLoginID
);
lLoginID
if(!bSuccess)
{
Example
printf("CLIENT_RecordStartEx Failed!
Note None
CLIENT_RecordStopEx
Option Instruction
description CLIENT_RecordStop())
BOOL CLIENT_RecordStopEx(
);
lLoginID
323/339
Option Instruction
if (!CLIENT_RecordStopEx(g_lLoginHandle))
printf("CLIENT_RecordStop Failed!
else
g_RecordFlag = FALSE;
CLIENT_TalkSendData
Option Instruction
Interface
Interface for sending audio data to device
description
LONG CLIENT_TalkSendData(
LLONG lTalkHandle,
DWORD dwBufSize
);
lTalkHandle
pSendBuf
324/339
Option Instruction
dwBufSize
[in]buffer size
Return value Succeed return data length has been transferred practically, failed return -1.
dwBufSize);
if(lSendLen != (long)dwBufSize)
Example {
CLIENT_GetLastError());
CLIENT_AudioDecEx
Option Instruction
Interface
Extensive interface for decoding audio data
description
BOOL CLIENT_AudioDecEx(
LLONG lTalkHandle,
DWORD dwBufSize
);
lTalkHandle
pAudioDataBuf
325/339
Option Instruction
dwBufSize
// send the audio data which received from device-end to SDK to decode and
play.
Example {
CLIENT_GetLastError());
CLIENT_SetDVRMessCallBack
Option Instruction
Interface
Interface for setting alarm callback function.
description
void CLIENT_SetDVRMessCallBack(
fMessCallBack cbMessage,
Function
LDWORD dwUser
);
cbMessage
dwUser
[in] user data, SDK sends the data to user for further use via real-time
326/339
Option Instruction
CLIENT_StartListenEx
Option instruction
Interface
Extensive interface for subscribing alarm event from device
description
BOOL CLIENT_StartListenEx(
);
lLoginID
if( CLIENT_StartListenEx(g_lLoginHandle))
g_bStartListenFlag = TRUE;
else
printf("CLIENT_StartListenEx Failed!Last
327/339
Option instruction
Error[%x]\n" , CLIENT_GetLastError());
All the device alarm events are sent to user via callback function set in
Note
interface CLIENT_SetDVRMessCallBack.
CLIENT_StopListen
Option Instruction
Interface
Interface for stopping subscribing alarm
description
BOOL CLIENT_StopListen(
);
lLoginID
if (g_bStartListenFlag)
if (!CLIENT_StopListen(g_lLoginHandle))
printf("CLIENT_StopListen Failed!Last
Example
Error[%x]\n", CLIENT_GetLastError());
else
g_bStartListenFlag = FALSE;
328/339
Option Instruction
Note None
CLIENT_StopSearchDevices
Option Instruction
Interface Interface for stopping async search for IPC, NVS and etc. within same
description segment.
BOOL CLIENT_StopSearchDevices(
);
lSearchHandle
CLIENT_StartSearchDevices etc.
if (NULL != g_lSearchHandle)
if (FALSE == CLIENT_StopSearchDevices(g_lSearchHandle))
Example {
CLIENT_GetLastError());
329/339
CLIENT_SearchDevicesByIPs
Option Instruction
Interface
Interface for sync searching for cross-segment device
description
BOOL CLIENT_SearchDevicesByIPs(
DEVICE_IP_SEARCH_INFO* pIpSearchInfo,
fSearchDevicesCB cbSearchDevices,
char* szLocalIp,
DWORD dwWaitTime
);
pIpSearchInfo
cbSearchDevices
When there are response package returned from device-end, SDK will
analyze them to valid information and inform user via callback function, see
dwUserData
SDK send the data to user for further use via callback function
fSearchDevicesCB
szLocalIp
[in] local IP
dwWaitTime
330/339
Option Instruction
User can set the parameter as needed, as this is a sync interface, only
when the time set here is out, can the interface have a return .
// please note that only when the time set here is out, can the interface have a
CLIENT_GetLastError());
return;
As this is a sync interface, only when the time set here is out, can the interface
Note
have a return . user can decide the timeout time according to net condition.
CLIENT_RealLoadPictureEx
Option Instruction
description
LLONG lLoginID,
int nChannelID,
DWORD dwAlarmType,
BOOL bNeedPicFile,
fAnalyzerDataCallBack cbAnalyzerData,
LDWORD dwUser,
331/339
Option Instruction
void* Reserved
);
Parameter lLoginID
nChannelID
start from 0.
dwAlarmType
bNeedPicFile
callback function.
the callback function(reduce network flux when do not need to picture info).
cbAnalyzerData
When device has intelligent picture alarm to report,SDK will call this function
dwUser
[in] user data, SDK sends the data to user for further use via intelligent
Reserved
Return value Failed return 0,otherwise return ID of intelligent picture alarm subscription to
332/339
Option Instruction
LDWORD dwUser = 0;
g_lRealLoadHandle = CLIENT_RealLoadPictureEx(g_lLoginHandle, 0,
if (0 == g_lRealLoadHandle)
CLIENT_GetLastError());
return;
event.
If a user wants to set all types of event for one channel, the parameter
If you want to set two types of events for one channel,please call
CLIENT_ControlDeviceEx
Option Instruction
description
LLONG lLoginID,
CtrlType emType,
void* pInBuf,
333/339
Option Instruction
);
Parameter lLoginID
emType
[in]control type.
pInBuf
did not indicate what struct pInBuf is in enum instruction, set the parameter
to NULL.
pOutBuf
did not indicate what struct pOutBuf is in enum instruction, set the
parameter to NULL.
nWaitTime
stuSanpParam.nChannel = 0;
sizeof(stuSanpParam.bySequence) - 1);
334/339
Option Instruction
// manually snapshot trigger alarm function, this function is only valid for ITC
device
if (FALSE == CLIENT_ControlDeviceEx(g_lLoginHandle,
DH_MANUAL_SNAP, &stuSanpParam))
CLIENT_GetLastError());
break;
Note None
CLIENT_StopLoadPic
Option Instruction
description
CLIENT_RealLoadPictureEx etc.
LLONG lAnalyzerHandle
);
Parameter lAnalyzerHandle
interface as CLIENT_RealLoadPictureEx.
335/339
Option Instruction
if (0 != g_lRealLoadHandle)
if (FALSE == CLIENT_StopLoadPic(g_lRealLoadHandle))
CLIENT_GetLastError());
else
g_lRealLoadHandle = 0;
Note None.
CLIENT_GetDownloadPos
Option Instruction
Interface
Interface for searching record download process,uint is KB.
description
LLONG lFileHandle,
int *nTotalSize,
int *nDownLoadSize
);
Parameter lFileHandle
CLIENT_DownloadByTimeEx.
nTotalSize
336/339
Option Instruction
nDownLoadSize
int nDownLoad = 0;
&nDownLoad))
CLIENT_GetLastError());
Note None
CLIENT_SetSnapRevCallBack
Option Instruction
description
fSnapRev OnSnapRevMessage,
LDWORD dwUser
);
Parameter OnSnapRevMessage
dwUser
[in] user data, SDK returns data to user by front-end snapshot callback
337/339
Option Instruction
CLIENT_SetSnapRevCallBack(SnapRev, NULL);
snapshot interface.
CLIENT_SnapPictureEx
Option Instruction
description
LLONG lLoginID,
SNAP_PARAMS *par,
int *reserved = 0
);
Parameter lLoginID
par
[in]snapshot parameter.
reserved
[in]reserved field.
SNAP_PARAMS stuSnapParams;
338/339
Option Instruction
stuSnapParams.Channel = nChannelId;
stuSnapParams.mode = nSnapType;
stuSnapParams.CmdSerial = ++g_nCmdSerial;
short.
CLIENT_GetLastError());
return;
else
printf("CLIENT_SnapPictureEx succ\n");
Note None
339/339