SDK Programming GuideV3.4.7 Preface Purpose Welcome to use NetSDK(SDK for short below) programming guide. 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 in SDK, and also provided example codes. Target reader SDK software development engineers Symbols The symbols shown in the sheet below may appear in the document, their meanings are shown below. Symbol Instruction Means: supplement to the body of the text Revise history Time Revised content 2016-01-15 Create 2016-08-16 Revise Catalogue PREFACE ................................................................................................................................2 CATALOGUE ...........................................................................................................................3 1 INTRODUCTION ........................................................................................................... 10 1.1 ABSTRACT ............................................................................................................................................................ 10 1.2 APPLICABILITY ...................................................................................................................................................... 11 2 MAJOR FUNCTIONS .................................................................................................... 12 2.1 SDK I NITAILIZATION MODULE ............................................................................................................................... 12 2.1.1 Module Intro.......................................................................................................................................... 12 2.1.2 Interfa ce Overview ............................................................................................................................... 12 2.1.3 SDK Initialization Instruction .............................................................................................................. 13 2.1.4 Example Code........................................................................................................................................ 14 2.2 DEVICE LOGIN ...................................................................................................................................................... 17 2.2.1 Intro ........................................................................................................................................................ 17 2.2.2 Interfa ce Overview ............................................................................................................................... 18 2.2.3 Process Instruction ............................................................................................................................... 18 2.2.4 Example Codes ...................................................................................................................................... 19 2.3 REAL-TIME MONITORING...................................................................................................................................... 23 2.3.1 Intro ........................................................................................................................................................ 23 2.3.2 Interfa ce Overview ............................................................................................................................... 23 2.3.3 Process Instruction ............................................................................................................................... 24 2.3.4 Example Code........................................................................................................................................ 27 2.4 RECORD PLAYBACK ............................................................................................................................................... 38 2.4.1 Intro ........................................................................................................................................................ 38 2.4.2 Interfa ce Overview ............................................................................................................................... 39 2.4.3 Process Instruction ............................................................................................................................... 39 2.4.4 Example Code........................................................................................................................................ 44 3/339 2.5 RECORD DOWNLOAD............................................................................................................................................ 59 2.5.1 Intro ........................................................................................................................................................ 59 2.5.2 Interfa ce Overview ............................................................................................................................... 60 2.5.3 Process Instruction ............................................................................................................................... 60 2.5.4 Example Code........................................................................................................................................ 65 2.6 PTZ CONTROL ...................................................................................................................................................... 80 2.6.1 Intro ........................................................................................................................................................ 80 2.6.2 Interfa ce Overview ............................................................................................................................... 80 2.6.3 Process Instruction ............................................................................................................................... 81 2.6.4 Example Code........................................................................................................................................ 83 2.7 AUDIO INTERCOM................................................................................................................................................. 95 2.7.1 Intro ........................................................................................................................................................ 95 2.7.2 Interfa ce Overview ............................................................................................................................... 95 2.7.3 Process Instruction ............................................................................................................................... 96 2.7.4 Example Code...................................................................................................................................... 100 2.8 SNAPSHOT.......................................................................................................................................................... 129 2.8.1 Intro ...................................................................................................................................................... 129 2.8.2 Interfa ce Overview ............................................................................................................................. 129 2.8.3 Process Instruction ............................................................................................................................. 129 2.8.4 Example code ...................................................................................................................................... 130 2.9 REPORT ALARM .................................................................................................................................................. 138 2.9.1 Intro ...................................................................................................................................................... 138 2.9.2 Interfa ce Overview ............................................................................................................................. 138 2.9.3 Process Instruction ............................................................................................................................. 138 2.9.4 Example Code...................................................................................................................................... 140 2.10 DEVICE SEARCH............................................................................................................................................. 147 2.10.1 Intro ...................................................................................................................................................... 147 2.10.2 Interfa ce Overview ............................................................................................................................. 148 2.10.3 Process Intruction ............................................................................................................................... 148 2.10.4 Example Code...................................................................................................................................... 150 4/339 2.11 I NTELLIGENT EVENT R EPORT AND SNAPSHOT.................................................................................................. 162 2.11.1 Intro ...................................................................................................................................................... 162 2.11.2 Interfa ce Overview ............................................................................................................................. 162 2.11.3 Process Intruction ............................................................................................................................... 162 2.11.4 Example Code...................................................................................................................................... 164 3 CALLBACK FUNCTION DEFINITION .......................................................................... 174 3.1 FDISCONNECT .................................................................................................................................................... 174 3.2 FHAVERECONNECT ............................................................................................................................................. 175 3.3 FREAL DATACALL BACKEX..................................................................................................................................... 176 3.4 FDOWNLOADPOSCALL BACK ............................................................................................................................... 177 3.5 FDATACALL BACK ................................................................................................................................................ 178 3.6 FTIMEDOWNLOADPOSCALL BACK ....................................................................................................................... 179 3.7 FMESSCALL BACK................................................................................................................................................ 180 3.8 FSEARCHDEVICESCB........................................................................................................................................... 182 3.9 FANALYZERDATACALL BACK ................................................................................................................................. 183 3.10 FSNAP REV .................................................................................................................................................... 185 3.11 FREAL PLAYDISCONNECT................................................................................................................................ 186 3.12 PFAUDIODATACALL BACK ............................................................................................................................... 187 APPENDIX 1 STRUCT DEFINITION ...................................................................................... 189 NET_DEVICEINFO....................................................................................................................................................... 189 NET_IN_STARTLOGINEX............................................................................................................................................ 190 NET_O UT_STARTLOGINEX ....................................................................................................................................... 191 NET_PARAM ............................................................................................................................................................... 191 NET_DEVICEINFO_EX ................................................................................................................................................ 193 TAGVIDEOFRAMEPARAM ................................................................................................................................................. 194 TAGCBPCMDATAPARAM ................................................................................................................................................ 197 NET_TIME ................................................................................................................................................................... 198 NET_RECORDFILE_INFO ........................................................................................................................................... 199 CFG_PTZ_PROTOCOL_CAPS_INFO .......................................................................................................................... 200 5/339 CFG_PTZ_MOTION_RANGE ..................................................................................................................................... 207 CFG_PTZ_LIGHTING_CONTROL............................................................................................................................... 208 DHDEV_TALKFORMAT_LIST ..................................................................................................................................... 208 DHDEV_TALKDECODE_INFO .................................................................................................................................... 209 DHDEV_SYSTEM_ATTR_CFG .................................................................................................................................... 210 NET_SPEAK_PARAM.................................................................................................................................................. 213 NET_TALK_TRANSFER_PARAM................................................................................................................................ 214 DEVICE_NET_INFO _EX .............................................................................................................................................. 215 MANUAL_SNAP_PARAMETER ................................................................................................................................. 218 OPR_RIGHT_EX .......................................................................................................................................................... 218 OPR_RIGHT_NEW ...................................................................................................................................................... 219 NET_DEV_CHN_COUNT_INFO ................................................................................................................................ 219 NET_CHN_COUNT_INFO .......................................................................................................................................... 220 NET_IN_SNAP_CFG_CAPS ........................................................................................................................................ 221 NET_O UT_SNAP_CFG_CAPS .................................................................................................................................... 222 DH_RESOLUTION_INFO ............................................................................................................................................ 223 DEOENC_ VIDEOENC_OPT ....................................................................................................................................... 223 CFG_VIDEO_FORMAT ............................................................................................................................................... 225 CFG_AUDIO_ENCODE_FORMAT ............................................................................................................................. 229 CFG_VIDEO_COVER................................................................................................................................................... 231 CFG_COVER_INFO ..................................................................................................................................................... 232 CFG_RECT.................................................................................................................................................................... 233 CFG_RGBA .................................................................................................................................................................. 234 CFG_ENCODE_INFO .................................................................................................................................................. 234 SNAP_PARAMS........................................................................................................................................................... 237 DH_VERSION_INFO ................................................................................................................................................... 238 DH_DSP_ENCODECAP............................................................................................................................................... 239 APPENDIX 2 ENUM DEFINITION.......................................................................................... 243 NET_DEVICE_TYPE .................................................................................................................................................... 243 EM_LOGIN_SPAC_CAP_TYPE................................................................................................................................... 245 6/339 ..................................................................................................................................... 289 CLIENT_FINDCLOSE ............................ 268 CFG_IMAGE_QUALITY ............................................................................................................................................................................................................................................ 276 CLIENT_S ET NETWORKPARAM .......................................................................................................................................... 251 DH_TALK_CODING_TYPE............................ 277 CLIENT_LOGINEX2 .......................................................................................................................................................................................................................................... 254 CTRLTYPE .............................................................................................................................................................................................................. 283 CLIENT_FINDFILE........................................................................................................................................................................................ 268 CFG_AUDIO_FORMAT.................................................................................. 290 7/339 ........................................................ 280 CLIENT_REALPLAYEX .................................................... 277 CLIENT_LOGOUT .................................... 286 CLIENT_FINDNEXTFILE ..... 248 EM_SUPPORT_FOCUS_MODE........................................... 246 EM_QUERY_RECORD_TYPE ................................. 267 CFG_BITRATE_CONTROL ... 271 CLIENT_I NIT .............................................................................................................................................................................................................................................................................................................................................................................................................. 269 EM_REALPLAY_DISCONNECT_EVENT_TYPE ................................................................................................................................................................................................................... 271 CLIENT_CLEANUP ............... 250 DH_PTZ_CONTROLTYPE ............................................................................................................................................................................................................................................................................................................................. 250 DH_EXTPTZ_CONTROLT YPE ................................ 273 CLIENT_S ETAUTORECONNECT .................. DH_R EAL PLAYTYPE ........................................................................................................................................................................................................................................................................................................... 269 APPENDIX 3 INTERFACE DEFINITION........................................................................................................................ 268 CFG_H264_PROFILE_RANK .................................................................................................................. 274 CLIENT_S ETCONNECTTIME ...................................................................................................................................................................................... 247 EM_USEDEV_MODE ..................................................................................................................................................................... 281 CLIENT_STOPREALPLAY EX ............................................................................................................................................................................................. 255 CFG_VIDEO_COMPRESSION .................................................. 272 CLIENT_GETSDKVERSION............................................................................................................................................................................................................................................................................. 282 CLIENT_S ETREAL DATACALL BACKEX .................................................................................................................................................................................................................... 273 CLIENT_GET LAST ERROR ............................................................................................................ ........................................................................................................................................................................................................................................................................................... 294 CLIENT_GETPLAY BACKO SDTIME .......................................................................................................................................................................................................................................................................CLIENT_PLAYBACKBYTIMEEX ................................................................................................................................................................................................................................................................................ 326 CLIENT_S TARTLISTEN EX ........... 306 CLIENT_SLOWPLAYBACK..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 327 CLIENT_STOPLISTEN ............................................................................................. 312 CLIENT_QUERY NEWSYSTEMI NFO........................................................................................................................................................................................... 322 CLIENT_RECORDSTARTEX................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 323 CLIENT_TALKSENDDATA ......................... 304 CLIENT_S EEKPLAYBACK ............................................................................................................. 305 CLIENT_FASTPLAYBACK ............ 325 CLIENT_S ETDVRMESSCALL BACK................ 302 CLIENT_PAUSEPLAYBACK .................................................... 301 CLIENT_PLAYBACKBYRECORDFILEEX....................................... 311 CLIENT_DHPTZCONTROL EX2....................................................... 317 CLIENT_S TARTSEARCHDEVICES.......................... 299 CLIENT_STOPDOWNLOAD........................................................................................................................................... 309 CLIENT_PARSED ATA .................................. 324 CLIENT_AUDIODECEX........ 296 CLIENT_DOWNLOADBYTIMEEX........................................................................................................................................................... 294 CLIENT_QUERYR ECORDFILE..................................................................................................................................................................................................................................................................................................................................................................................................................... 328 CLIENT_STOPSEARCHDEVICES ........................................................................................... 318 CLIENT_QUERYD EVSTATE ................................... 321 CLIENT_STOPTALKEX .............. 314 CLIENT_S ETDEVICEMODE ............................................................. 307 CLIENT_NORMAL PLAYBACK ........................................................................ 291 CLIENT_STOPPLAYBACK ........................................................................................................................................................................... 319 CLIENT_S TARTTALKEX..................................... 322 CLIENT_RECORDSTOPEX............................. 308 CLIENT_DOWNLOADBYRECORDFILEEX................................................................................................................................................................................................................................................................ 329 CLIENT_S EARCHDEVICESBYIPS................... 330 8/339 .................. .......... 338 9/339 ..................................................................................................................................................................................................................................................................................................CLIENT_REALLOADPICTUREEX ................................................................................................................................................................................ 336 CLIENT_S ETSNAPREVCALL BACK........ 335 CLIENT_GETDOWNLOADPOS ...................................... 331 CLIENT_CONTROL DEVICEEX............................................................................................................. 333 CLIENT_STOPLOADPIC ..................................................................................................................................................... 337 CLIENT_SNAPPICTUREEX ................................................. device upgrade. real-time monitoring. device search.lib Lib file dhnetsdk.dll Interface library Infra. Files in development kit are shown below: Library type Library file name Library description dhnetsdk.dll 3rd generation library dhconfigsdk. audio intercom. 1 Introduction 1. video image parameter setup. intelligent devices to monitor network application.dll 3rd generation aux library json.dll Configure library dhconfigsdk.dll 3rd generation aux library dhplay. intelligent event report and picture snapshot. alarm report.h Header file avnetsdk.1Abstract SDK is the software development kit used by software developer when developing DVR(digital video recorder).dll 3 generation aux library StreamSvr. PTZ control. video snapshpot.) . record playback and playback control. DVS(digital video server). SD(speed dome).dll Decoding aux library AUX Library adpcmdecode. user management and some other functions (device restart.dll 3rd generation aux library NetFramework.h Header file avglobal. device network parameter setup and etc.dll Decoding aux library postproc. channel name setup.lib Lib file Network library dhnetsdk. IPC(IP camere).dll Decoding aux library 10/339 . The kit mainly includes the following functions: Device login.h Header file dhconfigsdk. record download.dll 3rd generation aux library rd Stream. IPC and SD real-time monitoring DVR. Linux CentOS/Red Hat/SUSE and other general Linux OS. NVR.dll mobile snapshoting decoding library IvsDrawer. IPC and SD Alarm Report DVR. Supported system by SDK: Windows Windows10/Windows8/Windows7/vista/XP/2000 and Windows Server 2008/2003. NVR.dll Decoding aux library amrdec. NVR. GCC version not below 4.dll Decoding aux library DhDecode. IPC and SD Device Search DVR.dll Intelligent drawing library 1. NVR.dll Decoding aux library mpeg4dec.1. IPC and SD Record Playback and Playback Control storage device as DVR and NVR Record Download storage device DVR and NVR PTZ Control SD audio intercom DVR.dll Decoding aux library h264dec.dll Decoding aux library aacdec.dll Decoding aux library mp3dec. mpeg4enc. mobile and smart SD 11/339 . IPC and SD Video snapshot DVR.dll Decoding aux library mjpegdec. NVR. IPC and SD Intelligent Event Report and Snapshot IVS.2Applicability Recommended memory: unused menory should not below 256M. Applicable devices for each functional module are shown below: Function Supported Device Device Login DVR.2. NVR. 2. The module itself does not include surveillance business.1.1SDK Initailization Module 2.2 Interface Overview SDK initialization module involves the following interfaces: Inteface Interface Description CLIENT_Init Interface for SDK initialization CLIENT_Cleanup Interface for cleaning up SDK resources CLIENT_GetSDKVersion Interface for getting SDK version information CLIENT_GetLastError Interface for getting the function execution failure code Interface for setting reconnection callback function after CLIENT_SetAutoReconnect disconnection Interface for setting device connection timeout value and CLIENT_SetConnectTime trial times CLIENT_SetNetworkParam Interface for setting log in network environment 12/339 .2 Major Functions All the example codes are tested under Windows OS only.1. The initialization module of SDK will occupy a certain memory . Within the same process. 2. You need to call cleanup interface to release resources after using SDK completely. but the module is responsible for SDK initialization. interfaces in this chapter will not make any interaction with Dahua device. and setting properties which influence business. 3. 2.1 Module Intro Initialization is the first step of SDK business. only the first initialization is valid. Warnings: 1. Internal SDK auto connect again when the device disconnect. Call CLIENT_GetSDKVersion to get SDK version information(optional). Start Initialization CLIENT_Init Get SDK version information CLIENT_GetSDKVersion Set callback function when the device converts from off-line to on-line. 4.2. Call CLIENT_SetAutoReconnect to set offline reconnection callback function (optional. 2.1. Call CLIENT_Init to initialize SDK.suggest calling). 3. CLIENT_SetAutoReconnect Set device connection timeout value and trial times CLIENT_SetConnectTime Set network parameters CLIENT_SetNetworkParam Optional Clean up SDK resources CLIENT_Cleanup Mandatory End Figure 2-1 SDK initialization process Process description: 1. Call CLIENT_SetConnectTime to set device connection timeout value and trial times 13/339 .3 SDK Initialization Instruction a) The SDK initialization process is shown below in Figure 2-1. 6. LDWORD dwUser). void CALLBACK DisConnectFunc(LONG lLoginID. //************************************************************************** ******* // commonly used callback set declaration. parameters include login timeout value and trial times(optional). Call CLIENT_SetNetworkParam to set network parameters.(optional). Call CLIENT_Cleanup to clean up SDK resources After using SDK function. 2. //The callback function set by CLINET_Init. // It is not recommended to call SDK interface in the SDK callback function. 14/339 .h> #include <stdio. // It is not recommended to call SDK interface in the SDK callback function. char *pchDVRIP.SDK will call this callback function.When the device is offline.h" #pragma comment(lib . //********************************************************************************* void InitTest() { // SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. \n"). DWORD dwUser). return. "dhnetsdk.lib") static BOOL g_bNetSDKInitFlag = FALSE.1. LONG nDVRPort. void CALLBACK HaveReConnect(LLONG lLoginID. // Callback function set after the device reconnected successfully. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail.4 Example Code #include<windows. // Set the callback function in CLIENT_SetAutoReconnect. SDK will call the function.h> #include "dhnetsdk. 5. 0). when offline device is reconnected successfully. char *pchDVRIP. LONG nDVRPort. // callback function used when device disconnected. 15/339 .but recommended. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). // The first time logining to device. CLIENT_SetConnectTime(nWaitTime. some data is needed to be initialized to enable normal business function. printf("\n"). CLIENT_SetAutoReconnect(&HaveReConnect. //Get the SDK version info. } else { printf("Initialize client SDK done. Sleep(1000). // timeout value is 5 seconds int nTryTimes = 3. dwNetSdkVersion). nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. int nWaitTime = 5000. //This is an optional. connection timeout value is 3000ms.it will try to log in three times. \n"). stuNetParm. when device gets offline. //Set more network parameter. CLIENT_SetNetworkParam(&stuNetParm). nTryTimes). // Set device connection timeout value and trial times. the waiting time varies by devices. //If timeout. SDK will reconnect internally //This operation is optional. printf("NetSDK version is [%d]". NET_PARAM stuNetParm = {0}. } // This operation is optional. 0). // Set CLIENT_SetAutoReconnect interface.nConnectTime = 3000. It is recommended to wait for a while after login. //when login.Once HaveReConnect is set. } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. //This operation is optional. } printf("nDVRPort[%d]\n". printf("lLoginID[0x%x]". RunTest(). } //********************************************************************************* //commonly used callback functions definition void CALLBACK DisConnectFunc(LONG lLoginID. } // task realizing operation } void EndTest() { printf("input any key to quit! \n"). EndTest(). DWORD dwUser) { printf("Call DisConnectFunc\n"). LDWORD dwUser) 16/339 . lLoginID). return 0. nDVRPort). printf("\n"). g_bNetSDKInitFlag = FALSE. if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). pchDVRIP). //Logout device operation. dwUser). } void CALLBACK HaveReConnect(LLONG lLoginID. char *pchDVRIP. getchar(). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". printf("dwUser[%p]\n". } int main() { InitTest(). LONG nDVRPort. } return. LONG nDVRPort. char *pchDVRIP. //Cleaning up initialization resources. nDVRPort).3.3 to learn about them. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n".2. Please refer to Ch 2. Overview Device login. printf("\n"). When SDK initialization is complete. as well as can call login and logout interface at application layer to manually control reconnection business. can we operate other businesses.2. printf("lLoginID[0x%x]".2.2Device Login 2. outage) which makes device become offline. user need to login to Dahua device first. 2. { printf("Call HaveReConnect\n"). } printf("nDVRPort[%d]\n". as device registration is the precondition of other businesses.3. other function SDK follows will require this login ID.2 and 2. } 2. Login ID is the unique sign to recognize the login. 17/339 .1.3. Reconnection SDK can set device reconnection function. Login Method It has three login methods according to function and use scene: sync login. pchDVRIP). async login and auto registration login. lLoginID). Only when the sole valid login ID is generated. it will try to reconnect to device continuously within SDK until being online.2. Among the three login methods. When encounter some special conditions (offline. successfully initialization should be done. User can call SDK self-carried reconnection function. printf("dwUser[%p]\n". auto registration login don’t support reconnection. dwUser).1 Intro Precondition Before logining to device. you must call logout interface to logout user and release SDK resource. Login and logout should be used as a pair. NOTE 1.2 Interface Overview Interface Interface Description CLIENT_Init Interface for initilization CLIENT_Cleanup Interface for SDK clearance CLIENT_LoginEx2 Extensive interface 2 for sync login CLIENT_Logout Interface for logout device CLIENT_GetLastError Interface for getting error code after failed calling interface 2.2. In case of resource leak. you can start the login operation. your login is successful. Login business process flow sheet is shown in Figure 2-2. not for other manufuature s’ devices.2. When the login interface return a valid login ID. 18/339 . 2. otherwise the device will not be able to login successfully. The provided login operation is for Dahua devices only. 2.3 Process Instruction When client with SDK has fluent connection to Dahua device. Please use the login operation carefully. Last but not the least. 2. call CLIENT_Cleanup to release SDK resource. After successful login. 2. After successful initialization,call CLIENT_LoginEx2 to login device. 3.2.h> #include <stdio. users can realize business as needed.4 Example Codes #include <windows. 4.h " 19/339 . call CLIENT_Logout to logout device. After realizing needed business. SDK initialization. Start SDK initialization ClIENT_Ini() NO Successfully register user to device? Get the error code and CLIENT_LoginEx2 analyze the failure reason YES Realize function business Logout user CLIENT_Logout Release SDK resource CLIENT_Cleanup END Figure 2-2 login business process flow sheet Process description: 1.h> #include " dhnetsdk. 5. // This operation is optional. when offline device is reconnected successfully. \n"). 20/339 .h ") static LLONG g_lLoginHandle = 0L. DWORD dwUser) // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. LDWORD dwUser) //********************************************************************************* void InitTest() { // SDK Initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. } else { printf("Initialize client SDK done. static char g_szPasswd[64] = "admin". #pragma comment(lib . static WORD g_nPort = 37777. } //Get the SDK version information. \n"). char *pchDVRIP.4. return. 0). static char g_szUserName[64] = "admin". LONG nDVRPort. char *pchDVRIP.32. LONG nDVRPort. static char g_szDevIp[32] = "172. " dhnetsdk.25". static BOOL g_bSDKInitFlag = FALSE. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. CLIENT_SetNetworkParam(&stuNetParm). dwNetSdkVersion). //This operation is optional.it will try to log in three times. not decimal showns in header file. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. g_szPasswd. 0). // timeout value is 5 seconds int nTryTimes = 3. while(0 == g_lLoginHandle) { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. g_nPort. It is to print hexadecimal here. nTryTimes). stuNetParm. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . when device gets offline. printf("NetSDK version is [%d]\n".nConnectTime = 3000. &stDevInfoEx. NET_PARAM stuNetParm = {0}. //If timeout. you can find corresponding explanation in dhnetsdk. g_szDevIp . error code is 0x80000017. // Set device connection timeout value and trial times. CLIENT_SetNetworkParam(&stuNetParm). g_nPort . connection timeout value is 3000ms. CLIENT_SetAutoReconnect(&HaveReConnect.but recommended. EM_LOGIN_SPEC_CAP_TCP. //when login. please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function. //Set more network parameter. CLIENT_SetConnectTime(nWaitTime. } else 21/339 . g_szUserName. NET_DEVICEINFO_Ex stDevInfoEx = {0}. SDK will reconnect internally //This operation is optional. // set CLIENT_SetAutoReconnect interface. //This operation is optional int nWaitTime = 5000. Decimal number 23 is hexadecimal 0x17. if (0 == g_lLoginHandle) { // according to error code. &nError). int nError = 0.h.Once HaveReConnect is set. CLIENT_GetLastError()). NULL. } else { g_lLoginHandle = 0. g_szDevIp . g_bSDKInitFlag = FALSE. { printf("CLIENT_LoginEx2 %s[%d] Success\n" . some data is needed to be initialized to enable normal business function. } // The first time logining to device. } } // clean up resource if (TRUE == g_bSDKInitFlag) { CLIENT_Cleanup(). // logout device if (0 == g_lLoginHandle) { if (FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". It is recommended to wait for a while after login. printf("\n"). g_nPort). getchar(). Sleep(1000). } return. the waiting time va ries by devices. } int main() { 22/339 . } } void RunTest() { // business realization } void EndTest() { printf("input any key to quit! \n"). CLIENT_GetLastError()). DWORD dwUser) { printf("Call DisConnectFunc\n"). RunTest(). InitTest(). lLoginID). SDK can obtain main stream. contrast. Support: Setup of image saturation. return 0. user can save callback stream to achieve it or call SDK interface to realize it.1 Intro Real-time monitoring which is to get real time stream from storage device or front-end device is an important part of a surveillance system. } 2. 2.2 Interface Overview 23/339 . } printf("nDVRPort[%d]\n". LONG nDVRPort. EndTest(). Support: Save real-time record to specific folder. } //********************************************************************************* // commonly used callback set definition void CALLBACK DisConnectFunc(LONG lLoginID. printf("dwUser[%p]\n". nDVRPort). printf("lLoginID[0x%x]".3. printf("\n"). let user process by himself. encode. aux stream and the third stream from device. Support: Config front-end device bit stream resolution. After login to device. dwUser).3. pchDVRIP). Support: Callback real-time stream data to user. exposure and etc. Support: User conveys window handle. SDK analyzes stream and play directly. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". char *pchDVRIP.3 Real-time Monitoring 2. bit rate and etc. user decodes and plays with a third-party library. CLIENT_LoginEx2 Extensive interface 2 for Sync login. 2.3 Process Instruction Real-time surveillance business includes the following two methods: SDK decoding and playing SDK realizes real-time play by calling playsdk library in aux library.Interface Interface Description CLIENT_Init Interface for SDK Initialization. CLIENT_RealPlayEx Extensive Interface for starting real-time monitoring CLIENT_StopRealPlayEx Extensive interface for stopping real-time monitoring Callback function Extensive interface for setting CLIENT_SetRealDataCallBackEx real-time monitoring data CLIENT_Logout Interface for logout CLIENT_GetLastError Interface for getting the function execution error code 2.1 SDK Decoding and Playing Process SDK decoding and playing process flow sheet is shown below in Figure 2-3. The third party decoding and playing SDK only callback real-time monitoring data stream to user. CLIENT_Cleanup Interface for cleaning up SDK resources. 24/339 .3.3.3. After realizing needed business. call CLIENT_LoginEx2 to login device. 5. 6. 4. Start SDK initialization Login device CLIENT_LoginEx2 Strat real-time monitoring. After completing real-time monitoring use. parameter hWnd is a valid window handle. 25/339 . 3. Last but not the least. After successful login. After successful initialization. call CLIENT_RealPlayEx to start real-time monitoring. SDK initialization 2. call CLIENT_Cleanup to release SDK resources. call CLIENT_Logout to logout device. call CLIENT_StopRealPlayEx to stop real-time monitoring.hWnd is a valid value CLIENT_RealPlayEx Close real-time monitoring CLIENT_StopRealPlayEx Logout user CLIENT_Logout Clean up SDK resources CLIENT_Cleanup End Figure 2-3 SDK Decoding and Playing Process Process description: 1. 3. After successful login.2 The third Party Decoding and Playing Process The third party decoding and playing process is shown below in Figure 2-4. 3.3. 2. After successful initialization.2. call CLIENT_RealPlayEx to start real-time monitoring. call CLIENT_LoginEx2 to login device. Start SDK initialization Login device CLIENT_LoginEx2 Strat real-time monitoring. SDK initialization. hWnd is a 26/339 .hWnd is a valid value CLIENT_RealPlayEx Set callback function CLIENT_SetRealDataCallBack fRealDataBackEx Close real-time monitoring CLIENT_StopRealPlayEx Logout user CLIENT_Logout Clean up SDK resources CLIENT_Cleanup End Figure 2-4 The third party decoding and playing process Process description: 1. 3. // Before tcp connects port.the port need to keep with tcp port config in expected login static char g_szUserName[64] = "admin". call CLIENT_Cleanup to release SDK resources.valid window handle. 8. static LLONG g_lRealHandle = 0. Set real-time data callback function in CLIENT_SetRealDataCallBackEx.11. "dhnetsdk.4 Example Code 2.h> #include "dhnetsdk. 7. 2. 4.h" #pragma comment(lib . static LLONG g_lLoginHandle = 0L. It is not recommended to do any work but data stored and data delivered.lib") typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)(). //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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 27/339 . call CLIENT_Logout to logout device. or the performance will be affected when there are too many monitoring channels.h> #include <stdio.4. call CLIENT_StopRealPlayEx to stop real-time monitoring.88".1 SDK Decoding and Playing #include <windows. 5. Last but not the least. static char g_szPasswd[64] = "admin". Save real-time data in callback function for further use. PROCGETCONSOLEWINDOW GetConsoleWindow. static char g_szDevIp[32] = "172. After completing real-time monitoring.3. 6. static WORD g_nPort = 37777. static BOOL g_bNetSDKInitFlag = FALSE.1. After realizing needed business. char *pchDVRIP.it will try to log in three times. } else { printf("Initialize client SDK done. CLIENT_SetAutoReconnect(&HaveReConnect. LONG nDVRPort. when offline device is reconnected successfully. return. dwNetSdkVersion). // Set device connection timeout value and trial times. 0). when device gets offline. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. \n").Once HaveReConnect is set. LONG nDVRPort. DWORD dwUser). //Set more network parameter. int nWaitTime = 5000. LDWORD dwUser). DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). CLIENT_SetConnectTime(nWaitTime. // set CLIENT_SetAutoReconnect interface. but recommended. //This operation is optional. 28/339 . void CALLBACK DisConnectFunc(LONG lLoginID. //This operation is optional. 0). char *pchDVRIP. printf("NetSDK version is [%d]\n". // timeout value is 5 seconds int nTryTimes = 3. nTryTimes). //if timeout. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. } //Get the SDK version info // This operation is optional. SDK will reconnect internally //This operation is optional. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. //********************************************************************************* void InitTest() { // SDK Initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. \n"). error code is 0x80000017. NULL. not decimal showns in header file. g_nPort. CLIENT_SetNetworkParam(&stuNetParm). the waiting time varies by devices. } // The first time logining to device. int nError = 0. you can find corresponding explanation in dhnetsdk.h. It is recommended to wait for a while after login. connection timeout value is 3000ms. &nError). g_szDevIp . g_nPort). g_szDevIp . } } void RunTest() { // judge whether initialization is successful or not if (FALSE == g_bNetSDKInitFlag) { return. Decimal number 23 is hexadecimal 0x17. please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function. //when login. if(0 == g_lLoginHandle) { // according to error code. printf("\n"). } //judge whether login device or not 29/339 . g_nPort . g_szUserName. stuNetParm. NET_PARAM stuNetParm = {0}. EM_LOGIN_SPEC_CAP_TCP. } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . Sleep(1000). NET_DEVICEINFO_Ex stDevInfoEx = {0}. It is to print hexadecimal here.nConnectTime = 3000. some data is needed to be initialized to enable normal business function. while(0 == g_lLoginHandle) { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. g_szPasswd. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . &stDevInfoEx. CLIENT_GetLastError()). HWND hWnd = GetConsoleWindow(). getchar(). CLIENT_GetLastError()). CLIENT_GetLastError()). hWnd. emRealPlayType). DH_RealPlayType emRealPlayType = DH_RType_Realplay. // Close preview if (0 != g_lRealHandle) { if(FALSE == CLIENT_StopRealPlayEx(g_lRealHandle)) { printf("CLIENT_StopRealPlayEx Failed!Last Error[%x]\n" . if (0 == g_lRealHandle) { printf("CLIENT_RealPlayEx: failed! Error code: %x. // real-time monitoring g_lRealHandle = CLIENT_RealPlayEx(g_lLoginHandle. //start real-time monitoring int nChannelID = 0."GetConsoleWindow"). } } void EndTest() { printf("input any key to quit! \n").\n". } // realize real-time monitoring //Get the console window handle HMODULE hKernel32 = GetModuleHandle("kernel32"). printf("user can input any key to quit during real play! \n"). nChannelID. } } 30/339 . } else { g_lRealHandle = 0. Sleep(1000). // preview channel NO. if (0 == g_lLoginHandle) { return. GetConsoleWindow = (PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32. //Exit device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". } else { g_lLoginHandle = 0. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". } printf("nDVRPort[%d]\n". EndTest(). RunTest(). return 0. DWORD dwUser) { printf("Call DisConnectFunc\n"). CLIENT_GetLastError()). } //********************************************************************************* //commonly used callback functions definition void CALLBACK DisConnectFunc(LONG lLoginID. pchDVRIP). } } int main() { InitTest(). } 31/339 . printf("dwUser[%p]\n". g_bNetSDKInitFlag = FALSE. } } // Clean up initialization resources if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). printf("lLoginID[0x%x]". printf("\n"). char *pchDVRIP. lLoginID). LONG nDVRPort. nDVRPort). dwUser). printf("lLoginID[0x%x]".1.lib") static BOOL g_bNetSDKInitFlag = FALSE. char *pchDVRIP. static LLONG g_lLoginHandle = 0L. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n".h" #pragma comment(lib . char *pchDVRIP.2 The third party decoding and playing #include <windows. } printf("nDVRPort[%d]\n". LONG nDVRPort.88".4. void CALLBACK HaveReConnect(LLONG lLoginID. lLoginID).11. } 2. "dhnetsdk. nDVRPort). LDWORD dwUser) { printf("Call HaveReConnect\n"). pchDVRIP). LONG nDVRPort. static char g_szDevIp[32] = "172. printf("dwUser[%p]\n". DWORD dwUser). static LLONG g_lRealHandle = 0.3. printf("\n").h> #include "dhnetsdk. static char g_szPasswd[64] = "admin".h> #include <stdio. // Before tcp connects port. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. dwUser). 32/339 . static WORD g_nPort = 37777.the po rt need to keep with tcp port config in expected login static char g_szUserName[64] = "admin". printf("NetSDK version is [%d]\n". when offline device is reconnected successfully. // Set device connection timeout value and trial times. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). SDK will call function. LONG param. // Real-time monitoring data callback function // Not recommended to call SDK interface in SDK callback function. LDWORD dwUser). dwNetSdkVersion). LDWORD dwUser).Once HaveReConnect is set. When real-time data is received. LONG nDVRPort. do not encode or decode data directly. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. //********************************************************************************* void InitTest() { // SDK Initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. // The callback function is set by CLIENT_ SetRealDataCallBackEx. 0). void CALLBACK RealDataCallBackEx(LLONG lRealHandle. // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. 0). DWORD dwBufSize. BYTE *pBuffer. char *pchDVRIP. // set CLIENT_SetAutoReconnect interface. when device gets offline.but recommended. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. } //Get the SDK version information. //Recommend user only save data in this callback. SDK will reconnect internally //This operation is optional. CLIENT_SetAutoReconnect(&HaveReConnect. DWORD dwDataType. 33/339 . \n"). } else { printf("Initialize client SDK done. // This operation is optional. \n"). return. //In other words: Copy data to your storage and encode or decode data after leaving callback. printf("\n"). CLIENT_SetConnectTime(nWaitTime. g_szDevIp . //This operation is optional int nWaitTime = 5000. } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . you can find corresponding explanation in dhnetsdk. CLIENT_SetNetworkParam(&stuNetParm). g_szUserName. } // The first time logining to device.h. CLIENT_SetNetworkParam(&stuNetParm). It is recommended to wait for a while after login. please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function.nConnectTime = 3000. if (0 == g_lLoginHandle) { // according to error code. } 34/339 . Decimal number 23 is hexadecimal 0x17. Sleep(1000). It is to print hexadecimal here. NULL. //This operation is optional. some data is needed to be initialized to enable normal business function. //Set more network parameter. stuNetParm. error code is 0x80000017. NET_PARAM stuNetParm = {0}. g_szPasswd. g_nPort . g_nPort). &nError). &stDevInfoEx. NET_DEVICEINFO_Ex stDevInfoEx = {0}. the waiting time varies by devices. while(0 == g_lLoginHandle) { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. CLIENT_GetLastError()). int nError = 0. g_nPort.it will try to log in three times. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. g_szDevIp . nTryTimes). //If timeout. //when login. EM_LOGIN_SPEC_CAP_TCP. not decimal showns in header file. // timeout value is 5 seconds int nTryTimes = 3. connection timeout value is 3000ms. Sleep(1000). NULL. return. &RealDataCallBackEx. } // Real-time monitoring realization operation printf("user can input any key to quit during real play data callback! \n"). // real-time monitoring g_lRealHandle = CLIENT_RealPlayEx(g_lLoginHandle. } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. dwFlag)) { printf("CLIENT_SetRealDataCallBackEx: failed! Error code: %x. if (0 == g_lRealHandle) { printf("CLIENT_RealPlayEx: failed! Error code: %x. // preview channel number DH_RealPlayType emRealPlayType = DH_RType_Realplay. NULL. nChannelID. } } } void EndTest() { printf("input any key to quit! \n"). CLIENT_GetLastError()).\n". } if (0 == g_lLoginHandle) { return. emRealPlayType). //start real-time monitoring int nChannelID = 0. CLIENT_GetLastError()). 35/339 . if (FALSE == CLIENT_SetRealDataCallBackEx(g_lRealHandle. } else { DWORD dwFlag = 0x00000001.\n". return. g_bNetSDKInitFlag = FALSE. } } //Exit device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". } else { g_lRealHandle = 0. RunTest(). } } int main() { InitTest(). //Close preview if (0 != g_lRealHandle) { if (FALSE == CLIENT_StopRealPlayEx(g_lRealHandle)) { printf("CLIENT_StopRealPlayEx Failed. g_lRealHandle[%x]!Last Error[%x]\n" . getchar(). CLIENT_GetLastError()). return 0. g_lRealHandle. CLIENT_GetLastError()). if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). } } // Clean up initialization resources. EndTest(). } else { g_lLoginHandle = 0. } //********************************************************************************* 36/339 . LDWORD dwUser) { printf("Call HaveReConnect\n"). //commonly used callback functions definition void CALLBACK DisConnectFunc(LONG lLoginID. dwUser). printf("dwUser[%p]\n". pchDVRIP). printf("lLoginID[0x%x]". if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". } printf("nDVRPort[%d]\n". pBuffer[%p]. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". dwUser[%p]\n". printf("lLoginID[0x%x]". } void CALLBACK HaveReConnect(LLONG lLoginID. dwBufSize[%d]. LDWORD dwUser) { // if more than one real-time monitoring use same data callback. lLoginID). param: lRealHandle[%p]. LONG nDVRPort. if (lRealHandle == g_lRealHandle) { switch(dwDataType) { case 0: //original A/V hybrid data printf("receive real data. DWORD dwUser) { printf("Call DisConnectFunc\n"). dwUser). } void CALLBACK RealDataCallBackEx(LLONG lRealHandle. pchDVRIP). dwDataType. char *pchDVRIP. 37/339 . printf("\n"). dwDataType[%d]. param[%p]. nDVRPort). param. pBuffer. lLoginID). DWORD dwDataType. printf("dwUser[%p]\n". LONG nDVRPort. printf("\n"). } printf("nDVRPort[%d]\n". DWORD dwBufSize. dwUser). dwBufSize. nDVRPort). we can judge by parameter lRealHandle. LONG param. lRealHandle. char *pchDVRIP. BYTE *pBuffer. please refer to Ch 2. Playback function includes several operations. record playback have two methods: SDK decoding playback and third-party decoding playback. draggering play and etc. such as play.in order to locate target video for research from a large quantity of videos.slow play. pause. break.3 for details.4. case 4: //original audio data break. Record Playback Method According to the different decoding method selected by users. case 3: //pcm audio data break.1 Intro Overview Record playback is to playback record of certain channels during specific periods. default: break.4. quick play. case 2: //yuv data break. } } } 2. 38/339 . case 1: //standard video data break.4Record Playback 2. r ecord playback have the following two methods: SDK decoding and playing back Firstly user inputs start time. CLIENT_StopPlayBack Interface for stopping record playback CLIENT_GetPlayBackOsdTime Interface for getting playback OSD time CLIENT_PausePlayBack Interface for pause or restoring playback Interface for fast play. playback. Increasing frame rate by CLIENT_FastPlayBack 1x Interface for slow play. 39/339 . right and etc.2 Interface Overview Interface Interface Description CLIENT_Init Interface for SDK initialization CLIENT_Cleanup Interface for cleaning up SDK resources CLIENT_LoginEx2 Extensive interface 2 for Sync login CLIENT_PlayBackByTimeEx Extensive interface for playback by time Interface for setting work mode such as audio CLIENT_SetDeviceMode intercom. Decreasing frame rate by CLIENT_SlowPlayBack 1x CLIENT_NormalPlayBack Interface for restoring normal play speed Interface for positioning record playback start CLIENT_SeekPlayBack point CLIENT_Logout Interface for logout Interface for getting error code after failed calling CLIENT_GetLastError interface 2.4.2.4.3 Process Instruction According to the different decoding method selected by users. 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. the data is called back to user for saving by playback stream callback function. 40/339 . After leaving callback function. 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.4.1 SDK Decoding and Playing Back SDK Decoding and Playing back process flow sheet is shown below in Figure 2-5. After SDK re ceives playback stream data.3. user calls a third-party library to analyze and display the saved stream data. 2. START SDK initialization Login to device CLIENT_LoginEx2 Set playback stream type (DH_RECORD_STREAM_TYPE) CLIENT_SetDeviceMode Set playback record file type (DH_RECORD_TYPE) CLIENT_SetDeviceMode Start playback Parameter hWind is a valid window handle value CLIENT_PlayBackByTimeEx CLIENT_SlowPlayBack – slow play CLIENT_FastPlayBack – fast play CLIENT_NormalPlayBack – nomal speed play CLIENT_PausePlayBack – pause/restore CLIENT_SeekPlayBack – play by dragging Stop playback CLIENT_StopPlayBack Logout user CLIENT_Logout Release SDK resource CLIENT_Cleanup END Figure 2-5 SDK Decoding and Playing back process flow sheet 41/339 . call CLIENT_SetDeviceMode twice to separately set playback stream type and playback record file type. call CLIENT_Cleanup to release SDK resource. Call CLIENT_PlayBackByTimeEx to start playback. 6. user can call CLIENT_SlowPlayBack to slowly play. After realizing needed business.3. 42/339 . 2. call CLIENT_Logout to logout device.2 The Third-party Decoding and Playing Back The third-party library decoding and playing back flow sheet is shown in Figure 2-6. After successful login. CLIENT_PausePlayBack to pause/store play. 4. 2. 8. 7. 5. call CLIENT_StopPlayBack to stop playback. Last but not the least. Process description: 1. During playback. SDK initialization. CLIENT_SeekPlayBack to play by dragging. parameter hWnd is set to valid window handle value.4. After playback is done. 3. After successful initialization.CLIENT_FastPlayBack to fast play , CLIENT_NormalPlayBack to play at normal speed. call CLIENT_LoginEx2 to login device. START SDK initialization Login to device CLIENT_LoginEx2 Set playback stream type Parameter emType is (DH_RECORD_STREAM_TYPE CLIENT_SetDeviceMode Set playback record file type Parameter emType is DH_RECORD_TYPE CLIENT_SetDeviceMode Start playback Parameter hWind is set to NULL Callback function Parameter fDownLoadDataCallBack is valid pointer pointing to callback function fDataCallBack CLIENT_PlayBackByTimeEx CLIENT_SlowPlayBack – slow play CLIENT_FastPlayBack – fast play CLIENT_NormalPlayBack– nomal speed play CLIENT_PausePlayBack – pause/restore CLIENT_SeekPlayBack – play by dragging These interface can be used together with a third-party library interface Stop playback CLIENT_StopPlayBack Logout user CLIENT_Logout Release SDK resource CLIENT_Cleanup END Figure 2-6 The third-party library decoding and playing back flow sheet 43/339 . h" #pragma comment(lib . CLIENT_SeekPlayBack to play by dragging together with the third-party interfaces. static WORD g_nPort = 37777. call CLIENT_LoginEx2 to login device.13". 4. parameter fDownLoadDataCallBack is a valid pointer pointing to a callback function. After leaving callback function. 7. call CLIENT_Cleanup to release SDK resource. 6.4. parameter hWnd is set to NULL. After SDK receives playback stream data. call CLIENT_PlayBackByTimeEx to start playback. Process description: 1. the data is called back to user for saving by playback stream callback function fDownLoadDataCallBack. After successful initialization. After successful login. During playback. user calls a third-party library to analyze and display the saved stream data. static BOOL g_bNetSDKInitFlag = FALSE. call CLIENT_StopPlayBack to stop playback. SDK initialization. user can call CLIENT_SlowPlayBack to slowly play. static LLONG g_lLoginHandle = 0L. After realizing needed business.CLIENT_FastPlayBack to fast play. 2.1 SDK Decoding and Playing Back #include <windows. After playback is done. 44/339 . After successful login.1. static char g_szUserName[64] = "admin". 5. call CLIENT_SetDeviceMode twice to separately set playback stream type and playback record file type.CLIENT_NormalPlayBack to play at normal speed.4.h> #include "dhnetsdk. static char g_szDevIp[32] = "172. static LLONG g_lPlayHandle = 0L.h> #include <stdio.4. 9. call CLIENT_Logout to logout device. 3.lib") extern "C" HWND WINAPI GetConsoleWindow(). 2.11. Last but not the least. "dhnetsdk.4 Example Code 2. 8.CLIENT_PausePlayBack to pause/store play. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). LONG nDVRPort. char *pchDVRIP.Once HaveReConnect is set. printf("NetSDK version is [%d]\n". when offline device is reconnected successfully. 0). // Set device connection timeout value and trial times. } //Get the SDK version info // This operation is optional. SDK will reconnect internally //This operation is optional. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. CLIENT_SetAutoReconnect(&HaveReConnect. //********************************************************************************* void InitTest() { // SDK Initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. when device gets offline. return. static char g_szPasswd[64] = "admin". dwNetSdkVersion). \n"). 45/339 . \n"). 0). if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. LDWORD dwUser). LONG nDVRPort. // set CLIENT_SetAutoReconnect interface. DWORD dwUser). // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. but recommended. char *pchDVRIP. } else { printf("Initialize client SDK done. EM_LOGIN_SPEC_CAP_TCP. some data is needed to be initialized to enable normal business function. } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . nTryTimes). stuNetParm. g_szUserName. //Set more network parameter. g_nPort . Decimal number 23 is hexadecimal 0x17. g_szDevIp .it will try to log in three times. //This operation is optional. } } 46/339 . CLIENT_SetConnectTime(nWaitTime. &stDevInfoEx. // when login. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. // timeout value is 5 seconds int nTryTimes = 3. int nWaitTime = 5000. if(0 == g_lLoginHandle) { // according to error code. you can find corresponding explanation in dhnetsdk. printf("\n"). Sleep(1000).nWaittime = 3000. CLIENT_GetLastError()). It is recommended to wait for a while after login.h. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . It is to print hexadecimal here. //if timeout. CLIENT_SetNetworkParam(&stuNetParm). NET_PARAM stuNetParm = {0}. int nError = 0. not decimal showns in header file. g_nPort. } // The first time logining to device. &nError). NULL. NET_DEVICEINFO_Ex stDevInfoEx = {0}. g_szPasswd. connection timeout value is 3000ms. error code is 0x80000017. //This operation is optional. g_nPort). please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function. the waiting time varies by devices. g_szDevIp . while(0 == g_lLoginHandle) { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. dwDay = 21.dwYear = 2015. &stuStartTime. hWnd. // 0-main/sub stream. CLIENT_GetLastError()). // all records CLIENT_SetDeviceMode(g_lLoginHandle. NULL).dwMonth = 11. stuStopTime. stuStopTime. NET_TIME stuStartTime = {0}. nChannelID. void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return.dwMonth = 11. 47/339 . // channel NO. NULL. } if (0 == g_lLoginHandle) { return.2-sub stream CLIENT_SetDeviceMode(g_lLoginHandle. if (0 == g_lPlayHandle) { printf("CLIENT_PlayBackByTimeEx: failed! Error code: %x. DH_RECORD_STREAM_TYPE.\n". NET_TIME stuStopTime = {0}. DH_RECORD_TYPE. &stuStopTime. stuStartTime.dwYear = 2015. NULL. NULL.dwDay = 20. &nStreamType). stuStopTime. stuStartTime. // set playback record file type NET_RECORD_TYPE emFileType = NET_RECORD_TYPE_ALL.1-main stream. // set playback stream type int nStreamType = 0. //start record playback int nChannelID = 0. } // record playback function // get console window handle HWND hWnd = GetConsoleWindow(). &emFileType). stuStartTime. g_lPlayHandle = CLIENT_PlayBackByTimeEx(g_lLoginHandle. // CLIENT_SlowPlayBack to slowly play /* example code if (FALSE == CLIENT_SlowPlayBack (g_lPlayHandle)) { printf("CLIENT_SlowPlayBack Failed. g_lPlayHandle. CLIENT_GetLastError()). CLIENT_GetLastError()). TRUE)) { printf("CLIENT_PausePlayBack Failed. g_lPlayHandle[%x]!Last Error[%x]\n" . g_lPlayHandle. CLIENT_GetLastError()). } */ // CLIENT_PausePlayBack to pause/restore play /* example code if (FALSE == CLIENT_PausePlayBack (g_lPlayHandle. CLIENT_GetLastError()). we cannot show user record playback and playback control at the same time. } // user can control palyback according to needs // due to it is a console demo. g_lPlayHandle[%x]!Last Error[%x]\n" . } */ // CLIENT_NormalPlayBack to play at normal speed /* example code if (FALSE == CLIENT_NormalPlayBack (g_lPlayHandle)) { printf("CLIENT_NormalPlayBack Failed. g_lPlayHandle. g_lPlayHandle. g_lPlayHandle[%x]!Last Error[%x]\n" . g_lPlayHandle[%x]!Last Error[%x]\n" . } */ // CLIENT_FastPlayBack to fast play /* example code if (FALSE == CLIENT_FastPlayBack (g_lPlayHandle)) { printf("CLIENT_FastPlayBack Failed. } */ // CLIENT_SeekPlayBack to play by dragging 48/339 . here are some examples for reference. g_lPlayHandle. g_lPlayHandle[%x]!Last Error[%x]\n" . } else { g_lPlayHandle = 0. g_lPlayHandle. CLIENT_GetLastError()). 49/339 . g_lRealHandle[%x]!Last Error[%x]\n" . // drag to 2*60*60s after stuStartTime to start play if (FALSE == CLIENT_SeekPlayBack (g_lPlayHandle. CLIENT_GetLastError()). 0)) { printf("CLIENT_SeekPlayBack Failed. } } // logout device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". /* example code int nOffsetSeconds = 2 * 60 * 60. } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). } else { g_lLoginHandle = 0. CLIENT_GetLastError()). nOffsetSeconds. getchar(). // close playback if (0 != g_lPlayHandle) { if (FALSE == CLIENT_StopPlayBack(g_lPlayHandle)) { printf("CLIENT_StopPlayBack Failed. } */ } void EndTest() { printf("input any key to quit! \n"). pchDVRIP). lLoginID). } printf("nDVRPort[%d]\n". if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". return 0. DWORD dwUser) { printf("Call DisConnectFunc\n"). printf("lLoginID[0x%x]". } 50/339 . pchDVRIP). lLoginID). EndTest(). printf("\n"). } return. g_bNetSDKInitFlag = FALSE. } printf("nDVRPort[%d]\n". } int main() { InitTest(). dwUser). } //********************************************************************************* // commonly used callback set definition void CALLBACK DisConnectFunc(LLONG lLoginID. nDVRPort). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". RunTest(). LDWORD dwUser) { printf("Call HaveReConnect\n"). char *pchDVRIP. nDVRPort). dwUser). char *pchDVRIP. } void CALLBACK HaveReConnect(LLONG lLoginID. LONG nDVRPort. printf("dwUser[%p]\n". LONG nDVRPort. printf("\n"). printf("dwUser[%p]\n". printf("lLoginID[0x%x]". DWORD dwUser). static char g_szPasswd[64] = "admin". static char g_szUserName[64] = "admin". // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect.lib") static BOOL g_bNetSDKInitFlag = FALSE. SDK will call this function. // playback data callback function // It’s not recommended to call SDK interfaces in this callback function //when parameter hWnd is NULL. 1:means this callback is successful.2 The Third-party Decoding and Playing Back #include <windows. LONG nDVRPort. static char g_szDevIp[32] = "172.4. next callback will return follow-up data. when playback data is received. // playback progress callback function // It’s not recommended to call SDK interfaces in this callback function // set this callback function in CLIENT_PlayBackByTimeEx.2. DWORD dwDownLoadSize.h> #include <stdio. static WORD g_nPort = 37777. LONG nDVRPort.11.h" #pragma comment(lib .6". when offline device is reconnected successfully.1. char *pchDVRIP. LDWORD dwUser). //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. LDWORD dwUser). char *pchDVRIP. next callback will return the same data. static LLONG g_lPlayHandle = 0L.h> #include "dhnetsdk. "dhnetsdk. 51/339 . DWORD dwTotalSize. void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle. the function return 0: means this callback failed.4. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. static LLONG g_lLoginHandle = 0L. nTryTimes). SDK will call this function. when playback data is received. // Set device connection timeout value and trial times. 0). nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. \n"). dwNetSdkVersion). \n"). when devic e gets offline. but recommended. } else { printf("Initialize client SDK done. BYTE *pBuffer. //if timeout. DWORD dwBufSize. and next time callback will return follow-up data // set this callback function in CLIENT_PlayBackByTimeEx. // timeout value is 5 seconds int nTryTimes = 3. //This operation is optional. //Set more network parameter. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). // when parameter hWnd is’t NULL. LDWORD dwUser). 0). //************************************************************************************* void InitTest() { // SDK Initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail.it will try to log in three times. NET_PARAM stuNetParm = {0}. int CALLBACK DataCallBack(LLONG lRealHandle. int nWaitTime = 5000. return. CLIENT_SetAutoReconnect(&HaveReConnect. SDK will reconnect internally //This operation is optional.Once HaveReConnect is set. } //Get the SDK version info // This operation is optional. 52/339 . CLIENT_SetConnectTime(nWaitTime. printf("NetSDK version is [%d]\n". //This operation is optional. DWORD dwDataType. // set CLIENT_SetAutoReconnect interface. it will be treated as callback successful no matter what the return value is. } } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. EM_LOGIN_SPEC_CAP_TCP. the waiting time varies by devices. you can find corresponding explanation in dhnetsdk. &nError). g_szPasswd. } // The first time logining to device. while(0 == g_lLoginHandle) { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. connection timeout value is 3000ms. It is to print hexadecimal here. g_nPort). g_szDevIp . please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function. Sleep(1000). g_szDevIp . } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . &stDevInfoEx.nWaittime = 3000. int nError = 0. CLIENT_GetLastError()). if(0 == g_lLoginHandle) { // according to error code. CLIENT_SetNetworkParam(&stuNetParm). NULL. printf("\n").h. not decimal showns in header file. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . g_szUserName. Decimal number 23 is hexadecimal 0x17. } if (0 == g_lLoginHandle) { return. It is recommended to wait for a while after login. g_nPort . g_nPort. // when login. 53/339 . stuNetParm. error code is 0x80000017. NET_DEVICEINFO_Ex stDevInfoEx = {0}. some data is needed to be in itialized to enable normal business function. &nStreamType). if (g_lPlayHandle == 0) { printf("CLIENT_PlayBackByTimeEx: failed! Error code: %x. // channel NO.dwMonth = 11. } // record playback function // set playback stream type int nStreamType = 0.\n". we cannot show user record playback and playback control at the same time. when a user calls SDK playback control interface. he needs to call control interface of third-party library at the same time // due to it is a console demo. &emFileType). stuStartTime. // parameter hWnd need to be NULL // parameter fDownLoadDataCallBack need to be a valid pointer pointing to a callback function g_lPlayHandle = CLIENT_PlayBackByTimeEx(g_lLoginHandle. CLIENT_GetLastError()). NULL). stuStopTime. stuStopTime. here are some examples for reference. } // user control playback according to need // due to it is third-party library decoding. NET_TIME stuStopTime = {0}. stuStartTime.dwYear = 2015. // all records CLIENT_SetDeviceMode(g_lLoginHandle. &DataCallBack. // CLIENT_SlowPlayBack to slowly play /* example code 54/339 . NULL. // 0-main/sub stream. stuStopTime. stuStartTime. DH_RECORD_TYPE.1-main stream. DH_RECORD_STREAM_TYPE. //start record playback int nChannelID = 0. &DownLoadPosCallBack.dwDay = 20.dwMonth = 11. &stuStopTime. // set playback record file type NET_RECORD_TYPE emFileType = NET_RECORD_TYPE_ALL.2-sub stream CLIENT_SetDeviceMode(g_lLoginHandle. nChannelID. NULL.dwDay = 21. &stuStartTime. NET_TIME stuStartTime = {0}.dwYear = 2015. } //the third-party interface call */ // CLIENT_FastPlayBack to fast play /* example code if (FALSE == CLIENT_FastPlayBack (g_lPlayHandle)) { printf("CLIENT_FastPlayBack Failed. CLIENT_GetLastError()). if (FALSE == CLIENT_SlowPlayBack (g_lPlayHandle)) { printf("CLIENT_SlowPlayBack Failed. g_lPlayHandle. TRUE)) { printf("CLIENT_PausePlayBack Failed. g_lPlayHandle[%x]!Last Error[%x]\n" . g_lPlayHandle[%x]!Last Error[%x]\n" . g_lPlayHandle. CLIENT_GetLastError()). g_lPlayHandle[%x]!Last Error[%x]\n" . g_lPlayHandle[%x]!Last Error[%x]\n" . CLIENT_GetLastError()). } // the third-party interface call */ // CLIENT_NormalPlayBack to play at nomal speed /* example code if (FALSE == CLIENT_NormalPlayBack (g_lPlayHandle)) { printf("CLIENT_NormalPlayBack Failed. } // the third-party interface call */ // CLIENT_SeekPlayBack to play by dragging 55/339 . CLIENT_GetLastError()). g_lPlayHandle. g_lPlayHandle. } //the third-party interface call */ // CLIENT_PausePlayBack to pause/restore play /* example code if (FALSE == CLIENT_PausePlayBack (g_lPlayHandle. /* example code int nOffsetSeconds = 2 * 60 * 60. CLIENT_GetLastError()). } else { g_lLoginHandle = 0. CLIENT_GetLastError()). g_lPlayHandle. } //the third-party interface call */ } void EndTest() { printf("input any key to quit! \n"). nOffsetSeconds. CLIENT_GetLastError()). // close playback if (0 != g_lPlayHandle) { if (FALSE == CLIENT_StopPlayBack(g_lPlayHandle)) { printf("CLIENT_StopPlayBack Failed. 0)) { printf("CLIENT_SeekPlayBack Failed. g_lPlayHandle. // drag to 2*60*60s after stuStartTime to start play if (FALSE == CLIENT_SeekPlayBack (g_lPlayHandle. getchar(). } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) 56/339 . } } // logout device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". g_lPlayHandle[%x]!Last Error[%x]\n" . g_lRealHandle[%x]!Last Error[%x]\n" . } else { g_lPlayHandle = 0. } int main() { InitTest(). } void CALLBACK HaveReConnect(LLONG lLoginID. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". pchDVRIP). LDWORD dwUser) { printf("Call HaveReConnect\n"). } //********************************************************************************* // commonly used callback set definition void CALLBACK DisConnectFunc(LLONG lLoginID. RunTest(). printf("lLoginID[0x%x]". char *pchDVRIP. EndTest(). pchDVRIP). DWORD dwUser) { printf("Call DisConnectFunc\n"). { CLIENT_Cleanup(). dwUser). printf("lLoginID[0x%x]". char *pchDVRIP. } printf("nDVRPort[%d]\n". if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". return 0. nDVRPort). g_bNetSDKInitFlag = FALSE. } return. printf("dwUser[%p]\n". lLoginID). LONG nDVRPort. lLoginID). LONG nDVRPort. printf("\n"). 57/339 . LDWORD dwUser) { int nRet = 0. printf("call DataCallBack\n"). } void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle. printf("dwUser[%p]\n". printf("dwDataType[%d]\n". dwUser). BYTE *pBuffer. printf("dwTotalSize[%d]\n". printf("dwBufSize[%d]\n". pBuffer). } printf("nDVRPort[%d]\n". printf("dwUser[%p]\n". dwDataType). lRealHandle). switch(dwDataType) { case 0: //Original data // users can save stream data here for further process such as decoding and 58/339 . nDVRPort). LDWORD dwUser) { // If different playback/download uses the same process callback function . // If different playback/download uses the same callback function. DWORD dwDownLoadSize. please be careful printf("lPlayHandle[%p]\n". DWORD dwTotalSize. dwTotalSize). dwBufSize). we can judge by parameter lRealHandle if(lRealHandle == g_lPlayHandle) { BOOL bSuccess = TRUE. printf("\n"). printf("\n"). printf("\n"). dwDownLoadSize). DWORD dwBufSize. we can judge by parameter 1PlayHandle if (lPlayHandle == g_lPlayHandle) { printf("lPlayHandle[%p]\n". printf("dwUser[%p]\n". dwUser). // the following printing will cause frequently screen refresh. dwUser). lPlayHandle). DWORD dwDataType. printf("dwDownLoadSize[%d]\n". } } int CALLBACK DataCallBack(LLONG lRealHandle. printf("pBuffer[%p]\n". default: break. bank. It allows user to download records in currently selected channel. and export the records to local hard disk or U disk.5. transferring after getting out of callback function nRet = 1. case 3: //pcm audio data break. Therefore.1 Intro Video monitoring system is widely used in safe city. Record download process is that users get the records from storage device and save them to local.5Record Download 2. subway. factory and etc. record download is a commonly used application module. } 2. case 2: //yuv data break.// break. } } return nRet. case 1: //Standard video data break. airport. case 4: //Original audio data break. it’s needed to download records to leaders、police and media as evidence for further use. 59/339 . When something happened. 5.2 Interface Overview Interface Interface Description CLIENT_Init Interface for SDK initialization CLIENT_Cleanup Interface for cleaning up SDK resources CLIENT_LoginEx2 Extensive interface 2 for Sync login Interface for setting work mode of device audio intercom. user can also provide a callback function pointer. Record Download Methods Record download have two methods: download by file and download by time.3. At the same time. CLIENT_SetDeviceMode playback and right CLIENT_QueryRecordFile Interface for searching all files in a specified time period CLIENT_FindFile Interface for opening record search handle CLIENT_FindNextFile Interface for searching record file CLIENT_FindClose Interface for closing record search handle CLIENT_DownloadByRecordFileEx Extensive interface for downloading record by file CLIENT_DownloadByTimeEx Extensive interface for downloading record by time CLIENT_GetDownloadPos Interface for searching record download process CLIENT_StopDownload Interface for stopping record download CLIENT_Logout Interface for logout Interface for getting error code after failed calling CLIENT_GetLastError interface 2. 2.5.5. please refer to Ch 2.3 Process Instruction Record download includes the following two methods: Download by file Users need to point the downloaded record file’s information and SDK can download the specified file and save it to a specified file. so that SDK send the downloaded file info to users for further use by callback 60/339 . user can also provide a callback function pointer. so that SDK send the downloaded file info to users for further use by callback function.3. Download by time User will need to point the start time and end time of the download file. At the same time.1 Download by File Download by file process flow sheet is shown below in Figure 2-7. 2. SDK can download the specified file in a specified time period and save it to a specified file.function. 61/339 .5. START SDK initialization ClIENT_Ini() Login to device CLIENT_LoginEx2 Set record stream type during search CLIENT_SetDeviceMode Get the single record file info CLIENT_QueryRecordFile Get record search handle Close record search handle Download by file CLIENT_DownByRecordFileEx Search record download progress CLIENT_GetDownLoadPos Stop download CLIENT_StopDownload Logout user CLIENT_Logout optional mandatory Release SDK resource CLIENT_Cleanup END Figure 2-7 Download by file process flow sheet 62/339 . Process description: 1. SDK initialization. 2. After successful initialization,call CLIENT_LoginEx2 to login device. 3. Set record stream type in Call CLIENT_SetDeviceMode. Parameter EmType is DH_RECORD_STREAM_TYPE which is recommended to set to “0-main/sub stream”,or some devices will not return a result. If you only need main stream record, you can filter out sub stream record info in result. Please refer to Appendix 2 “EM_USEDEV_MODE” enumeration note. 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. Call CLIENT_QueryRecordFile to get all record files info in a specified period. 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. 6. During the download, call CLIENT_GetDownloadPos to search record download progress as needed. 7. After download is finished, call CLIENT_StopDownload to stop download. 8. After business is finished, call CLIENT_Logout to logout device. 9. Last but not the least, call CLIENT_Cleanup to release SDK resource. 2.5.3.2 Download by Time Download by time process flow sheet is shown in Figure 2-8. 63/339 START SDK initialization CLIENT_init Login to device CLIENT_LoginEx2 Set record stream type CLIENT_SetDeviceMode Download by time CLIENT_DownloadByTimeEx Stop download CLIENT_StopDownload Logout user CLIENT_Logout Release SDK resource CLIENT_Cleanup END Figure 2-8 Download by time process flow sheet Process description: 1. SDK initialization 2. After successful initialization,call CLIENT_LoginEx2 to login device. 3. Set record stream type in Call CLIENT_SetDeviceMode. Parameter EmType is DH_RECORD_STREAM_TYPE,Please refer to Appendix 2 “EM_USEDEV_MODE” enumeration note. 64/339 4. Call CLIENT_DownloadByTimeEx to start to download by time. At least one input parameter sSavedFileName and fDownLoadDataCallBack is valid. 5. After download is finished, call CLIENT_StopDownload to stop download. We can stop download when download is finished or when download is still in progress as needed. 6. After business is finished, call CLIENT_Logout to logout device. 7. Last but not the least, call CLIENT_Cleanup to release SDK resource. 2.5.4 Example Code 2.5.4.1 Download by File #include <windows.h> #include <stdio.h> #include <vector> #include "dhnetsdk.h" #pragma comment(lib , "dhnetsdk.lib") static BOOL g_bNetSDKInitFlag = FALSE; static LLONG g_lLoginHandle = 0L; static LLONG g_lDownloadHandle = 0L; static char g_szDevIp[32] = "172.11.1.30"; static WORD g_nPort = 37777; static char g_szUserName[64] = "admin"; static char g_szPasswd[64] = "admin"; static const int g_nMaxRecordFileCount = 5000; //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID, char *pchDVRIP, LONG nDVRPort, DWORD dwUser); // callback function used after device is reconnected successfully // It’s 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 65/339 void CALLBACK HaveReConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser); // playback/download progress callback function // It’s not recommended to call SDK interfaces in this callback function // dwDownLoadSize: -1 means playback/download finished,-2 means failed to write file,other value means valid data // Set this callback function in CLIENT_DownloadByRecordFileEx. When SDK receives playback/downloaded data, SDK will call this function. void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD dwDownLoadSize, LDWORD dwUser); // playback/download data callback function // It’s not recommended to call SDK interfaces in this callback function // playback:return value:0 means this playback failed,next callback will return the same data, 1 means this callback successful, next callback will return the following data // Download:no matter what return from the callback function, it will be treated as callback is successful, next callback will return the following data // Set this callback function in CLIENT_DownloadByRecordFileEx. When SDK receives playback/downloaded data, SDK will call this function. int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, LDWORD dwUser); //********************************************************************************* void InitTest() { // SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc, 0); if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail; \n"); return; } else { printf("Initialize client SDK done; \n"); } // get SDK version info // this operation is optional DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(); printf("NetSDK version is [%d]\n", dwNetSdkVersion); 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 connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000; // timeout time is set to 5s 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); NET_DEVICEINFO_Ex stDevInfoEx = {0}; int nError = 0; while(0 == g_lLoginHandle) { // login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp, g_nPort, g_szUserName, g_szPasswd, EM_LOGIN_SPEC_CAP_TCP, NULL, &stDevInfoEx, &nError); 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 once;2,take 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; NET_TIME stuStopTime = {0}; stuStopTime.dwYear = 2015; stuStopTime.dwMonth = 9; stuStopTime.dwDay = 30; int lFindHandle = CLIENT_FindFile(g_lLoginHandle, nChannelID, 0, NULL, &stuStartTime, &stuStopTime, FALSE, 5000); if (0 == lFindHandle) { printf("CLIENT_FindFile Failed!Last Error[%x]\n",CLIENT_GetLastError()); return; 68/339 NULL). if (nFileIndex > 0) { memcpy(&stuNetFileInfo. DownLoadPosCallBack.dav". for (int nFileIndex = 0. if (0 == g_lDownloadHandle) 69/339 . NULL. } // set the first file queried as download file NET_RECORDFILE_INFO stuNetFileInfo. return\n"). sizeof(stuNetFileInfo)). DataCallBack. if (0 == result)// finish taking record files info { break. break. } else { printf("no record. &bufFileInfo[nFileIndex]).CLIENT_GetLastError()). &stuNetFileInfo. "test. nFileIndex < g_nMaxRecordFileCount. } // record file download // start record download // at least one of the two parameters sSavedFileName and fDownLoadDataCallBack is valid // the downloaded data is save to parameter sSavedFileName or save to callback function as needed g_lDownloadHandle = CLIENT_DownloadByRecordFileEx(g_lLoginHandle. } // demo std::vector<NET_RECORDFILE_INFO> bufFileInfo(g_nMaxRecordFileCount). ++nFileIndex) { int result = CLIENT_FindNextFile(lFindHandle. return. (void *)&bufFileInfo[0]. } } //stop search if(0 != lFindHandle) { CLIENT_FindClose(lFindHandle). } else if (1 != result)// parameter error { printf("CLIENT_FindNextFile Failed!Last Error[%x]\n". } else { g_lDownloadHandle = 0.we can call this interface after download ends or during download. } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). g_lDownloadHandle. } } void EndTest() { printf("input any key to quit! \n"). CLIENT_GetLastError()). } } // logout device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". } return. 70/339 . // stop download. } else { g_lLoginHandle = 0. CLIENT_GetLastError()). g_lDownloadHandle[%x]!Last Error[%x]\n" . CLIENT_GetLastError()). { printf("CLIENT_DownloadByRecordFileEx: failed! Error code: %x. g_bNetSDKInitFlag = FALSE.\n". getchar(). if (0 != g_lDownloadHandle) { if (FALSE == CLIENT_StopDownload(g_lDownloadHandle)) { printf("CLIENT_StopDownload Failed. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". printf("\n"). nDVRPort). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". pchDVRIP). EndTest(). LDWORD dwUser) { printf("Call HaveReConnect\n"). } printf("nDVRPort[%d]\n". printf("lLoginID[0x%x]". } int main() { InitTest(). printf("dwUser[%p]\n". char *pchDVRIP. lLoginID). pchDVRIP). printf("\n"). DWORD dwDownLoadSize. } void CALLBACK DownLoadPosCallBack(LLONG lPlayHandle. char *pchDVRIP. dwUser). printf("dwUser[%p]\n". lLoginID). DWORD dwUser) { printf("Call DisConnectFunc\n"). LDWORD dwUser) { 71/339 . } //********************************************************************************* // commonly used callback set definition void CALLBACK DisConnectFunc(LONG lLoginID. return 0. } void CALLBACK HaveReConnect(LLONG lLoginID. nDVRPort). printf("lLoginID[0x%x]". LONG nDVRPort. dwUser). LONG nDVRPort. RunTest(). } printf("nDVRPort[%d]\n". DWORD dwTotalSize. printf("dwUser[%p]\n". printf("dwBufSize[%d]\n". lPlayHandle). we can judge by parameter 1RealHandle if(lRealHandle == g_lDownloadHandle) { printf("lPlayHandle[%p]\n". printf("\n"). printf("\n"). we can judge by parameter 1PlayHandle if (lPlayHandle == g_lDownloadHandle) { printf("lPlayHandle[%p]\n". case 1: //Standard video data break. DWORD dwBufSize. dwUser). case 2: //yuv data 72/339 . printf("dwTotalSize[%d]\n". printf("pBuffer[%p]\n". printf("call DataCallBack\n"). printf("dwUser[%p]\n". LDWORD dwUser) { int nRet = 0. dwDownLoadSize). pBuffer). lRealHandle). dwDataType). // If different playback/download uses the same process callback function. // If different playback/download uses the same data callback function. printf("dwDownLoadSize[%d]\n". dwBufSize). break. BYTE *pBuffer. printf("dwDataType[%d]\n". DWORD dwDataType. } } int CALLBACK DataCallBack(LLONG lRealHandle. dwUser). dwTotalSize). switch(dwDataType) { case 0: //Original data // users can save stream data here for further process such as decoding and transferring after getting out of callback function nRet = 1. DWORD dwUser). } 2. case 3: //pcm audio data break. LONG nDVRPort.221". char *pchDVRIP.4. } } return nRet.h> #include <stdio.h> #include "dhnetsdk. static char g_szUserName[64] = "admin". "dhnetsdk. static char g_szDevIp[32] = "172.11.5. case 4: //Original audio data break. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. static LLONG g_lDownloadHandle = 0L. // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function 73/339 . static char g_szPasswd[64] = "admin".2 Download by Time #include <windows. static LLONG g_lLoginHandle = 0L.1. break. default: break. static WORD g_nPort = 37777.lib") static BOOL g_bNetSDKInitFlag = FALSE.h" #pragma comment(lib . 0). SDK will call this function. LDWORD dwUser). SDK will call this function. void CALLBACK TimeDownLoadPosCallBack(LLONG lPlayHandle. int CALLBACK DataCallBack(LLONG lRealHandle. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. When SDK receives playback/downloaded data. } // get SDK version info // this operation is optional 74/339 . BYTE *pBuffer. NET_RECORDFILE_INFO recordfileinfo. When SDK receives playback/downloaded data. DWORD dwBufSize. DWORD dwDataType. // playback by time progress callback function // It’s not recommended to call SDK interfaces in this callback function // dwDownLoadSize: -1 means playback/download finished,-2 means failed to write file,other value means valid data // Set this callback function in CLIENT_DownloadByTimeEx. when offline device is reconnected successfully. LDWORD dwUser). next callback will return the following data // Download:no matter what return from the callback function. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. // Set the callback function in CLIENT_SetAutoReconnect. LDWORD dwUser). DWORD dwTotalSize. LONG nDVRPort. \n"). \n"). int index. char *pchDVRIP. // playback/download data callback function // It’s not recommended to call SDK interfaces in this callback function // playback:return value:0 means this playback failed,next callback will return the same data, 1 means this callback successful. } else { printf("Initialize client SDK done. DWORD dwDownLoadSize. //********************************************************************************* void InitTest() { // SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. next callback will return the following data // Set this callback function in CLIENT_DownloadByTimeEx. it will be treated as callback is successful. return. not decimal showns in header file. while(0 == g_lLoginHandle) { // login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. //Set more network parameter. &stDevInfoEx.nWaittime = 3000. you can find corresponding explanation in dhnetsdk. NULL. g_szUserName. CLIENT_GetLastError()). connection timeout value is 3000ms. g_nPort. } else { 75/339 . // set connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000. but recommended CLIENT_SetAutoReconnect(&HaveReConnect. It is to print hexadecimal here. //This operation is optional. you have 3 attempts CLIENT_SetConnectTime(nWaitTime. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). g_szPasswd. CLIENT_SetNetworkParam(&stuNetParm). // if timeout. dwNetSdkVersion). when device gets offline. g_nPort . if (0 == g_lLoginHandle) { // according to error code. &nError). SDK will reconnect internally // this operation is optional. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. nTryTimes).Once HaveReConnect is set. NET_PARAM stuNetParm = {0}. NET_DEVICEINFO_Ex stDevInfoEx = {0}. printf("NetSDK version is [%d]\n". Decimal number 23 is hexadecimal 0x17. please be careful with conversion // example: // #define NET_NOT_SUPPORTED_EC(23) // current SDK does not support the function. EM_LOGIN_SPEC_CAP_TCP. int nError = 0. 0). // when login. corresponding error code is 0x80000017. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" .h. g_szDevIp . // set CLIENT_SetAutoReconnect interface. stuNetParm. // timeout time is set to 5s int nTryTimes = 3. 1-main stream. g_szDevIp . stuStartTime. stuStopTime. It is recommended to wait for a while after login. TimeDownLoadPosCallBack. // 0-main/sub stream. &stuStartTime.dwYear = 2015. stuStartTime. } // record file search // set record stream type int nStreamType = 0. Sleep(1000). EM_RECORD_TYPE_ALL. &stuStopTime.dwMonth = 9. stuStopTime. g_nPort). 76/339 .2-sub stream CLIENT_SetDeviceMode(g_lLoginHandle. } } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return.dwYear = 2015. // start record download // at least one of the two parameters sSavedFileName and fDownL oadDataCallBack is valid g_lDownloadHandle = CLIENT_DownloadByTimeEx(g_lLoginHandle. stuStartTime. int nChannelID = 0. stuStopTime.dwDay = 18. &nStreamType). printf("CLIENT_LoginEx2 %s[%d] Success\n" . DH_RECORD_STREAM_TYPE. some data is needed to be initialized to enable normal business function. the waiting time varies by devices. } // The first time logining to device.dwMonth = 9.dwDay = 17. } if (0 == g_lLoginHandle) { return. // channel no. nChannelID. "test. NET_TIME stuStartTime = {0}.dav". NET_TIME stuStopTime = {0}. printf("\n"). if (g_lDownloadHandle == 0) { printf("CLIENT_DownloadByTimeEx: failed! Error code: %x. getchar(). g_lDownloadHandle. g_bNetSDKInitFlag = FALSE. } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). } } void EndTest() { printf("input any key to quit! \n").we can call this interface after download end or during download.NULL. g_lDownloadHandle[%x]!Last Error[%x]\n" . if (0 != g_lDownloadHandle) { if (FALSE == CLIENT_StopDownload(g_lDownloadHandle)) { printf("CLIENT_StopDownload Failed. } 77/339 . DataCallBack. } } // logout device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". // stop download.\n". CLIENT_GetLastError()). } else { g_lDownloadHandle = 0. } else { g_lLoginHandle = 0. CLIENT_GetLastError()). NULL). CLIENT_GetLastError()). } int main() { InitTest(). lLoginID). printf("lLoginID[0x%x]". nDVRPort). lLoginID). RunTest(). printf("dwUser[%p]\n". printf("lLoginID[0x%x]". } void CALLBACK TimeDownLoadPosCallBack(LLONG lPlayHandle. EndTest(). dwUser). printf("\n"). } //********************************************************************************* // commonly used callback set definition void CALLBACK DisConnectFunc(LONG lLoginID. LONG nDVRPort. LONG nDVRPort. printf("\n"). LDWORD dwUser) { printf("Call HaveReConnect\n"). 78/339 . pchDVRIP). nDVRPort). return 0. return. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". char *pchDVRIP. } printf("nDVRPort[%d]\n". DWORD dwUser) { printf("Call DisConnectFunc\n"). } printf("nDVRPort[%d]\n". DWORD dwTotalSize. char *pchDVRIP. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". pchDVRIP). dwUser). } void CALLBACK HaveReConnect(LLONG lLoginID. printf("dwUser[%p]\n". LDWORD dwUser) { // If different playback/download uses the same process callback function. printf("dwUser[%p]\n". printf("dwUser[%p]\n". switch(dwDataType) { case 0: //Original data // users can save stream data here for further process such as decoding and transferring after getting out of callback function nRet = 1. int index. case 1: //Standard video data break. printf("call DataCallBack\n"). dwTotalSize). BYTE *pBuffer. dwDataType). dwBufSize). printf("dwTotalSize[%d]\n". printf("pBuffer[%p]\n". LDWORD dwUser) { int nRet = 0. break.DWORD dwDownLoadSize. printf("\n"). // If different playback/download uses the same data callback function. we can judge by parameter 1PlayHandle if (lPlayHandle == g_lDownloadHandle) { printf("lPlayHandle[%p]\n". lRealHandle). printf("dwDataType[%d]\n". dwDownLoadSize). 79/339 . lPlayHandle). DWORD dwDataType. dwUser). we can judge by parameter 1RealHandle if(lRealHandle == g_lDownloadHandle) { printf("lPlayHandle[%p]\n". printf("dwBufSize[%d]\n". DWORD dwBufSize. NET_RECORDFILE_INFO recordfileinfo. pBuffer). printf("dwDownLoadSize[%d]\n". dwUser). } } int CALLBACK DataCallBack(LLONG lRealHandle. printf("\n"). 1 Intro PTZ is a mechanical platform which carries camera device and protective cover can remote monitor and control in all directions.6PTZ Control 2. such as move up/down/left/right. } 2. case 2: //yuv data break.2 Interface Overview Interface Interface Description CLIENT_Init Interface for SDK initialization CLIENT_Cleanup Interface for cleaning up SDK resources CLIENT_LoginEx2 Extensive interface 2 for sync login 80/339 . PTZ control is an important part of a surveillance system. 2. Users have different demands for suiveillance in different application scene. focus. point-to-point tour and 3D positioning. default: break. For example. zoom in/out. Users can control PTZ device via SDK. PTZ is made of two motors and capable for horizontal and vertical motion.6. case 4: //Original audio data break. case 3: //pcm audio data break. } } return nRet. therefore it can provide omnibearing and multi-angle viewing for video camere. users may want to track the surveillance screen in a normal application scene.6. 3 Process Instruction PTZ controller process flow sheet is shown in Figure 2-9.6.Interface Interface Description CLIENT_ParseData Interface for analyzing the obtained config info CLIENT_DHPTZControlEx2 Extensive interface for private PTZ control CLIENT_QueryNewSystemInfo Interface for obtaining new system capacity set CLIENT_Logout Interface for logout device CLIENT_GetLastError Interface for getting error code after failed calling interface 2. 81/339 . START SDK initialization CLIENT_init Login to device CLIENT_LoginEx2 Get PTZ capacity set CLIENT_QueryNewSystemInfo Analyze obtained json data CLIENT_ParseData PTZ control operation ClIENT_DHPTZControlEx2 Logout user ClIENT_Logout Release SDK resource CLIENT_Cleanup END Figure 2-9 PTZ controller process flow sheet Process description: 1. call CLIENT_LoginEx2 to login device. SDK initialization 2. and secondly call CLIENT_ParseData interface,The parameter szCommand is set to 82/339 . firstly call CLIENT_QueryNewSystemInfo interface. After successfully login. The second parameter szCommand is set to CFG_CAP_CMD_PTZ to obtain PTZ capacity set. 3. After successful initialization. 5. static int g_nPort = 37777.2.h> #include <vector> #include <string> #include "dhnetsdk. Different PTZ command requires may have different parameters.6.lib") static BOOL g_bNetSDKInitFlag = FALSE. LONG nDVRPort.h" #include "dhconfigsdk. need to match tcp port config in expected login device page static char g_szUserName[64] = "admin". After SDK function is done.lib") #pragma comment(lib . call CLIENT_Cleanup to release SDK resource. static LLONG g_lLoginHandle = 0L. After operation is done. 2. "dhconfigsdk. // tcp to connect port. For example some commands as left/right movement may require corresponding stop command. Please refer to example code. DWORD dwUser). CFG_CAP_CMD_PTZ to analyze the obtained capacity set. char *pchDVRIP.7. 6. Call CLIENT_DHPTZControlEx2 interface to operate PTZ according to the demand. 4.34". static LLONG g_lDownloadHandle = 0L.4 Example Code #include<windows. "dhnetsdk. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID.h> #include <stdio. static char g_szPasswd[64] = "admin".h" #pragma comment(lib . static char g_szDevIp[32] = "171. 83/339 . call CLIENT_Logout to logout device. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. you have 3 attempts CLIENT_SetConnectTime(nWaitTime. 0). // set CLIENT_SetAutoReconnect interface. SDK will reconnect internally.Once HaveReConnect is set. printf("NetSDK version is [%d]\n". //********************************************************************************** void InitTest() { // SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. nTryTimes). return. dwNetSdkVersion). //Set more network parameter. char *pchDVRIP. NET_PARAM stuNetParm = {0}. \n"). //This operation is optional. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. but recommended CLIENT_SetAutoReconnect(&HaveReConnect. } else { printf("Initialize client SDK done. when device gets offline. // this operation is optional. // set connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000. LONG nDVRPort. 0). // if timeout. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. } // get SDK version info // this operation is optional DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). LDWORD dwUser). // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. when offline device is reconnected successfully. // timeout time is set to 5s int nTryTimes = 3. \n"). 84/339 . g_nPort).nWaittime = 3000. g_szDevIp . EM_LOGIN_SPEC_CAP_TCP. bool bStopFlag):m_iCmd(iCmd).h. m_bStopFlag(bStopFlag){} int m_iCmd. printf("\n"). Decimal number 23 is hexadecimal 0x17. Sleep(1000). g_szPasswd. connection timeout value is 3000ms. g_szUserName. not decimal showns in header file. m_sDescription(sDescription). } // The first time logining to device. int nError = 0. CLIENT_GetLastError()). corresponding error code is 0x80000017. It is recommended to wait for a while after login. } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . t he waiting time varies by devices. It is to print hexadecimal here. const std::string& sDescription. &stDevInfoEx. g_nPort . // when login. g_nPort. if (0 == g_lLoginHandle) { // according to error code. stuNetParm. std::string m_sDescription. bool m_bStopFlag. you can find corresponding explanation in dhSDK. please be careful with conversion // example: // #define NET_NOT_SUPPORTED_EC(23) // current SDK does not support the function. NET_DEVICEINFO_Ex stDevInfoEx = {0}. } } // Ptz control info struct typedef struct tagPtzControlInfo { tagPtzControlInfo():m_iCmd(-1). NULL. some data is needed to be initialized to enable normal business function. // parial Ptz operation,after start need to call corresponding stop 85/339 . printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . m_bStopFlag(false){} tagPtzControlInfo(int iCmd. g_szDevIp . &nError). while(0 == g_lLoginHandle) { // login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. CLIENT_SetNetworkParam(&stuNetParm). } // PTZ operation std::vector<PtzControlInfo> vecPtzControl. if (FALSE == CLIENT_QueryNewSystemInfo(g_lLoginHandle. if (TRUE == stuPtzCapsInfo. sizeof(stuPtzCapsInfo). cmd[CFG_CAP_CMD_PTZ]. } // get PTZ capacity set char szBuffer[2048] = "". &nError)) { printf("CLIENT_QueryNewSystemInfo Failed.operation }PtzControlInfo. &stuPtzCapsInfo. int& nError). CFG_CAP_CMD_PTZ.bTile) 86/339 . (DWORD)sizeof(szBuffer). if (FALSE == CLIENT_ParseData(CFG_CAP_CMD_PTZ. int nError = 0. szBuffer. return. CLIENT_GetLastError()). Last Error[%x]\n" . szBuffer. cmd[CFG_CAP_CMD_PTZ]. void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. NULL)) { printf("CLIENT_ParseData Failed. return. // get int input int GetIntInput(char *szPromt. Last Error[%x]\n" . 0. CLIENT_GetLastError()). } CFG_PTZ_PROTOCOL_CAPS_INFO stuPtzCapsInfo = {sizeof(CFG_PTZ_PROTOCOL_CAPS_INFO)}. } if (0 == g_lLoginHandle) { return. "up".push_back(PtzControlInfo(int(DH_PTZ_FOCUS_ADD_CONTROL).bPan) { vecPtzControl. "aperture +". true)). true)).bZoom) { vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_APERTURE_DEC_CONTROL). true)). "right". true)).push_back(PtzControlInfo(int(DH_PTZ_APERTURE_ADD_CONTROL). "zoom -".push_back(PtzControlInfo(int(DH_PTZ_UP_CONTROL).push_back(PtzControlInfo(int(DH_PTZ_ZOOM_DEC_CONTROL). "zoom +".push_back(PtzControlInfo(int(DH_PTZ_FOCUS_DEC_CONTROL). true)). } if (TRUE == stuPtzCapsInfo.push_back(PtzControlInfo(int(DH_PTZ_RIGHT_CONTROL). true)). "left".push_back(PtzControlInfo(int(DH_PTZ_ZOOM_ADD_CONTROL).push_back(PtzControlInfo(int(DH_PTZ_DOWN_CONTROL). vecPtzControl. } if (TRUE == stuPtzCapsInfo. true)). } if (TRUE == stuPtzCapsInfo. vecPtzControl. "aperture -". true)). vecPtzControl. "focus -". "focus +".bIris) { vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_LEFT_CONTROL). { vecPtzControl. "down". true)). } if (TRUE == stuPtzCapsInfo.push_back(PtzControlInfo(int(DH_PTZ_POINT_MOVE_CONTROL). true)).bPreset) { vecPtzControl.bFocus) { vecPtzControl. vecPtzControl. 87/339 . } if (TRUE == stuPtzCapsInfo. vecPtzControl. vecPtzControl. vecPtzControl. false)).push_back(PtzControlInfo(int(DH_PTZ_POINT_SET_CONTROL). "delete preset point in tour". true)). false)).bTile && TRUE == stuPtzCapsInfo. "quick position". "clear tour". false)). "delete preset point".bRemovePreset) { vecPtzControl. "left down".push_back(PtzControlInfo(int(DH_EXTPTZ_RIGHTDOWN). } if (TRUE == stuPtzCapsInfo.push_back(PtzControlInfo(int(DH_EXTPTZ_DELFROMLOOP). vecPtzControl.push_back(PtzControlInfo(int(DH_PTZ_POINT_LOOP_CONTROL). false)). "right up"."go to preset point".bMoveRelatively) { vecPtzControl.push_back(PtzControlInfo(int(DH_EXTPTZ_ADDTOLOOP).push_back(PtzControlInfo(int(DH_EXTPTZ_FASTGOTO).bPan) { vecPtzControl. true)).bRemoveTour) { vecPtzControl. } if (TRUE == stuPtzCapsInfo. true)). } if (TRUE == stuPtzCapsInfo. "add preset point to tour". "point-to-point tour".bTour) { vecPtzControl. vecPtzControl. "right down". true)).push_back(PtzControlInfo(int(DH_EXTPTZ_LEFTDOWN).push_back(PtzControlInfo(int(DH_PTZ_POINT_DEL_CONTROL). false)).push_back(PtzControlInfo(int(DH_EXTPTZ_RIGHTTOP). } if (TRUE == stuPtzCapsInfo. "set preset point". vecPtzControl. vecPtzControl. false)). } if (TRUE == stuPtzCapsInfo. false)).push_back(PtzControlInfo(int(DH_EXTPTZ_LEFTTOP). false)).push_back(PtzControlInfo(int(DH_EXTPTZ_CLOSELOOP). "left up". 88/339 . push_back(PtzControlInfo(int(-2).c_str()).bMoveAbsolutely) { vecPtzControl. } } if (iterFind == vecPtzControl.end()) { printf("pleas input valid operation\n"). "3D position precisely ".begin(). true)). iter != vecPtzControl. "exit". ++iterFind) { if (nChoose == iterFind->m_iCmd) { break. PtzControlInfo cLastChoose. vecPtzControl. 89/339 .push_back(PtzControlInfo(int(-1). for (std::vector<PtzControlInfo>::const_iterator iter = vecPtzControl. "pause". iter->m_iCmd. false)). ++iter) { printf("\t%d\t:%s\n".end(). iter->m_sDescription.begin(). } if (TRUE == stuPtzCapsInfo. nError). for (.push_back(PtzControlInfo(int(DH_EXTPTZ_EXACTGOTO). continue. } // stop the last opetation int nChannelId = 0. while(TRUE) { printf("PTZ control operation:\n"). iterFind != vecPtzControl. continue. int nChoose = GetIntInput("\t selection:". false)). } int nError = 0. } std::vector<PtzControlInfo>::iterator iterFind = vecPtzControl. if (0 != nError) { printf("invalid input! \n").end(). } vecPtzControl. TRUE)) { printf("CLIENT_DHPTZControlEx2 Failed. nChannelId. Parameter setup guide are showing below: // extra parameter LONG lParam1 = 0. LONG lParam3 = 0. 0. valid range (1-8) lParam1 = 3. 0. } else if (DH_PTZ_ZOOM_ADD_CONTROL <= iterFind->m_iCmd && iterFind->m_iCmd <= DH_PTZ_APERTURE_DEC_CONTROL) { // speed.m_bStopFlag) { if (FALSE == CLIENT_DHPTZControlEx2(g_lLoginHandle. if (DH_PTZ_UP_CONTROL <= iterFind->m_iCmd && iterFind->m_iCmd <= DH_PTZ_RIGHT_CONTROL) { // vertical/horizontal movement speed,valid range (1-8) lParam2 = 3. cLastChoose.m_iCmd. LONG lParam2 = 0. cLastChoose.m_iCmd. cLastChoose->GetCmd()[%x]!Last Error[%x]\n" . if (true == cLastChoose. 0. continue. } else if (DH_PTZ_POINT_MOVE_CONTROL <= iterFind->m_iCmd && iterFind->m_iCmd <= DH_PTZ_POINT_DEL_CONTROL) { 90/339 . void* pParam4 = NULL. } // different PTZ commands correspond to different extra parameter setup plans . } if (iterFind->m_sDescription == "exit") { break. CLIENT_GetLastError()). } } if (iterFind->m_sDescription == "pause") { cLastChoose = *iterFind. wTourMax).stuPtzCapsInfo. stuPtzCapsInfo. stuPtzCapsInfo.(%2d-%2d):".wPresetMax).wTourMax). printf("\t1:start \n\t2: stop \n\t select:").wTourMin. scanf("%d". &lParam1). scanf("%d".wPresetMin. scanf("%d".wTourMin. } else if (DH_PTZ_POINT_LOOP_CONTROL == iterFind->m_iCmd) { // lParam1 means tour path. &lParam1).stuPtzCapsInfo. } else if (DH_EXTPTZ_LEFTTOP <= iterFind->m_iCmd && iterFind->m_iCmd <= DH_EXTPTZ_RIGHTDOWN) { // vertical speed, valid range (1-8) lParam1 = 1. lParam3:76 start;96 stop printf("\t tour path(%2d-%2d):". 91/339 . // lParam2 means preset point NO. int nTmp = 0. &lParam2). } } else if (DH_PTZ_LAMP_CONTROL == iterFind->m_iCmd) { // lParam1 means switch control printf("\t1:enable\n\t0:disable\n\t select:"). printf("\t preset point NO. &nTmp). } else if (DH_EXTPTZ_ADDTOLOOP <= iterFind->m_iCmd && iterFind->m_iCmd <= DH_EXTPTZ_DELFROMLOOP) { // lParam1 means tour path printf("\t tour path (%2d-%2d):". } else if (2 == nTmp) { lParam3 = 96. if (1 == nTmp) { lParam3 = 76. scanf("%d". stuPtzCapsInfo. // horizontal speed, valid range (1-8) lParam2 = 1.stuPtzCapsInfo. nChannelId. } else if (DH_EXTPTZ_CLOSELOOP == iterFind->m_iCmd) { // lParam1 means tour path printf("\t tour path(%2d-%2d):". // zoom,valid range (1 ~ 128) lParam3 = 2. &lParam2). scanf("%d". accuracy is 10x of capacity set acquisition range printf("\t vertical coordinate (%2d-%2d):". // vertical coordinate. scanf("%d".nVerticalAngleMin. lParam2. scanf("%d". valid range (-16 ~ 16) lParam3 = 2. iterFind->m_iCmd. 10*stuPtzCapsInfo.wTourMax). pParam4)) { 92/339 . } else if (DH_EXTPTZ_FASTGOTO == iterFind->m_iCmd) { // horizontal coordinate,valid range (-8191 ~ 8191) lParam1 = 2000. &lParam1). (%2d-%2d):". 10*stuPtzCapsInfo.stuPtzMotionRange. 10*stuPtzCapsInfo. FALSE. stuPtzCapsInfo.stuPtzMotionRange.stuPtzMotionRange. valid range and accuracy is 10x of capacity set acquisition range printf("\t horizontal coordinate (%2d-%2d):".stuPtzMotionRange. printf("\t preset point NO. 10*stuPtzCapsInfo.wTourMin. &lParam1). &lParam2).stuPtzCapsInfo. stuPtzCapsInfo. // vertical coordinate. &lParam1). valid range. // lParam2 means preset point NO.nVerticalAngleMax).nHorizontalAngleMax).wPresetMin. scanf("%d". // zoom. lParam3. scanf("%d". } if (FALSE == CLIENT_DHPTZControlEx2(g_lLoginHandle. } else if (DH_EXTPTZ_EXACTGOTO == iterFind->m_iCmd) { // horizontal coordinate. lParam1. valid range (-8191 ~ 8191) lParam2 = 2000.nHorizontalAngleMin.wPresetMax).stuPtzCapsInfo. // logout device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". CLIENT_GetLastError()). EndTest(). CLIENT_GetLastError()). RunTest(). nChoose. } } void EndTest() { printf("input any key to quit! \n"). printf("CLIENT_DHPTZControlEx2 Failed. } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). } return. getchar(). } cLastChoose = *iterFind. nChoose[%x]!Last Error[%x]\n" . return 0. } int main() { InitTest(). } else { g_lLoginHandle = 0. g_bNetSDKInitFlag = FALSE. } 93/339 . LONG nDVRPort. //********************************************************************************* // commonly used callback set definition void CALLBACK DisConnectFunc(LLONG lLoginID. pchDVRIP). nGet = strtol(szUserInput. lLoginID). printf("dwUser[%p]\n". printf("dwUser[%p]\n". if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". } printf("nDVRPort[%d]\n". dwUser). } int GetIntInput(char *szPromt. printf("lLoginID[0x%x]". char *pchDVRIP. printf(szPromt). int& nError) { long int nGet = 0. LONG nDVRPort. nDVRPort). dwUser). char *pchDVRIP. printf("lLoginID[0x%x]". printf("\n"). &pError. } printf("nDVRPort[%d]\n". char szUserInput[32] = "". gets(szUserInput). DWORD dwUser) { printf("Call DisConnectFunc\n"). char* pError = NULL. pchDVRIP). nDVRPort). } void CALLBACK HaveReConnect(LLONG lLoginID. 10). printf("\n"). lLoginID). if ('\0' != *pError) { // input parameter error nError = -1. LDWORD dwUser) { printf("Call HaveReConnect\n"). } 94/339 . 1 Intro Audio intercom is mainly used for audio interacting between local platform and front -end device located environment.7Audio intercom 2. CLIENT_Cleanup Interface for cleaning up SDK resources CLIENT_LoginEx2 Extensive interface 2 for Sync login CLIENT_QueryDevState Interface for searching device status CLIENT_StartTalkEx Extensive interface for opening audio intercom CLIENT_StopTalkEx Extensive interface for stopping audio intercom Extensive interface for starting client recording(valid in Windows CLIENT_RecordStartEx platform only) Extensive interface for stopping client recording(valid in Windows CLIENT_RecordStopEx platform only) 95/339 . The chapter mainly tells users how to use SDK to audio intercoming with front-end device.7. 2.2 Interface Overview Interface Interface Description CLIENT_Init Interface for SDK Initialization.7. please refer to Ch 2. else { nError = 0. } return nGet. } 2.7. Audio intercom mode Audio intercom has two modes: client mode and server mode.3 for details. The callback function is called when SDK receives audio data from front-end device. The callback function is called when SDK collects audio data from local sound card or receives data from the front-end.1 Client Mode Client mode process flow sheet is shown below in Figure 2-10. For local audio data.3. Interface Interface Description CLIENT_TalkSendData Interface for sending audio data to device Extensive interface for decoding audio data(valid in Windows CLIENT_AudioDecEx platform only) CLIENT_Logout Interface for logout CLIENT_GetLastError Interface for getting error code after failed calling interface 2. user can collect it by calling a third-party library and then send it to device by calling SDK interface.7. In callback function user can save audio data received from front-end device for future use such as audio data transfer. Server mode SDK allows user to provide one callback function.3 Process Instruction Audio intercom has two modes: Client mode SDK allows user to provide a callback function. calling a third-party library to decode and play audio data and etc.7. 2. This mode is valid in Windows platform only. 96/339 . 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. Start SDK initialization Login device CLIENT_LoginEx2 Set as client intercom mode CLIENT_SetDeviceMode Set audio intercom encode info CLIENT_SetDeviceMode Set intercom parameter CLIENT_SetDeviceMode Set transfer mode CLIENT_SetDeviceMode Start audio intercom CLIENT_StartTackEx Set callback function pfAudioDataCallBack Decode device audio data in callback Start PC recording CLIENT_RecordStartEx decode device audio data CLIENT_AudioDec Send PC audio data to device in callback Stop PC recording Send PC audio data to device CLIENT_RecordStopEx CLIENT_TalkSendData Stop audio intercom CLIENT_StopTalkEx Logout user CLIENT_Logout Release SDK resources CLIENT_Cleanup Optional flow-progress End Figure 2-10 Client mode process flow sheet 97/339 . 7. SDK initialization 2. Parameter emType is DH_TALK_CLIENT_MODE. Last but not the least. Call CLIENT_SetDeviceMode to set audio intercom parameter. After successful initialization. 6. 10. Call CLIENT_Logout to logout device. and transfer mode means audio intercom between local PC and front-end device connected with specific channel of the logined device. can audio intercom callback function set by CLIENT_StartTalkEx will receive local audio data. 12. Call CLIENT_RecordStartEx to start PC recording. call CLIENT_RecordStopEx to stop PC recording. Call CLIENT_SetDeviceMode to set client mode as audio intercom mode. 3. Call CLIENT_StopTalkEx to stop audio intercom. Call CLIENT_SetDeviceMode to set audio intercom transfer mode. 4. Call CLIENT_SetDeviceMode to set audio intercom encode information. 5. 98/339 . call CLIENT_Cleanup to release SDK resources. After audio intercom is finished. 9. Only after this interface is called. 2. Process description: 1. Call CLIENT_StartTalkEx to set callback function and start audio intercom. 7. call CLIENT_LoginEx2 to login device. call CLIENT_AudioDec to decode audio data sent by device and call CLIENT_TalkSendData to send audio data from PC to device. no-transfer mode means audio intercom between local PC and logined device.3. Parameter emType is DH_TALK_SPEAK_PARAM. 8.In callback function.2 Server Mode Server mode process flow sheet is shown below in Figure 2-11.Parameter emType is DH_TALK_ENCODE_TYPE. 11. SDK initialization 2.Call CLIENT_TalkSendData to send audio data to device Stop audio intercom CLIENT_StopTalkEx Logout user CLIENT_Logout Release SDK resources CLIENT_Cleanup End Figure 2-11 Server mode process flow sheet Process description: 1. Start SDK initialization Login device CLIENT_LoginEx2 Set as server intercom mode CLIENT_SetDeviceMode Set audio intercom encode info CLIENT_SetDeviceMode Set intercom parameter CLIENT_SetDeviceMode Set forwarding mode CLIENT_SetDeviceMode Start audio intercom In callback. call CLIENT_LoginEx2 to login device. user transfers or CLIENT_StartTackEx Set callback function decodes device audio data by pfAudioDataCallBack himself 1. 99/339 . After successful initialization.Encode original audio data to be the same type with intercom encode type 2. Parameter emType is DH_TALK_SPEAK_PARAM. 4.h> #include "dhnetsdk. In callback function. 5. Call CLIENT_SetDeviceMode to set audio intercom transfer mode. Call CLIENT_Logout to logout device. then adds 8 corresponding private protocol bytes in front of encoded data. no-transfer mode means audio intercom between local PC and logined device.7. Parameter emType is DH_TALK_SERVER_MODE. 7.4. call CLIENT_StopTalkEx to stop audio intercom.7.1 Client Mode #include <windows. 11. 6. Call CLIENT_SetDeviceMode to set server mode as audio intercom mode. 8. 2. the audio data sent by device can be dealt with by users with the methods as transfer or decoding and playing.h" #pragma comment(lib . 10.4 Example Code 2. and transfer mode means audio intercom between local PC and front-end device connected with specific channel of the logined device. Call CLIENT_StartTalkEx to set callback function and start audio intercom. After intercom function is finished. At first user encodes original audio data to be the same type with intercom encode typ e.h> #include <stdio. Call CLIENT_SetDeviceMode to set audio intercom encode information. Last but not the least. "dhnetsdk.Parameter emType is DH_TALK_ENCODE_TYPE. and finally calls CLIENT_TalkSendData to send audio data to device.lib") 100/339 . call CLIENT_Cleanup to release SDK resources. Call CLIENT_SetDeviceMode to set audio intercom parameter. 9. 3. 66". static LLONG g_lLoginHandle = 0L. DWORD dwBufSize. char *pchDVRIP. DWORD dwUser). but in this callback function CLIENT_TalkSendData and CLIENT_AudioDec SDK interface s can be called.23. static LLONG g_lTalkHandle = 0L. static char g_szDevIp[32] = "172. LONG nDVRPort. static char g_szUserName[64] = "admin". char *pDataBuf. void CALLBACK AudioDataCallBack(LLONG lTalkHandle. DWORD dwUser). static BOOL g_bNetSDKInitFlag = FALSE.or audio data sent by device. static WORD g_nPort = 37777. BYTE byAudioFlag. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID.2. char *pchDVRIP. when offline device is reconnected successfully. LDWORD dwUser).. LONG nDVRPort. // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. // audio intercom data callback function // It is not recommended to call SDK interface in the SDK callback function. // Set the callback function in CLIENT_StartTalkEx. //********************************************************************************* void InitTest() 101/339 . static char g_szPasswd[64] = "admin". static BOOL g_bRecordFlag = FALSE. SDK will call this function when receiving sound card data detected by local PC. 102/339 .Once HaveReConnect is set.it will try to log in three times. connection timeout value is 3000ms. } //Get the SDK version info // This operation is optional.but recommended. CLIENT_SetAutoReconnect(&HaveReConnect. int nWaitTime = 5000. //if timeout. // when login. { // SDK Initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. return. when device gets offline. \n"). //This operation is optional. NET_PARAM stuNetParm = {0}. stuNetParm. } else { printf("Initialize client SDK done. printf("NetSDK version is [%d]\n". // Set device connection timeout value and trial times. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). SDK will reconnect internally //This operation is optional. // set CLIENT_SetAutoReconnect interface. 0). CLIENT_SetNetworkParam(&stuNetParm).nWaittime = 3000. nTryTimes). \n"). CLIENT_SetConnectTime(nWaitTime. //Set more network parameter. 0). //This operation is optional. dwNetSdkVersion). if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. // timeout value is 5 seconds int nTryTimes = 3. g_szDevIp . &stDevInfoEx. EM_LOGIN_SPEC_CAP_TCP. not decimal showns in header file. Sleep(1000). NULL. It is recommended to wait for a while after login. Decimal number 23 is hexadecimal 0x17. NET_DEVICEINFO_Ex stDevInfoEx = {0}. the waiting time varies by devices. g_szPasswd.h. printf("\n"). int nError = 0. g_nPort). error code is 0x80000017. while(0 == g_lLoginHandle) { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. g_nPort. CLIENT_GetLastError()). g_szDevIp . g_nPort . } // The first time logining to device. } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . if(0 == g_lLoginHandle) { // according to error code. It is to print hexadecimal here. some data is needed to be initialized to enable normal business function. please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function. you can find corresponding explanation in dhnetsdk. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . &nError). g_szUserName. } } void RunTest() { 103/339 . } if (0 == g_lLoginHandle) { return. } 104/339 . 3000). &retlen. if (FALSE == g_bNetSDKInitFlag) { return. } //Get audio intercom encode type supported by front-end device DHDEV_TALKFORMAT_LIST stulstTalkEncode. DH_TALK_CLIENT_MODE. } //Set as audio intercom client mode BOOL bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. return. DH_DEVSTATE_TALK_ECTYPE. CLIENT_GetLastError()). bSuccess = CLIENT_QueryDevState(g_lLoginHandle. NULL). CLIENT_GetLastError()). DH_TALK_CLIENT_MODE. (char*)&stulstTalkEncode. if (FALSE == bSuccess) { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" . return. sizeof(stulstTalkEncode). DH_DEVSTATE_TALK_ECTYPE. if (FALSE == bSuccess || retlen != sizeof(stulstTalkEncode)) { printf("CLIENT_QueryDevState cmd[%d] Failed!Last Error[%x]\n" . int retlen = 0. if (FALSE == bSuccess) { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" . if (FALSE == bSuccess) { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" .bTransfer = FALSE. 105/339 . set 0 bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. stuSpeak. stuSpeak. //Close transfer mode because it’s intercom with login device. user can select other encode method as needed. // audio intercom channel number. curTalkMode = stulstTalkEncode. DHDEV_TALKDECODE_INFO curTalkMode. // 0:intercom(default mode),1:shout;Reset stuSpeak. } //Set as transfer mode NET_TALK_TRANSFER_PARAM stuTransfer = {sizeof(stuTransfer)}.nSpeakerChannel = 0.nMode when switch from shout to intercom. return. } //Set audio intercom parameter NET_SPEAK_PARAM stuSpeak = {sizeof(stuSpeak)}. DH_TALK_SPEAK_PARAM. return.type[0]. //Select the first encode method in the list. bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. CLIENT_GetLastError()). DH_TALK_ENCODE_TYPE. DH_TALK_ENCODE_TYPE. DH_TALK_TRANSFER_MODE. stuTransfer.nMode = 0. &stuSpeak). DH_TALK_SPEAK_PARAM. CLIENT_GetLastError()). &curTalkMode). //Set audio intercom encode info. if (FALSE == bSuccess) { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" . CLIENT_GetLastError()). AudioDataCallBack. } } } 106/339 .&stuTransfer). DH_TALK_TRANSFER_MODE. if(0 != g_lTalkHandle) { //Start local recording. } else { if (FALSE == CLIENT_StopTalkEx(g_lTalkHandle)) { printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n".It’s no need to call this interface if it is one-way audio intercom between DVR and PC. (DWORD)NULL). CLIENT_GetLastError()). BOOL bSuccess = CLIENT_RecordStartEx(g_lLoginHandle). return. } g_lTalkHandle = CLIENT_StartTalkEx(g_lLoginHandle. if(TRUE == bSuccess) { g_bRecordFlag = TRUE. } else { g_lTalkHandle = 0. } } void EndTest() { printf("input any key to quit! \n"). CLIENT_GetLastError()). } } //Stop audio intercom if (0 != g_lTalkHandle) { if(FALSE == CLIENT_StopTalkEx(g_lTalkHandle)) { printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n". //Stop local recording if (TRUE == g_bRecordFlag) { if (!CLIENT_RecordStopEx(g_lLoginHandle)) { printf("CLIENT_RecordStop Failed!Last Error[%x]\n". CLIENT_GetLastError()). getchar(). CLIENT_GetLastError()). } else { 107/339 . else { printf("CLIENT_StartTalkEx Failed!Last Error[%x]\n". } else { g_bRecordFlag = FALSE. CLIENT_GetLastError()). g_lTalkHandle = 0. EndTest(). RunTest(). } else { g_lLoginHandle = 0. g_bNetSDKInitFlag = FALSE. } } // Clean up initialization resources. return 0. } return. if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). } } //Exit device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". 108/339 . } int main() { InitTest(). printf("\n"). printf("lLoginID[0x%x]". pchDVRIP). char *pchDVRIP. printf("\n"). } printf("nDVRPort[%d]\n". } //********************************************************************************* //commonly used callback functions definition void CALLBACK DisConnectFunc(LLONG lLoginID. LDWORD dwUser) { printf("Call HaveReConnect\n"). nDVRPort). dwUser). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". } 109/339 . nDVRPort). printf("lLoginID[0x%x]". pchDVRIP). LONG nDVRPort. DWORD dwUser) { printf("Call DisConnectFunc\n"). } void CALLBACK HaveReConnect(LLONG lLoginID. LONG nDVRPort. printf("dwUser[%p]\n". printf("dwUser[%p]\n". } printf("nDVRPort[%d]\n". dwUser). lLoginID). char *pchDVRIP. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". lLoginID). pDataBuf. "a+b")) != NULL ) { int numwritten = fwrite( pDataBuf. BYTE byAudioFlag. #ifdef _DEBUG FILE *stream. void CALLBACK AudioDataCallBack(LLONG lTalkHandle. This interface must follow the interface CLIENT_RecordStartEx. dwBufSize). } } else if(1 == byAudioFlag) { //Send received audio data sent by device to SDK for decoding and playing. fclose( stream ). char *pDataBuf. user can judge by parameter 1TalkHandle. 110/339 . } if(0 == byAudioFlag) { //Send received sound card data which is detected by local PC to device. dwBufSize). sizeof( char ).txt". dwBufSize. if (g_lTalkHandle != lTalkHandle) { return. if(lSendLen != (LONG)dwBufSize) { printf("CLIENT_TalkSendData Failed!Last Error[%x]\n" . LONG lSendLen = CLIENT_TalkSendData(lTalkHandle. DWORD dwUser) { //If different audio intercoms use the same data callback function. stream ). if( (stream = fopen("E:\\Talk. CLIENT_GetLastError()). DWORD dwBufSize. CLIENT_AudioDec(pDataBuf. LONG nDVRPort. static DHDEV_TALKDECODE_INFO g_curTalkMode. Take Dahua encoding/decoding library for example in the following example code.h> #include "dhplay. "dhplay.lib") static BOOL g_bNetSDKInitFlag = FALSE.h" #pragma comment(lib . static char g_szPasswd[64] = "admin". char *pchDVRIP.4. static char g_szUserName[64] = "admin".1. static WORD g_nPort = 37777. } #endif } } 2.2 Server Mode #include <windows. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID.23.h" #include "Alaw_encoder. static char g_szDevIp[32] = "172. 111/339 .27".h> #include <stdio. static BOOL g_bOpenAudioRecord = FALSE. "dhnetsdk. #pragma comment(lib . DWORD dwUser).lib") // the third-party encoding/decoding library.7.h" #include "dhnetsdk. static LLONG g_lTalkHandle = 0L. static LLONG g_lLoginHandle = 0L. //********************************************************************************* void InitTest() { // SDK Initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. Dahua encoding/decoding library will call this function.or audio data sent by device. // audio intercom data callback function //only audio data sent by device can be received in server mode // It is not recommended to call SDK interface in the SDK callback function.. LDWORD dwUser). // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. // PC audio encode send callback function //pDataBuffer is original audio data. // Set the callback function in CLIENT_StartTalkEx. 0). BOOL StartAudioRecord(). BYTE byAudioFlag. DWORD dwUser). void CALLBACK AudioDataCallBack(LLONG lTalkHandle. but in this callback function CLIENT_TalkSendData and CLIENT_AudioDec SDK interfaces can be called. DWORD dwBufSize. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. if (FALSE == g_bNetSDKInitFlag) 112/339 . char *pDataBuf. LONG nDVRPort. void* pUser). //********************************************************************************* // function declaration // This interface is an example to call Dahua encoding/decoding library to collect audio intercom data. void CALLBACK AudioCallFunction(LPBYTE pDataBuffer. DWORD DataLength. DataLength is the length of valid data. SDK will call this function when receiving sound card data detected by local PC. when detecting sound card data. BOOL StopAudioRecord(). char *pchDVRIP. Use Dahua encoding/decoding library to get PC original audio stream. //Set up PLAY_OpenAudioRecord interface By Dahua encoding/decoding library. when offline device is reconnected successfully. it will try to log in three times. connection timeout value is 3000ms. dwNetSdkVersion). nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). { printf("Initialize client SDK fail. nTryTimes). //This operation is optional. when device gets offline. // set CLIENT_SetAutoReconnect interface.but recommended. stuNetParm. CLIENT_SetConnectTime(nWaitTime. // Set device connection timeout value and trial times. while(0 == g_lLoginHandle) 113/339 .nWaittime = 3000. //This operation is optional. } else { printf("Initialize client SDK done. CLIENT_SetAutoReconnect(&HaveReConnect. NET_DEVICEINFO_Ex stDevInfoEx = {0}. // when login. \n"). //Set more network parameter. } //Get the SDK version info // This operation is optional. 0). // timeout value is 5 seconds int nTryTimes = 3. int nError = 0. //if timeout. CLIENT_SetNetworkParam(&stuNetParm). return. \n"). NET_PARAM stuNetParm = {0}. int nWaitTime = 5000. printf("NetSDK version is [%d]\n". SDK will reconnect internally //This operation is optional.Once HaveReConnect is set. g_szDevIp . &stDevInfoEx. EM_LOGIN_SPEC_CAP_TCP. not decimal showns in header file. g_nPort .h. CLIENT_GetLastError()). you can find corresponding explanation in dhnetsdk. } 114/339 . Decimal number 23 is hexadecimal 0x17. } // The first time logining to device. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . if(0 == g_lLoginHandle) { // according to error code. error code is 0x80000017. g_szUserName. printf("\n"). some data is needed to be initialized to enable normal business function. the waiting time varies by devices. please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function. It is recommended to wait for a while after login. NULL. { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. } } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. It is to print hexadecimal here. &nError). Sleep(1000). g_szDevIp . } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . g_nPort). g_nPort. g_szPasswd. DH_DEVSTATE_TALK_ECTYPE. DH_TALK_SERVER_MODE. if (0 == g_lLoginHandle) { return. DH_TALK_SERVER_MODE. DH_TALK_ENCODE_TYPE. return. sizeof(stulstTalkEncode). NULL). (char*)&stulstTalkEncode. if (FALSE == bSuccess || retlen != sizeof(stulstTalkEncode)) { printf("CLIENT_QueryDevState cmd[%d] Failed!Last Error[%x]\n" . if (FALSE == bSuccess) 115/339 . CLIENT_GetLastError()). CLIENT_GetLastError()). 3000). return. } //Set audio intercom encode info g_curTalkMode = stulstTalkEncode.type[0]. &g_curTalkMode). bSuccess = CLIENT_QueryDevState(g_lLoginHandle. } //Get audio intercom encode type supported by front-end device DHDEV_TALKFORMAT_LIST stulstTalkEncode. int retlen = 0. DH_DEVSTATE_TALK_ECTYPE. } //Set as server intercom mode BOOL bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. if (FALSE == bSuccess) { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" . &retlen. bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. nSpeakerChannel = 0. } //Set as transfer mode NET_TALK_TRANSFER_PARAM stuTransfer = {sizeof(stuTransfer)}.set 0. //audio intercom channel number. } 116/339 . DH_TALK_SPEAK_PARAM. if (FALSE == bSuccess) { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" . &stuSpeak). CLIENT_GetLastError()).nMode = 0. bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. return. &stuTransfer). CLIENT_GetLastError()). } //Set intercom parameter NET_SPEAK_PARAM stuSpeak = {sizeof(stuSpeak)}. return.nMode when switch from shout to intercom stuSpeak.bTransfer = FALSE. return. DH_TALK_ENCODE_TYPE. if (FALSE == bSuccess) { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" . DH_TALK_TRANSFER_MODE. stuSpeak. bSuccess = CLIENT_SetDeviceMode(g_lLoginHandle. CLIENT_GetLastError()). DH_TALK_TRANSFER_MODE. //Close transfer mode because it’s intercom with login device. stuTransfer. // 0:intercom(default mode),1:shout;Reset stuSpeak. { printf("CLIENT_SetDeviceMode cmd[%d] Failed!Last Error[%x]\n" . DH_TALK_SPEAK_PARAM. // clean up Dahua encoding/decoding library resources. if(0 != g_lTalkHandle) { bSuccess = StartAudioRecord(). AudioDataCallBack. g_lTalkHandle = 0. } } else { printf("CLIENT_StartTalkEx Failed!Last Error[%x]\n". (DWORD)NULL). } else { printf("StartAudioRecord Failed!\n"). if(TRUE == g_bOpenAudioRecord) { if (TRUE == StopAudioRecord()) { 117/339 . } } void EndTest() { printf("input any key to quit! \n"). CLIENT_GetLastError()). CLIENT_StopTalkEx(g_lTalkHandle). g_lTalkHandle = CLIENT_StartTalkEx(g_lLoginHandle. getchar(). if(TRUE == bSuccess) { g_bOpenAudioRecord = TRUE. } else { g_lLoginHandle = 0. } else { g_lTalkHandle = 0. } } //Logout device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". CLIENT_GetLastError()). CLIENT_GetLastError()). if (TRUE == g_bNetSDKInitFlag) { 118/339 . } } //Stop audio intercom if (0 != g_lTalkHandle) { if(FALSE == CLIENT_StopTalkEx(g_lTalkHandle)) { printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n". g_bOpenAudioRecord = FALSE. } } // Clean up initialization resources. EndTest(). } printf("nDVRPort[%d]\n". nDVRPort). CLIENT_Cleanup(). g_bNetSDKInitFlag = FALSE. dwUser). } return. } int main() { InitTest(). printf("\n"). printf("dwUser[%p]\n". pchDVRIP). LONG nDVRPort. lLoginID). printf("lLoginID[0x%x]". char *pchDVRIP. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". return 0. } //********************************************************************************* //commonly used callback functions definition void CALLBACK DisConnectFunc(LLONG lLoginID. DWORD dwUser) { printf("Call DisConnectFunc\n"). RunTest(). } 119/339 . } printf("nDVRPort[%d]\n". // The following is an example of dealing with the data with Dahua encoding/decoding library 120/339 . lLoginID). LDWORD dwUser) { printf("Call HaveReConnect\n"). LONG nDVRPort. dwUser). pchDVRIP). user can judge by parameter 1TalkHandle. BYTE byAudioFlag. DWORD dwBufSize. if (g_lTalkHandle != lTalkHandle) { return. char *pDataBuf. char *pchDVRIP. void CALLBACK HaveReConnect(LLONG lLoginID. printf("dwUser[%p]\n". printf("lLoginID[0x%x]". nDVRPort). DWORD dwUser) { //If different audio intercoms use the same data callback function. } void CALLBACK AudioDataCallBack(LLONG lTalkHandle. printf("\n"). } if(1 == byAudioFlag) { // User can handle the audio data sent by device by himself such as transfer and decoding and playing. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". stream ). if (NULL == pCbData) { 121/339 . i < dwBufSize. if( (stream = fopen("E:\\Talk. } } //You can use PLAY SDK to decode to get PCM and then encode to other formats if you to get a uniform formats. } #endif } } void CALLBACK AudioCallFunction(LPBYTE pDataBuffer. //For PCM format withour header . pCbData = new char[102400]. int nPort = 99. please add 128. for (unsigned int i = 0. i++) { pDataBuf[i] += (char)128. void* pUser) { char* pCbData = NULL. dwBufSize. DWORD DataLength.dwBufSize). "a+b")) != NULL ) { int numwritten = fwrite( pDataBuf.encodeType == DH_TALK_DEFAULT) { nPort = 100. #ifdef _DEBUG FILE *stream. PLAY_InputData(nPort.(BYTE *)pDataBuf. sizeof( char ). fclose( stream ). if (g_curTalkMode.txt". dwSampleRate ) { pCbData[5]=0x02. others are audio data of corresponding intercom encode type. pCbData[3]=0xF0. // The following codes show that what the former 8 bytes are when PCM、g711a and g711u encoding.//8k } else if(16000 == g_curTalkMode. } } pCbData[0]=0x00. } int iCbLen = 0. j < DataLength. if( 8000 == g_curTalkMode.dwSampleRate) { pCbData[5] = 0x04. } 122/339 . pCbData[4]=g_curTalkMode.nAudioBit == 8) { for(unsigned int j = 0 . pCbData[2]=0x01.nAudioBit==8?0x07:0x0C.encodeType == DH_TALK_PCM) { if (g_curTalkMode. if (g_curTalkMode. //Former 8 bytes in intercom stream are private protocol data. j++) { *(pDataBuffer + j) += 128. return. pCbData[1]=0x00.encodeType == DH_TALK_DEFAULT || g_curTalkMode. iCbLen = 8+DataLength. } //Private bit stream format frame head pCbData[0]=0x00.dwSampleRate) { pCbData[5] = 0x09. DataLength). pCbData[1]=0x00. pCbData[4]=0x0E. pCbData[3]=0xF0. } *(DWORD*)(pCbData+6)=DataLength. pDataBuffer.dwSampleRate) 123/339 . pCbData+8.//8k } else if(16000 == g_curTalkMode. //G711A if( 8000 == g_curTalkMode. else if(48000 == g_curTalkMode. &iCbLen) != 1) { goto end.encodeType == DH_TALK_G711a) { //Encode the original audio data to g711a. if (g711a_Encode((char*)pDataBuffer. pCbData[2]=0x01. memcpy(pCbData+8.dwSampleRate ) { pCbData[5]=0x02. DataLength. } else if (g_curTalkMode. encodeType == DH_TALK_G711u) { // Encode the original audio data to g711u. } else if (g_curTalkMode. } pCbData[6]=BYTE(iCbLen&0xff). pCbData[3]=0xF0. { pCbData[5] = 0x04. //8k 124/339 . pCbData[7]=BYTE(iCbLen>>8). if (g711u_Encode((char*)pDataBuffer. &iCbLen) != 1) { goto end. pCbData[0]=0x00. iCbLen += 8. DataLength. pCbData[2]=0x01. //G711u if( 8000 == g_curTalkMode. pCbData[4]=0x0A. } else if(48000 == g_curTalkMode.dwSampleRate ) { pCbData[5]=0x02. pCbData+8.dwSampleRate) { pCbData[5] = 0x09. pCbData[1]=0x00. } //Private bit stream format frame head. } else if(16000 == g_curTalkMode.dwSampleRate) { pCbData[5] = 0x04; } else if(48000 == g_curTalkMode.dwSampleRate) { pCbData[5] = 0x09; } pCbData[6]=BYTE(iCbLen&0xff); pCbData[7]=BYTE(iCbLen>>8); iCbLen += 8; } else { goto end; } // Send the data from the PC to DVR CLIENT_TalkSendData(g_lTalkHandle, (char *)pCbData, iCbLen); end: if (pCbData != NULL) { delete[] pCbData; } } //********************************************************************************* 125/339 BOOL StartAudioRecord() { // It is the characteristics of Dahua encoding/decoding library. //First confirm decode port.DH_TALK_DEFAULT is 100 port number and then rest is 99 port number. int nPort = 99; if (g_curTalkMode.encodeType == DH_TALK_DEFAULT) { nPort = 100; } //Then specify frame length int nFrameLength = 1024; switch(g_curTalkMode.encodeType) { case DH_TALK_DEFAULT: case DH_TALK_PCM: nFrameLength = 1024; break; case DH_TALK_G711a: nFrameLength = 1280; break; case DH_TALK_AMR: nFrameLength = 320; break; case DH_TALK_G711u: nFrameLength = 320; break; case DH_TALK_G726: nFrameLength = 320; break; 126/339 case DH_TALK_AAC: nFrameLength = 1024; default: break; } if (g_curTalkMode.dwSampleRate == 48000) //If sampling rate is 48K,update audio length. { nFrameLength = 48*40*2; // sampling rate multiply by 40 and 2. } BOOL bRet = FALSE; //Then call PLAYSDK library to begin recording audio BOOL bOpenRet = PLAY_OpenStream(nPort,0,0,1024*900); if(bOpenRet) { BOOL bPlayRet = PLAY_Play(nPort,0); 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() { // It is the characteristics of Dahua encoding/decoding library. BOOL bSuccess = PLAY_CloseAudioRecord(); if(TRUE == bSuccess) { PLAY_Stop(100); PLAY_Stop(99); PLAY_StopSoundShare(100); PLAY_StopSoundShare(99); PLAY_CloseStream(100); PLAY_CloseStream(99); } else { printf("PLAY_CloseAudioRecord Failed! \n"); } 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 users for platform development requirements. 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 encoding type and resolution. 2.8.2 Interface Overview Interface Interface Description CLIENT_Init Interface for SDK Initialization. CLIENT_Cleanup Interface for cleaning up SDK resources. CLIENT_LoginEx2 Extensive interface 2 for Sync login. CLIENT_SetSnapRevCallBack Set vedio snapshotdata callback function CLIENT_SnapPictureEx Extensive interface for snapshot request. CLIENT_Logout Interface for logout device. CLIENT_GetLastError Interface for getting error code after failed calling interface. 2.8.3 Process Instruction Video snapshot process flow sheet is shown below in Figure 2-12. 129/339 Start SDK initialization Login device CLIENT_LoginEx2 User gets and saves video snapshot Set video snapshot data callback function picture information for further use by CLIENT_SetSnapRevCallBack video snapshot data callback function(fSnapRev) Send snapshot command to front-end device CLIENT_SnapPictureEx Logout user CLIENT_Logout Release SDK sources CLIENT_Cleanup End Figure 2-12 Video snapshot process flow sheet Process discription: 1. SDK initialization. 2. After successful initialization, call CLIENT_LoginEx2 to login device. 3. Call CLIENT_SetSnapRevCallBack to set snapshot callback function, when SDK receives snapshot data sent from device,it will call fSnapRev callback function to recall picture informatio n and data to user. 4. Call CLIENT_SnapPictureEx to send snapshot command to front-end device, wait for device to reply picture information in callback function(fSnapRev). 5. Call CLIENT_Logout to logout device. 6. Last but not the least, call CLIENT_Cleanup to release SDK resources. 2.8.4 Example code 130/339 1. #include <windows. void CALLBACK SnapRev(LLONG lLoginID. UINT RevLen. when offline device is reconnected successfully. //********************************************************************************* // commonly used function set declaration 131/339 . // It’s not recommended to call SDK interfaces in this callback function. //Snapshot callback function. // callback function used after device is reconnected successfully. char *pchDVRIP. static short g_nCmdSerial = 0. UINT EncodeType.SDK will call this function.when snapshot data is sent over by front-end device. // Before tcp connects port. //snapshot SN //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s not recommended to call SDK interfaces in this callback function //Set the callback function in CLIENT_Init.lib") #pragma comment(lib. char *pchDVRIP. "dhconfigsdk. // Set the callback function in CLIENT_SetAutoReconnect. static LLONG g_lLoginHandle = 0L. LONG nDVRPort. DWORD CmdSerial. "dhnetsdk. SDK will call the function.h" #pragma comment(lib. // It’s not recommended to call SDK interfaces in this callback function.when device gets offline. //Set the callback function in CLIENT_SetSnapRevCallBack.23.lib") static BOOL g_bNetSDKInitFlag = FALSE. BYTE *pBuf.h> #include <time. static char g_szDevIp[32] = "172.27". static char g_szPasswd[64] = "admin".h> #include "dhnetsdk. DWORD dwUser).h" #include "dhconfigsdk. LDWORD dwUser). LONG nDVRPort.SDK will call this function automatically void CALLBACK DisConnectFunc(LLONG lLoginID. static WORD g_nPort = 37777.the port need to keep with tcp port config in expected login static char g_szUserName[64] = "admin". void CALLBACK HaveReConnect(LLONG lLoginID. LDWORD dwUser).h> #include <stdio. when device gets offline. \n"). // set connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000. } // get SDK version info // this operation is optional DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). CLIENT_SetConnectTime(nWaitTime. //Get int input int GetIntInput(char *szPromt.Once HaveReConnect is set. return. 132/339 . // this operation is optional. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. //Timeout value is 5 seconds. //Get input string void GetStringInput(const char *szPromt . \n"). dwNetSdkVersion). nTryTimes). 0).it will try to log in three times. but recommended CLIENT_SetAutoReconnect(&HaveReConnect. g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. printf("NetSDK version is [%d]\n". // set CLIENT_SetAutoReconnect interface. char *szBuffer). SDK will reconnect internally. //********************************************************************************* void InitTest() { //SDK initialization. int& nError). if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. } else { printf("Initialize client SDK done. //Set more network parameter. int nTryTimes = 3. //If timeout. 0). some data is needed to be initialized to enable normal business function. while(0 == g_lLoginHandle) { //Login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp.h. you can find corresponding explanation in dhnetsdk. NULL. please be careful with conversion //Example: #define NET_NOT_SUPPORTED_EC(23) //Current SDK does not support this function. NET_PARAM stuNetParm = {0}. g_nPort . if(0 == g_lLoginHandle) { // according to error code. g_szDevIp . EM_LOGIN_SPEC_CAP_TCP. int nError = 0. NET_DEVICEINFO_Ex stDevInfoEx = {0}. not decimal shows in header file. the waiting time varies by devices. stuNetParm. connection timeout value is 3000ms. &nError). printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . g_nPort. It is recommended to wait for a while after login. } 133/339 . g_szDevIp . Sleep(1000). &stDevInfoEx. It is to print hexadecimal here. g_szPasswd. Decimal number 23 is hexadecimal 0x17.nWaittime = 3000. g_szUserName. CLIENT_GetLastError()). error code is 0x80000017. printf("\n"). } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . } // The first time logining to device. g_nPort). // when login. } } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. CLIENT_SetNetworkParam(&stuNetParm). //This operation is optional. &stuSnapParams)) { printf("CLIENT_SnapPictureEx Failed!Last Error[%x]\n".CmdSerial = ++g_nCmdSerial. //Logout device if (0 != g_lLoginHandle) 134/339 . stuSnapParams. getchar(). NULL). valid range 0~65535.over this range will be cut to unsigned short if (FALSE == CLIENT_SnapPictureEx(g_lLoginHandle. return. CLIENT_SetSnapRevCallBack(SnapRev. // Snapshot channel defaults 0.mode = nSnapType.0:request one frame. CLIENT_GetLastError()). } void EndTest() { printf("input any key to quit! \n"). and mode defaults” request one frame”. }while('q' != szUserChoose[0]).// Snapshot mode.1:send out requestion regularly. if (0 == g_lLoginHandle) { return.Channel = nChannelId. szUserChoose). //Send snapshot command to front-end device. stuSnapParams. stuSnapParams. int nChannelId = 0. } else { printf("CLIENT_SnapPictureEx succ\n"). } //Set snapshot callback function. return. //request SN. } GetStringInput("'q': exit.2: Request consecutively SNAP_PARAMS stuSnapParams. 'c': continue\n". int nSnapType = 0. } int main() { InitTest(). char *pchDVRIP. 135/339 . LONG nDVRPort. } //********************************************************************************* // commonly used callback set declaration void CALLBACK DisConnectFunc(LLONG lLoginID. CLIENT_GetLastError()). RunTest(). } else { g_lLoginHandle = 0. DWORD dwUser) { printf("Call DisConnectFunc\n"). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). EndTest(). printf("lLoginID[0x%x]". } exit(0). } } // Clean up initialization resources. } printf("nDVRPort[%d]\n". pchDVRIP). return 0. { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". g_bNetSDKInitFlag = FALSE. nDVRPort). lLoginID). "wb"). LDWORD dwUser) { printf("[SnapRev] -.jpg". LDWORD dwUser) { printf("Call HaveReConnect\n"). printf("lLoginID[0x%x]". while(nWrite != RevLen) { 136/339 . "%d_%s. char szTmpTime[128] = "". gmtime(&stuTime)). } void CALLBACK SnapRev(LLONG lLoginID.1. strftime(szTmpTime. lLoginID). printf("dwUser[%p]\n". sizeof(szTmpTime) . } printf("nDVRPort[%d]\n". printf("\n").receive data!\n"). LONG nDVRPo rt. BYTE *pBuf. if (NULL == pFile) { return. printf("dwUser[%p]\n". nDVRPort). pchDVRIP). time_t stuTime. if(lLoginID == g_lLoginHandle) { if (NULL != pBuf && RevLen > 0) { char szPicturePath[256] = "". CmdSerial. } void CALLBACK HaveReConnect(LLONG lLoginID. } int nWrite = 0. "%y%m%d_%H%M%S". dwUser). UINT EncodeType. sizeof(szPicturePath)-1. _snprintf(szPicturePath. DWORD CmdSerial. time(&stuTime). printf("\n"). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". dwUser). char *pchDVRIP. FILE* pFile = fopen(szPicturePath. UINT RevLen. szTmpTime). } else { nError = 0. int& nError) { long int nGet = 0. } 137/339 . &pError.nWrite. 1. RevLen . printf(szPromt). char* pError = NULL. char szUserInput[32] = "". gets(szUserInput). } } } //********************************************************************************* // commonly used function set declaration int GetIntInput(char *szPromt. gets(szBuffer). char *szBuffer) { printf(szPromt). } return nGet. } fclose(pFile). 10). if ('\0' != *pError) { //input parameter error nError = -1. nGet = strtol(szUserInput. } void GetStringInput(const char *szPromt . pFile). nWrite += fwrite(pBuf + nWrite. 9Report Alarm 2. The method of alarm report is that SDK actively connects device and subscribes alarm function from device. 138/339 . The platform may receive external alarm、video signal lost alarm、tampering alarm and motion detection alarm uploaded by device.9.2.9.9.3 Process Instruction Report alarm process flow sheet is shown in Figure 2-13.1 Intro Report alarm. When device detects alarm event. when front-end device detects special event set previously. it will immediately send the event to SDK. 2.2 Interface Overview Interface Interface Description CLIENT_Init Interface for initilization CLIENT_Cleanup Interface for cleaning up SDK resources CLIENT_LoginEx2 Extensive interface for sync login CLIENT_SetDVRMessCallBack Interface for setting alarm callback function Extensive interface for subscribing alarm event from CLIENT_StartListenEx device CLIENT_StopListen Interface for stopping subscribing alarm CLIENT_Logout Interface for logout device Interface for getting error code after failed calling CLIENT_GetLastError interface 2. send alarm to platform-end and notify the platform. call CLIENT_LoginEx2 to login device. Call CLIENT_StartListenEx to subscribe alarm from device. 3. SDK initialization 2. START SDK initialization CLIENT_init Login to device CLIENT_LoginEx2 Set alarm event callback function Alarm event callback function CLIETN_SetDVRMessCallBack Subscribe alarm from device CLIENT_StartListenEx Subscribe alarm from device CLIENT_StopListen Logout user CLIENT_Logout Release SDK resource CLIENT_Cleanup END Figure 2-13 Report alarm process flow sheet Process discription: 1. After successful initialization. After successful subscription. call CLIENT_StopListen to stop device alarm 139/339 . 4. 5. Call CLIENT_SetDVRMessCallBack to set alarm event callback function,this interface shall be called before alarm subscription. alarm event reported by device is sent to user via callback function set in CLIENT_SetDVRMessCallBack. After alarm report function is finished. static LLONG g_lLoginHandle = 0L.2. DWORD dwUser).h> #include "dhnetsdk. static char g_szPasswd[64] = "admin". char *pchDVRIP. "dhnetsdk. static WORD g_nPort = 37777. LONG nDVRPort.h" #pragma comment(lib . when offline device is reconnected successfully. char *pchDVRIP. // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect.66".4 Example Code #include<windows. Call CLIENT_Logout to logout device. call CLIENT_Cleanup to release SDK resources. static BOOL g_bStartListenFlag = FALSE. Last but not the least. // alarm event callback function 140/339 . LONG nDVRPort. static char g_szUserName[64] = "admin". SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID.subscription. 7.h> #include <stdio. LDWORD dwUser).9. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. 6. static char g_szDevIp[32] = "172.lib") static BOOL g_bNetSDKInitFlag = FALSE.23. 2. // It’s not recommended to call SDK interfaces in this callback function // set this callback function in CLIENT_SetDVRMessCallBack. when device gets offline. \n"). but recommended CLIENT_SetAutoReconnect(&HaveReConnect. //********************************************************************************** void InitTest() { // SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. // when login. nTryTimes). char *pchDVRIP. you have 3 attempts CLIENT_SetConnectTime(nWaitTime. NET_PARAM stuNetParm = {0}. LLONG lLoginID. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. nWaittime and nConnectTryNum in NET_PARAM has th e same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. SDK will reconnect internally. //This operation is optional. // set CLIENT_SetAutoReconnect interface. 141/339 . char *pBuf. //Set more network parameter. stuNetParm. // if timeout. LDWORD dwUser).nWaittime = 3000. LONG nDVRPort. \n"). } else { printf("Initialize client SDK done. 0). DWORD dwBufLen. When receiving alarm event reported by device,SDK will call this function BOOL CALLBACK MessCallBack(LONG lCommand. dwNetSdkVersion). return. 0). } // get SDK version info // this operation is optional DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). // timeout time is set to 5s int nTryTimes = 3. printf("NetSDK version is [%d]\n". connection timeout value is 3000ms.Once HaveReConnect is set. // set connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000. // this operation is optional. It is recommended to wait for a while after login. CLIENT_SetNetworkParam(&stuNetParm). while(0 == g_lLoginHandle) { // login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. corresponding error code is 0x80000017. please be careful with conversion // example: // #define NET_NOT_SUPPORTED_EC(23) // current SDK does not support the function. Decimal number 23 is hexadecimal 0x17. g_szDevIp . g_nPort. &nError). if (0 == g_lLoginHandle) { // according to error code. } } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. &stDevInfoEx. } if (0 == g_lLoginHandle) 142/339 . g_nPort). CLIENT_GetLastError()). NET_DEVICEINFO_Ex stDevInfoEx = {0}. EM_LOGIN_SPEC_CAP_TCP. some data is needed to be initialized to enable normal business function. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . g_szUserName. g_szPasswd. int nError = 0. Sleep(1000). not decimal showns in header file.h. It is to print hexadecimal here. } // The first time logining to device. NULL. g_nPort . the waiting time varies by devices. } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . printf("\n"). you can find corresponding explanation in dhnetsdk. g_szDevIp . { return... printf("CLIENT_StartListenEx Success! \nJust Wait Event. } // set alarm event callback function CLIENT_SetDVRMessCallBack(MessCallBack .. CLIENT_GetLastError()).\n"). // stop subscribing alarm from device if (TRUE == g_bStartListenFlag) { if (FALSE == CLIENT_StopListen(g_lLoginHandle)) { printf("CLIENT_StopListen Failed!Last Error[%x]\n". NULL). // subscribe alarm from device if( TRUE == CLIENT_StartListenEx(g_lLoginHandle)) { g_bStartListenFlag = TRUE. } else { g_bStartListenFlag = FALSE. } } void EndTest() { printf("input any key to quit! \n"). getchar(). } else { printf("CLIENT_StartListenEx Failed!Last Error[%x]\n" . CLIENT_GetLastError()). } } 143/339 . CLIENT_GetLastError()). } int main() { InitTest(). } else { g_lLoginHandle = 0. EndTest(). return 0. LONG nDVRPort. } //********************************************************************************* // commonly used callback definition set void CALLBACK DisConnectFunc(LLONG lLoginID. // logout device if (0 != g_lLoginHandle) { if(FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". g_bNetSDKInitFlag = FALSE. char *pchDVRIP. } return. RunTest(). } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). DWORD dwUser) { 144/339 . lLoginID). nDVRPort). lLoginID). please refer to related event explanation in header file dhnetsdk. user can deal with corresponding alarm event info accordingly. printf("Call DisConnectFunc\n"). printf("lLoginID[0x%x]". pchDVRIP). char *pchDVRIP. printf("dwUser[%p]\n". DWORD dwBufLen. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". } BOOL CALLBACK MessCallBack(LONG lCommand. dwUser). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n".h for details. nDVRPort). LONG nDVRPort. pchDVRIP . // only part of alarm processing methods is listed in the demo. port[%d]\n" . printf("\n"). } printf("nDVRPort[%d]\n". nDVRPort). LDWORD dwUser) { printf("Call HaveReConnect\n"). printf("\n"). } printf("nDVRPort[%d]\n".Get Event IP[%s] . switch(lCommand) { 145/339 . pchDVRIP). char *pchDVRIP. } void CALLBACK HaveReConnect(LLONG lLoginID. dwUser). LLONG lLoginID. printf("lLoginID[0x%x]". LONG nDVRPort. printf("dwUser[%p]\n". char *pBuf. LDWORD dwUser) { printf("[MessCallBack] -. i. printf("nChannelID = %d\n" . if (NULL != pBuf) { BYTE* pInfo = (BYTE*)pBuf. ++i) { printf("nChannelID = [%2d]. *(pInfo + i)). i < dwBufLen/sizeof(BYTE). for(unsigned int i = 0. } } } break. if (NULL != pBuf) { ALARM_REMOTE_ALARM_INFO* pInfo = (ALARM_REMOTE_ALARM_INFO *)pBuf. case DH_ALARM_ALARM_EX: { printf("\n external alarm\n"). 146/339 . pInfo->nState). *(pInfo + i)). state = [%d]\n". state = [%d]\n". case DH_MOTION_ALARM_EX: { printf("\n motion detection alarm\n"). for(unsigned int i = 0. i. case DH_ALARM_ALARM_EX_REMOTE: { printf("\n remote external alarm \n"). printf("nState = %d\n" . i < dwBufLen/sizeof(BYTE). } } } break. ++i) { printf("nChannelID = [%2d]. if (NULL != pBuf) { BYTE* pInfo = (BYTE*)pBuf. pInfo->nChannelID). } 2. } } break. default: printf("\n[MessCallBack] – other alarm Get lCommand = 0x%x\n" . Device search can work with login function. pInfo->szCardNo). pInfo->emOpenMethod). } return TRUE. printf(" unlock method = %d\n" .10 Device Search 2.1 Intro Device search is mainly used to help user to get device info from network. lCommand). if (NULL != pBuf) { ALARM_ACCESS_CTL_EVENT_INFO* pInfo = (ALARM_ACCESS_CTL_EVENT_INFO *)pBuf.10. case DH_ALARM_ACCESS_CTL_EVENT: { printf("\n access control event \n"). printf(" card NO. } } break. Device search interface can find relevant devices and login interface can 147/339 . break. = [%s]\n" . Device search is classified into the following two types by whether crossing segment or not: Async same -segment device search Search for device info within current segment. 2. within CLIENT_StartSearchDevices same segment Interface for stopping async search for IPC. login these devices. searching for device in corresponding segment. NVS and etc. 148/339 . NVS and etc.10.10.3.2 Interface Overview Interface Interface Description CLIENT_Init Interface for initilization CLIENT_Cleanup Interface for cleaning up SDK resources Interface for async searching for IPC.1 Async Search for Same-segment Device Async search for device within the same segment is shown in Figure 2-14. Sync cross-segment device search According to user-set segment info.10.3 Process Intruction 2. CLIENT_StopSearchDevices within same segment CLIENT_SearchDevicesByIPs Interface for sync searching cross-segment device CLIENT_GetLastError Interface for getting error code after failed calling interface 2. 4. call CLIENT_Cleanup to release SDK resourc e.2 Sync Search for Cross-segment Device Sync search for cross-segment device is shown in Figure 2-15. SDK initialization 2. user needs to stop searching by calling interface CLIENT_StopSearchDevices. When SDK function use is done. 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 Stop aSync search device within the same segment CLIENT_StopSearchDevice Release SDK resource CLIENT_Cleanup END Figure 2-14 Async search for devices within the same segment Process discription: 1. 149/339 . Call CLIENT_StartSearchDevices to async search for devices within the same segment. 3. Call CLIENT_StopSearchDevices to stop async searching device within the same segment. 2.3. User gets the obtained device info via callback function fSearchDevicesCB which is set in this interface. The search operation has no timeout time.10. lib") 150/339 . 2.10.1 Async Search for Same-segment Device #include<windows. Only when searching time is out or searching all the devices cross the segment . SDK initialization. "dhnetsdk.10. 3. 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 Release SDK resource CLIENT_Cleanup END Figure 2-15 Sync search for cross-segment device Process description: 1. User can decide the timeout time according to net condition.4 Example Code 2.h> #include <stdio. Call CLIENT_Cleanup to release SDK resource.4.h> #include <list> #include "dhnetsdk. User gets the obtained device info via callback function fSearchDevicesCB which is set in this interface.h" #pragma comment(lib . Call CLIENT_SearchDevicesByIPs to sync search for device crossing segment. 2. the interface return. DWORD dwUser). // initialization SDK g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. when offline device is reconnected successfully. // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. char *pchDVRIP. // device list //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. SDK will call this function when device is found. if (FALSE == g_bNetSDKInitFlag) 151/339 . // device list operation lock static std::list<DEVICE_NET_INFO_EX> g_lDeviceList. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. static BOOL g_bNetSDKInitFlag = FALSE. void* pUserData). // async search for device callback // It’s not recommended to call SDK interfaces in this callback function // set this callback function in CLIENT_StartSearchDevices/CLIENT_SearchDevicesByIPs. LONG nDVRPort. static CRITICAL_SECTION g_mDeviceListLock. char *pchDVRIP. void CALLBACK SearchDevicesCB(DEVICE_NET_INFO_EX *pDevNetInfo. 0). LDWORD dwUser). LONG nDVRPort. static LLONG g_lSearchHandle = 0L. //********************************************************************************* void InitTest() { // initialization thread lock InitializeCriticalSection(&g_mDeviceListLock). // set CLIENT_SetAutoReconnect interface. printf("NetSDK version is [%d]\n". nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. CLIENT_SetNetworkParam(&stuNetParm). } // get SDK version info // this operation is optional DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). NET_PARAM stuNetParm = {0}. return. connection timeout value is 3000ms. SDK will reconnect internally. nTryTimes). // when login. // timeout time is set to 5s int nTryTimes = 3. you have 3 attempts CLIENT_SetConnectTime(nWaitTime.Once HaveReConnect is set. but recommended CLIENT_SetAutoReconnect(&HaveReConnect. \n"). } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. stuNetParm. // this operation is optional.nWaittime = 3000. // set connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000. //Set more network parameter. dwNetSdkVersion). \n"). } else { printf("Initialize client SDK done. { printf("Initialize client SDK fail. //This operation is optional. 0). } 152/339 . when device gets offline. // if timeout. erase(iter). iter->iIPVersion). &g_lDeviceList). ++nIndex).) { printf("\n************** find device *************\n"). } 153/339 . printf("nIndex[%d]\n".// search lasts for 10s.begin(). if (NULL == g_lSearchHandle) { printf("CLIENT_StartSearchDevices Failed!Last Error[%x]\n". } int nIndex = 0. Sleep(1000). printf("iIPVersion[%d]\n". iter != g_lDeviceList. } LeaveCriticalSection(&g_mDeviceListLock). // start async search for same-segment device g_lSearchHandle = CLIENT_StartSearchDevices(SearchDevicesCB. printf("szIP[%s]\n". iter->nPort). printf("nPort[%d]\n". g_lDeviceList. } EnterCriticalSection(&g_mDeviceListLock). iter = g_lDeviceList. int nSearchTime = 0. user can modify this value according to network condition while (TRUE) { if (nSearchLimit == nSearchTime++) { break. CLIENT_GetLastError()). for (std::list<DEVICE_NET_INFO_EX>::iterator iter = g_lDeviceList.end(). return. int nSearchLimit = 10.begin(). iter->szIP). RunTest(). } void EndTest() { printf("input any key to quit! \n"). } } int main() { InitTest(). } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). CLIENT_GetLastError()). EndTest(). getchar(). g_bNetSDKInitFlag = FALSE. // cleanup thread lock resource DeleteCriticalSection(&g_mDeviceListLock). 154/339 . // stop async search for same-segment devices if (NULL != g_lSearchHandle) { if (FALSE == CLIENT_StopSearchDevices(g_lSearchHandle)) { printf("CLIENT_StopSearchDevices Failed!Last Error[%x]\n". } printf("nDVRPort[%d]\n". pchDVRIP). nDVRPort). dwUser). } printf("nDVRPort[%d]\n". nDVRPort). printf("dwUser[%p]\n". dwUser). lLoginID). DWORD dwUser) { printf("Call DisConnectFunc\n"). char *pchDVRIP. printf("dwUser[%p]\n". pchDVRIP). } void CALLBACK DisConnectFunc(LLONG lLoginID. void* pUserData) { if ((NULL == pDevNetInfo) || (NULL == pUserData)) { 155/339 . return 0. printf("\n"). LONG nDVRPort. lLoginID). LDWORD dwUser) { printf("Call HaveReConnect\n"). printf("lLoginID[0x%x]". LONG nDVRPort. } void CALLBACK SearchDevicesCB(DEVICE_NET_INFO_EX *pDevNetInfo. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". } void CALLBACK HaveReConnect(LLONG lLoginID. char *pchDVRIP. printf("lLoginID[0x%x]". if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". printf("\n"). } std::list<DEVICE_NET_INFO_EX>* pDeviceList = (std::list<DEVICE_NET_INFO_EX>*)pUserData. // device list // ***************************************get local IP interface std::string GetLocalIpAddress().lib") static BOOL g_bNetSDKInitFlag = FALSE. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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(LONG lLoginID. LONG nDVRPort. } 2. LeaveCriticalSection(&g_mDeviceListLock).h> #include <stdio. return. static std::list<DEVICE_NET_INFO_EX> g_lDeviceList. return. EnterCriticalSection(&g_mDeviceListLock). "dhnetsdk. // callback function used after device is reconnected successfully 156/339 . printf("warming param is null\n").4. DWORD dwUser).2 Sync Search for Cross-segment Device #include<windows.10.h" #pragma comment(lib . pDeviceList->push_back(*pDevNetInfo).h> #include <list> #include "dhnetsdk. char *pchDVRIP. when offline device is reconnected successfully. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. // timeout time is set to 5s 157/339 . LONG nDVRPort. when device gets offline. printf("NetSDK version is [%d]\n". } else { printf("Initialize client SDK done. // sync search for device callback // It’s not recommended to call SDK interfaces in this callback function // set this callback function in CLIENT_StartSearchDevices/CLIENT_SearchDevicesByIPs. but recommended CLIENT_SetAutoReconnect(&HaveReConnect. // this operation is optional. return. 0). SDK will reconnect internally. //********************************************************************************* void InitTest() { // SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. LDWORD dwUser). // set connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000.Once HaveReConnect is set. char *pchDVRIP. 0). dwNetSdkVersion). } // get SDK version info // this operation is optional DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). void* pUserData). void CALLBACK SearchDevicesCB(DEVICE_NET_INFO_EX *pDevNetInfo. // set CLIENT_SetAutoReconnect interface. \n"). SDK will call this function when device is found. \n"). %d". DEVICE_IP_SEARCH_INFO stuTmp = {sizeof(stuTmp)}. GetLocalIpAddress(). "172. // when login.c_str(). user shall decide timeout time according to net condition if (FALSE == CLIENT_SearchDevicesByIPs(&stuTmp. dwWaitTime)) { printf("CLIENT_SearchDevicesByIPs Failed!Last Error[%x]\n".11. //This operation is optional. stuNetParm. // valid IP address number for (unsigned int i = 0. ++i) { // user needs to ensure IP address validity and network connection. szLocalIp.szIP[i]. CLIENT_SetNetworkParam(&stuNetParm).1). connection timeout value is 3000ms. // if timeout. you have 3 attempts CLIENT_SetConnectTime(nWaitTime. //Set more network parameter.nWaittime = 3000. // please note that this interface will return until timeout.1. stuTmp. } // start sync search for cross-segment device char szLocalIp[64] = "". i). (LDWORD)&g_lDeviceList.11. sizeof(stuTmp.szIP[i]) .1. 158/339 . Here the searching segment is 172. i < stuTmp. sizeof(szLocalIp) .77 _snprintf(stuTmp. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime.xxx. nTryTimes). int nTryTimes = 3. } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. strncpy(szLocalIp. NET_PARAM stuNetParm = {0}. and local IP address is 10. SearchDevicesCB.1. } DWORD dwWaitTime = 5000.34.3.nIpNum.nIpNum = 256. iter != g_lDeviceList.end(). } } int main() { InitTest(). printf("szIP[%s]\n". 159/339 . iter->nPort). iter->iIPVersion). // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup().CLIENT_GetLastError()). for (std::list<DEVICE_NET_INFO_EX>::iterator iter = g_lDeviceList. iter->szIP). printf("nIndex[%d]\n". RunTest(). printf("nPort[%d]\n". ++iter) { printf("\n************** find device *************\n"). g_bNetSDKInitFlag = FALSE.begin(). } int nIndex = 0. getchar(). printf("iIPVersion[%d]\n". ++nIndex). return. } } void EndTest() { printf("input any key to quit! \n"). } printf("nDVRPort[%d]\n". EndTest(). char *pchDVRIP. lLoginID). dwUser). printf("\n"). } 160/339 . nDVRPort). } void CALLBACK HaveReConnect(LLONG lLoginID. printf("dwUser[%p]\n". printf("\n"). printf("lLoginID[0x%x]". if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". printf("dwUser[%p]\n". dwUser). LDWORD dwUser) { printf("Call HaveReConnect\n"). return 0. pchDVRIP). pchDVRIP). printf("lLoginID[0x%x]". DWORD dwUser) { printf("Call DisConnectFunc\n"). } //********************************************************************************* //commonly used callback set definition void CALLBACK DisConnectFunc(LLONG lLoginID. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". lLoginID). char *pchDVRIP. LONG nDVRPort. nDVRPort). } printf("nDVRPort[%d]\n". LONG nDVRPort. } // *************************************** get local IP interface std::string GetLocalIpAddress() { WSADATA wsaData. hostent* ph = gethostbyname(local). &wsaData)) { return "". sizeof(local)). std::string localIP(inet_ntoa(addr)). ph->h_addr_list[0]. } in_addr addr. memcpy(&addr. if (0 != WSAStartup(MAKEWORD(2. void CALLBACK SearchDevicesCB(DEVICE_NET_INFO_EX *pDevNetInfo. 161/339 . if (NULL == ph) { return "". sizeof(in_addr)). } std::list<DEVICE_NET_INFO_EX>* pDeviceList = (std::list<DEVICE_NET_INFO_EX>*)pUserData. void* pUserData) { if ((NULL == pDevNetInfo) || (NULL == pUserData)) { printf("warming param is null\n"). return. return. pDeviceList->push_back(*pDevNetInfo). gethostname(local. } char local[255] = "".2). 11. leave picket zone. cross picket line. 162/339 . across enclosure. carry-over detection. Intelligent snapshot event: user manually sends a command to device after subscribing event successfully. straggle detection. return localIP.11 Intelligent Event Report and Snapshot 2. } 2.3 Process Intruction Intelligent event report and snapshot process flow sheet is shown in Figure 2-16. Device snapshots pictute of current scene and reports it to user via intelligent event. go in the wrong direction etc. move detection. goods protection.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.11. WSACleanup().11.2 Interface Overview Interface Interface Description CLIENT_Init Interface for initilization CLIENT_Cleanup Interface for cleaning up SDK resources CLIENT_LoginEx2 Extensive interface 2 for sync login CLIENT_RealLoadPictureEx Interface for intelligent picture alarm subscription CLIENT_ControlDeviceEx Extensive interface for device control CLIENT_Logout Interface for logout device CLIENT_GetLastError Interface for getting error code after failed calling interface 2. illegal parking. fast moving. 2. enter picket zone. Intelligent events are: scene change. in picket zone. user should converts input character to corresponding struct according to the instruction in SDK header files. and then displays 163/339 . After successful subscription. Call CLIENT_RealLoadPictureEx to subscribe intelligent snapshot alarm from device. START SDK initialization Device login CLIENT_LoginEx2 User obtains and saves intelligent alarm Subscribe intelligent picture alarm from device info and carried picture info by callback CLIENT_RealLoadPictureEx fAnalyzerDataCallBack Trigger intelligent picture alarm manually CLIENT_ControlDeviceEx. In callback function.emType is DH_MANUAL_SNAP Stop subscribing intelligent picture alarm from device CLIENT_StopLoadPic Logout user CLIENT_Logout Release SDK resource CLIENT_Cleanup END Figure 2-16 intelligent event report and snapshot Process discription: 1. SDK initialization 2. 3. the intelligent snapshot alarm event reported by device will be sent to user by callback function fAnalyzerDataCallBack. call CLIENT_LoginEx2 to login device. After successful initialization. lib") static BOOL g_bNetSDKInitFlag = FALSE. "dhnetsdk. static char g_szDevIp[32] = "192.168. static char g_szPasswd[64] = "admin". If a user wants to manually trigger intelligent picture alarm. call CLIENT_Logout to logout device.h" #pragma comment(lib . device then snapshots current monitoring video and reports it to user. otherwise SDK will abandon data pack over 2M 4.h> #include "dhnetsdk.11.h> #include <list> #include <time.4 Example Code #include<windows. 5. Due to SDK receving buffer is 2M by default. 2.4.user need to call CLIENT_SetNetworkParam interface to set receiving buffer again. static int g_nPort = 37777. call CLIENT_Cleanup to release SDK resource. 7. //********************************************************************************* // commonly used callback set declaration // callback function used when device gets offline // It’s 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 164/339 .and saves event as needed. After intelligent picture alarm report function is done. static LLONG g_lLoginHandle = 0L. when callback picture info exceed 2M. he can call CLIENT_ControlDeviceEx interface with parameter emType DH_MANUAL_SNAP.12".h> #include <stdio. SDK will send command to device. static char g_szUserName[64] = "admin". After business use is done. After SDK function use is done. call CLIENT_StopLoadPic to stop subscribing intelligent picture alarm from device. static LLONG g_lRealLoadHandle = 0L. 6. 0 means it is the first time to appear. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK fail. char *pchDVRIP. DWORD dwAlarmType. SDK will call the function void CALLBACK HaveReConnect(LLONG lLoginID. DWORD dwBufSize. LONG nDVRPort. SDK will call this function when device-end has intelligent picture event to report. // nSequence is used when uploading the same picture. LONG nDVRPort. 165/339 . when callback picture info exceed 2M. no special meaning // due to SDK receving buffer is 2M by default. 1 means offline data. LDWORD dwUser. LDWORD dwUser). when offline device is reconnected successfully. return. 2 means it is the last time to appear or only appear once. // return value is abolished. 2 means offline transmission done. 0 means real-time data. 1 means it will appear again later // int nState =* (int*) reserved means current callback data status. DWORD dwUser). // callback function used after device is reconnected successfully // It’s not recommended to call SDK interfaces in this callback function // Set the callback function in CLIENT_SetAutoReconnect. void* pAlarmInfo.automatically void CALLBACK DisConnectFunc(LONG lLoginID. void *reserved). char *pchDVRIP. otherwise SDK will abandon data pack over 2M int CALLBACK AnalyzerDataCallBack(LLONG lAnalyzerHandle. } else { printf("Initialize client SDK done. //********************************************************************************* void InitTest() { // SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. \n").use r need to call CLIENT_SetNetworkParam interface to set receiving buffer again. 0). BYTE *pBuffer. // intelligent analyzing data callback // It’s not recommended to call SDK interfaces in this callback function // set this callback function in CLIENT_RealLoadPictureEx/CLIENT_RealLoadPicture. int nSequence. \n"). when device gets offline. //This operation is optional. you have 3 attempts CLIENT_SetConnectTime(nWaitTime. you can find corresponding explanation in dhSDK. nWaittime and nConnectTryNum in NET_PARAM has the same meaning with the timeout time and trial time set in interface CLIENT_SetConnectTime. printf("NetSDK version is [%d]\n". EM_LOGIN_SPEC_CAP_TCP. g_nPort . printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . //Set more network parameter. It is to print hexadecimal here. stuNetParm. g_szDevIp . 0). please be careful with conversion // example: // #define NET_NOT_SUPPORTED_EC(23) // current SDK does not support the function. while(0 == g_lLoginHandle) { // login device g_lLoginHandle = CLIENT_LoginEx2(g_szDevIp. Decimal number 23 is hexadecimal 0x17.Once HaveReConnect is set. NET_DEVICEINFO_Ex stDevInfoEx = {0}. connection timeout value is 3000ms. g_szUserName. but recommended CLIENT_SetAutoReconnect(&HaveReConnect. 166/339 . g_nPort. &stDevInfoEx. int nError = 0. nTryTimes). // when login. CLIENT_SetNetworkParam(&stuNetParm). not decimal showns in header file. SDK will reconnect internally. NET_PARAM stuNetParm = {0}. NULL. } // get SDK version info // this operation is optional DWORD dwNetSdkVersion = CLIENT_GetSDKVersion(). &nError). dwNetSdkVersion). // set connectting device timeout time and attempts // this operation is optional int nWaitTime = 5000. // if timeout.h. // set CLIENT_SetAutoReconnect interface. corresponding error code is 0x80000017. g_szPasswd.nWaittime = 3000. // this operation is optional. if (0 == g_lLoginHandle) { // according to error code. // timeout time is set to 5s int nTryTimes = 3. } // The first time logining to device. some data is needed to be initialized to enable normal business function. nChannel. // each setup corresponds to one channel. NULL). printf("\n"). It is recommended to wait for a while after login. dwUser. if (0 == g_lRealLoadHandle) 167/339 . Sleep(1000). Int nChannel = 0.CLIENT_GetLastError()). EVENT_IVS_ALL. } } void RunTest() { if (FALSE == g_bNetSDKInitFlag) { return. } if (0 == g_lLoginHandle) { return. the parameter dwAlarmType should be set to EVENT_IVS_ALL // If you want to set that one channel uploads two events. please call CLIENT_RealLoadPictureEx twice and set different event type g_lRealLoadHandle = CLIENT_RealLoadPictureEx(g_lLoginHandle. g_szDevIp . } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . and corresponds to event of a certain type // if a user wants to set all types of event for one channel. TRUE. } // subscribe intelligent picture alarm LDWORD dwUser = 0. AnalyzerDataCallBack. g_nPort). the waiting time varies by devices. gets(szGetBuf). sizeof(szGetBuf) . \'q\': quit. other: yes\n"). CLIENT_GetLastError()). CLIENT_GetLastError()). sizeof(stuSanpParam. break. printf("manual snap. &stuSanpParam)) { printf("CLIENT_ControlDeviceEx Failed!Last Error[%x]\n".bySequence)). } } } void EndTest() { 168/339 . // manually snapshot trigger alarm function. "q". other s mean to trigger alarm if (0 == strncmp(szGetBuf. } // manually snapshot trigger intelligent picture alarm function while(1) { char szGetBuf[64] = "". } MANUAL_SNAP_PARAMETER stuSanpParam = {0}. DH_MANUAL_SNAP.bySequence.nChannel = 0. this function is only valid for ITC device if (FALSE == CLIENT_ControlDeviceEx(g_lLoginHandle. return. strncpy((char*)stuSanpParam. "just for test".1)) { break. { printf("CLIENT_RealLoadPictureEx Failed!Last Error[%x]\n". // enter 'q' to exit manual snapshot trigger alarm. stuSanpParam. } } // cleanup initialization resource if (TRUE == g_bNetSDKInitFlag) { CLIENT_Cleanup(). } } // logout device if (0 != g_lLoginHandle) { if (FALSE == CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". CLIENT_GetLastError()). // stop subscribing picture alarm if (0 != g_lRealLoadHandle) { if (FALSE == CLIENT_StopLoadPic(g_lRealLoadHandle)) { printf("CLIENT_StopLoadPic Failed!Last Error[%x]\n". getchar(). } else { g_lRealLoadHandle = 0. CLIENT_GetLastError()). } else { g_lLoginHandle = 0. 169/339 .printf("input any key to quit! \n"). g_bNetSDKInitFlag = FALSE. return 0. } //********************************************************************************* // commonly used callback set definition void CALLBACK DisConnectFunc(LLONG lLoginID. } printf("nDVRPort[%d]\n". pchDVRIP). DWORD dwUser) { printf("Call DisConnectFunc\n"). } return. } int main() { InitTest(). RunTest(). LONG nDVRPort. dwUser). LDWORD dwUser) { printf("Call HaveReConnect\n"). EndTest(). pchDVRIP). printf("\n"). lLoginID). } void CALLBACK HaveReConnect(LLONG lLoginID. nDVRPort). lLoginID). if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". char *pchDVRIP. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". char *pchDVRIP. 170/339 . printf("dwUser[%p]\n". printf("lLoginID[0x%x]". LONG nDVRPort. printf("lLoginID[0x%x]". DEV_EVENT_PARKINGDETECTION_INFO* pStuInfo = (DEV_EVENT_PARKINGDETECT ION_INFO*)pAlarmInfo. printf("nChannelID[%d]\n". int nSequence. } int nAlarmChn = 0. void *reserved) { if (lAnalyzerHandle != g_lRealLoadHandle) { return 0. nAlarmChn = pStuInfo->nChannelID. nAlarmChn = pStuInfo->nChannelID. pStuInfo->nChannelID). } 171/339 . DWORD dwBufSize. dwUser). pStuInfo->nChannelID). DWORD dwAlarmType. printf("nChannelID[%d]\n". } break. case EVENT_IVS_PARKINGDETECTION: { printf("EVENT_IVS_PARKINGDETECTION event\n"). DEV_EVENT_TRAFFIC_OVERLINE_INFO* pStuInfo = (DEV_EVENT_TRAFFIC_OVERLINE_INFO*)pAlarmInfo. nDVRPort). void* pAlarmInfo. LDWORD dwUser. } printf("nDVRPort[%d]\n". BYTE *pBuffer. switch(dwAlarmType) { case EVENT_IVS_TRAFFIC_OVERLINE: { printf("EVENT_IVS_TRAFFIC_OVERLINE event\n"). printf("dwUser[%p]\n". } int CALLBACK AnalyzerDataCallBack(LLONG lAnalyzerHandle. printf("\n"). time(&stuTime). static int i.jpg". time_t stuTime. szTmpTime). default: printf("other event type[%d]\n". } break. mark with i than saving pictures via receiving time which may cause overlapping. ++i. char szTmpTime[128] = "". DEV_EVENT_TRAFFIC_MANUALSNAP_INFO* pStuInfo = (DEV_EVENT_TRAFFIC_MANUALSNAP_INFO*)pAlarmInfo. } 172/339 . strftime(szTmpTime. if (NULL == pFile) { return 0. char szPicturePath[256] = "". break. dwAlarmType). "%d_%s. // pStuInfo->szManualSnapNo should be "just for test" printf("nChannelID[%d]\n". _snprintf(szPicturePath. FILE* pFile = fopen(szPicturePath. } if (dwBufSize > 0 && NULL != pBuffer) { // in case of too many picturse being received at the same time. sizeof(szPicturePath)-1. case EVENT_IVS_TRAFFIC_MANUALSNAP: { printf("EVENT_IVS_TRAFFIC_MANUALSNAP event\n"). break.1. sizeof(szTmpTime) . "wb"). "%y%m%d_%H%M%S". pStuInfo->nChannelID). nAlarmChn = pStuInfo->nChannelID. gmtime(&stuTime)). int nWrite = 0. dwBufSize .nWrite. } return 1. while(nWrite != dwBufSize) { nWrite += fwrite(pBuffer + nWrite. pFile). } fclose(pFile). 1. } 173/339 . 3 Callback function definition 3. nDVRPort Device port. pchDVRIP and nDVRPort. 174/339 . Precondition none typedef void(CALLBACK *fDisConnect)( LLONG lLoginID. Parameter Disconnected device IP which is the input IP of login interface. pchDVRIP Device IP. Informing user via this callback when Interface description logined device gets disconnected. LDWORD dwUser ). Note User can identify which device gets disconnected via parameters lLoginID. Return value of login interface CLIENT_LoginEx2 . lLoginID Logined device ID. Disconnected device port which is the input port of login interface.1fDisConnect Option Instruction Disconnection callback function. Function LONG nDVRPort. char *pchDVRIP. dwUser User data Return value None Set this callback in interface CLIENT_Init. lLoginID Logined device ID. dwUser User data Return value None Set this callback in interface CLIENT_SetAutoReconnect. Disconnected device port which is the input port of login interface. Note User can identify which device gets reconnected via parameters lLoginID、 pchDVRIP and nDVRPort. 175/339 . pchDVRIP Device IP. Interface When the disconnected device gets reconnected. char *pchDVRIP. Precondition None typedef void (CALLBACK *fHaveReConnect)( LLONG lLoginID. Return value of login interface CLIENT_LoginEx2. LDWORD dwUser ). Parameter Disconnected device IP which is the input IP of login interface. call this interface to inform description user.2fHaveReConnect Option Instruction Successful reconnection callback function.3. nDVRPort Device port. Function LONG nDVRPort. dwDataType description Parameter 0 Original data which is the data stored by CLIENT_SaveRealData 1 Frame data 2 Yuv data 3 Pcm data pBuffer Buffer for callback data.3. Data of different length will be called back according to different dwDataType value. Function DWORD dwBufSize. LONG param. The type is decided by parameter dwFlag set in CLIENT_SetRealDataCallBackEx. BYTE *pBuffer. LDWORD dwUser ). Return value of real-tme monitoring interface like CLIENT_RealPlayExc et. DWORD dwDataType. dwDataType. lRealHandle Real-time monitoring handle. The data are called back by frame for every 176/339 .3fRealDataCallBackEx Option Instruction Interface description Real-time monitoring data callback function prototype extension Precondition None typedef void (CALLBACK*fRealDataCallBackEx)( LLONG lRealHandle. Type of data being called back. (unit: byte). Return value None Set the callback function in CLIENT_SetRealDataCallBackEx. each time one frame is called back. param is 0. See struct tagVideoFrameParam for details. Different dwDataType has different length. Note User can identify which real-time monitoring the callback data belongs to via parameter lRealHandle. dwUserData user data. param is a pointer of struct tagCBPCMDataParam type.Option Instruction dwDataType value but 0. LDWORD dwUser 177/339 . when dwDataType is 0 and 2. param is a pointer of struct tagVideoFrameParam type. dwBufSize Callback data length. Function DWORD dwTotalSize.4fDownLoadPosCallBack Option Instruction Interface description Playback pos callback function Precondition None typedef void (CALLBACK *fDownLoadPosCallBack)( LLONG lPlayHandle. 3. When dwDataType is 3. When dwDataType is 1. param callback data parameter struct. See struct tagCBPCMDataParam for details. DWORD dwDownLoadSize. lPlayHandle Playback handle Return value of playback interface like CLIENT_PlayBackByTimeEx etc. DWORD dwBufSize. LDWORD dwUser ).Option Instruction ). Parameter lRealHandle 178/339 . DWORD dwDataType. (unit: KB) dwDownLoadSize = -1 means the playback is finished. dwTotalSize Total size of the playback. dwUser User data Return value None Set the callback function in CLIENT_PlayBackByTimeEx.(unit: KB) parameter dwDownLoadSize The size has been played. 3. dwDownLoadSize = -2 means failed to write files. Function BYTE *pBuffer. Note User can identify which playback it is via parameter lRealHandle.5fDataCallBack Option Instruction Interface description Playback data callback function Precondition None typedef int (CALLBACK *fDataCallBack)( LLONG lRealHandle. dwDataType Data type. no Note matter what value returns. Set the callback function in interfaces like CLIENT_PlayBackByTimeEx etc. and next time the follow-up data will be returned. the callback is being considered successful and next callback will return follow-up data. Used to store callback video data. 3. dwBufSize Data stored buffer length. The value remains 0.6fTimeDownLoadPosCallBack Option Instruction Interface description Download by time callback function Precondition None typedef void (CALLBACK *fTimeDownLoadPosCallBack) ( Function LLONG lPlayHandle. pBuffer Data stored buffer.Option Instruction Playback handle Return value of playback interface like CLIENT_PlayBackByTimeEx etc.(unit: byte) dwUser User data 0: means callback failed. User can identify which playback it is via parameter lRealHandle. and next time the same data will be returned. 179/339 .which means data of original type. If parameter hWnd of CLIENT_PlayBackByTimeEx is not NULL. Return value 1: means callback succeeded. User can identify which download it is via parameter lRealHandle. NET_RECORDFILE_INFO recordfileinfo. recordfileinfo Current downloaded files info. LDWORD dwUser ). lPlayHandle Download handle Return value of interfaces like CLIENT_DownloadByTimeEx etc. dwUser User data Return value None Set the callback function in interfaces like CLIENT_DownloadByTimeEx Note etc. int index. dwTotalSize Total size to be downloaded. 3. See struct NET_RECORDFILE_INFO for details.Option Instruction DWORD dwTotalSize. DWORD dwDownLoadSize. during current download.(unit: KB) Parameter index Video files NO.(unit: KB) dwDownLoadSize The size has been downloaded.7fMessCallBack Option Instruction Interface description Alarm report callback function prototype precondition None 180/339 . Please see “note” for details。 dwBufLen The length of pBuf (unit:BYTE) pchDVRIP Device IP which reports alarm nDVRPort Device port which reports alarm dwUser User data 181/339 . function DWORD dwBufLen. Return value of login interface CLIENT_LoginEx2. char *pchDVRIP. pBuf Alarm data received buffer. lCommand Alarm event type being called back. Use matched with pBuf.Option Instruction typedef BOOL (CALLBACK *fMessCallBack)( LONG lCommand. char *pBuf. pBuf points to different data type according to different listen interface parameter and different lCommand . LLONG lLoginID. Please see “note” below for details. LONG nDVRPort. LDWORD dwUser ). different lCommand has different pBuf. lLoginID Logined device ID. Note It’s not recommended to call SDK interfaces in this callback function. Parameter See struct DEVICE_NET_INFO_EX for details.h for details: // Extensive alarm type.8fSearchDevicesCB Option Instruction Interface Device search callback prototype description Precondition None typedef void (CALLBACK *fSearchDevicesCB)( DEVICE_NET_INFO_EX *pDevNetInfo. pBuf points to different data type according to different listen interface and different lCommand. here we don’t introduce them all.corresponding to CLIENT_StartListenEx #define DH_ALARM_ALARM_EX 0x2101 // External alarm 3. pUserData User data Return value None Device search callback function. User judges which login report the alarm by parameter lLoginID. pDevNetInfo Device info struct. Function void* pUserData ).Option Instruction Return value None All the logined device use the same alarm report callback function . user can search the following key section in header file Eng_dhnetsdk. 182/339 . Note As there are too many alarm events. 3. Function DWORD dwBufSize. When device is searched out. BYTE *pBuffer. we can judge which subscription is by this parameter. void* pAlarmInfo. lAnalyzerHandle Intelligent picture alarm subscription handle. int nSequence.Option Instruction Set the callback function in CLIENT_StartSearchDevices /CLIENT_SearchDevicesByIPs.9fAnalyzerDataCallBack Option Instruction Interface Intellengent picture alarm callback function prototype description Precondition None typedef int (CALLBACK *fAnalyzerDataCallBack)( LLONG lAnalyzerHandle. DWORD dwAlarmType. dwAlarmType Parameter Intelligent picture alarm type,this parameter should be used matched with parameter pBuffer. here we don’t introduce them all. When multiple intelligent picture alarm subscriptions use the same callback function.h for details: 183/339 . LDWORD dwUser.SDK will call this function. As there are too many alarm events. user can search the following key section in header file Eng_dhnetsdk. void *reserved ). 0 is OK. used match with dwAlarmType.the value of *(int *)reserved is 0) Return value The return value has no meaning. (as most of alarms has an unique picture. Intellengent picture alarm callback function. 2:this picture is the same as the one shown in tha last alarm.and it will never show up again.Option Instruction pAlarmInfo Struct pointer. and the follow-up alarms may use the picture. 1:this picture is the same as the one shown in tha last alarm. 184/339 .or it is the only time that the picture shows up.see “note” below for information. This parameter is an int pointer. what *(int *)reserved is: 0:current data is real-time data 1:current data is off-line data 2:off-line transfer is finished (as most of the intelligent picture alarm data is real-time data . the value is 2) reserved The state of the current callback. pBuffer Intelligent picture info buffer dwBufSize The size of intelligent picture info dwUser User data nSequence Whether the picture is repeated 0:it’s the first time that the picture shows up. Note It’s not recommended to call SDK interfaces in this callback function. and the follow-up alarms may use the picture. different dwAlarmType match with different pointer. here we don’t introduce them all. when callback picture info exceed 2M. DWORD CmdSerial.h for details: #define EVENT_IVS_ALL 0x00000001 // subscription all event 3. Different dwAlarmType matched with different pointer.Option Instruction Set this callback function in CLIENT_RealLoadPictureEx / CLIENT_RealLoadPicture.user need to call CLIENT_SetNetworkParam interface to set receiving buffer again.10 fSnapRev Option Instruction Interface Front-end video snapshot callback function prototype description Precondition None typedef void (CALLBACK *fSnapRev)( LLONG lLoginID. user can search the following key section in header file Eng_dhnetsdk. When there are intelligent picture event reported by device-end. Function UINT EncodeType. LDWORD dwUser ). otherwise SDK will abandon data pack over 2M. BYTE *pBuf. Parameter When multiple front-end video snapshots use the same callback function. we can judge which snapshot is by this parameter. UINT RevLen. Due to SDK receving buffer is 2M by default. lLoginID Logined device ID. pBuf 185/339 . As there are too many alarm events. SDK will call this function. When there are Note snapshot picture data sent by device-end.user need to call CLIENT_SetNetworkParam interface to set receiving buffer again. otherwise SDK will abandon data pack over 2M. EM_REALPLAY_DISCONNECT_EVENT_TYPE dwEventType. Due to SDK receving buffer is 2M by default.Option Instruction Picture info buffer Used to store the picture info return by storage device.11 fRealPlayDisConnect Option Instruction Interface Real-time monitoring disconnection callback function prototype description Precondition None typedef void (CALLBACK *fRealPlayDisConnect)( Function LLONG lOperateHandle. RevLen The size of picture info buffer EncodeType Encode type 10:jpeg picture. It is input by CLIENT_SnapPictureEx input parameter dwUser User data Return value None Snapshot callback function It’s not recommended to call SDK interfaces in this callback function. 0:i frame of mpeg4 CmdSerial The serial number. SDK will call this function. when callback picture info exceed 2M. Set this callback function in CLIENT_SetSnapRevCallBack. 3. 186/339 . when real-time monitoring is disconnected. we can judge which operation is by this parameter. Note Set the callback in CLIENT_StartRealPlay. param Reserved paramerer. LDWORD dwUser ). DWORD dwBufSize. 187/339 . When multiple real-time monitoring device use the same callback function.Option Instruction void* param.SDK will call this function.12 pfAudioDataCallBack Option Instruction Interface Audion data callback function protptype description Precondition None typedef void (CALLBACK *pfAudioDataCallBack)( LLONG lTalkHandle. default value is NULL. dwEventType Parameter Event which causes disconnection. 3. Function char *pDataBuf. See enum EM_REALPLAY_DISCONNECT_EVENT_TYPE for reference. dwUser User data Return value None Real-time monitoring disconnection callback function It’s not recommended to call SDK interfaces in this callback function. LOperateHandle Real-time monitoring handle. dwUser User data Return value None Note Set the callback in audio intercom interface such as CLIENT_StartTalkEx etc.only CLIENT_RecordStartEx interface is called. 188/339 . LDWORD dwUser ).Option Instruction BYTE byAudioFlag. 1 indicates the data received is sent by device-end. lTalkHandle Handle of audion intercom Return value of audio intercom interfaces such as CLIENT_StartTalkEx etc. can the data be called back. pDataBuf Audio data being called back Where the data from is decided by parameter byAudioFlag dwBufSize The length of audio data being called back (unit:BYTE) Parameter byAudioFlag Flag indicates where the audio data from 0 indicates that the audio data received is PC-end data collected by local audio library. BYTE byDiskNum. *LPNET_DEVICEINFO. BYTE byAlarmOutPortNum. Union { BYTE byChanNum.Please refer to enum DHDEV_DEVICE_TYPE 189/339 . } NET_DEVICEINFO. sSerialNumber SN byAlarmInPortNum DVR alarm input amount byAlarmOutPortNum member DVR alarm output amount byDiskNum DVR HDD amount byDVRType DVR type. BYTE byAlarmInPortNum.Appendix 1 struct definition NET_DEVICEINFO Option Instruction Struct Device info description typedef struct { BYTE sSerialNumber[DH_SERIALNO_LEN]. struct BYTE byDVRType. BYTE byLeftLogTimes. }. Option Instruction byChanNum DVR channel amount byLeftLogTimes When login failed due to password error. }NET_IN_STARTLOGINEX. LDWORD dwUser. szIp device ip member dwPort login port szName username szPwd 190/339 . DWORD dwPort. const char* szIp. const char* szPwd.It should be set to sizeof(NET_IN_STARTLOGINEX) when used. dwSize The size of the struct. notice user via this parameter. remaining login times 0 means this parameter is invalid NET_IN_STARTLOGINEX Option Instruction Struct description Input parameter CLIENT_StartLoginEx typedef struct tagNET_IN_STARTLOGINEX { DWORD dwSize. struct const char* szName. fHaveLogin cbLogin. int nConnectTime. 191/339 . password cbLogin login result call,see callback function fHaveLogin for details. int nGetDevInfoTime. dwUser call user parameter NET_OUT_STARTLOGINEX Option Instruction Struct description Out put parameter of CLIENT_StartLoginEx typedef struct tagNET_OUT_STARTLOGINEX { Struct DWORD dwSize. int nConnectBufSize. }NET_OUT_STARTLOGINEX. NET_PARAM Option Instruction Struct Relevant parameters of login description typedef struct { int nWaittime.It should be set to sizeof(NET_OUT_STARTLOGINEX)when used. int nSubConnectSpaceTime. Struct int nConnectTryNum. int nGetConnInfoTime. dwSize Member The size of the struct. 0:default 1. nConnectTime Connection timeout value(Unit is ms). 0:default 250*1024 nGetConnInfoTime Access to sub-connect information timeout(Unit is ms). nWaittime Waiting time(unit is ms). 0:default 5000ms. 0:default 10ms. nGetDevInfoTime Access to device information timeout. 0:default 1000ms. int nsubDisconnetTime. int nSearchRecordTime. int nPicBufSize. BYTE bKeepLifeInterval. nConnectTryNum Connection trial times. default 3000ms nsubDisconnetTime dislink disconnect time. 1-WAN byPlaybackBufSize 192/339 . } NET_PARAM. nSubConnectSpaceTime Sub-connection waiting time(Unit is ms). nSearchRecordTime Timeout value of search video (unit ms). BYTE bReserved[4]. BYTE byNetType. 0:default 1000ms. BYTE byPlaybackBufSize. Member nConnectBufSize Each connected to receive data buffer size(Bytes). 0:default 1500ms. 0-LAN.0:default 60000ms byNetType net type. BYTE bDetectDisconnTime. and the min time is 2s bKeepLifeInterval Pulse send out interval(second). int nLockLeftTime.default 4M bDetectDisconnTime Pulse detect offline time(second) . struct int nDVRType.when value = 0.default 2*1024*1024 bReserved reserved NET_DEVICEINFO_Ex Option Instruction Struct device info extension description typedef struct { BYTE sSerialNumber[DH_SERIALNO_LEN]. the default setup is 10s. int nDiskNum. char Reserved[24]. nPicBufSize actual pictures of the receive buffer size(byte)when value = 0. int nAlarmOutPortNum. BYTE byLeftLogTimes. playback data from the receive buffer size(m). int nAlarmInPortNum. int nChanNum.When it is 0. BYTE byLimitLoginTime. BYTE bReserved[2]. the min internal is 2s. the default setup is 60s. When it is 0. 193/339 . refer to enum DHDEV_DEVICE_TYPE nChanNum number of DVR channel Member byLimitLoginTime Online Timeout. notice user via this parameter. not 0 Minutes Limit Said byLeftLogTimes When login failed due to password error. the left time for users to unlock (seconds). remaining login times is 0 means this parameter is invalid bReserved keep bytes. Reserved reserved tagVideoFrameParam Option Instruction Struct Frame parameter struct of Callback video data frame description 194/339 . } NET_DEVICEINFO_Ex. bytes aligned nLockLeftTime when log in failed. sSerialNumber SN nAlarmInPortNum count of DVR alarm input nAlarmOutPortNum count of DVR alarm output nDiskNum number of DVR disk nDVRType DVR type. *LPNET_DEVICEINFO_Ex. Not Limited Access to 0. -1 indicate the device haven’t set the parameter. NET_TIME struTime.1 size 195/339 . DWORD reserved.4 frametype frame type Member different value corresponds to different frame type: I frame .2 format video format different value corresponds to different different video format: PAL – 0 NTSC . DWORD fourcc. Struct BYTE size.0 P frame .Option Instruction typedef struct _tagVideoFrameParam { BYTE encode. encode Encode type Different value corresponds to different encode type: MPEG4 encode: – 1 Dahua H264 encode:– 2 ADI H264 encode:– 3 Standard H264 encode:.1 B frame . } tagVideoFrameParam. BYTE format. BYTE frametype. 18 fourcc If it is H264 encode type. Or is *( DWORD*)"DIVX" that is 0x58564944 reserved reserved struTime Time information See struct NET_TIME for information 196/339 . the parameter value is always 0.Option Instruction resolution ratio different value corresponds to different different video 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 . } tagCBPCMDataParam.tagCBPCMDataParam Option Instruction Struct Frame parameter struct of audio data callback description typedef struct _tagCBPCMDataParam { BYTE channels. Value:8/16 show directly param1 audio data type 0 .44100 6 . Struct BYTE depth.32000 5 .16000 3 . BYTE param1. channels Track amount samples sample rate different value corresponds to different different sample rate: 0 – 8000 1 – 11025 2 .48000 depth Sampling depth.22050 Member 4 .indication with symbol 197/339 . DWORD reserved. BYTE samples.indication no symbol 1 . DWORD dwHour. DWORD dwMonth. dwYear year dwMonth month dwDay day Member dwHour hour dwMinute minute dwSecond second 198/339 .Option Instruction reserved reserved NET_TIME Option Instruction Struct Time struct,exact to second description typedef struct { DWORD dwYear. } NET_TIME. DWORD dwSecond.*LPNET_TIME. DWORD dwMinute. Struct DWORD dwDay. NET_TIME starttime. BYTE bRecType. BYTE bImportantRecID. *LPNET_RECORDFILE_INFO. BYTE nRecordFileType.NET_RECORDFILE_INFO Option Instruction Struct Record file info struct description typedef struct { unsigned int ch. unsigned int driveno. } NET_RECORDFILE_INFO. BYTE bHint. char filename[124]. unsigned int framenum. unsigned int startcluster. ch Channel number filename File name framenum Member the total number of file frames size File length starttime Start time endtime 199/339 . Struct NET_TIME endtime. unsigned int size. 0~127:local record.main stream record 1-sub1 stream record 2-sub2 stream record 3-sub3 stream record CFG_PTZ_PROTOCOL_CAPS_INFO Option Instruction Struct PTZ capability set information 200/339 .64:HDD 1. 2:motion detection.3:card number record .Option Instruction End time driveno HDD number (used to distinguish net record and local record. 4:image 5:intelligent record bImportantRecID flag of whether it’s important record 0:general record 1:Important record bHint Document Indexing (nRecordFileType==4<picture>时,bImportantRecID<<8 +bHint ,make up picture locate index) bRecType stream type 0.1:alarm record.128:net record) startcluster Initial cluster number nRecordFileType record file type 0:general record. BOOL bPattern. BOOL bReset. BOOL bPan. BOOL bZoom. BOOL bFlip. BOOL bIris. BOOL bLight. Struct BOOL bAux.Option Instruction description typedef struct tagCFG_PTZ_PROTOCOL_CAPS_INFO { int nStructSize. WORD wCamAddrMin. BOOL bRemoveTour. 201/339 . BOOL bRemovePreset. BOOL bMoveAbsolutely. BOOL bMoveRelatively. BOOL bGetStatus. BOOL bWiper. BOOL bIsSupportViewRange. BOOL bAlarm. BOOL bTile. BOOL bSupportLimit. BOOL bAutoScan. BOOL bPtzDevice. BOOL bTour. BOOL bPreset. BOOL bAutoPan. BOOL bMenu. CFG_PTZ_LIGHTING_CONTROL stuPtzLightingControl. WORD wMonAddrMax. DWORD dwType. WORD wMonAddrMin. DWORD dwNearLightNumber. WORD wTourMax. WORD wPresetMax. WORD wPresetMin. WORD wAutoScanMin. WORD wPanSpeedMin. WORD wAutoScanMax. char szAuxs[CFG_COMMON_STRING_32][CFG_COMMON_STRING_32]. DWORD dwAlarmLen. WORD wTileSpeedMin. WORD wAuxMax. DWORD dwFarLightNumber. DWORD dwInterval. WORD wTileSpeedMax. char szName[MAX_PROTOCOL_NAME_LEN]. WORD wTourMin. 202/339 . CFG_PTZ_MOTION_RANGE stuPtzMotionRange.Option Instruction WORD wCamAddrMax. WORD wPatternMax. DWORD dwSupportFocusMode. DWORD dwSupportViewRangeType. WORD wPanSpeedMax. WORD wPatternMin. WORD wAuxMin. Option Instruction BOOL bSupportPresetTimeSection. }CFG_PTZ_PROTOCOL_CAPS_INFO. BOOL bFocus. nStructSize set to sizeof(CFG_PTZ_PROTOCOL_CAPS_INFO) when used bPan Whether to support PTZ horizontal swing bTile bTile Whether to support PTZ vertical swinging bZoom Whether to support PTZ changed times bIris Whether to support PTZ aperture adjustment bPreset Whether to support the preset point bRemovePreset Member Whether to support removal of preset point bTour Whether to support automatic cruise lines bRemoveTour Whether to support Clear cruise bPattern Whether to support the track line bAutoPan Whether to support automatic level swing bAutoScan Whether to support automatic scanning bAux Whether to support accessibility 203/339 . bWiper Whether or not support the wipers bFlip Whether or not support Flip camera bMenu Whether or not support PTZ built-in menus bMoveRelatively Whether or not support the PTZ by a relative coordinate positioning bMoveAbsolutely Whether or not support PTZ in absolute coordinates bReset Whether or not support PTZ reset bGetStatus Whether or not support Get the state of motion and orientation coordinates of PTZ bSupportLimit Whether or not support the limit bPtzDevice Whether or not support PTZ equipment bIsSupportViewRange Whether or not support PTZ visible range wCamAddrMin The minimum channel address wCamAddrMax 204/339 . the contents see below "stuPtzLightingControl".Option Instruction bAlarm Support alarm function bLight Whether or not support the lighting. Option Instruction The maximum number of channel address wMonAddrMin Minimum monitoring addresses wMonAddrMax The maximum number of monitoring the address wPresetMin Minimum preset points wPresetMax The maximum preset points wTourMin The minimum value of automatic cruise lines wTourMax The maximum number of automatic cruise lines wPatternMin The minimum value of track circuit wPatternMax The maximum number of track circuit wTileSpeedMin The minimum value of vertical speed wTileSpeedMax The maximum vertical speed wPanSpeedMin The minimum value of horizontal velocity wPanSpeedMax The maximum horizontal velocity wAutoScanMin The minimum value of automatic scanning wAutoScanMax The maximum number of automatic scanning 205/339 . Option Instruction wAuxMin The minimum value of auxiliary functions wAuxMax The maximum number of auxiliary functions dwInterval Send the command time interval dwType The type of agreement, 0 - Local PTZ 1 - Remote PTZ dwAlarmLen The length of the alarm of the agreement dwNearLightNumber The number of near light group, 0-4, 0 means not supported dwFarLightNumber The number of beam group, 0-4, 0 means not supported dwSupportViewRangeType Visual field data acquisition mode supported by the mask, from low to high depending on the number , currently supported. The first 1: 1 expressed support the "ElectronicCompass" electronic compass mode. dwSupportFocusMode Supported Focus mode mask, from low to high depending on the number, see enum EM_SUPPORT_FOCUS_MODE szName The name of the protocol operations szAuxs PTZ auxiliary function names list stuPtzMotionRange PTZ rotation angle range, unit: degree,see struct CFG_PTZ_MOTION_RANGEfor details 206/339 Option Instruction stuPtzLightingControl Lighting control content, see struct CFG_PTZ_LIGHTING_CONTROL for details bSupportPresetTimeSection Whether to support the function of the preset point time configuration bFocus Whether to support to Ptz focus CFG_PTZ_MOTION_RANGE Option Instruction Struct PTZ rotation angle rang struct description typedef struct tagCFG_PTZ_MOTION_RANGE { int nHorizontalAngleMin; Struct int nHorizontalAngleMax; int nVerticalAngleMin; int nVerticalAngleMax; }CFG_PTZ_MOTION_RANGE; nHorizontalAngleMin Minimum level angle range, unit: degree nHorizontalAngleMax The maximum horizontal angle range, unit: degree Member nVerticalAngleMin Vertical angle range minimum, unit: degree nVerticalAngleMax Maximum vertical angle range, unit: degree 207/339 CFG_PTZ_LIGHTING_CONTROL Option Instruction Struct description PTZ rotation angle range, unit: degree typedef struct tagCFG_PTZ_LIGHTING_CONTROL { char szMode[CFG_COMMON_STRING_32]; Struct DWORD dwNearLightNumber; DWORD dwFarLightNumber; }CFG_PTZ_LIGHTING_CONTROL; szMode Manual Lighting Control Mode "on-off":Direct Switch Mode, "adjustLight":Manually Adjust Brightness Mode Member dwNearLightNumber The number of near light group dwFarLightNumber The number of beam group DHDEV_TALKFORMAT_LIST Option Instruction Strict description The audio talk type the device supported 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 See struct DHDEV_TALKDECODE_INFO for details reserved reserved DHDEV_TALKDECODE_INFO Option Instruction Struct description Audio encode information typedef struct { DH_TALK_CODING_TYPE encodeType; int nAudioBit; Struct DWORD dwSampleRate; int nPacketPeriod; char reserved[60]; } DHDEV_TALKDECODE_INFO; encodeType Encode type See enum DH_TALK_CODING_TYPE for details nAudioBit Bit:8/16 Member dwSampleRate Sampling rate such as 8000 or 16000 nPacketPeriod Pack Period,Unit:ms reserved reserved 209/339 DHDEV_SYSTEM_ATTR_CFG Option Instruction Struct description System information typedef struct { DWORD dwSize; /* The following are read only for device */ DH_VERSION_INFO stVersion; DH_DSP_ENCODECAP stDspEncodeCap; BYTE szDevSerialNo[DH_DEV_SERIALNO_LEN]; BYTE byDevType; BYTE szDevType[DH_DEV_TYPE_LEN]; BYTE byVideoCaptureNum; BYTE byAudioCaptureNum; BYTE byTalkInChanNum; BYTE byTalkOutChanNum; Struct BYTE byDecodeChanNum; BYTE byAlarmInNum; BYTE byAlarmOutNum; BYTE byNetIONum; BYTE byUsbIONum; BYTE byIdeIONum; BYTE byComIONum; BYTE byLPTIONum; BYTE byVgaIONum; BYTE byIdeControlNum; BYTE byIdeControlType; BYTE byCapability; BYTE byMatrixOutNum; /* The following are read-write part for device */ 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 size of struct, the parameter can be set to sizeof(DHDEV_SYSTEM_ATTR_CFG) when used /* The following are read only for device */ stVersion device version information, see struct DH_VERSION_INFO for details stDspEncodeCap DSP capability description, see struct DH_DSP_ENCODECAP for details szDevSerialNo Member SN ByDevType device type. Please refer to enumeration DHDEV_DEVICE_TYPE szDevType Device detailed type. String format. It may be empty. ByVideoCaptureNum Video port amount ByAudioCaptureNum Audio port amount byTalkInChanNum 211/339 Option Instruction NSP ByTalkOutChanNum NSP byDecodeChanNum NSP ByAlarmInNum Alarm input port amount ByAlarmOutNum Alarm output amount port ByNetIONum network port amount byUsbIONum USB port amount ByIdeIONum IDE amount ByComIONum COM amount ByLPTIONum LPT amount byVgaIONum NSP byIdeControlNum NSP byIdeControlType NSP byCapability NSP. expansible description ByMatrixOutNum video matrix output amount 212/339 . 213/339 . int nSpeakerChannel.".Option Instruction /* The following are read-write part for device */ ByOverWrite Deal method when HDD is full. 0--disable WDevNo Device serial number.1-12H) byLanguage Please refer to DH_LANGUAGE_TYPE for enumeration value NET_SPEAK_PARAM Option Instruction Struct description Audio talk parameter struct typedef struct __NET_SPEAK_PARAM { DWORD dwSize. Remote control can use this SN to control.1:"-".2:"/") ByTimeFmt Time separator (0-24H. 0: stop) ByRecordLen Video Package length ByDSTEnable Enable DTS or not 1--enable. ByVideoStandard Video format ByDateFormat Date format ByDateSprtr Date separator(0:". Struct int nMode. (1:overwrite. BOOL bEnableWait. set to sizeof(NET_TALK_TRANSFER_PARAM) when used. Member bTransfer Open the forwarding mode of intercom or not. dwSize sizeof sturct.FALSE:no.Option Instruction } NET_SPEAK_PARAM. }NET_TALK_TRANSFER_PARAM. dwSize struct size,set to sizeof(NET_SPEAK_PARAM) when used nMode mode type 0: talk back(default).need afresh to configure Member nSpeakerChannel reproducer channel. 1: propaganda. the timeout time is set by CLIENT_SetNetworkParam. TRUE: yes.from propaganda ro talk back. valid when nMode ==1. FALSE: no 214/339 . Default setup is no. BOOL bTransfer. corresponds to nWaittime in struct NET_PARAM.TRUE:wait . NET_TALK_TRANSFER_PARAM Option Instruction Struct description Open the forwarding mode of intercom or not typedef struct tagNET_TALK_TRANSFER_PARAM { Struct DWORD dwSize. bEnableWait Wait for device to responding or not when enable bidirectional talk. char szDeviceType[DH_DEV_TYPE_LEN]. bool bDhcpEn. char szGateway[64]. char szDevName[DH_MACHINE_NAME_NUM]. char szSerialNo[DH_DEV_SERIALNO_LEN]. char szDetailType[DH_DEV_TYPE_LEN].DEVICE_NET_INFO_EX Option Instruction Struct description Callback info struct of to CLIENT_StartSearchDevices typedef struct { int iIPVersion. WORD wRemoteVideoInputCh. WORD wAlarmInputCh. char szSubmask[64]. Struct char verifyData[88]. WORD wVideoInputCh. char szMac[DH_MACADDR_LEN]. char szDevSoftVersion[DH_MAX_URL_LEN]. char szVendor[DH_MAX_STRING_LEN]. BYTE byDefinition. char szIP[64]. BYTE byReserved1. 215/339 . char szUserName[DH_USER_NAME_LENGT H_EX]. WORD wVideoOutputCh. char szPassWord[DH_USER_NAME_LENGTH_EX]. int nPort. WORD wAlarmOutputCh. BYTE byManuFactory. unsigned short nHttpPort. used for byte alignment verifyData verify data. true-open.0. iIPVersion ip version.1" IPV6 like "2008::1/64" nPort tcp port szSubmask Subnet mask(IPV6 do not have subnet mask) szGateway Gateway szMac MAC address szDeviceType Member Device type byManuFactory device manufactory. see class EM_IPC_TYPE byDefinition 1-Standard definition 2-High definition bDhcpEn Dhcp. obtained in CLIENT_StartSearchDevices callback function(the data can be used to verify when modifying IP) szSerialNo SN 216/339 . 4 for IPV4, 6 for IPV6 szIP IP IPV4 like"192.Option Instruction char cReserved[244].168. false-close byReserved1 reserved. }DEVICE_NET_INFO_EX. Option Instruction szDevSoftVersion soft version szDetailType device detail type 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 HTTP server port wVideoInputCh count of video input channel wRemoteVideoInputCh count of remote video input wVideoOutputCh count of video output channel wAlarmInputCh count of alarm input wAlarmOutputCh count of alarm output cReserved reserved 217/339 . the string can be returned when corresponding Member intelligent picture reported. BYTE byReserved[60]. byReserved reserved OPR_RIGHT_EX Option Instruction Struct Right information description typedef struct _OPR_RIGHT_EX { DWORD dwID.start with 0 bySequence snap sequence string. user can identify witch snap is by this parameter. Struct char name[DH_RIGHT_NAME_LENGT H]. }MANUAL_SNAP_PARAMETER. } OPR_RIGHT_EX. nChannel snap channel. Struct BYTE bySequence[64]. 218/339 . char memo[DH_MEMO_LENGTH].MANUAL_SNAP_PARAMETER Option Instruction Struct Manual snap parameter description typedef struct _MANUAL_SNAP_PARAMETER{ int nChannel. If triggering multiple manual snap events at the same time. each right has its own ID. name Member right name memo right note OPR_RIGHT_NEW Option Instruction Struct description Right information typedef struct _OPR_RIGHT_NEW { DWORD dwSize. set to sizeof(OPR_RIGHT_NEW) when used dwID right ID. dwSize size of struct. } OPR_RIGHT_NEW. Struct DWORD dwID. Member name Right name memo note NET_DEV_CHN_COUNT_INFO Option Instruction 219/339 . char name[DH_RIGHT_NAME_LENGT H]. char memo[DH_MEMO_LENGTH]. each right has its own ID.Option Instruction dwID right ID. stuVideoOut Video Output Channel. } NET_CHN_COUNT_INFO. dwSize size of struct.Option Instruction Struct Device channel amount information struct description typedef struct tagNET_DEV_CHN_COUNT_INFO { DWORD dwSize. 220/339 . Struct NET_CHN_COUNT_INFO stuVideoIn. int nMaxTotal. int nCurRemote. int nCurLocal.see struct NET_CHN_COUNT_INFO for details. see struct NET_CHN_COUNT_INFO for details. int nCurTotal. Struct int nMaxLocal. NET_CHN_COUNT_INFO stuVideoOut. NET_CHN_COUNT_INFO Option Instruction Struct Channel number information description typedef struct tagNET_CHN_COUNT_INFO { DWORD dwSize. } NET_DEV_CHN_COUNT_INFO. set to sizeof(NET_DEV_CHN_COUNT_INFO) when used stuVideoIn Member Video Input Channel. int nMaxRemote. nChannelId Member channel NO. BYTE bReserved[1024].Option Instruction dwSize size of struct. bReserved 221/339 . including motherboard and pluggable cartoon nCurLocal configured local channel number nMaxRemote Maximum number of remote channel nCurRemote Configured remote channel number NET_IN_SNAP_CFG_CAPS Option Instruction Struct Snap configure capacity input parameter description typedef struct tagNET_IN_SNAP_CFG_CAPS { Struct int nChannelId. set to sizeof(NET_CHN_COUNT_INFO) when used nMaxTotal Equipment to the total number of channels (the sum of all valid channel number nCurTotal the number of configured on channels nMaxLocal Member Maximum number of local channels. }NET_IN_SNAP_CFG_CAPS. DWORD dwFramesPerSecNum. } NET_OUT_SNAP_CFG_CAPS.Option Instruction reserved NET_OUT_SNAP_CFG_CAPS Option Instruction Struct Snap configure capacity output parameter description typedef struct tagNET_OUT_SNAP_CFG_CAPS { int nResolutionTypeNum. used corresponding with parameter nResolutionTypeNum dwFramesPerSecNum NO. used corresponding with parameter stuResolutionTypes stuResolutionTypes Member resolution info struct. DH_RESOLUTION_INFO stuResolutionTypes[DH_MAX_CAPT URE_SIZE_ NUM]. DWORD dwMode. of supported frame rate info. Struct int nFramesPerSecList[DH_MAX_FPS_NUM]. of supported video resolution infor. nResolutionTypeNum NO. DWORD dwQualityMun. used corresponding with parameter nFramesPerSecLis 222/339 . DWORD dwFormat. BYTE bReserved[2048]. DWORD nQualityList[DH_MAX_QUALITY_NUM]. unsigned short snHight.Option Instruction nFramesPerSecList frame rate list dwQualityMun supported video quality info. }DH_RESOLUTION_INFO. snWidth width Member snHight heigh DEOENC_ VIDEOENC_OPT Option Instruction 223/339 . bit 2: jpg bReserved reserved DH_RESOLUTION_INFO Option Instruction Struct Image resolution struct description typedef struct { Struct unsigned short snWidth. used corresponding with parameter nQualityList nQualityList video quality info list . used corresponding with parameter dwQualityMun dwMode mode presented in bit: bit 1: fixed time .bit 2: manual dwFormat picture format presented in bit: bit 1:bmp. it used to indicate whether supporting audio enabled or not abSnapEnable used to indicate whether abSnapEnable is valid. } CFG_VIDEOENC_OPT. BOOL bAudioAddEnable. bool abAudioFormat. Struct BOOL bVideoEnable. bool abSnapEnable. BOOL bSnapEnable. CFG_VIDEO_FORMAT stuVideoFormat. it used to indentify whether supporting audio enabled or not in setting. abVideoEnable used to indicate whether bVideoEnable is valid. CFG_AUDIO_ENCODE_FORMAT stuAudioFormat. BOOL bAudioEnable. it used to indentify whether supporting video enabled or not in setting. bool abAudioEnable. bool abAudioAdd.Option Instruction Struct Video encode parameter description typedef struct tagCFG_VIDEOENC_OPT { bool abVideoEnable. it used to indentify whether supporting timer snapshot or not in setting. in obtaining. Member in obtaining. it used to indicate whether supporting video enabled or not abAudioEnable used to indicate whether bAudioEnable is valid. it used to indicate whether supporting timer snapshot or not abAudioAdd 224/339 . in obtaining. CFG_VIDEO_FORMAT Option Instruction Struct Video format struct description typedef struct tagCFG_VIDEO_FORMAT { Struct bool abCompression. in obtaining. used matched with abAudioAdd stuAudioFormat Audio format. used matched with abSnapEnable bAudioAddEnable Audio add enable. used matched with abAudioEnable bSnapEnable Schedule snapshot enable. see struct CFG_AUDIO_ENCODE_FORMAT for details. bool abWidth. it used to indicate whether supporting audio format or not sbVideoEnable Video enable. it used to indentify whether supporting audio format or not in setting. it used to indicate whether supporting audio add or not abAudioFormat used to indicate whether stuAudioFormatvalid. see struct CFG_VIDEO_FORMAT for details bAudioEnable Audio enable. 225/339 .Option Instruction used to indicate whether bAudioAddEnableis valid. used matched with abAudioFormat. it used to indentify whether supporting audio add enabled or not in setting. in obtaining. used matched with abVideoEnable stuVideoFormat Video format. float nFrameRate. abHeight TRUE:nHeight is valid;FALSE:nHeight is invalid 226/339 . bool abImageQuality. bool abBitRate. bool abIFrameInterval. abWidth Member TRUE:nWidth is valid . bool abBitRateControl. CFG_IMAGE_QUALITY emImageQuality. CFG_VIDEO_COMPRESSION emCompression. Not recommended to be modified. int nIFrameInterval. FALSE:emCompression is invalid The parameter is read only. } CFG_VIDEO_FORMAT. bool abFrameRate. FALSE:nWidth is invalid The parameter is read only. int nFrameType. and subject to obtaining. bool abProfile. and subject to obtaining. int nWidth. abCompression TRUE:emCompression is valid. int nBitRate. bool abFrameType. int nHeight. CFG_BITRATE_CONTROL emBitRateControl.Option Instruction bool abHeight. Not recommended to be modified. CFG_H264_PROFILE_RANK emProfile. abFrameType TRUE:nFrameType is valid;FALSE:nFrameType is invalid The parameter is read only. and subject to obtaining. Not recommended to be modified. and subject to obtaining. abIFrameInterval TRUE:nIFrameInterval is valid;FALSE:nIFrameInterval is invalid The parameter is read only. Not recommended to be modified. Not recommended to be modified. Not recommended to 227/339 . and subject to obtaining. Not recommended to be modified. abFrameRate TRUE:nFrameRate is valid;FALSE:nFrameRate is invalid The parameter is read only. abBitRate TRUE:nBitRate is valid;FALSE:nBitRate is invalid The parameter is read only. and subject to obtaining. and subject to obtaining. Not recommended to be modified. abImageQuality TRUE:emImageQuality is valid;FALSE:emImageQuality is invalid The parameter is read only. abBitRateControl TRUE:emBitRateControl is valid;FALSE:emBitRateControl is invalid The parameter is read only. and subject to obtaining. Not recommended to be modified.Option Instruction The parameter is read only. abProfile TRUE:emProfile is valid;FALSE:emProfile is invalid The parameter is read only. and subject to obtaining. and subject to obtaining. Not recommended to be modified. For example. 50 means there is I frame in each 49 B frame or P frame.see enum CFG_BITRATE_CONTROL for details. see enum CFG_VIDEO_COMPRESSION for details. emCompression Video compression mode If this parameter is valid is decided by abCompression. 228/339 . nWidth video width Whether this parameter valid or not is decided by abCompression nHeight video height Whether this parameter valid or not is decided by abHeight emBitRateControl stream control mode Whether this parameter valid or not is decided by abBitRateControl. nBitRate video stream (kbps) Whether this parameter valid or not is decided by abBitRate nFrameRate video frame rate Whether this parameter valid or not is decided by abFrameRate nIFrameInterval I frame interval(1-100). Whether this parameter valid or not is decided by abIFrameInterval emImageQuality Video quality Whether this parameter valid or not is decided by abImageQuality. see enum CFG_IMAGE_QUALITY for details.Option Instruction be modified. AV_int32 nDepth.0-DHAV. bool abFrameType. Struct bool abPacketPeriod. CFG_AUDIO_FORMAT emCompression. AV_int32 nPacketPeriod.1-"PS" Whether this parameter valid or not is decided by abFrameType emProfile H. AV_int32 nFrameType. CFG_AUDIO_ENCODE_FORMAT Option Instruction Struct Audion format description typedef struct tagCFG_AUDIO_FORMAT { bool abCompression.FALSE:emCompression is invalid 229/339 .Option Instruction nFrameType Sniffer mode. abCompression Member TRUE:emCompression is valid. see enum CFG_H264_PROFILE_RANK for details. AV_int32 nMode. bool abMode. AV_int32 nFrequency.264 Encode level Whether this parameter valid or not is decided by abProfile. bool abFrequency. } CFG_AUDIO_ENCODE_FORMAT. bool abDepth. abFrequency TRUE:nFrequency is valid. and subject to obtaining.FALSE:nFrequency is invalid The parameter is read only. Not recommended to be modified. and subject to obtaining. see enum CFG_AUDIO_FORMAT for details. abDepth TRUE:nDepth is valid.Option Instruction The parameter is read only. and subject to obtaining. FALSE:nMode is invalid The parameter is read only. and subject to obtaining. and subject to obtaining. Not recommended to be modified. 230/339 . nDepth Audio sampling depth Whether this parameter valid or not is decided by abDepth.FALSE:nFrameType is invalid The parameter is read only. abPacketPeriod TRUE:nPacketPeriod is valid. abMode TRUE:nMode is valid. Not recommended to be modified. emCompression Audio compression mode Whether this parameter valid or not is decided by abCompression. Not recommended to be modified. Not recommended to be modified.FALSE:nDepth is invalid The parameter is read only. and subject to obtaining.FALSE:nPacketPeriod is invalid The parameter is read only. abFrameType TRUE:nFrameType is valid. Not recommended to be modified. stuCoverBlock The mask zone. 1-PS Audio pack mode Whether this parameter valid or not is decided by abFrameType nPacketPeriod Audio pack period(unit: ms) Whether this parameter valid or not is decided by abPacketPeriod CFG_VIDEO_COVER Option Instruction Struct Multiple-zone mask configuration description typedef struct tagCFG_VIDEO_COVER { int nTotalBlocks. see struct CFG_COVER_INFO for details 231/339 . CFG_COVER_INFO stuCoverBlock[MAX_VIDEO_COVER_NUM]. 0-DHAV. Struct int nCurBlocks.Option Instruction nFrequency Audio sampling frequency Whether this parameter valid or not is decided by abFrequency nMode Audio encode mode Whether this parameter valid or not is decided by abMode nFrameType audio pack mode. } CFG_VIDEO_COVER. nTotalBlocks The supported privacy mask zone amount nCurBlocks Member The amount of zones already set. CFG_RGBA stuColor. FALSE:nBlockType is invalid The parameter is read only. Not recommended to 232/339 . } CFG_COVER_INFO. Struct CFG_RECT stuRect. FALSE:nPreviewBlend is invalid The parameter is read only. Not recommended to be modified. abEncodeBlend Member TRUE:nEncodeBlend is valid. bool abPreviewBlend. and subject to obtaining. bool abEncodeBlend. Not recommended to be modified. and subject to obtaining. int nEncodeBlend. abBlockType TRUE:nBlockType is valid. int nBlockType. and subject to obtaining. int nPreviewBlend.Option Instruction CFG_COVER_INFO Option Instruction Struct Privacy mask information description typedef struct tagCFG_COVER_INFO { bool abBlockType. FALSE:nEncodeBlend is invalid The parameter is read only. abPreviewBlend TRUE:nPreviewBlend is valid. Option Instruction be modified. } CFG_RECT. int nRight.0-disable Whether this parameter valid or not is decided by abEncodeBlend. stuColor The mask color.1-enable. nBlockType The mask mode . int nBottom. nEncodeBlend Encode-level privacy mask. CFG_RECT Option Instruction Struct Zone information description typedef struct tagCFG_RECT { int nLeft. Struct int nTop. see struct CFG_RGBA for details. stuRect The position (coordinates) of the mask zone.1-enable.0-disable Whether this parameter valid or not is decided by abPreviewBlend. nLeft Member left side of the zone 233/339 . see struct CFG_RECT for details. nPreviewBlend Preview mask.1-Mosaic Whether this parameter valid or not is decided by abBlockType.0-black block. } CFG_RGBA. nRed red nGreen green member nBlue blue nAlpha pellucidity CFG_ENCODE_INFO Option Instruction 234/339 . int nAlpha.Option Instruction nTop top of the zone nRight right side of the zone nBottom buttom of the zone CFG_RGBA Option Instruction Struct RGBA information description typedef struct tagCFG_RGBA { int nRed. Struct int nGreen. int nBlue. } CFG_ENCODE_INFO. CFG_VIDEOENC_OPT stuSnapFormat[MAX_VIDEOSTREAM_NUM]. DWORD dwCoverAbilityMask. invalid when setting szChnName invalid parameter Member stuMainStream main stream property information stuMainStream[0]-General record property information stuMainStream[1]-Motion detect record property information stuMainStream[2]-alarm record property information see struct CFG_VIDEOENC_OPT for details 235/339 . CFG_OSD_INFO stuChnTitle. int nProtocolVer. nChannelID Channel number(Begins with 0) valid when obtaining. CFG_VIDEOENC_OPT stuExtraStream[MAX_VIDEOSTREAM_NUM]. Struct DWORD dwCoverEnableMask. CFG_COLOR_INFO stuVideoColor.Option Instruction Struct Video channel property information description typedef struct tagCFG_ENCODE_INFO { int nChannelID. CFG_OSD_INFO stuTimeTitle. char szChnName[MAX_CHANNELNAME_LEN]. CFG_VIDEO_COVER stuVideoCover. CFG_AUDIO_FORMAT emAudioFormat. CFG_VIDEOENC_OPT stuMainStream[MAX_VIDEOSTREAM_NUM]. read only valid when obtaining.Option Instruction stuExtraStream sub-stream property information stuExtraStream[0]-General record property information stuExtraStream[1]-Motion detect record property information stuExtraStream[2]-alarm record property information see struct CFG_VIDEOENC_OPT for details. invalid when setting 236/339 .. stuSnapFormat snapshot property information stuSnapFormat[0]-0-General snapshot property information stuSnapFormat[1]-Motion detect snapshot property information stuSnapFormat[2]-alarm snapshot property information see struct CFG_VIDEOENC_OPT for details dwCoverAbilityMask invalid parameter dwCoverEnableMask invalid parameter stuVideoCover invalid parameter stuChnTitle invalid parameter stuTimeTitle invalid parameter stuVideoColor invalid parameter emAudioFormat invalid parameter nProtocolVer Protocol Version No. the bigger the value is. Channel Snapshot channel Quality Image quality: evel 1 to level 6. } SNAP_PARAMS. unsigned int CmdSerial. the better quality the image is ImageSize Invalide parameter Member Mode Snapshot mode -1:stop snapshotting 0:request one frame 1:send out requestion regularly 2: Request consecutively InterSnap 237/339 .SNAP_PARAMS Option Instruction Struct Snapshot parameter structure description typedef struct _snap_param { unsigned int Channel. Struct unsigned int mode. unsigned int InterSnap. unsigned int ImageSize. unsigned int Quality. unsigned int Reserved[4]. *LPSNAP_PARAMS. valid range 0~65535.nFrameRate in configure CFG_CMD_ENCODE CmdSerial Snapshot Request serial number. Reserved reserved DH_VERSION_INFO Option Instruction Struct Device software version information. DWORD dwDspSoftwareVersion. 238/339 . Only certain special device(such as mobile device) sets snapshot interval through this parameter. DWORD dwDspSoftwareBuildDate. over this range will be cut to unsigned short. typedef struct { DWORD dwSoftwareVersion.Option Instruction Snapshot interval(unit: s) If mode=1. Struct DWORD dwPanelVersion. DWORD dwWebVersion. The higher 16-bit means the main version description number and low 16-bit means second version number. Other device is suggested to realize related function through setting parameter tuSnapFormat[nSnapMode]. DWORD dwWebBuildDate. it means send out requestion regularly.stuVideoFormat. DWORD dwPanelSoftwareBuildDate. DWORD dwHardwareVersion. DWORD dwHardwareDate. DWORD dwSoftwareBuildDate. 239/339 . dwSoftwareVersion software version dwSoftwareBuildDate software version build date dwDspSoftwareVersion dsp software version dwDspSoftwareBuildDate dsp software version build date dwPanelVersion not used Member dwPanelSoftwareBuildDate not used dwHardwareVersion hardware version dwHardwareDate not used dwWebVersion web version dwWebBuildDate web version build date DH_DSP_ENCODECAP Option Instruction Struct DSP capacity description description typedef struct Struct { DWORD dwVideoStandardMask. *LPDH_VERSION_INFO.Option Instruction } DH_VERSION_INFO. } DH_DSP_ENCODECAP. dwVideoStandardMask video format mask. *LPDH_DSP_ENCODECAP. Bit stands for the video format device supported. DWORD dwStreamCap. WORD wChannelMaxSetSync.Option Instruction DWORD dwImageSizeMask. DWORD dwImageSizeMask_Assi[8]. 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 . Bit stands for the resolution setup devices supported. dwImageSizeMask Resolution mask. WORD wMaxSupportChannel. DWORD dwMaxEncodePower. DWORD dwEncodeModeMask. The first bit:main stream The second bit:extra stream 1 The third bit:extra stream 2 The fifth bit: snapshot in . dwMaxEncodePower 241/339 .jpg format dwImageSizeMask_Assi When the main stream is the corresponding resolution. the supported extra stream resolution mask. dwStreamCap The multiple-media function the devices supported. Bit stands for the encode mode devices supported.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. Option Instruction The highest encode capacity DSP supported wMaxSupportChannel The max video channel amount each DSP supported. wChannelMaxSetSync Max encode bit setup in each DSP channel are synchronized or not .0:does not synchronized.1:synchronized 242/339 . // MPEG1 8-ch DVR NET_DVR_MPEG4_8. // MPEG4 16-ch DVR NET_DVR_MPEG4_SX2.used to different device type. // SDIP series NET_IPC_SERIAL. NET_DVR_NONREALTIME_MACE. // Network video server NET_DVR_MPEG1_2. //IPCseries NET_NVS_B.Appendix 2 Enum definition NET_DEVICE_TYPE Option Instruction Enum description Enum of device type. // GB series DVR NET_DVR_MEPG4_SH2. // LB series DVR NET_DVR_MEPG4_ST2. // LN series NET_BAV_SERIAL. Enum definition typedef enum tagNET_DEVICE_TYPE { NET_PRODUCT_NONE = 0. // MPEG1 2-ch DVR NET_DVR_MPEG1_8. // NVS B series 243/339 . // HB series DVR NET_DVR_MPEG4_GBE. // II network video server NET_DVR_STD_NEW. // 2nd non real-time NB series DVR NET_LN_SERIAL. // BAV series NET_SDIP_SERIAL. //New standard configuration protocol NET_DVR_DDNS. // Non real-time NET_NVS_MPEG1. // GBE series DVR NET_DVR_MPEG4_NVSII. // MPEG4 8-ch DVR NET_DVR_MPEG4_16. // ATM series NET_NB_SERIAL. // DDNS server NET_DVR_ATM. // Non real-time MACE NET_DVR_NONREALTIME. // N52 NET_DVR_N56. // N51 NET_ITSE_SERIAL. NET_NVD_SERIAL. // pc-nvr 244/339 . // N5 NET_DVR_MIX_DVR. // NVS E series NET_DVR_NEW_PROTOCOL. // NVS H series NET_NVS_S. // HDVR NET_SVR_SERIAL. // ESS NET_IVS_PC. // IVS(intelligent video server series) NET_IVS_B.Option Instruction NET_NVS_C. // number statistic server NET_PC_NVR. // SVR series NET_SVR_BS. it is in string format. //SVR-BS NET_NVR_SERIAL. //Intelligent traffic camera equipment NET_HWS_SERIAL. // NVR series NET_DVR_N51. // face recognisation server NET_IVS_V. // universal intelligent detect video server series NET_IVS_F. // portable video record NET_IVS_SERIAL. // NVD NET_DVR_N5. // N56 NET_ESS_SERIAL. // matrix NET_DVR_N52. //video quality diagnosis server NET_MATRIX_SERIAL. // NVS S series NET_NVS_E. // radar speedometer HWS NET_PVR_SERIAL. // ITSE Intelligent Analysis Box NET_ITC_SERIAL. //Search device type from QueryDevState. //Network alarm host NET_A_SERIAL. //TPC series product. // No criteria login EM_LOGIN_SPEC_CAP_SERVER_CONN=2. //VTO series product NET_VTNC_SERIAL. // K-Lite Codec Pack NET_AF6016. //multicast login. EM_LOGIN_SPAC_CAP_TYPE Option Instruction Enum Enum of login type. //an embedded intelligent video analysis system NET_DVR_N6. //Access control series of products NET_NVS_SERIAL. //Video network alarm host NET_AH2008. // TCP login. //NVS series product NET_VTO_SERIAL. description Enum definition typedef enum tagEM_LOGIN_SPAC_CAP_TYPE { EM_LOGIN_SPEC_CAP_TCP = 0. default EM_LOGIN_SPEC_CAP_ANY = 1. }NET_DEVICE_TYPE .Option Instruction NET_DSCON. // screen controller NET_EVS. // Alarm host series NET_BSC_SERIAL.used to select different ways to login. // DVR-N6 NET_UDS. //network video storage server NET_EIVS. it is the thermal device. // VTNC series product NET_TPC_SERIAL. default 245/339 . // Bank alarm host NET_AS5008. //auto sign up login EM_LOGIN_SPEC_CAP_MULT ICAST=3. correspond with CLIENT_RealPlayEx and CLIENT_StartRealPlay interfaces Enum definition typedef enum _RealPlayType { DH_RType_Realplay = 0. //only main connection login EM_LOGIN_SPEC_CAP_SSL=7. //login device do not config EM_LOGIN_SPEC_CAP_U_LOGIN=11. //cloud login EM_LOGIN_SPEC_CAP_AUT H_TWICE=17. //LDAP login EM_LOGIN_SPEC_CAP_AD=13. //login IVS box remote device EM_LOGIN_SPEC_CAP_NO_CONFIG=10. //SSL encryption login EM_LOGIN_SPEC_CAP_INTELLIGENT_BOX=9. //UDP method login EM_LOGIN_SPEC_CAP_MAIN_CONN_ONLY=6. //web private login EM_LOGIN_SPEC_CAP_MOBILE=20. DH_RealPlayType Option Instruction Enum description Preview type. //AD(ActiveDirectory) login EM_LOGIN_SPEC_CAP_RADIUS=14. // Real-time preview 246/339 .//dual authentication loin EM_LOGIN_SPEC_CAP_TS=18. //Socks5 login EM_LOGIN_SPEC_CAP_CLOUD =16. //TS stream client login EM_LOGIN_SPEC_CAP_P2P=19. //Radius login EM_LOGIN_SPEC_CAP_SOCKET_5=15. //mobile client login EM_LOGIN_SPEC_CAP_INVALID // invalid login }EM_LOGIN_SPAC_CAP_TYPE. //USB key device login EM_LOGIN_SPEC_CAP_LDAP =12.Option Instruction EM_LOGIN_SPEC_CAP_UDP=4. //Multiple-channel preview--9-window DH_RType_Multiplay_16. // Multiple-channel preview DH_RType_Realplay_0. //All the recorded video EM_RECORD_TYPE_ALARM=1. //Multiple-channel preview--12-window DH_RType_Multiplay_25. //Multiple-channel preview--36-window } DH_RealPlayType. //Multiple-channel preview--6-window DH_RType_Multiplay_12. //Multiple-channel preview--16-window DH_RType_Multiplay_6.extra stream 2 DH_RType_Realplay_3. //1 Real-time monitor---extra stream 1 DH_RType_Realplay_2.extra stream 3 DH_RType_Multiplay_1. //The video of external alarm EM_RECORD_TYPE_MOTION_DETECT=2. //3 Real-time monitor -. //The video of dynamic detection alarm EM_RECORD_TYPE_ALARM_ALL=3.1-window DH_RType_Multiplay_4. //Multiple-channel preview-.Option Instruction DH_RType_Multiplay. //2 Real-time monitor-. EM_QUERY_RECORD_TYPE Option Instruction Enum description Type of video search Enum definition typedef enum tagEmQueryRecordType { EM_RECORD_TYPE_ALL=0. //Multiple-channel preview--8-window DH_RType_Multiplay_9. It is the same as DH_RType_Realplay DH_RType_Realplay_1. //Real-time monitor-main stream. //All the alarmed video 247/339 . //Multiple-channel preview--25-window DH_RType_Multiplay_36. //Multiple-channel preview--4-window DH_RType_Multiplay_8. used by HB-U or NVS EM_RECORD_TYPE_PICTURE=9. // Set client-end mode to begin audio talk DH_TALK_SERVER_MODE.Option Instruction EM_RECORD_TYPE_CARD=4. //query pictures by the card number. // Set encode format for audio talk DH_ALARM_LISTEN_MODE. // Set alarm subscribe way DH_CONFIG_AUTHORITY_MODE. //Smart record search EM_RECORD_TYPE_TRANS_DATA=16. //query by field EM_RECORD_TYPE_INTELLI_VIDEO =11. // invalid query type }EM_QUERY_RECORD_TYPE. // Set server mode to begin audio talk DH_TALK_ENCODE_TYPE. //query the video of serial data EM_RECORD_TYPE_IMPORTANT=17. EM_USEDEV_MODE Option Instruction Enum description Audio talk way(not describe some extensive data type) Enum definition typedef enum __EM_USEDEV_MODE { DH_TALK_CLIENT_MODE. //combination query EM_RECORD_TYPE_CARD_PICTURE=8. //query by condition EM_RECORD_TYPE_JOIN=6. //query the important video EM_RECORD_TYPE_TALK_DATA =18. // Set user right to realize 248/339 . //query by the card number EM_RECORD_TYPE_CONDITION=5. //query pictures.used by HB-U or NVS EM_RECORD_TYPE_FIELD=10. //query the recording file EM_RECORD_TYPE_INVALID = 256. net RECORD TYPE) DH_TALK_MODE3.1-only main stream.1-on) DH_TALK_TRANSFER_MODE. corresponding to NET_VT_TALK_PARAM structure DH_TARGET_DEV_ID. // Set voice intercom parameters of three generations of equipment and the corresponding structure NET TALK the EX DH_PLAYBACK_REALTIME_MODE .locate device forwards the information) 249/339 . // Set the stream type of the record for query(0-both main and extra stream.corresponding to NET_SPEAK_PARAM DH_RECORD_TYPE. (not zero . //Set real time playback function(0-off. (corresponding to NET_TALK_TRANSFER_PARAM) DH_TALK_VT_PARAM. //Judge the voice intercom if it was a forwarding mode.Option Instruction configuration management DH_TALK_TALK_CHANNEL. // Set talking channel(0~MaxChannel-1) DH_RECORD_STREAM_TYPE. // Set by time video playback and download the video file TYPE (see. // Set speaking parameter.2-only extra stream) DH_TALK_SPEAK_PARAM. //Set target device identifier for searching system capacity information. //Set VT talk parameter. // + Aperture 250/339 . // -Zoom out DH_PTZ_APERTURE_ADD_CONTROL. // Up DH_PTZ_DOWN_CONTROL. DH_PTZ_ControlType Option Instruction Enum description Enum of General PTZ control command Enum definition typedef enum _PTZ_ControlType { DH_PTZ_UP_CONTROL = 0.Option Instruction } EM_USEDEV_MODE. // Down DH_PTZ_LEFT_CONTROL. // -Zoom out DH_PTZ_FOCUS_ADD_CONTROL. //See the license plate number mode ENUM_SUPPORT_FOCUS_PEOPLE= 3. // +Zoom in DH_PTZ_FOCUS_DEC_CONTROL. EM_SUPPORT_FOCUS_MODE Option Instruction Enum description Enum of focus mode supported Enum definition typedef enum tagSUPPORT_FOCUS_MODE { ENUM_SUPPORT_FOCUS_CAR= 1. // Right DH_PTZ_ZOOM_ADD_CONTROL. //See the face mode }EM_SUPPORT_FOCUS_MODE. //See people mode ENUM_SUPPORT_FOCUS_FACE= 4. // +Zoom in DH_PTZ_ZOOM_DEC_CONTROL. // Left DH_PTZ_RIGHT_CONTROL. //See the car mode ENUM_SUPPORT_FOCUS_PLATE= 2. // Down right DH_EXTPTZ_ADDTOLOOP. // Delete tour tour DH_EXTPTZ_STARTPANCRUISE. // Upper right DH_EXTPTZ_LEFTDOWN. // Set right limit DH_EXTPTZ_STARTLINESCAN. // Add preset to tour Tour Preset value DH_EXTPTZ_DELFROMLOOP. DH_EXTPTZ_ControlType Option Instruction Enum description PTZ control extensive command Enum definition typedef enum _EXTPTZ_ControlType { DH_EXTPTZ_LEFTTOP = 0x20. // Stop scanning DH_EXTPTZ_SETMODESTART. // Delete DH_PTZ_POINT_LOOP_CONTROL. // Delete preset in tour Tour Preset value DH_EXTPTZ_CLOSELOOP. // Upper left DH_EXTPTZ_RIGHTTOP. // Set DH_PTZ_POINT_DEL_CONTROL. // Go to preset DH_PTZ_POINT_SET_CONTROL. // Tour DH_PTZ_LAMP_CONTROL // Light and wiper } DH_PTZ_ControlType. // Down left DH_EXTPTZ_RIGHTDOWN. // Set left limit DH_EXTPTZ_SETRIGHTBORDER. // Start mode Mode line 251/339 .Option Instruction DH_PTZ_APERTURE_DEC_CONTROL. // Begin scanning DH_EXTPTZ_CLOSELINESCAN. // Stop pan rotation DH_EXTPTZ_SETLEFTBORDER. // Begin pan rotation DH_EXTPTZ_STOPPANCRUISE. // -Aperture DH_PTZ_POINT_MOVE_CONTROL. // Light controller DH_EXTPTZ_EXACTGOTO. // auxiliary open Auxiliary point DH_EXTPTZ_AUXICLOSE.// Open dome menu DH_EXTPTZ_CLOSEMENU. // menu left DH_EXTPTZ_MENURIGHT. // Alarm activate PTZ parm1:Alarm input channel. // Flip DH_EXTPTZ_FASTGOTO. // Reset 3D positioning as zero DH_EXTPTZ_MOVE_ABSOLUTELY.parm2:Alarm activation type 1-preset 2-scan 3-tour. // Disable mode Mode line DH_EXTPTZ_DELETEMODE. // Close menu DH_EXTPTZ_MENUOK. DH_EXTPTZ_MATRIXSWITCH = 0x41. // Enable mode Mode line DH_EXTPTZ_STOPMODE. // menu down DH_EXTPTZ_MENULEFT.param4 corresponding struct 252/339 . // Cancel menu DH_EXTPTZ_MENUUP. // Stop mode Mode line DH_EXTPTZ_RUNMODE. parm2: tilt coordinates(0~900).such as preset value. // Delete mode Mode line DH_EXTPTZ_REVERSECOMM. // Menu right DH_EXTPTZ_ALARMHANDLE = 0x40. // Auxiliary close Auxiliary point DH_EXTPTZ_OPENMENU = 0x36.parm3:matrix number DH_EXTPTZ_LIGHTCONTROL. // menu up DH_EXTPTZ_MENUDOWN. // 3D accurately positioning parm1:Pan degree(0~3600). // Matrix switch parm1:monitor number(video output number). // 3D position X address(8192) Y address(8192)zoom(4) DH_EXTPTZ_AUXIOPEN.Option Instruction DH_EXTPTZ_SETMODESTOP. //Absolute motion control commands. // Confirm menu DH_EXTPTZ_MENUCANCEL.parm2:video input number.parm 3:activation value. parm3:zoom(1~128) DH_EXTPTZ_RESETZERO. param1、param2、param3 is invalid) DH_EXTPTZ_VERSECTORSCAN = 0x4C. // Right + TELE DH_EXTPTZ_LEFTUP_TELE. param4 is invalid DH_EXTPTZ_SET_FISHEYE_EPTZ = 0x4E.param4 corresponding struct PTZ_CONTROL_CONTINUOUSLY DH_EXTPTZ_GOTOPRESET. // Set absolute focus. focus on value. similarly hereinafter DH_EXTPTZ_DOWN_TELE. // Down + TELE DH_EXTPTZ_LEFT_TELE.Option Instruction PTZ_CONTROL_ABSOLUTELY DH_EXTPTZ_MOVE_CONTINUOUSLY. // Left + TELE DH_EXTPTZ_RIGHT_TELE. //Control fish eye PTZ. //Set to horizon(param4 corresponding struct PTZ_VIEW_RANGE_INFO) DH_EXTPTZ_FOCUS_ABSOLUTELY = 0x4A. // Vertical sweep fan (param4correspondingPTZ_CONTROL_SECTORSCAN.parm4 corresponding struct PTZ_CONTROL_GOTOPRESET DH_EXTPTZ_SET_VIEW_RANGE = 0x49. param3. // Up + TELE param1=speed(1-8) . // Continuous motion control commands. // Upper left + TELE 253/339 . param1、param2、param3 is invalid) DH_EXTPTZ_SET_ABS_ZOOMFOCUS = 0x4D. param2 as the focus.param4corresponding to structure PTZ_CONTROL_SET_FISHEYE_EPTZ DH_EXTPTZ_UP_TELE = 0x70. param1 for focal length. // Absolute focus (param4 corresponding struct PTZ_FOCUS_ABSOLUTELY) DH_EXTPTZ_HORSECTORSCAN = 0x4B. scope: [0255]. at a certain speed to preset locus. // PTZ control command. //Level fan sweep (param4 corresponding PTZ_CONTROL_SECTORSCAN. range: [0255]. Option Instruction DH_EXTPTZ_LEFTDOWN_TELE. DH_TALK_CODING_TYPE Option Instruction Enum description Audio encode type Enum definition typedef enum __TALK_CODING_TYPE { DH_TALK_DEFAULT = 0. // Down left+ WIDE DH_EXTPTZ_TIGHTUP_WIDE. // Upper right + WIDE DH_EXTPTZ_RIGHTDOWN_WIDE. // Down left + TELE DH_EXTPTZ_TIGHTUP_TELE. // No-head PCM DH_TALK_PCM = 1. // Down right + TELE DH_EXTPTZ_UP_WIDE. // With head PCM DH_TALK_G711a. // Right + WIDE DH_EXTPTZ_LEFTUP_WIDE. // G723_53 DH_TALK_G723_63. // AMR DH_TALK_G711u. // Up + WIDE param1=speed (1-8). // max command value } DH_EXTPTZ_ControlType. // G711u DH_TALK_G726. // AAC 254/339 . // G723_63 DH_TALK_AAC. // G726 DH_TALK_G723_53. // Upper left + WIDE DH_EXTPTZ_LEFTDOWN_WIDE. // Down right + WIDE DH_EXTPTZ_TOTAL. // Upper right + TELE DH_EXTPTZ_RIGHTDOWN_TELE. // Left + WIDE DH_EXTPTZ_RIGHT_WIDE. // Down + WIDE DH_EXTPTZ_LEFT_WIDE. similarly hereinafter DH_EXTPTZ_DOWN_WIDE. // G711a DH_TALK_AMR. DH_KEYBOARD_RIGHT. // G. 255/339 . DH_KEYBOARD_UP. // G729 DH_TALK_MPEG2. DH_KEYBOARD_BTN1. DH_KEYBOARD_BTN2. // MPEG2 DH_TALK_MPEG2_Layer2. // HDD management DH_KEYBOARD_POWER = 3.Option Instruction DH_TALK_OGG. // OGG DH_TALK_G729 = 10. CtrlType Option Instruction Enum description Audio encode type Enum definition typedef enum _CtrlType { DH_CTRL_REBOOT = 0. DH_KEYBOARD_BTN0. // MPEG2-Layer2 DH_TALK_G722_1. // ADPCM DH_TALK_MP3 = 22. // Shut down device DH_CTRL_DISK. DH_KEYBOARD_BTN4. // MP3 } DH_TALK_CODING_TYPE. // Reboot device DH_CTRL_SHUTDOWN. DH_KEYBOARD_LEFT. DH_KEYBOARD_BTN3. DH_KEYBOARD_DOWN.722. // Network keyboard DH_KEYBOARD_ENTER.1 DH_TALK_ADPCM = 21. DH_KEYBOARD_ESC. DH_KEYBOARD_SLOW. DH_KEYBOARD_ADDR. DH_KEYBOARD_BTN11. DH_KEYBOARD_FAST. DH_KEYBOARD_BTN13. DH_KEYBOARD_BTN12. DH_KEYBOARD_FN2. DH_KEYBOARD_SPLIT. DH_KEYBOARD_PLAY. DH_KEYBOARD_BTN15. DH_KEYBOARD_INFO. DH_KEYBOARD_BTN6. 256/339 . DH_KEYBOARD_ONE. DH_KEYBOARD_BTN8. DH_KEYBOARD_REC. DH_KEYBOARD_JMPDOWN. DH_KEYBOARD_FN1. DH_KEYBOARD_10PLUS.Option Instruction DH_KEYBOARD_BTN5. DH_KEYBOARD_PREW. DH_KEYBOARD_NEXT. DH_KEYBOARD_BTN16. DH_KEYBOARD_BTN14. DH_KEYBOARD_BTN9. DH_KEYBOARD_BTN10. DH_KEYBOARD_BTN7. DH_KEYBOARD_NINE. DH_KEYBOARD_STOP. DH_KEYBOARD_JMPUP. // Burner control:overlay password (The string ended with '\0'. // Clear log DH_TRIGGER_ALARM_WIRELESS = 200. // Burner control:begin burning DH_BURNING_STOP. // Network hard disk partition DH_BURNING_ATTACH. Max length is 8 bits. // Burner control:stop burning DH_BURNING_ADDPWD. //Activate device snapshot DH_CTRL_CLEARLOG. // SD card control(for IPC series). // Annex burning 257/339 . ) DH_BURNING_ADDHEAD. Use '\n' to Enter.) DH_BURNING_ADDSIGN. // Activate alarm input DH_TRIGGER_ALARM_OUT. // Burner control:overlay head title (The string ended with '\0'. //Mark important record DH_CTRL_DISK_SUBAREA.Option Instruction DH_KEYBOARD_SHIFT. // Activate wireless alarm (IPC series) DH_MARK_IMPORTANT_RECORD. // switch video channel DH_TRIGGER_ALARM_IN = 100. //restore device default setup DH_CTRL_CAPTURE_START. Max length is 1024 bytes. Use '\n' to Enter) DH_CTRL_RESTOREDEFAULT. // Matrix control DH_CTRL_SDCARD. // new network keyboard function DH_KEYBOARD_CHNNEL . DH_KEYBOARD_LOGIN . Please refer to HDD control DH_BURNING_START. Max length is 1024 bytes. // Burner control:overlay dot to the burned information(No parameter) DH_BURNING_ADDCURSTOMINFO. DH_KEYBOARD_BACK. // Activate alarm output DH_CTRL_MATRIX. // Burner control:self-defined overlay (The string ended with '\0'. // wifi disconnect 258/339 . // Rain Brush DH_MANUAL_SNAP. // Stop to device backup DH_VIHICLE_WIF I_ADD. // Burn Postponed DH_CTRL_OEMCTRL. // route info DH_BACKUP_FORMAT. // sapredisk control DH_WIFI_CONNECT. // local preview split(struct DEVICE_LOCALPREVIEW_SLIPT_PARAMETER) DH_CTRL_INIT_RAID. // Burn Pause DH_BURNING_CONTINUE. // Start to buzzer control DH_BUZZER_STOP. // Shield User DH_RAINBRUSH. // Stop to buzzer control DH_REJECT_USER. // Start to device backup DH_BACKUP_STOP. // RAID init DH_CTRL_RAID. // RAID control DH_CTRL_SAPREDISK. // OEM control DH_BACKUP_START. // Reject User DH_SHIELD_USER. // manual snap (struct MANUAL_SNAP_PARAMETER) DH_MANUAL_NTP_TIMEADJUST.Option Instruction DH_BURNING_PAUSE. // Burn Resume DH_BURNING_POSTPONE. // manual ntp time adjust DH_NAVIGATION_SMS. // Delete WIFI configuration manually for car device DH_BUZZER_START. // backup device format DH_DEVICE_LOCALPREVIEW_SLIPT. // navigation info and note DH_CTRL_ROUTE_CROSSING. // Add WIFI configuration manually for car device DH_VIHICLE_WIF I_DEC. // wifi connect (struct WIFI_CONNECT) DH_WIFI_DISCONNECT. // eject burner (struct NET_CTRL_BURNERDOOR) need wait 4s DH_CTRL_CLEAR_ALARM. // TV wall information display corresponding structure NET (CTRL MONITORWALL TVINFO) DH_CTRL_START_VIDEO_ANALYSE. // format pattion (struct DH_FORMAT_PATITION) DH_CTRL_EJECT_STORAGE. //Controlled start equipment upgrades. // STOP intelligent VIDEO analysis corresponding structure NET (CTRL STOP VIDEO ANALYSE) DH_CTRL_UPGRADE_DEVICE. //eject storage device (struct DH_EJECT_STORAGE_DEVICE) DH_CTRL_LOAD_STORAGE. independently complete the upgrade process 259/339 . //start Intelligent VIDEO analysis (corresponding structure NET CTRL START VIDEO ANALYSE) DH_CTRL_STOP_VIDEO_ANALYSE. // Arm/disarm operation DH_CTRL_IP_MODIFY. // close burner (struct NET_CTRL_BURNERDOOR) need wait 6s DH_CTRL_EJECT_BURNER. // IP modify (struct DHCTRL_IPMODIFY_PARAM) DH_CTRL_WIFI_BY_WPS. // alarm elimination corresponding structure NET (CTRL CLEAR ALARM) DH_CTRL_MONITORWALL_TVINFO. // load storage device (struct DH_LOAD_STORAGE_DEVICE) DH_CTRL_CLOSE_BURNER. // wps connect wifi(struct DHCTRL_CONNECT_WIFI_BYWPS) DH_CTRL_FORMAT_PATITION.Option Instruction (struct WIFI_CONNECT) DH_CTRL_ARMED. // Power timing group open the switch quantity output corresponding. // PROJECTOR drop (corresponding to the.net CTRL PROJECTOR PARAM) DH_CTRL_PROJECTOR_STOP.net CTRL PROJECTOR PARAM) DH_CTRL_INFRARED_KEY.net (CTRL SEQPOWER PARAM) DH_CTRL_PROJECTOR_RISE. net (CTRL SEQPOWER PARAM) DH_CTRL_SEQPOWER_CLOSE_ALL.net (CTRL PROJECTOR PARAM) DH_CTRL_PROJECTOR_FALL. // INFRARED buttons (corresponding to the.// Turn on the switch power supply timing device output corresponding. //Multi-channel preview playback channel switching corresponding structure NET (CTRL MULTIPLAYBACK CHANNALES) DH_CTRL_SEQPOWER_OPEN. // Power sequence set close the switch quantity output corresponding. net (CTRL SEQPOWER PARAM) DH_CTRL_SEQPOWER_CLOSE. // PROJECTOR up corresponding.Option Instruction by the equipment do not need to upgrade file DH_CTRL_MULTIPLAYBACK_CHANNALES. // PROJECTOR stop (corresponding to the. // Equipment stop playback of audio file 260/339 . // Device START playback of audio file corresponding structure NET (CTRL START PLAYAUDIO) DH_CTRL_STOP_PLAYAUDIO. net (CTRL SEQPOWER PARAM) DH_CTRL_SEQPOWER_OPEN_ALL. // Close the switch power supply timing device output corresponding.net CTRL INFRARED KEY PARAM) DH_CTRL_START_PLAYAUDIO. // Corresponding structure NET open alarm (CTRL ALARMBELL) DH_CTRL_STOP_ALARMBELL. //Corresponding structure NET BYPASS function (CTRL SET BYPASS) DH_CTRL_RECORDSET_INSERT.net CTRL you PARAM) DH_CTRL_RECORDSET_REMOVE.net CTRL you INSERT PARAM) DH_CTRL_RECORDSET_UPDATE. // Add records to record set number (corresponding to the. // Talk no response (corresponding to structure NET_CTRL_TALKING_REFUSE) 261/339 .net CTRL you PARAM) DH_CTRL_RECORDSET_CLEAR. // Close the warning signal corresponding structure NET (CTRL ALARMBELL) DH_CTRL_ACCESS_OPEN. // Entrance guard control - CLOSE corresponding structure NET (CTRL ACCESS CLOSE) DH_CTRL_ALARM_SUBSYSTEM_ACT IVE_SET. // OPEN ACCESS control - corresponding structure NET (CTRL ACCESS OPEN) DH_CTRL_SET_BYPASS. // Update a record of the number (corresponding to the.net (CTRL you PARAM) DH_CTRL_ACCESS_CLOSE. // Remove all RECORDSET information corresponding. //Disable device open gateway(corresponding to structure NET_CTRL_FORBID_OPEN_STROBE) DH_CTRL_OPEN_STROBE. //Enable gateway (corresponding to structure NET_CTRL_OPEN_STROBE) DH_CTRL_TALKING_REFUSE. // Alarm sub system activation setup(corresponding structure NET_CTRL_ALARM_SUBSYSTEM_SETACT IVE) DH_CTRL_FORBID_OPEN_STROBE.Option Instruction DH_CTRL_START_ALARMBELL. // According to the record set number to delete a record (corresponding to the. Option Instruction DH_CTRL_ARMED_EX. CTRL_ARM_DISARM_PARAM upgrade. //Set air work mode (corresponding to structure NET_CTRL_ADJUST_TEMPERATURE) DH_CTRL_AIRCONDITION_SETWINDMODE. // send event to device (corresponding to structure NET_NOTIFY_EVENT_DATA) DH_CTRL_SILENT_ALARM_SET. // mute alarm setup 262/339 . //Open air conditioner (corresponding to structure NET_CTRL_OPEN_AIRCONDITION) DH_CTRL_AIRCONDITION_CLOSE. // Set temperature (corresponding to structure NET_CTRL_SET_TEMPERATURE) DH_CTRL_AIRCONDITION_ADJUST_TEMPERAT URE.recommended DH_CTRL_NET_KEYBOARD = 400. // Recover device default and set new protocol(corresponding to structure NET_CTRL_RESTORE_DEFAULT) // Recover config and use this enumeration first. // Set fan mode (corresponding to structure NET_CTRL_AIRCONDITION_SETMODE) DH_CTRL_RESTOREDEFAULT_EX . try again DH_CTRL_RESTOREDEFAULT restore config. DH_CTRL_NOTIFY_EVENT.and CLIENT_GetLastError return NET_UNSUPPORTED. //Adjust temperature(corresponding to structure NET_CTRL_ADJUST_TEMPERATURE) DH_CTRL_AIRCONDITION_SETMODE. // Net keyboard control(corresponding to structure DHCTRL_NET_KEYBOARD) DH_CTRL_AIRCONDITION_OPEN. if port failed. //Close air-conditioner (corresponding to structure NET_CTRL_CLOSE_AIRCONDITION) DH_CTRL_AIRCONDITION_SET_TEMPERATURE. //arm-disarm operation (corresponding to structure CTRL_ARM_DISARM_PARAM_EX). // Delete specific wireless device(corresponding structure NET_CTRL_LOWRATEWPAN_REMOVE) DH_CTRL_LOWRATEWPAN_MODIFY. device will delete original IC card info(corresponding structure NET_CTRL_ECK_SYNC_IC_CARD_PARAM) DH_CTRL_LOWRATEWPAN_REMOVE. //device stop sound report DH_CTRL_CLOSE_STROBE. // Intelligent parking system in/out device IC card info import (corresponding structure NET_CTRL_ECK_IC_CARD_IMPORT_PARAM) DH_CTRL_ECK_SYNC_IC_CARD. // Modify wireless device 263/339 . // add record.(corresponding to NET_CTRL_RECORDSET_INSERT_PARAM) DH_CTRL_RECORDSET_UPDATEEX. //device start sound report(corresponding to structure NET_CTRL_START_PLAYAUDIOEX) DH_CTRL_STOP_PLAYAUDIOEX. receive this command. //close gateway (corresponding to structure NET_CTRL_CLOSE_STROBE) DH_CTRL_SET_ORDER_STATE.Option Instruction DH_CTRL_START_PLAYAUDIOEX. // Parking lot entrance/exit controller LED setup(corresponding structure NET_CTRL_ECK_LED_SET_PARAM) DH_CTRL_ECK_IC_CARD_IMPORT. //set parking reservation status (corresponding to structure NET_CTRL_SET_ORDER_STATE) DH_CTRL_RECORDSET_INSERTEX. // update record set no’s record(corresponding to NET_CTRL_RECORDSET_PARAM) DH_CTRL_CAPTURE_FINGER_PRINT. // fingerprint collection (corresponding to structure NET_CTRL_CAPTURE_FINGER_PRINT) DH_CTRL_ECK_LED_SET. // Intelligent parking system in/out device IC card info sync command.get record collection no. // Rain-brush brush cyclic. // Set up the vehicle spot information of the machine at the passageway of the intelligent parking system (corresponding to NET_CTRL_ECK_SET_PARK_INFO_PARAM) DH_CTRL_VTP_DISCONNECT. efficient when set as manual mode(corresponding to NET_CTRL_RAINBRUSH_MOVEONCE) DH_CTRL_RAINBRUSH_MOVECONTINUOUSLY. efficient when set as manal mode(corresponding to NET_CTRL_RAINBRUSH_MOVECONTINUOUSLY) DH_CTRL_RAINBRUSH_STOPMOVE. // hang up the video phone (corresponding to NET_CTRL_VTP_DISCONNECT) DH_CTRL_UPDATE_FILES. // Rain-brush brush one time. // recover the relationship between the hyponymy matrixes (corresponding to NET_CTRL_MATRIX_RESTORE_SWITCH) DH_CTRL_VTP_DIVERTACK. efficient when set as manal mode(corresponding to NET_CTRL_RAINBRUSH_STOPMOVE) DH_CTRL_ALARM_ACK.Option Instruction info(corresponding structure NET_CTRL_LOWRATEWPAN_MODIFY) DH_CTRL_ECK_SET_PARK_INFO. // Rain-brush stop. // the update of the remote multimedia files (corresponding to NET_CTRL_UPDATE_FILES) DH_CTRL_MATRIX_SAVE_SWITCH. // Save up the relationship between the hyponymy matrixes (corresponding to NET_CTRL_MATRIX_SAVE_SWITCH) DH_CTRL_MATRIX_RESTORE_SWITCH. // video talk phone divert ack (corresponding to NET_CTRL_VTP_DIVERTACK) DH_CTRL_RAINBRUSH_MOVEONCE. // affirm the alarm event (corresponding to NET_CTRL_ALARM_ACK) 264/339 . // Disable and enable door (Corresponding to structure NET_CTRL_ACCESS_USE_DOOR) DH_CTRL_ACCESS_SHUT_LOCK. //pOutBuf = NET_OUT_AUDIO_REC_MNG_NAME * DH_CTRL_AUDIO_REC_STOP_NAME. //pOutBuf= NET_OUT_RADIOMETRY_SETOSDMARK * DH_CTRL_AUDIO_REC_START_NAME. //Continuous unlocking instruction (Corresponding to structure NET_CTRL_OPEN_DOOR_CONTINUE) //The following commands are only for CLIENT_ControlDeviceEx DH_CTRL_THERMO_GRAPHY_ENSHUTTER = 0x10000. //pInBuf . // NET_IN_RADIOMETRY_SETOSDMARK*. // Close audio file and return file name.Option Instruction // DH_CTRL_ALARM_ACK DO NOT call this method in callback interface DH_CTRL_RECORDSET_IMPORT. // Batch import record set info (Corresponding to NET_CTRL_RECORDSET_PARAM) DH_CTRL_ACCESS_USE_DOOR. //pOutBuf = NET_OUT_AUDIO_REC_MNG_NAME * 265/339 . // The latch and the cancellation of the lock. //pOutBuf= NET_OUT_THERMO_EN_SHUTTER * DH_CTRL_RADIOMETRY_SETOSDMARK. // Enable audio record and get audio name. can not pass through the door(Corresponding to structure NET_CTRL_ACCESS_SHUT_LOCK) DH_CTRL_OPEN_DOOR_CONTINUE. //pInBuf = NET_IN_AUDIO_REC_MNG_NAME *.NET_IN_AUDIO_REC_MNG_NAME *. // Enable or disable thermal shutter. //pInBuf= NET_IN_THERMO_EN_SHUTTER*. // Del a POS device. // Modify a POS device. //pOutBuf = NET_OUT_POS_ADD * DH_CTRL_SET_SOUND_ALARM. //pInBuf = NET_IN_POS_REMOVE_MULT I *. //pInBuf = NET_IN_SOUND_ALARM *. //pOutBuf = NET_OUT_SOUND_ALARM * DH_CTRL_AUDIO_MATRIX_SILENCE. pInBuf = NET_IN_LOG_MNG_CTRL *. pInBuf = NET_IN_POS_ADD *.Option Instruction DH_CTRL_SNAP_MNG_SNAP_SHOT. // Add a POS device. // pOutBuf = NET_OUT_LOG_MNG_CTRL * DH_CTRL_POS_ADD. //Manual snap. pInBuf = NET_IN_POS_REMOVE *. //pInBuf = NET_IN_LOG_MNG_CTRL *. //pOutBuf = NET_OUT_POS_ADD * DH_CTRL_POS_REMOVE. pInBuf = NET_IN_SNAP_MNG_SHOT *. //pOutBuf = NET_OUT_POS_REMOVE_MULTI * DH_CTRL_POS_MODIFY. // Del several POS device. //Trigger alarm with sound. // Forcedly sync buffer data to the database and close the database. //audiomatrix silence. 266/339 . //pOutBuf = NET_OUT_LOG_MNG_CTRL * DH_CTRL_LOG_RESUME. // Resume database. pInBuf = NET_IN_POS_ADD *. //pOutBuf = NET_OUT_POS_REMOVE * DH_CTRL_POS_REMOVE_MULTI. //pOutBuf = NET_OUT_SNAP_MNG_SHOT * DH_CTRL_LOG_STOP. 265 } CFG_VIDEO_COMPRESSION. CFG_VIDEO_COMPRESSION Enum description Instruction Enum definition Video compression format type Enum description typedef enum tagCFG_VIDEO_COMPRESSION { VIDEO_FORMAT_MPEG4. // reboot network decoding device. // manual upload picture. // MPEG2 VIDEO_FORMAT_MPEG1. // MPEG4 VIDEO_FORMAT_MS_MPEG4. //pInBuf = NET_IN_MANUAL_UPLOAD_PICTURE *.263 VIDEO_FORMAT_MJPG. // MJPG VIDEO_FORMAT_FCC_MPEG4. // MPEG1 VIDEO_FORMAT_H263. // MS-MPEG4 VIDEO_FORMAT_MPEG2. //pOutBuf = NET_OUT_REBOOT_NET_DECODING_DEV * } CtrlType. //pInBuf = NET_IN_REBOOT_NET_DECODING_DEV *.Option Instruction //pInBuf = NET_IN_AUDIO_MATRIX_SILENCE*. // H. 267/339 . // H. // H. // FCC-MPEG4 VIDEO_FORMAT_H264. //pOutBUf = NET_OUT_MANUAL_UPLOAD_PICTURE * DH_CTRL_REBOOT_NET_DECODING_DEV.264 VIDEO_FORMAT_H265. //pOutBuf = NET_OUT_AUDIO_MATRIX_SILENCE* DH_CTRL_MANUAL_UPLOAD_PICT URE. // 80 percent image quality IMAGE_QUALITY_Q100. CFG_IMAGE_QUALITY Option Instruction Enum description Bit rate control Enum definition typedef enum tagCFG_IMAGE_QUALITY { IMAGE_QUALITY_Q10 = 1. // 10 percent image quality IMAGE_QUALITY_Q30.CFG_BITRATE_CONTROL Option Instruction Enum description Bit rate control Enum definition typedef enum tagCFG_BITRATE_CONTROL { BITRATE_CBR. //Fixed bit rate BITRATE_VBR. // 30 percent image quality IMAGE_QUALITY_Q50. // 60 percent image quality IMAGE_QUALITY_Q80. CFG_H264_PROFILE_RANK Option Instruction Enum description H264 encode rank Enum definition typedef enum tagCFG_H264_PROFILE_RANK { PROFILE_BASELINE=1. // 100 percent image quality } CFG_IMAGE_QUALITY. // 50 percent image quality IMAGE_QUALITY_Q60.only support progressive scanning and CAVLC 268/339 . //variable bit rate } CFG_BITRATE_CONTROL. //Provide I/P Frame. lossless video coding. // AAC } CFG_AUDIO_FORMAT. //resources is taken by 269/339 . EM_REALPLAY_DISCONNECT_EVENT_TYPE Option Instruction Enum description Realplay disconnect event type Enum definition typedef enum_EM_REALPLAY_DISCONNECT_EVENT_TYPE { DISCONNECT_EVENT_REAVE. // PCM AUDIO_FORMAT_G711U. //Based on FRExt. // AMR AUDIO_FORMAT_AAC.and many more yuv formats. // G711a AUDIO_FORMAT_PCM.support progressive and interlaced. only support progressive scanning and CAVLC PROFILE_HIGH.Main_Profile. // G711u AUDIO_FORMAT_AMR. custom //quant. //Provide I/P/B Frame. //Provide I/P/B/SP/SI Frame.Option Instruction PROFILE_MAIN. }CFG_H264_PROFILE_RANK. CFG_AUDIO_FORMAT Option Instruction Enum description Audio encode format Enum definition typedef enum tatCFG_AUDIO_FORAMT { AUDIO_FORMAT_G711A.provide CAVLC and CABAC PROFILE_EXTENDED. new add: 8x8 intra prediction. //forbidden DISCONNECT_EVENT_SUBCONNECT.Option Instruction advanced user DISCONNECT_EVENT_NETFORBID. 270/339 . //sublink disconnect }EM_REALPLAY_DISCONNECT_EVENT_TYPE. otherwise return FALSE. info includes login ID. Parameter cbDisConnect [in] callback function used when device gets disconnected.when online device is offline.1fDisConnect”for details. Precondition None Function BOOL CLIENT_Init( fDisConnect cbDisConnect. void CALLBACK DisConnectFunc(LONG lLoginID. LDWORD dwUser ).please refer to “3. LONG nDVRPort. Return value Succeeded return TRUE. dwUser [in]user data. // callback function used when device gets disconnected.SDK will send data to user via this function for further operation. unless call CLIENT_GetLastError to get error code in current process.login port etc. //When online device gets offline. 271/339 .SDK will notify user by this callback.Appendix 3 Interface definition CLIENT_Init Option Instruction Interface Interface for SDK initialization.call it when application programs need to be description initialized. DWORD dwUser) { printf("Call DisConnectFunc\n").device IP. Example // It’s not recommended to call SDK interface in callback function.when callback function cbDisConnect is not 0.SDK will call this callback function set by CLINET_Init. char *pchDVRIP.when function is set to 0.it means to prohibit the callback. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". \n").the first time is valid. dwUser). CLIENT_Cleanup Option Instruction Interface Interface for SDK clearance. 0). } Note Before call other SDK interface. printf("\n"). If call this interface repeatedly. return. printf("dwUser[%p]\n". ************** //SDK initialization g_bNetSDKInitFlag = CLIENT_Init(DisConnectFunc. } else { printf("Initialize client SDK done. if (FALSE == g_bNetSDKInitFlag) { printf("Initialize client SDK failed. description 272/339 . the underneath are interface using examples. call this interface firstly. lLoginID). } ************ Above are callback function definition. \n"). pchDVRIP). } printf("nDVRPort[%d]\n".Option Instruction printf("lLoginID[0x%x]". nDVRPort). Note None CLIENT_GetLastError Option Instruction Interface Interface for getting error code after failed calling interface.42 19000. Example //Get SDK version info DWORD dwNetSdkVersion = CLIENT_GetSDKVersion( ). CLIENT_Cleanup(). Parameter None Return value None Example // release initialization resources printf("CLIENT_Cleanup! \n"). Precondition Have called CLIENT_Init interface. CLIENT_GetSDKVersion Option Instruction Interface Interface for getting SDK version information. description Precondition Have called CLIENT_Init interface.for example 34219000 corresponding to version 3.get current thread description error code. Function void CLIENT_Cleanup( ).Option Instruction Precondition Have called CLIENT_Init interface. Parameter None Return value Return value is version. 273/339 . printf("NetSDK version is [%d]\n". dwNetSdkVersion). Function DWORD CLIENT_GetSDKVersion( ). Note When application program is closed . call this interface to release resources at last. Parameter None Return value Current thread error code Example // according to error code. CLIENT_SetAutoReconnect Option Instruction Interface Interface for setting reconnection callback function after disconnection. corresponds with return value from CLIENT_GetLastError interface. CLIENT_GetLastError()). Decimal number 23 is hexadecimal 0x17. #define _EC(x) (0x80000000|x) To find instruction of corresponding error code.Function DWORD CLIENT_GetLastError(void).when description device gets offline. DWORD dwUser ). //Example: #define NET_NOT_SUPPORTED_EC(23) //Now SDK does not support this function.SDK call this interface to note the user 274/339 . not decimal shows in header file. you can find corresponding explanation in dhnetsdk. Function void CLIENT_SetAutoReconnect( HaveReConnect cbAutoConnect.user can search the following fields in dhnetsdk.h. Parameter [in] cbAutoConnect Callback function set after the device reconnected successfully. Precondition Have called CLIENT_Init interface. It is to print hexadecimal here. SDK will reconnect internally. it is not illustrate here.h: //error code. Because of too much error code. Note Call this interface after failed calling interface. please be careful with conversion. printf("Last Error[%x]\n" . After device reconnects successfully. error code is 0x80000017. [in] dwUser User data. if (NULL != pchDVRIP) { printf("pchDVRIP[%s]\n". Return value None Example //Not recommended to call SDK interface in SDK callback function.SDKwill call this function. Note After setting callback function cbAutoConnect. when device gets offline. } printf("nDVRPort[%d]\n". SDK will reconnect internally.Once HaveReConnect is set. set the callback function in CLIENT_SetAutoReconnect. char *pchDVRIP. //When offline device is reconnected successfully. //Callback function set after the device reconnected successfully. nDVRPort). lLoginID). void CALLBACK HaveReConnect(LLONG lLoginID. printf("lLoginID[0x%x]". LDWORD dwUser) { printf("Call HaveReConnect\n"). the underneath are interface using examples. Return to user for further use by callback function cbAutoConnect. dwUser). printf("dwUser[%p]\n".************** //Set CLIENT_SetAutoReconnect interface. once device gets 275/339 . } ************ Above are callback function definition. CLIENT_SetAutoReconnect(&HaveReConnect. pchDVRIP).unless get current thread error code via CLIENT_GetLastError. LONG nDVRPort. set by user.Option Instruction reconnection successful. 0). printf("\n"). If reconnection is successful. SDK will not try to reconnect to device. SDK will try to reconnect to device constantly. nTryTimes [in]The trial time means the times of trying to connect device in every login. SDK will inform user via the callback function. Parameter nWaitTime [in] The timeout time means waiting time for device’s answer in every login. CLIENT_SetConnectTime Option Instruction Interface Interface for setting device connection timeout value and trial times.Option Instruction disconnected. CLIENT_SetConnectTime(nWaitTime. description Precondition Have called CLIENT_Init interface. //If timeout. nTryTimes).it will try to log in three times. 276/339 . // timeout time is 5 seconds int nTryTimes = 3. //This is optional. If the interface is not called or callback function cbAutoConnect in the interface is NULL . int nWaitTime = 5000. Return value None Example // Set device connection timeout time and trial times. nWaitTime is 5000 as default and nTryTimes is 1 as default. Note If CLIENT_SetConnectTime interface is not called. when device-end gets disconnected. int nTryTimes ). Function void CLIENT_SetConnectTime( int nWaitTime. Note None CLIENT_LoginEx2 Option Instruction Interface Extensive interface 2 for login. NET_PARAM stuNetParm = {0}. Function void CLIENT_SetNetworkParam( NET_PARAM *pNetParam ). 277/339 . CLIENT_SetNetworkParam(&stuNetParm). stuNetParm. const char *pchPassword.CLIENT_SetNetworkParam Option Instruction Interface Interface for setting log in network environment. //Change login timeout value to 10s,other parameters still use default values. description Precondition Have called CLIENT_Init interface. used to register user to device. Parameter pNetParam [in]used to provide net login parameter.could define description device capacity user supported.please refer to structure NET_TIME Return value None Example //Set the network login parameters. const char *pchUserName.nWaittime = 10000. Function LLONG CLIENT_LoginEx2( const char *pchDVRIP. WORD wDVRPort.include login timeout time and trial times. Precondition Have called CLIENT_Init interface. void* pCapParam.work in with emSpecCap. LPNET_DEVICEINFO_Ex lpDeviceInfo.it will input NULL.this parameter value is 278/339 . lpDeviceInfo [out]If device login successfully. pchPassword [in] User password Not allow over 64 bytes.such as the remaining login times.If not.Option Instruction EM_LOGIN_SPAC_CAP_TYPE emSpecCap. Parameter pchDVRIP [in]device IP.please refer to structure NET_DEVICEINFO. save part information of login device. emSpecCap [in] supported capacity of device.not allowed over 128 bytes.please refer to enum EM_LOGIN_SPAC_CAP_TYPE If emSpecCap value not has corresponding parameter instruction about pCapParam. int *error = 0 ).save part information of relevant login . wDVRPort [in] device port which used to login device.please refer to enum EM_LOGIN_SPAC_CAP_TYPE. IP address of login device. pchUserName [in] User name Not allow over 64 bytes. error [out] (If function returns success. pCapParam [in]Additional parameter to emSpecCap. int nError = 0.there is no USB in device 13.EM_LOGIN_SPEC_CAP_TCP.client's Ip don't have power login. Example //Login device NET_DEVICEINFO_Ex stDevInfoEx = {0}.only support the third agreement 12. g_lLoginHandle=CLIENT_LoginEx2(g_szDevIp. not decimal showns in header file. After login successfully.&stDevInfoEx.account locked 6. please be careful with conversion.account is blacklisted 7-system is busy.resource is not enough. you can find corresponding explanatio n in dhnetsdk.device ID can cooperate with SDK interface to operate equipment. For example: 1. //Example: #define NET_NOT_SUPPORTED_EC(23) 279/339 .otherwise return 0.Option Instruction insignificance). g_szPasswd.g_szUserName. Return value Succeeded return device ID. &nError). It is to print hexadecimal here.h.not exist user name 3-login timeout 4-account logged in 5. if(0 == g_lLoginHandle) { // according to error code. 8-failed subconnection 9-failed main connection 10-over max connections 11.return login error code.erroneous password 2.NULL.g_nPort. Recommended client to use emSpecCap = EM_LOGIN_SPEC_CAP_TCP which means login under TCP mode. device handle will be returned for relevant function to call. description Function BOOL CLIENT_Logout(LLONG lLoginID). Return value of CLIENT_LoginEx2 interface.Option Instruction //Now SDK does not support this function. g_nPort). g_szDevIp . if(!CLIENT_Logout(g_lLoginHandle)) { printf("CLIENT_Logout Failed!Last Error[%x]\n". Return value Succeeded return TRUE. printf("CLIENT_LoginEx2 %s[%d]Failed!Last Error[%x]\n" . g_nPort . } else { printf("CLIENT_LoginEx2 %s[%d] Success\n" . error code is 0x80000017. CLIENT_GetLastError()). Parameter lLoginID [in]device login handle ID.otherwise return FALSE. } 280/339 . If succeed. CLIENT_Logout Option Instruction Interface Interface for logout. } Note After successful initialization. g_szDevIp . CLIENT_GetLastError()).call this interface to register to designated device. Decimal number 23 is hexadecimal 0x17. Example printf("CLIENT_Logout! \n"). Note When logout device. Default type is DH_RType_Realplay.realize get real-time monitoring description data stream from logined device. Parameter lLoginID [in] device login ID.related businesses will stop . Precondition Have called login interface CLIENT_LoginEx2. Return value Failed return 0. CLIENT_RealPlayEx Option Instruction Interface Extensive interface for real-time monitoring. HWND hWnd. rType [in] real-time monitoring type. 281/339 . Example typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)().please refer to definition of enum DH_RealPlayType.when value is 0. nChannelID [in] real-time monitoring channel number which starts from 0. int nChannelID. DH_RealPlayType rType = DH_RType_Realplay ). data is not decoded and image is not displayed. Function LLONG CLIENT_RealPlayEx( LLONG lLoginID.otherwise return real-time monitoring ID(real-time monitoring handle) and used as related function parameter.such as real-time preview etc. //Please refer to example code of sync login in device login. hWnd [in] window handle. Return value of corresponding device login interface CLIENT_LoginEx2. if (g_lRealHandle == 0) { printf("CLIENT_RealPlayEx: failed! Error code: %x. If succeeded. GetConsoleWindow = (PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32. } Note NVR device fills nChannelID as video output channel number in multiplay preview. g_lRealHandle = CLIENT_RealPlayEx(g_lLoginHandle.such as CLIENT_RealPlayEx interface. you can open any real-time monitoring and display it in any designated window by calling this in terface. DH_RealPlayType emRealPlayType = DH_RType_Realplay. real-time monitoring ID is returned for more operation and control. CLIENT_StopRealPlayEx Option Instruction Interface Extensive interface for stopping real-time monitoring ."GetConsoleWi ndow"). // preview channel NO. nChannelID. int nChannelID = 0. emRealPlayType). Precondition Have called interface for getting real-time monitoring data stream . hWnd. HWND hWnd = GetConsoleWindow(). According to device information got when login. CLIENT_GetLastError()). //Start real-time monitoring.\n". //Get the console window handle. stop getting real-time description monitoring data stream from logined device.Option Instruction PROCGETCONSOLEWINDOW GetConsoleWindow. 282/339 . HMODULE hKernel32 = GetModuleHandle("kernel32"). LDWORD dwUser. CLIENT_GetLastError()). g_lRealHandle. Example if (!CLIENT_StopRealPlayEx(g_lRealHandle)) { printf("CLIENT_StopRealPlayEx Failed. DWORD dwFlag ). Parameter lRealHandle [in] real-time monitoring handle.otherwise return FALSE. Parameter lRealHandle 283/339 . Return value of getting real-time monitoring data stream interface as CLIENT_RealPlayEx etc. description Precondition Have called get real-time monitoring data stream interface as CLIENT_RealPlayEx etc. Function BOOL CLIENT_SetRealDataCallBackEx( LLONG lRealHandle.Option Instruction Function BOOL CLIENT_StopRealPlayEx ( LLONG lRealHandle ). Return value Succeeded return TRUE. g_lRealHandle[%x]!Last Error[%x]\n" . } Note None CLIENT_SetRealDataCallBackEx Option Instruction Interface Extensive interface for setting real-time monitoring data callback function. fRealDataCallBackEx cbRealData. Example // It’s not recommended to call SDK interface in callback function.different value corresponds to different data type: dwFlag Data type 0x00000001 Equal with original data 0x00000002 Standard data of MPEG4/H264 0x00000004 YUV data 0x00000008 PCM data 0x00000010 Original audio data 0x0000001f The above five types of data Return value If succeeded.call back real-time monitoring data via callback function cbRealData.Option Instruction [in] real-time monitoring handle. cbRealData [in] real-time monitoring data callback function If cbRealData value is 0.otherwise return FALSE. Return value of getting real-time monitoring data stream interface as CLIENT_RealPlayEx etc. //prototype of real-time monitor data callback function --extensive //The callback function is set by CLIENT_ SetRealDataCallBackEx. When 284/339 .return TRUE. dwFlag [in] flag of callback data selection we can recall data selectively as needed.not call back real-time monitoring data.SDK sends the data to user for further use via callback function fRealDataCallBackEx. unless call CLIENT_GetLastError to get error code in current process. dwUser [in] User data. If cbRealData value is not 0.please refer to callback function (fRealDataCallBackEx) for details. do not recall data type which is not set. and encode or decode data after leaving callback. In the other word:copy data to your storage.lRealHandle. //Recommend users only save data in this callback. DWORD dwBufSize. dwBufSize. //Not recommend users encode or decode data directly in callback function. case 4: 285/339 . void CALLBACK RealDataCallBackEx(LLONG lRealHandle. case 3: //pcm audio data break. dwDataType[%d]. dwUser). break.pBuffer[%p]. dwDataType. case 1: // standard video data break.dwBufSize[%d].Option Instruction real-time data is received. SDK will call function. pBuffer. LONG param.param:lRealHandle[%p]. BYTE *pBuffer. DWORD dwDataType. case 2: //yuv data break. LDWORD dwUser) { if (lRealHandle == g_lRealHandle) { switch(dwDataType) { case 0: //original A/V hybrid data printf("receive real data. param. param[%p].dwUser[%p]\n". ************** DWORD dwFlag = 0x00000001. int nChannelId.Option Instruction //original audio data break. Function LLONG CLIENT_FindFile( LLONG lLoginID. 286/339 . we can recall data selectively as needed. if(!CLIENT_SetRealDataCallBackEx(g_lRealHandle. default: break. int nRecordFileType. the underneath are interface using examples.&RealDataCallBackEx. } Note Add a callback data type flag.dwFlag. description Precondition Have called login interface CLIENT_LoginEx2. CLIENT_GetLastError()). } } } ************ Above are callback function definition.\n". do not recall data type which is not set. NULL. dwFlag)) { printf("CLIENT_SetRealDataCallBackEx: failed! Error code: %x. CLIENT_FindFile Option Instruction Interface Interface for opening record query handle. LPNET_TIME time_start. BOOL bTime.Option Instruction char* cardid. Different value corresponds with different record file type. Return value of login interface CLIENT_LoginEx2.please refer to enum EM_QUERY_RECORD_TYPE cardid [in] extensive parameter. int waittime ). nRecordFileType cardid EM_RECORD_TYPE_CARD card number EM_RECORD_TYPE_CONDI card number &&transaction TION type&&transaction amount (such as wish to skip a empty word) EM_RECORD_TYPE_CARD_ card number PICTURE EM_RECORD_TYPE_FIELD FELD1&&FELD2&& FELD3&&( such as wish to skip a empty word.start from 0.works in with nRecordFileType.corresponding position 287/339 . nChannelId [in] channel ID. nRecordFileType [in] Record file type. Parameter lLoginID [in]device login ID. LPNET_TIME time_end. dwYear = 2015.dwMinute = 0.dwDay = 20. bTime [in] whether query by time This parameter is invalid now. Please refer to structure NET_TIME. Return value Succeeded return record query handle.recommend to input FALSE. waittime [in] wait time.Option Instruction is null) In addition to the above situation. if(!CLIENT_FindFile (lLoginHandle.dwHour = 0. cardid value is null. tmEnd [in] end time of query record. //Get record query handle. StopTime.dwDay = 21. StopTime. StartTime.dwHour = 15. StartTime. int nFileCount = 0. 288/339 . StartTime. StartTime. Please refer to structure NET_TIME.dwMonth = 9. NET_RECORDFILE_INFO netFileInfo[30] = {0}. tmStart [in] start time of query record.otherwise return 0.dwMonth = 9. StartTime. nChannelID. StopTime. NET_TIME StopTime = {0}.dwYear = 2015. Example NET_TIME StartTime = {0}. StopTime. lpFindData [out]buffer of record file information. Parameter lFindHandle [in] record query handle. Used to output queried record file information . CLIENT_FindNextFile Option Instruction Interface Interface for searching record file. Example NET_RECORDFILE_INFO struFileData = {0}. FALSE.call CLIENT_FindClose to close query handle. LPNET_RECORDFILE_INFO lpFindData ). Correspond with return value of CLIENT_FindFile interface. &StopTime.then call CLIENT_FindNextFile function to return a detailed video record for playing.Option Instruction (int)EM_RECORD_TYPE_ALL. Function int CLIENT_FindNextFile( LLONG lFindHandle. description Precondition Have called get record query handle interface as CLIENT_FindFile.\n". &StartTime.after query is finished. CLIENT_GetLastError()). } Note You can call this interface for querying video record before playback.please refer to structure NET_RECORDFILE_INFO. 289/339 . 0:Video record has been exhausted. 5000)) { printf("CLIENT_FindFile: failed! Error code: %x. -1:parameter error. NULL. Return value 1:take back a video record successfully. One call returns one video record information. Return value Succeeded return TRUE. if(result == 1) //Take back a record file information. & struFileData). CLIENT_GetLastError()).Option Instruction int result = CLIENT_FindNextFile(lFindHandle. Parameter lFindHandle [in] record query handle. } else if(result == 0) // Data of record file information has been exhausted. { //Save record file. } else //Parameter error.otherwise return FALSE. { printf("CLIENT_FindNextFile: failed! Error code:0x%x. description Precondition Have called get record query handle interface as CLIENT_FindFile. } Note Call CLIENT_FindFile for opening query handle before call this interface. 290/339 .\n". CLIENT_FindClose Option Instruction Interface Interface for closing record query handle. Correspond with return value of CLIENT_FindFile interface. { . Function BOOL CLIENT_FindClose( LLONG lFindHandle ). Corresponding with return value of login interface CLIENT_LoginEx2. nChannelID [in] channel ID. CLIENT_GetLastError()). 291/339 . int nChannelID. LPNET_TIME lpStopTime.\n".and release resources.Option Instruction Example if(!CLIENT_FindClose (lFindHandle)) { printf("CLIENT_FindNextFile: failed! Error code:0x%x. LDWORD dwDataUser ).after query is finished. fDataCallBack fDownLoadDataCallBack. HWND hWnd. Function LLONG CLIENT_PlayBackByTimeEx( LLONG lLoginID. } Note Call CLIENT_FindFile for opening query handle.it is needed to call this function to close query handle. Parameter lLoginID [in] device login ID. fDownLoadPosCallBack cbDownLoadPos. LPNET_TIME lpStartTime. LDWORD dwPosUser. CLIENT_PlayBackByTimeEx Option Instruction Interface Extensive interface for playing back by time description Precondition Have called login interface CLIENT_LoginEx2. start from 0. not call back playback data process. SDK sends the data to user for further use via callback function fDownLoadPosCallBack. If cbDownLoadPos value is not 0. If fDownLoadDataCallBack value is 0. hWnd [in] playback window.please refer to fDownLoadPosCallBack callback function for details. SDK sends the data to user for further use via callback function fDownLoadDataCallBack. cbDownLoadPos [in] progress callback of user parameter If cbDownLoadPos value is 0.otherwise return 0. dwPosUser [in] user data.call back playback data process via callback function cbDownLoadPos.If fDownLoadDataCallBack value is not 0. lpStopTime [in]end time of playback. 292/339 . dwDataUser [in] user data.please refer to fDataCallBack for details. Return value If succeeded.call back record playback data via callback function fDownLoadDataCallBack. Please refer to structure NET_TIME for details. fDownLoadDataCallBack [in] record data callback function.Option Instruction lpStartTime [in] start time of playback.return record playback handle ID.not call back record playback data. Please refer to structure NET_TIME for details. \n". PROCGETCONSOLEWINDOW GetConsoleWindow.dwDay = 3. CLIENT_GetLastError()).dwMonth = 9. if (g_lPlayHandle == 0) { printf("CLIENT_PlayBackByTimeEx: failed! Error code: 0x%x. &stuStartTime. &stuStopTime. NULL. NULL).dwYear = 2015. int nChannelID = 0. GetConsoleWindow = (PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32. 293/339 ."GetConsoleWi ndow").dwYear = 2015. stuStopTime. nChannelID. NET_TIME stuStopTime = {0}. // Get console window handle HMODULE hKernel32 = GetModuleHandle("kernel32"). stuStartTime. g_lPlayHandle = CLIENT_PlayBackByTimeEx(g_lLoginHandle. hWnd.dwDay = 12. //channel NO NET_TIME stuStartTime = {0}. NULL. stuStopTime. stuStartTime. stuStopTime.otherwise interface will return 0. HWND hWnd = GetConsoleWindow().Option Instruction Example // this demo decoding by playsdk library typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)(). } Note Parameter hWnd and fDownLoadDataCallBack can not be NULL at the same time. stuStartTime.dwMonth = 9. NULL. g_lPlayHandle. Example if (!CLIENT_StopPlayBack(g_lPlayHandle)) { printf("CLIENT_StopPlayBack Failed.otherwise return FALSE.and close record playback handle via CLIENT_StopPlayBack.CLIENT_StopPlayBack Option Instruction Interface Interface for stopping record playback.otherwise it is insignificant. can parameter got by this interface be valid. CLIENT_GetPlayBackOsdTime Option Instruction Interface Interface for getting playback OSD time. Precondition Have called get record playback handle interface as CLIENT_PlayBackByTimeEx etc. Parameter lPlayHandle [in] record playback handle. } Note users get record playback handle via CLIENT_PlayBackByTimeEx interface etc. Return value Succeeded return TRUE. description Only when parameter hWnd in record playback interface is valid. Correspond with return value of CLIENT_PlayBackByTimeEx interface etc. Function BOOL CLIENT_StopPlayBack( LLONG lPlayHandle ). description Precondition Have called get record playback handle interface as CLIENT_PlayBackByTimeEx etc. Function BOOL CLIENT_GetPlayBackOsdTime( 294/339 . CLIENT_GetLastError()). g_lPlayHandle[%x]!Last Error[%x]\n" . can parameter got by this interface be valid. g_lPlayHandle. 295/339 . LPNET_TIME lpStartTime. &stuStartTime. CLIENT_GetLastError()). Please refer to structure NET_TIME for details. Return value Succeeded return TRUE.Option Instruction LLONG lPlayHandle. lpOsdTime [out] OSD time Please refer to structure NET_TIME for details. NET_TIME stuEndTime = {0}. LPNET_TIME lpOsdTime. } Note Only when parameter hWnd in record playback interface is valid. if (!CLIENT_GetPlayBackOsdTime (g_lPlayHandle. Please refer to structure NET_TIME for details. Correspond with return value of CLIENT_PlayBackByTimeEx interface etc. g_lPlayHandle[%x]!Last Error[%x]\n" .otherwise return FALSE. lpStartTime [out]start time of playback. lpEndTime [out] end time of playback.otherwise it is insignificant. Parameter lPlayHandle [in]record playback handle. &stuOsdTime. NET_TIME stuStartTime = {0}. LPNET_TIME lpEndTime ). Example NET_TIME stuOsdTime = {0}. &stuEndTime)) { printf("CLIENT_ GetPlayBackOsdTime Failed. int nChannelId. BOOL bTime = FALSE ). description Precondition Have called login interface CLIENT_LoginEx2. int nRecordFileType. Correspond with return value of login interface CLIENT_LoginEx2. nChannelId [in] channel ID. LPNET_RECORDFILE_INFO nriFileinfo. char* pchCardid. nRecordFileType [in] record file type. int waittime=1000. Different value corresponds with different record file type.start from 0.please refer to enum EM_QUERY_RECORD_TYPE.CLIENT_QueryRecordFile Option Instruction Interface Interface for querying all files in pointed time period. Function BOOL CLIENT_QueryRecordFile( LLONG lLoginID. Parameter lLoginID [in] device login ID. LPNET_TIME tmStart. 296/339 . tmStart [in] start time of record query. int *filecount. LPNET_TIME tmEnd. int maxlen. 297/339 . nRecordFileType pchCardid EM_RECORD_TYPE_CARD card number EM_RECORD_TYPE_CONDITION card number &&transaction type&&transaction amount (such as wish to skip a empty word) EM_RECORD_TYPE_CARD_PICTURE card number EM_RECORD_TYPE_FIELD FELD1&&FELD2&&FELD3 &&( such as wish to skip a empty word.Option Instruction Please refer to structure NET_TIME.recommend length: (100~200)*sizeof(NET_RECORDFILE_INFO) filecount [out] file count of returned. This is a pointer of structure array of NET_RECORDFILE_INFO.work in with nRecordFileType. tmEnd [in] end time of record query. (unit:byte.please refer to structure NET_RECORDFILE_INFO for details. nriFileinfo [out] record file information of returned. Please refer to structure NET_TIME. pchCardid value is null. maxlen [in]max length of nriFileinfo buffer. pchCardid [in] extensive parameter.corresponding position is null) In addition to the above situation. bTime [in] whether query by time This parameter is invalid now. CLIENT_GetLastError()). Return value Succeeded return TRUE. StartTime.5000.dwYear = 2015. nChannelID. (int)EM_RECORD_TYPE_ALL. &nFileCount. NET_RECORDFILE_INFO netFileInfo[30] = {0}. StartTime. StartTime. &netFileInfo[0]. sizeof(netFileInfo). StartTime. If 298/339 .dwHour = 0.dwMonth = 9. StopTime.it’s needed to call this interface to query video record.dwMonth = 9.\n". NET_TIME StopTime = {0}.recommended to input FALSE. &StopTime. Example NET_TIME StartTime = {0}. NULL.dwHour = 15.otherwise return FALSE. int nFileCount = 0.dwYear = 2015.dwMinute = 0. } Note Before playback by file. StopTime. FALSE)) { printf("CLIENT_QueryRecordFile: failed! Error code: %x. &StartTime. StopTime.dwDay = 21. //query record file if(!CLIENT_QueryRecordFile(lLoginHandle. StartTime. waittime [in] wait time.Option Instruction Output parameter only querys to the biggest video record which buffer is full.dwDay = 20. StopTime. int nRecordFileType. lLoginID [in] logined device ID Return value of login interface CLIENT_LoginEx2.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. LDWORD dwUserData. Parameter nChannelId [in] channel NO. start from 0. LDWORD dwDataUser. void* pReserved = NULL ). CLIENT_DownloadByTimeEx Option Instruction Interface Extensive interface for downloading record by time description Precondition Have called login interface CLIENT_LoginEx2. Function char *sSavedFileName. LPNET_TIME tmStart. LLONG CLIENT_DownloadByTimeEx( LLONG lLoginID. fTimeDownLoadPosCallBack cbTimeDownLoadPos.. nRecordFileType [in] record file type 299/339 .and can continue querying as needed. int nChannelId. fDataCallBack fDownLoadDataCallBack. LPNET_TIME tmEnd. // channel NO. meaningless until now. 300/339 . dwUserData [in] user data of download progress callback function SDK send the data to user for further use via callback function fTimeDownLoadPosCallBack fDownLoadDataCallBack [in] download data callback function See callback function fDataCallBack for details. Return value succeed return download ID.Option Instruction See enum EM_QUERY_RECORD_TYPE for details tmStart [in] record download start time See struct NET_TIME for details tmEnd [in] record download end time See struct NET_TIME for details sSavedFileName [in] name of the record file to be saved Recommended to use the full path name cbTimeDownLoadPos [in] download progress callback function See callback function fTimeDownLoadPosCallBack for details. default value is NULL. dwDataUser [in] user data of download data callback function SDK send the data to user for further use via callback function fDataCallBack pReserved [in]reserved parameter Used for further extension. failed return 0. Example int nChannelID = 0. stuStartTime. 301/339 . g_lDownloadHandle = CLIENT_DownloadByTimeEx(g_lLoginHandle. DataCallBack. "test.dwDay = 17. NET_TIME stuStopTime = {0}.Option Instruction NET_TIME stuStartTime = {0}. stuStopTime. stuStartTime.dwYear = 2015. // at least one of the two formal parameters sSavedFileName and fDownLoadDataCallBack is valid. &stuStartTime. fDownLoadDataCallBack is not NULL. CLIENT_StopDownload Option Instruction Interface Interface for stopping record download description Precondition Have called record download interface as CLIENT_DownloadByTimeEx etc. NULL).dwDay = 18. call CLIENT_StopDownload to close download handle. EM_RECORD_TYPE_ALL. nChannelID. stuStopTime.dwMonth = 9.\n". record data is returned via this callback Note function. NULL.dwMonth = 9. record data is written to the corresponding file.dav". if (g_lDownloadHandle == 0) { printf("CLIENT_DownloadByTimeEx: failed! Error code: %x. } sSavedFileName is not NULL. CLIENT_GetLastError()).dwYear = 2015. After download. TimeDownLoadPosCallBack. stuStartTime. stuStopTime. // start record download. &stuStopTime. failed return FALSE // stop download. LLONG CLIENT_PlayBackByRecordFileEx( Function LLONG lLoginID. lFileHandle [in]download handle Parameter Return value of record download interface as CLIENT_DownloadByTimeEx etc. LPNET_RECORDFILE_INFO lpRecordFile. Value Succeed return TRUE. CLIENT_PlayBackByRecordFileEx Option Instruction Interface Extensive interface for playing back by file description Precondition Have called login interface CLIENT_LoginEx2. g_lDownloadHandle. } } Note We can stop download after download end or during download as needed.Option Instruction BOOL CLIENT_StopDownload( Function LLONG lFileHandle ). 302/339 . g_lDownloadHandle[%x] !Last Error[%x]\n" . if (g_lDownloadHandle) { if (!CLIENT_StopDownload(g_lDownloadHandle)) Example { printf("CLIENT_StopDownload Failed. CLIENT_GetLastError()).we can call this interface after download end or during download. If fDownLoadDataCallBack is not 0. lLoginID [in] logined device ID Return value of login interface CLIENT_LoginEx2. hWnd [in] playback window handle cbDownLoadPos [in] record progress callback function Parameter If cbDownLoadPos is 0.Option Instruction HWND hWnd. not call back playback data. not call back playback data progress. dwPosUser [in] user data SDK send the data to user for further use via callback function fDownLoadPosCallBack fDownLoadDataCallBack [in] record data callback function If fDownLoadDataCallBack is 0. call back playback data progress via 303/339 . LDWORD dwDataUser ). LDWORD dwPosUser. fDownLoadPosCallBack cbDownLoadPos. See struct NET_RECORDFILE_INFO for details. see callback function fDownLoadPosCallBack for details. call back playback data progress via callback function cbDownLoadPos. fDataCallBack fDownLoadDataCallBack. lpRecordFile [in] record file information Obtained by record information search interface as CLIENT_FindNextFile. If cbDownLoadPos is not 0. } Parameter hWnd and fDownLoadDataCallBack can not be NULL at the Note same time.\n". NULL. //stuNetFileInfo information is obtained by together of three interfaces CLIENT_FindFile. failed return 0. Example if (g_lPlayHandle == 0) { printf("CLIENT_PlayBackByRecordFileEx: failed! Error code: %x. see callback function fDataCallBackfor details. to obtain record Precondition playback handle. CLIENT_PausePlayBack Option Instruction Interface for pause or restoring playback Interface Only when the parameter hWnd in open record playback interface is valid.CLIENT_FindNextFile and CLIENT_FindClose.Option Instruction callback function fDownLoadDataCallBack. hWnd. // formal parameter hWnd must be valid. NULL). g_lPlayHandle = CLIENT_PlayBackByRecordFileEx(g_lLoginHandle. otherwise the interface will be failed. description can parameters this interface obtained be valid. dwDataUser [in] user data SDK send the data to user for further use via callback function fDownLoadDataCallBack Return value Succeed return playback handle. &stuNetFileInfo. otherwise it is no meaning. NULL. NULL. Hava called interface as CLIENT_PlayBackByTimeEx etc. CLIENT_GetLastError()). Function BOOL CLIENT_PausePlayBack(LLONG lPlayHandle. BOOL bPause). Parameter lPlayHandle 304/339 . BOOL CLIENT_SeekPlayBack( LLONG lPlayHandle. lPlayHandle [in] record playback handle Parameter Return value of interface as CLIENT_PlayBackByTimeEx etc. unsigned int offsetbyte ). Function unsigned int offsettime. Note can parameters this interface obtained be valid. to obtain record Precondition playback handle. g_lPlayHandle[%x]!Last Error[%x]\n" . g_lPlayHandle. failed return FALSE. bPause [in] flag of pause or restore playing TRUE :pause FALSE :restore playing Return value Succeed return TRUE.Option Instruction [in] record playback handle Return value of interface as CLIENT_PlayBackByTimeEx etc. offsettime 305/339 . if (!CLIENT_ PausePlayBack (g_lPlayHandle)) { Example printf("CLIENT_ PausePlayBack Failed. } Only when the parameter hWnd in open record playback interface is valid. CLIENT_GetLastError()). CLIENT_SeekPlayBack Option Instruction Interface Interface for positioning record playback start point description Hava called interface as CLIENT_PlayBackByTimeEx etc. otherwise it is no meaning. BOOL CLIENT_FastPlayBack( Function LLONG lPlayHandle ). g_lPlayHandle. g_lPlayHandle[%x]!Last Error[%x]\n" . to obtain record Precondition playback handle. Hava called interface as CLIENT_PlayBackByTimeEx etc. 306/339 . int nOffsetSeconds = 2 * 60 * 60. Return value Succeed return TRUE. lPlayHandle Parameter [in] record playback handle Return value of interface as CLIENT_PlayBackByTimeEx etc. failed return FALSE. Increasing frame rate by 1x Interface Only when the parameter hWnd in open record playback interface is valid. 0xffffffff)) Example { printf("CLIENT_SeekPlayBack Failed. CLIENT_GetLastError()). nOffsetSeconds.Option Instruction [in] relative offset of start time(unit : s) offsetbyte [in] this parameter is abolished Set to 0xffffffff. // drag to 2*60*60s after stuStartTime to start play. otherwise it is no meaning. if (FALSE == CLIENT_SeekPlayBack (g_lPlayHandle. can description parameters this interface obtained be valid. } Note None CLIENT_FastPlayBack Option Instruction Interface for fast play. BOOL CLIENT_SlowPlayBack ( Function LLONG lPlayHandle ). lPlayHandle Parameter [in] record playback handle Return value of interface as CLIENT_PlayBackByTimeEx etc. to obtain record Precondition playback handle. g_lPlayHandle. failed return FALSE.Option Instruction Return value Succeed return TRUE. Only when the parameter hWnd in open record playback interface is valid. Return value Succeed return TRUE. if (!CLIENT_SlowPlayBack (g_lPlayHandle)) Example { printf("CLIENT_SlowPlayBack Failed. Decreasing frame rate by 1x description Hava called interface as CLIENT_PlayBackByTimeEx etc. currently the max frame is 200. if the record is with sound. if (!CLIENT_ FastPlayBack (g_lPlayHandle)) { Example printf("CLIENT_ FastPlayBack Failed. otherwise it is no meaning. g_lPlayHandle[%x]!Last Error[%x]\n" . greater than this will return FALSE. fast forward is not Note supported. CLIENT_GetLastError()). failed return FALSE. } Can not fast forward without limit. g_lPlayHandle[%x]!Last 307/339 . can parameters this interface obtained be valid. CLIENT_SlowPlayBack Option Instruction Interface Interface for slow play. when the parameter hWnd in open record playback interface is 0 and device supports playback speed control. g_lPlayHandle. CLIENT_GetLastError()). } The min frame is 1. Return value Succeed return TRUE. to obtain record Precondition playback handle. less than 1 will return FALSE. Note when the parameter hWnd in open record playback interface is a valid value and device supports playback speed control. CLIENT_GetLastError()). } 308/339 . g_lPlayHandle[%x]!Last Error[%x]\n" . g_lPlayHandle. failed return FALSE. SDK can send speed control command to device. CLIENT_NormalPlayBack Option Instruction Interface Interface for restoring normal play speed description Hava called interface as CLIENT_PlayBackByTimeEx etc. lPlayHandle Parameter [in] record playback handle Return value of interface as CLIENT_PlayBackByTimeEx etc. if (!CLIENT_NormalPlayBack (g_lPlayHandle)) { Example printf("CLIENT_NormalPlayBack Failed.Option Instruction Error[%x]\n" . BOOL CLIENT_NormalPlayBack( Function LLONG lPlayHandle ). SDK can send speed control command to device and call the command to playsdk library which display records. fDataCallBack fDownLoadDataCallBack. see 309/339 . void* pReserved = NULL ). CLIENT_DownloadByRecordFileEx Option Instruction Interface Extensive interface for downloading record by file description Precondition Have called login interface CLIENT_LoginEx2. fDownLoadPosCallBack cbDownLoadPos. Note when the parameter hWnd in open record playback interface is a valid value and device supports playback speed control. lLoginID [in] logined device ID Return value of login interface CLIENT_LoginEx2. LDWORD dwDataUser. Function LDWORD dwUserData. LLONG CLIENT_DownloadByRecordFileEx( LLONG lLoginID. SDK can send speed control command to device. SDK can send speed control command to device and call the command to playsdk library which display records. LPNET_RECORDFILE_INFO lpRecordFile.Option Instruction when the parameter hWnd in open record playback interface is 0 and device supports playback speed control. char *sSavedFileName. Parameter lpRecordFile [in] record file information pointer Obtained by record search interface CLIENT_QueryRecordFile. see callback function fDataCallBackfor details. sSavedFileName [in] name of the record file to be saved Recommended to use the full path name cbDownLoadPos [in] record progress callback function If cbDownLoadPos is 0. call back playback data progress via callback function cbDownLoadPos. see callback function fDownLoadPosCallBack for details. If cbDownLoadPos is not 0.Option Instruction NET_RECORDFILE_INFO for details. failed return FALSE. call back playback data progress via callback function fDownLoadDataCallBack. invalid until now. If fDownLoadDataCallBack is not 0. Return value Succeed return TRUE. not call back playback data progress. Example // at least one of the two formal parameters sSavedFileName and 310/339 . dwDataUser [in] user data SDK send the data to user for further use via callback function fDownLoadDataCallBack pReserved [in]reserved parameter Used for further extension. default value is NULL. not call back playback data. dwPosUser [in] user data SDK send the data to user for further use via callback function fDownLoadPosCallBack fDownLoadDataCallBack [in] record data callback function If fDownLoadDataCallBack is 0. 311/339 . DWORD dwOutBufferSize.dav". fDownLoadDataCallBack is not NULL. char* szInBuffer. Function LPVOID lpOutBuffer. if (g_lDownloadHandle == 0) { printf("CLIENT_DownloadByRecordFileEx: failed! Error code: %x.\n". &stuNetFileInfo. BOOL CLIENT_ParseData( char* szCommand. szCommand Parameter [in] command parameter See “note” below for details. record data is returned via this callback Note function. After download. NULL. NULL). "test. record data is written to the corresponding file. DownLoadPosCallBack. CLIENT_ParseData Option Instruction Interface Interface for analyzing the obtained config info description Precondition Have called login interface CLIENT_LoginEx2. DataCallBack. } sSavedFileName is not NULL. CLIENT_GetLastError()). g_lDownloadHandle = CLIENT_DownloadByRecordFileEx(g_lLoginHandle. void* pReserved ). call CLIENT_StopDownload to close download handle.Option Instruction fDownLoadDataCallBack is valid. getCurrentProtocolCaps" // obtain PTZ capacity set (CFG_PTZ_PROTOCOL_CAPS_INFO) Note #define CFG_CMD_ENCODE "Encode" // image channel property configure (corresponds to CFG_ENCODE_INFO) See header file “dhconfigsdk. if (FALSE == CLIENT_ParseData(CFG_CAP_CMD_PTZ. CFG_PTZ_PROTOCOL_CAPS_INFO stuPtzCapsInfo = {sizeof(stuPtzCapsInfo)}. cmd[CFG_CAP_CMD_PTZ]. failed return FALSE. dwOutBufferSize [in] output buffer size pReserved [in] reserved parameter Return value Succeed return TRUE. } Command parameter: #define CFG_CAP_CMD_PTZ "ptz. NULL)) Example { printf("CLIENT_ParseData Failed. pBuffer. sizeof(stuPtzCapsInfo). Last Error[%x]\n" . Support 3-D quick positioning and 312/339 . CLIENT_GetLastError()).h” for more command parameters.Option Instruction szInBuffer [in] input buffer To be analyzed json string lpOutBuffer [out] output buffer Different command parameter correspond to different struct type. CLIENT_DHPTZControlEx2 Option Instruction Interface Extensive interface for private PTZ control. &stuPtzCapsInfo. void* param4 = NULL ).Option Instruction description fish-eye. Precondition Have called login interface CLIENT_LoginEx2. dwPTZCommand [in] dome control command See enum DH_PTZ_ControlType and enum DH_EXT PTZ_ControlType for Parameter details.. BOOL CLIENT_DHPTZControlEx2( LLONG lLoginID. BOOL dwStop . LONG lParam3. lParam1 [in] ancillary parameter 1 Used matched with other parameter. nChannelId [in] channel NO. int nChannelID. different control command has different lParam2 313/339 . start from 0. different control command has different lParam1. DWORD dwPTZCommand. Function LONG lParam2. LONG lParam1. lLoginID [in] logined device ID Return value of login interface CLIENT_LoginEx2. lParam2 [in] ancillary parameter 2 Used matched with other parameter. otherwise in when operating others the parameter is set to FALSE. NULL)) { Example printf("CLIENT_DHPTZControlEx2 Failed. different control command has different lParam3 dwStop [in] stop or not Valid when operating PTZ eight direction and lens. nChannelId. if (!CLIENT_DHPTZControlEx2(g_lLoginHandle. CLIENT_QueryNewSystemInfo Option Description Interface Interface for obtaining new system capacity set (take the form of Json. 0. CLIENT_GetLastError()). see description config SDK for details ) Precondition Have called login interface CLIENT_LoginEx2. 0. NULL as default. failed return FALSE.Option Instruction lParam3 [in] ancillary parameter3 Used matched with other parameter. Used matched with other parameter.please refer to the CLIENT_DHPTZControlEx2 Note interface in ‘Network SDK Development Manual. nChoose[DH_PTZ_UP_CONTROL]!Last Error[%x]\n" . 0. DH_PTZ_UP_CONTROL. 314/339 . lParam4 [in] ancillary parameter4. different control command has different lParam4 Return value Succeed return TRUE. FALSE.chm’ . } More Information of Param . Option Description BOOL CLIENT_QueryNewSystemInfo( LLONG lLoginID. char* szCommand. partial commands not support Parameter setting to -1. int waittime=1000 ). netsdk will write corresponding error code to this pointer address. int nChannelID. int *error. szOutBuffer [in] buffer zone used to store data Used to store the queried json string data dwOutBufferSize [in] buffer size error [out] returned error code When failed obtaining. set to -1 means searching all the channels. DWORD dwOutBufferSize. Function char* szOutBuffer. lLoginID [in] logined device ID Return value of login interface CLIENT_LoginEx2. szCommand [in] search command See Note for details nChannelID [in] search channel Channel NO. 315/339 . is start from 0. Last Error[%x]\n" .Option Description waittime [in] timeout time Timeout time of waiting command returned. take 1000ms as default Return value Succeed return TRUE. Note The capacity set corresponds to CLIENT_QueryNewSystemInfo are as follows: #define CFG_CAP_CMD_PTZ "ptz. if (FALSE == CLIENT_QueryNewSystemInfo(g_lLoginHandle. 2048. failed return FALSE.getCurrentProtocolCaps" // 316/339 .otherwise can not be used. 0. } The json string obtained by this interface must be analyzed by CLIENT_ParseData interface. if (NULL == pBuffer) { return. } int nError = 0. pBuffer. pBuffer = NULL. &nError)) { Example printf("CLIENT_QueryNewSystemInfo Failed. } return. if (pBuffer) { delete [] pBuffer. CLIENT_GetLastError()). char* pBuffer = new char[2048]. CFG_CAP_CMD_PTZ. cmd[CFG_CAP_CMD_PTZ]. Function EM_USEDEV_MODE emType. emType [in] working mode type Parameter See enum EM_USEDEV_MODE for details pValue [in] extensive parameter Different emType corresponds to different pValue. &nStreamType)) { 317/339 .2-sub stream Example if(!CLIENT_SetDeviceMode(g_lLoginHandle. // 0-main/sub stream.see enum EM_USEDEV_MODE for details.Option Description obtaining PTZ capacity set (CFG_PTZ_PROTOCOL_CAPS_INFO) See header file “dhconfigsdk. //set playback stream type int nStreamType = 0. lLoginID [in] logined device ID Return value of login interface CLIENT_LoginEx2. Return value Succeed return TRUE. CLIENT_SetDeviceMode Option Instruction Interface Interface for setting work mode such as audio intercom. Precondition Have called login interface CLIENT_LoginEx2.h” for more command parameters. right and description etc. BOOL CLIENT_SetDeviceMode( LLONG lLoginID. playback. DH_RECORD_STREAM_TYPE. failed return FALSE.1-main stream. void* pValue ). cbSearchDevices [in] device search callback function When there are response package returned from device-end.\n". char* szLocalIp=NULL ). Return value Succeed return handle. Function void* pUserData. Example // start async searching for same-segment device 318/339 . see callback function fSearchDevicesCB for details. within same segment description Precondition Have called CLIENT_Init interface LLONG CLIENT_StartSearchDevices( fSearchDevicesCB cbSearchDevices.Option Instruction printf("CLIENT_ SetDeviceMode: failed! Error code: 0x%x. NetSDK will analyze them to valid information and inform user via callback function. NVS and etc. szLocalIp [in] local IP NULL as default if this parameter is not set. pUserData Parameter [in] user data NetSDK will return the value to user for further user via callback function fSearchDevicesCB. failed return FALSE. CLIENT_GetLastError()). } Note None CLIENT_StartSearchDevices Option Instruction Interface Interface for async searching for IPC. nType [in] search type 319/339 . lLoginID [in] logined device ID Parameter Return value of login interface CLIENT_LoginEx2. &g_lDeviceList).Option Instruction g_lSearchHandle = CLIENT_StartSearchDevices(SearchDevicesCB. search Note cross-segment device interface is CLIENT_SearchDevicesByIPs. int waittime=1000 ). int *pRetLen. CLIENT_GetLastError()). CLIENT_QueryDevState Option Instruction Interface Interface for searching device status description Precondition Have called login interface CLIENT_LoginEx2. int nType. if (NULL == g_lSearchHandle) { printf("CLIENT_StartSearchDevices Failed!Last Error[%x]\n". char *pBuf. } This interface is for searching device in the same segment. return. BOOL CLIENT_QueryDevState( LLONG lLoginID. Function int nBufLen. Option Instruction See “note” below for details. pBuf [out] output buffer zone Used to store the queried device infor, used matched with nType, see “note” below for details. nBufLen [in] buffer zone size pRetLen [out] lenth of queried data(unit : BYTE) waittime [in] searching waiting time , 1000ms as default Return value Succeed return TRUE, failed return FALSE. //Get audio intercom encode type supported by front-end device DHDEV_TALKFORMAT_LIST stulstTalkEncode; int retlen = 0; bSuccess = CLIENT_QueryDevState(g_lLoginHandle, DH_DEVSTATE_TALK_ECTYPE, (char*)&stulstTalkEncode, Example sizeof(stulstTalkEncode), &retlen, 3000); if (!(bSuccess && retlen == sizeof(stulstTalkEncode))) { printf("CLIENT_QueryDevState cmd[%d] Failed!Last Error[%x]\n" , DH_DEVSTATE_TALK_ECTYPE, CLIENT_GetLastError()); } Supported searching type is shown in below: #define DH_DEVSTATE_TALK_ECTYPE 0x0009 Note //searching audiointercom type list device supported, see struct DHDEV_TALKFORMAT_LIST for details. See dhnetsdk.h header file for more command parameter. 320/339 CLIENT_StartTalkEx Option Instruction Interface Extensive interface for opening audio intercom description Precondition Have called login interface CLIENT_LoginEx2. LLONG CLIENT_StartTalkEx( LLONG lLoginID, Function pfAudioDataCallBack pfcb, LDWORD dwUser ); lLoginID [in] logined device ID Return value of login interface CLIENT_LoginEx2. pfcb [in] audio intercom audio data callback function Parameter See callback function pfAudioDataCallBack for details. dwUser [in] user data 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. g_lTalkHandle = CLIENT_StartTalkEx(g_lLoginHandle, AudioDataCallBack, (DWORD)NULL); if(0 == g_lTalkHandle) Example { printf("CLIENT_StartTalkEx Failed!Last Error[%x]\n", CLIENT_GetLastError()); } Note None 321/339 CLIENT_StopTalkEx Option Instruction Interface Extensive interface for stopping audio intercom description Precondition Have called open audio intercom interface as CLIENT_StartTalkEx etc. BOOL CLIENT_StopTalkEx( Function LLONG lTalkHandle ); lTalkHandle Parameter [in] audio intercom handle Corresponding to return value of interface as CLIENT_StartTalkEx etc. Return value Succeed return TRUE, failed return FALSE. if(!CLIENT_StopTalkEx(g_lTalkHandle)) { printf("CLIENT_StopTalkEx Failed!Last Error[%x]\n", CLIENT_GetLastError()); Example } else { g_lTalkHandle = 0; } Note None CLIENT_RecordStartEx Option Instruction Interface Extensive interface for starting PC-end recording(extension of description CLIENT_RecordStart()) Precondition Have called login interface CLIENT_LoginEx2. Function BOOL CLIENT_RecordStartEx( 322/339 Option Instruction LLONG lLoginID ); lLoginID Parameter [in] logined device ID Return value of login interface CLIENT_LoginEx2. Return value Succeed return TRUE, failed return FALSE. BOOL bSuccess = CLIENT_RecordStartEx(g_lLoginHandle); if(!bSuccess) { Example printf("CLIENT_RecordStartEx Failed! Last Error[%x]\n", CLIENT_GetLastError()); } Note None CLIENT_RecordStopEx Option Instruction Interface Extensive interface for stopping PC-end recording(extension of description CLIENT_RecordStop()) Precondition Have called open local recording interface as CLIENT_RecordStartEx etc. BOOL CLIENT_RecordStopEx( Function LLONG lLoginID ); lLoginID Parameter [in] logined device ID Return value of login interface CLIENT_LoginEx2. Return value Succeed return TRUE, failed return FALSE. // stop local recording Example if (g_RecordFlag) 323/339 Option Instruction { if (!CLIENT_RecordStopEx(g_lLoginHandle)) { printf("CLIENT_RecordStop Failed! Last Error[%x]\n", CLIENT_GetLastError()); } else { g_RecordFlag = FALSE; } } CLIENT_RecordStopEx interface needs to be used corresponding to Note CLIENT_RecordStartEx CLIENT_TalkSendData Option Instruction Interface Interface for sending audio data to device description Precondition Have called login interface CLIENT_LoginEx2. LONG CLIENT_TalkSendData( LLONG lTalkHandle, Function char *pSendBuf, DWORD dwBufSize ); lTalkHandle [in] audio intercom handle Parameter Corresponding to return value of interface as CLIENT_StartTalkEx etc. pSendBuf [in] send buffer zone 324/339 Option Instruction Store data to be sent dwBufSize [in]buffer size Length of data to be sent(unit: BYTE) Return value Succeed return data length has been transferred practically, failed return -1. LONG lSendLen = CLIENT_TalkSendData(lTalkHandle, pDataBuf, dwBufSize); if(lSendLen != (long)dwBufSize) Example { printf("CLIENT_TalkSendData Failed!Last Error[%x]\n" , CLIENT_GetLastError()); } Send the data which is called back by callback function set in Note CLIENT_StartTalkEx to device CLIENT_AudioDecEx Option Instruction Interface Extensive interface for decoding audio data description Precondition Have called login interface CLIENT_LoginEx2. BOOL CLIENT_AudioDecEx( LLONG lTalkHandle, Function char *pAudioDataBuf, DWORD dwBufSize ); lTalkHandle [in] audio intercom handle Parameter Corresponding to return value of interface as CLIENT_StartTalkEx etc. pAudioDataBuf 325/339 Function LDWORD dwUser ). failed return FALSE.Option Instruction [in] audio buffer zone The audio data to be decoded. } Note Decode the data sent by device in audio intercom CLIENT_SetDVRMessCallBack Option Instruction Interface Interface for setting alarm callback function. pDataBuf. CLIENT_GetLastError()). cbMessage [in] alarm callback function. // send the audio data which received from device-end to SDK to decode and play. SDK sends the data to user for further use via real-time 326/339 . dwBufSize [in] buffer size Length of audio data to be decoded (unit : BYTE) Return value Succeed return TRUE. dwUser [in] user data. if (!CLIENT_AudioDecEx(lTalkHandle. Parameter Please refer to fMessCallBack for details. description Precondition Have called login interface CLIENT_LoginEx2. void CLIENT_SetDVRMessCallBack( fMessCallBack cbMessage. dwBufSize)) Example { printf("CLIENT_AudioDecEx Failed!Last Error[%x]\n" . failed return FALSE. Return value Succeeded return TRUE.\n"). Call CLIENT_SetDVRMessCallBack before alarm subscription... // subscribe alarm event from device if( CLIENT_StartListenEx(g_lLoginHandle)) { g_bStartListenFlag = TRUE. Return value None //Set alarm event callback function. lLoginID Parameter [in] logined device ID Return value of login interface CLIENT_LoginEx2. BOOL CLIENT_StartListenEx( Function LLONG lLoginID ). The events Note received by the callback function set don’t contain picture event. CLIENT_StartListenEx Option instruction Interface Extensive interface for subscribing alarm event from device description Precondition Have called login interface CLIENT_LoginEx2.Option Instruction monitoring data callback function fMessCallBack. NULL). } else { printf("CLIENT_StartListenEx Failed!Last 327/339 .. Example printf("Listen Success! \nJust Wait Event. Example CLIENT_SetDVRMessCallBack(MessCallBack . } else { g_bStartListenFlag = FALSE. lLoginID Parameter [in] logined device ID Return value of login interface CLIENT_LoginEx2. CLIENT_GetLastError()). CLIENT_GetLastError()). } 328/339 . CLIENT_StopListen Option Instruction Interface Interface for stopping subscribing alarm description Precondition Have called alarm report subscription interface as CLIENT_StartListenEx etc. BOOL CLIENT_StopListen( Function LLONG lLoginID ). failed return FALSE.Option instruction Error[%x]\n" . // stop subscribing alarm from device if (g_bStartListenFlag) { if (!CLIENT_StopListen(g_lLoginHandle)) { printf("CLIENT_StopListen Failed!Last Example Error[%x]\n". } All the device alarm events are sent to user via callback function set in Note interface CLIENT_SetDVRMessCallBack. Return value Succeeded return TRUE. 329/339 . NVS and etc. CLIENT_GetLastError()). failed return FALSE. Precondition Have called async search interface as CLIENT_StartSearchDevices etc.Option Instruction } Note None CLIENT_StopSearchDevices Option Instruction Interface Interface for stopping async search for IPC. Return value Succeeded return TRUE. } } Note This interface is used with CLIENT_StartSearchDevices as a pair. // stop async search for device within same segment if (NULL != g_lSearchHandle) { if (FALSE == CLIENT_StopSearchDevices(g_lSearchHandle)) Example { printf("CLIENT_StopSearchDevices Failed!Last Error[%x]\n". within same description segment. lSearchHandle [in] async search for device ID Parameter Corresponding to return value of async search for device interface as CLIENT_StartSearchDevices etc. BOOL CLIENT_StopSearchDevices( Function LLONG lSearchHandle ). dwWaitTime 330/339 . IP of device to be searched for. cbSearchDevices [in] searching for device callback function When there are response package returned from device-end. DWORD dwWaitTime ).CLIENT_SearchDevicesByIPs Option Instruction Interface Interface for sync searching for cross-segment device description Precondition Have called CLIENT_Init interface. Function LDWORD dwUserData. See header file “dhnetsdk. BOOL CLIENT_SearchDevicesByIPs( DEVICE_IP_SEARCH_INFO* pIpSearchInfo.h” for more information about “DEVICE_IP_SEARCH_INFO”. dwUserData [in] user data SDK send the data to user for further use via callback function fSearchDevicesCB szLocalIp [in] local IP NULL as default if this parameter is not set. fSearchDevicesCB cbSearchDevices. char* szLocalIp. SDK will analyze them to valid information and inform user via callback function. see Parameter callback function fSearchDevicesCB for details. pIpSearchInfo [in] information of device to be searched for. user can decide the timeout time according to net condition. fAnalyzerDataCallBack cbAnalyzerData. Return value Succeeded return TRUE. } As this is a sync interface. only when the time set here is out. // please note that only when the time set here is out.user can decide the timeout time according to net condition. if (FALSE == CLIENT_SearchDevicesByIPs(&stuTmp. int nChannelID. DWORD dwWaitTime = 5000. Function LLONG CLIENT_RealLoadPictureEx( LLONG lLoginID. 331/339 . DWORD dwAlarmType. as this is a sync interface. can the interface Note have a return . LDWORD dwUser. CLIENT_RealLoadPictureEx Option Instruction Interface Interface for intelligent picture alarm subscription. dwWaitTime)) Example { printf("CLIENT_SearchDevicesByIPs Failed!Last Error[%x]\n". return. only when the time set here is out. BOOL bNeedPicFile. can the interface have a return. description Precondition Have called login interface CLIENT_LoginEx2. (LDWORD)&g_lDeviceList. CLIENT_GetLastError()).Option Instruction [in] time for searching User can set the parameter as needed. szLocalIp. failed return FALSE. can the interface have a return . SearchDevicesCB. Parameter lLoginID [in] device login ID. Example: EVENT_IVS_ALL // subscription all event See header file “dhnetsdk. When device has intelligent picture alarm to report. Reserved [in] reserved parameter. nChannelID [in]channel number of intelligent picture alarm subscription.Option Instruction void* Reserved ).return intelligent picture info in the callback function.SDK will call this function to recall data for users. dwUser [in] user data.h” for more command parameters. FALSE:means not subscribe picture file. Return value Failed return 0. TRUE:means subscribe picture file. cbAnalyzerData [in] intelligent picture alarm callback function. bNeedPicFile [in] whether subscribe picture file. dwAlarmType [in] Alarm type of expected subscription .not return intelligent picture info in the callback function(reduce network flux when do not need to picture info). start from 0.otherwise return ID of intelligent picture alarm subscription to 332/339 . Recommended to be set to NULL. SDK sends the data to user for further use via intelligent picture alarm callback function fAnalyzerDataCallBack. Correspond with return value of login interface CLIENT_LoginEx2. g_lRealLoadHandle = CLIENT_RealLoadPictureEx(g_lLoginHandle. CtrlType emType. } Note Each subscription corresponds to one channel. Function BOOL CLIENT_ControlDeviceEx( LLONG lLoginID. TRUE. if (0 == g_lRealLoadHandle) { printf("CLIENT_RealLoadPictureEx Failed!Last Error[%x]\n". If you want to set two types of events for one channel. dwUser. and corresponds to a type of event. void* pInBuf. void* pOutBuf = NULL. 333/339 . AnalyzerDataCallBack. You can cancel subscription by CLIENT_StopLoadPic. CLIENT_ControlDeviceEx Option Instruction Interface Extensive interface for device control. the parameter dwAlarmType should be set to EVENT_IVS_ALL.Option Instruction be used as parameters of relatited function Example //subscribe intelligent picture alarm. description Precondition Have called login interface CLIENT_LoginEx2.please call CLIENT_RealLoadPictureEx twice and set different event type. return. CLIENT_GetLastError()). 0. LDWORD dwUser = 0. EVENT_IVS_ALL. If a user wants to set all types of event for one channel. NULL). sizeof(stuSanpParam.unit is ms. pInBuf [in] input parameter of device control.the default is NULL. Example MANUAL_SNAP_PARAMETER stuSanpParam = {0}.Option Instruction int nWaitTime = 1000 ). If the value of emType did not indicate what struct pOutBuf is in enum instruction. nWaitTime [in] timeout time of waiting for device returns. Work in with pInBuf and pOutBuf,different emType.bySequence) .please refer to enum CtrlType for datails.nChannel = 0. "just for test".pInBuf and pOutBuf point to different structures. Work in with emType,different emType and pInBuf point to different structure. The default value is 1000ms.bySequence. set the parameter to NULL. Work in with emType,different emType and pOutBuf point to different structures. emType [in]control type.1).otherwise return FALSE. 334/339 . Correspond with return value of login interface CLIENT_LoginEx2. If the value of emType did not indicate what struct pInBuf is in enum instruction. Parameter lLoginID [in] device login ID. Return value Succeeded return TRUE. memcpy(stuSanpParam. stuSanpParam. pOutBuf [in] output parameter of device control.please refer to enum CtrlType for datails. set the parameter to NULL.please refer to enum CtrlType for datails. &stuSanpParam)) { printf("CLIENT_ControlDeviceEx Failed!Last Error[%x]\n". DH_MANUAL_SNAP. CLIENT_GetLastError()).Option Instruction // manually snapshot trigger alarm function. Correspond with return value of intelligent picture alarm subscription interface as CLIENT_RealLoadPictureEx.otherwise return FALSE. this function is only valid for ITC device if (FALSE == CLIENT_ControlDeviceEx(g_lLoginHandle. Example //stop subscribing picture alarm 335/339 . break. Parameter lAnalyzerHandle [in] intelligent picture alarm subscription ID. description Precondition Have called intelligent picture alarm subscription interface as CLIENT_RealLoadPictureEx etc. Function BOOL CLIENT_StopLoadPic( LLONG lAnalyzerHandle ). } Note None CLIENT_StopLoadPic Option Instruction Interface Interface for stopping subscribing intelligent picture alarm. Return value Succeeded return TRUE. CLIENT_GetLastError()).Option Instruction if (0 != g_lRealLoadHandle) { if (FALSE == CLIENT_StopLoadPic(g_lRealLoadHandle)) { printf("CLIENT_StopLoadPic Failed!Last Error[%x]\n". int *nDownLoadSize ). } } Note None. nTotalSize 336/339 . description Precondition Have called record download interface as CLIENT_DownloadByTimeEx etc. int *nTotalSize.uint is KB. Parameter lFileHandle [in] download handle. CLIENT_GetDownloadPos Option Instruction Interface Interface for searching record download process. } else { g_lRealLoadHandle = 0. Correspond with return value of download record interface as CLIENT_DownloadByTimeEx. Function BOOL CLIENT_GetDownloadPos( LLONG lFileHandle. SDK returns data to user by front-end snapshot callback function (fSnapRev) for further use.unit is KB. Please refer to fSnapRev callback function. CLIENT_GetLastError()). description Precondition Have called login interface CLIENT_LoginEx2. 337/339 . LDWORD dwUser ). Parameter OnSnapRevMessage [in] front-end snapshot callback function. Example int nTotal = 0.Option Instruction [out] total size of download. } Note None CLIENT_SetSnapRevCallBack Option Instruction Interface Interface for setting front-end snapshot callback function.otherwise return FALSE.unit is KB. nDownLoadSize [out] Downloaded Size. if (FALSE == CLIENT_GetDownloadPos(g_lDownloadHandle. int nDownLoad = 0. Return value Succeeded return TRUE. dwUser [in] user data. &nDownLoad)) { printf("CLIENT_GetDownloadPos Failed!Last Error[%x]\n". &nTotal. Function void CLIENT_SetSnapRevCallBack( fSnapRev OnSnapRevMessage. par [in]snapshot parameter. description Precondition Have called login interface CLIENT_LoginEx2. Example // send snapshot command to front-end device. NULL). SNAP_PARAMS *par. Correspond with return value(dwUser) of login interface CLIENT_LoginEx2. Parameter lLoginID [in] device login ID.Option Instruction Return value None Example // set front-end snapshot callback function. int *reserved = 0 ). CLIENT_SnapPictureEx Option Instruction Interface Extensive interface for snapshot request. 338/339 .otherwise return FALSE. Please refer to structure SNAP_PARAMS. Function BOOL CLIENT_SnapPictureEx( LLONG lLoginID. Return value Succeeded return TRUE. CLIENT_SetSnapRevCallBack(SnapRev. Note CLIENT_SetSnapRevCallBack interface needs to be called before front-end snapshot interface. SNAP_PARAMS stuSnapParams. reserved [in]reserved field. } Note None 339/339 . stuSnapParams. //request SN.Channel = nChannelId.CmdSerial = ++g_nCmdSerial.valid range: 0~65535.mode = nSnapType. &stuSnapParams)) { printf("CLIENT_SnapPictureEx Failed!Last Error[%x]\n".over this range will be cut as unsigned short. if (FALSE == CLIENT_SnapPictureEx(g_lLoginHandle. } else { printf("CLIENT_SnapPictureEx succ\n"). CLIENT_GetLastError()).Option Instruction stuSnapParams. return. stuSnapParams.