Device Network SDK Programming Manual Decoder PDF
Device Network SDK Programming Manual Decoder PDF
(For Decoder)
I
Device Network SDK User Manual
The information in this documentation is subject to change without notice and does not represent any
commitment on behalf of HIKVISION. HIKVISION disclaims any liability whatsoever for incorrect data
that may appear in this documentation. The product(s) described in this documentation are furnished
subject to a license and may only be used in accordance with the terms and conditions of such license.
This documentation is issued in strict confidence and is to be used only for the purposes for
which it is supplied. It may not be reproduced in whole or in part, in any form, or by any means
or be used for any other purpose without prior written consent of HIKVISION and then only on
the condition that this notice is included in any such reproduction. No information as to the
contents or subject matter of this documentation, or any part thereof, or arising directly or
indirectly therefrom, shall be given orally or in writing or shall be communicated in any manner
whatsoever to any third party being an individual, firm, or company or any employee thereof
without the prior written consent of HIKVISION. Use of this product is subject to acceptance of
the HIKVISION agreement required to use this product. HIKVISION reserves the right to make
changes to its products as circumstances may warrant, without notice.
Index
1 SDK Overview ............................................................................................................................ 1
2 API Calling Procedure ................................................................................................................ 3
2.1 The Calling Procedure of Decoder ............................................................................... 3
2.2 Active Decoding Procedure ......................................................................................... 4
2.2.1 Decode Real-time Stream.................................................................................. 4
2.2.2 Remote File Playback ........................................................................................ 5
2.3 Passive Decoding Procedure ....................................................................................... 6
3 API Calling Example ................................................................................................................... 7
3.1 Example Code of Dynamic Decoding........................................................................... 7
3.1.1 Decode Real-time Stream.................................................................................. 7
3.1.2 Decode Remote File Recorded in the Device .................................................. 10
3.2 Example Code of Passive Decoding ........................................................................... 13
4 API Description ........................................................................................................................ 15
4.1 SDK Initialization........................................................................................................ 15
4.1.1 Initialize SDK: NET_DVR_Init ........................................................................... 15
4.1.2 Release SDK resource: NET_DVR_Cleanup ...................................................... 15
4.2 Get Error Message ..................................................................................................... 15
4.2.1 Get the error code of last operation: NET_DVR_GetLastError ........................ 15
4.2.2 Get the error message of last operation: NET_DVR_GetErrorMsg ................. 16
4.3 Login the Device ........................................................................................................ 16
4.3.1 Loin the device: NET_DVR_Login_V30 ............................................................ 16
4.3.2 Logout: NET_DVR_Logout ............................................................................... 16
4.4 Get the capability set of the device .......................................................................... 17
4.4.1 Get the capability set: NET_DVR_GetDeviceAbility ........................................ 17
4.5 Configuration and Control of the Display Channel .................................................... 18
4.5.1 Get the information of display channel: NET_DVR_MatrixGetDisplayCfg_V41 ..
......................................................................................................................... 18
4.5.2 Configure the display channel: NET_DVR_MatrixSetDisplayCfg_V41 ............. 18
4.5.3 Control the display channel: NET_DVR_MatrixDiaplayControl ....................... 18
4.6 Parameter Configuration ........................................................................................... 19
4.6.1 Get configuration of the device: NET_DVR_GetDVRConfig............................. 19
4.6.2 Set the parameters of the device: NET_DVR_SetDVRConfig ........................... 20
4.7 Function about Decoding Channel ............................................................................ 20
4.7.1 Get the configuration of decoding channel: NET_DVR_MatrixGetDecChanCfg ..
......................................................................................................................... 20
4.7.2 Configure the decoding channel: NET_DVR_MatrixSetDecChanCfg ............... 21
4.7.3 Get the video format of the decoding channel:
NET_DVR_MatrixGetVideoStandard ............................................................................... 21
4.7.4 Set the video format of the decoding channel:
NET_DVR_MatrixSetVideoStandard ............................................................................... 21
4.7.5 Get the status of current decoding channel:
III
Device Network SDK User Manual
NET_DVR_MatrixGetDecChanStatus............................................................................... 22
4.7.6 Get the switch of the decoding channel: NET_DVR_MatrixGetDecChanEnable .
......................................................................................................................... 22
4.7.7 Set the switch of the decoding channel: NET_DVR_MatrixSetDecChanEnable ..
......................................................................................................................... 22
4.8 Active Decoding......................................................................................................... 23
4.8.1 Start dynamic decoding: NET_DVR_MatrixStartDynamic_V30 ....................... 23
4.8.2 Stop dynamic decoding: NET_DVR_MatrixStopDynamic ................................ 23
4.8.3 Get the information of circle decoding channel:
NET_DVR_MatrixGetLoopDecChanInfo_V30 .................................................................. 24
4.8.4 Set the circle decoding channel: NET_DVR_MatrixSetLoopDecChanInfo_V30 ...
......................................................................................................................... 24
4.8.5 Get the circle switch of the decoding channel:
NET_DVR_MatrixGetLoopDecChanEnable ...................................................................... 25
4.8.6 Set the circle switch of the decoding channel:
NET_DVR_MatrixSetLoopDecChanEnable ...................................................................... 25
4.8.7 Set the circle switch of all decoding channels:
NET_DVR_MatrixGetLoopDecEnable .............................................................................. 26
4.8.8 Get the information of current decoding channel:
NET_DVR_MatrixGetDecChanInfo_V30 .......................................................................... 26
4.8.9 Configure the playback of remote files: NET_DVR_MatrixSetRemotePlay ..... 26
4.8.10 Control the playback of remote files: NET_DVR_MatrixSetRemotePlayControl .
......................................................................................................................... 27
4.8.11 Get the status of playback: NET_DVR_MatrixGetRemotePlayStatus .............. 28
4.9 Passive Decoding ....................................................................................................... 28
4.9.1 Start passive decoding: NET_DVR_MatrixStartPassiveDecode ....................... 28
4.9.2 Send data to the passive decoding channel: NET_DVR_MatrixSendData ....... 29
4.9.3 Stop the passive decoding: NET_DVR_MatrixStopPassiveDecode .................. 29
4.9.4 Get status of the passive decoding: NET_DVR_MatrixGetPassiveDecodeStatus
......................................................................................................................... 29
4.9.5 Control of the passive decoding: NET_DVR_MatrixPassiveDecodeControl .... 30
4.10 Upload the LOGO and Control Its Display.................................................................. 30
4.10.1 Upload the LOGO: NET_DVR_UploadLogo ...................................................... 30
4.10.2 Display control of the LOGO: NET_DVR_LogoSwitch ....................................... 30
4.11 Transparent Channel ................................................................................................. 31
4.11.1 Get the information of transparent channel:
NET_DVR_MatrixGetTranInfo_V30 ................................................................................. 31
4.11.2 Set the transparent channel: NET_DVR_MatrixSetTranInfo_V30 ................... 31
4.12 Device Status ............................................................................................................. 32
4.12.1 Get the status of the device: NET_DVR_MatrixGetDeviceStatus_V41............ 32
5 Macro Definition of Error Code ............................................................................................... 33
5.1 Error code of network communication library .......................................................... 33
5.2 Error code of RTSP communication library ............................................................... 37
5.3 Error code of software decoding library ................................................................... 38
1
Device Network SDK User Manual
1 SDK Overview
The device network SDK is developed based on private network communication protocol,
and it is designed for the remote connection and configuration of embedded devices. This
document is mainly for decoder, and the main device types are listed as below:
DS-6300D(-JX), DS-6400HD(-JX/-T) series decoder
This document introduces only the major function supported by decoder, and please get
more information about other function and related structures from Device Network SDK
Programming Manual.chm.
The device network SDK has both Windows and Linux version.
RTSP Communication
StreamTransClient.dll DLL file
Library
Encapsulation
Transformation SystemTransform.dll DLL file
Library
2. Linux version supports the system(32bit) that gcc-v is 4.1 or above. The tested system
have RedHat AS 5/6, (Fedora)FC10/12, CentOS 5, SUSE 10, openSUSE 11, and Ubuntu 9.04/10.04.
The SDK has the files:
Network
hcnetsdk.h head file
Communication
libhcnetsdk.so SO file
Library
2
Device Network SDK User Manual
RTSP Communication
libStreamTransClient.so SO file
Library
Encapsulation
Transformation libSystemTransform.so SO file
Library
HCNetSDK is required to be loaded for client development, and the other '.dll' files are
optional components.
The Network Communication Library is the main functional part of the device network SDK.
It is used for communication between the client and devices, including remote control &
configuration, video stream acquiring and handling, etc; and Network communication library
will dynamically loading RTSP communication library, Software decoding library, Hardware
decoding library, etc. Network communication library combines a lot of functions from the
Software decoding library and Hardware decoding library to facilitate the programming work.
However, it is suggested the users to get video stream from 'HCNetSDK.dll', and call relative
APIs in the Software decoding library or Hardware decoding library directly if you want to
build a system with more complete functions, or in a more flexible way.
The 'QosControl' library is stream bitrate control library, used for push mode SDK.
RTSP Communication Library only supports IP devices. Users need to load this component
for operations like streaming from products which support RTSP protocol.
Software Decoding Library is used for decoding real-time video stream (remote live view),
playback files, etc. It has included standard stream decoding function. If users needs to play
real-time stream or recoding data and display(i.e. the second structure parameter play
handle of NET_DVR_RealPlay_V30 interface set to effective), must load this component.
However, if users just need to use it for capturing data, then do external operation, needn't
load this component, this way is more flexible.
Encapsulation transformation library function can be divided into two pieces: one is
converting standard stream data to private encapsulation format stream data. When users
need to capture private format stream data from products supporting RTSP protocol(that is
setting callback function of NET_DVR_RealPlay_V30 interface for capturing data or call
NET_DVR_SetRealDataCallBack interface to capture data), must load this component.
Another is converting standard stream data to other package format, such as 3GPP,PS and so
on. For example, when users need to capture specific package format real-time stream data
from products supporting RTSP protocol(corresponding interface is NET_DVR_SaveRealData),
must load this component.
Hardware Decoding Library can only be used when there is MDI card installed in the PC, and
it can output video or video matrix to analog monitors. For decoder, this library is not
required.
3
Device Network SDK User Manual
Display channel control module: configuration of each parameter of display channel, audio
turn on & off, and zoom control of child window. For details, please refer to "Configuration
and Control of Display Channel".
Parameter configuration module: to configure the basic parameters of the multi-channel
decoder, the related APIs: NET_DVR_GetDVRConfig and NET_DVR_SetDVRConfig. For details,
please refer to Parameter Configuration.
Active decoding module: the decoder gets the stream data from encoder devices actively,
then decodes the data. The related function has: 1) get the parameter of dynamic decoding;
2)control the decoding, including the starting and stopping the dynamic decoding and circle
decoding, controlling the playback of remote files, and getting the status of decoding; 3)
upload LOGO to the decoder. For details, please refer to Active Decoding Procedure.
Passive decoding module: start decoding, send data and stop decoding of passive decoding
channels. For details, please refer to Passive Decoding Procedure.
Transparent channel configuration module: configure related parameters of transparent
4
Device Network SDK User Manual
After login the decoder, it requires to set the display channel firstly. Please set the decoding
channel associated with the display channel, otherwise, it is not able to start decoding
5
Device Network SDK User Manual
After login the decoder, it requires to set the display channel firstly. Please set the decoding
channel associated with the display channel, otherwise, it is not able to start decoding
normally. The related APIs: NET_DVR_MatrixGetDisplayCfg_V41,
NET_DVR_MatrixSetDisplayCfg_V41.
Set to decode remote record files: firstly, please call NET_DVR_MatrixSetRemotePlay to set
playback by time or by file name, and then call NET_DVR_MatrixSetRemotePlayControl to
start encoding.
Example Code
6
Device Network SDK User Manual
After login the decoder, it requires to set the display channel firstly. Please set the decoding
channel associated with the display channel, otherwise, it is not able to start decoding
normally. The related APIs: NET_DVR_MatrixGetDisplayCfg_V41,
NET_DVR_MatrixSetDisplayCfg_V41.
After calling NET_DVR_MatrixStartPassiveDecode to start passive decoding, please call
NET_DVR_MatrixSendData to send data to the decoding channel. The data to be decoded
can be get from remote device or read from record file, and the size of data for each sending
should be less than 30K bytes.
Decoding control: pause, fast play, slow play, open or close sound, clear buffer, and so on.
Related APIs: NET_DVR_MatrixPassiveDecodeControl.
Example Code
7
Device Network SDK User Manual
void main() {
//---------------------------------------
//Initialize SDK
NET_DVR_Init();
//Set connect time and reconnect time
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
//---------------------------------------
// Login the device (Login the decoder)
NET_DVR_DEVICEINFO_V30 struDeviceInfo;
memset(&struDeviceInfo, 0, sizeof(NET_DVR_DEVICEINFO_V30)); //The structure to save device information
LONG lUserID = NET_DVR_Login_V30("172.0.0.100", 8000, "admin", "12345", &struDeviceInfo);
if (lUserID < 0)
{
if (NET_DVR_GetLastError() == NET_DVR_PASSWORD_ERROR)//Password error
{
//Handle the error message
}
else if(NET_DVR_GetLastError() == NET_DVR_OVER_MAXLINK)
//The count of connection to the device over the limit
{
// Handle the error message
}
// Handle other error message
}
8
Device Network SDK User Manual
//Other operation
//Loop decoding
NET_DVR_MATRIX_LOOP_DECINFO_V30 m_MatLoopDec;
memset(&m_MatLoopDec, 0, sizeof(NET_DVR_MATRIX_LOOP_DECINFO_V30));
NET_DVR_MatrixGetLoopDecChanInfo_V30(lUserID, DecChanNum, &m_MatLoopDec);
//Get parameters of loop decoding channel
DWORD chanNum = 0
NET_DVR_MatrixGetLoopDecChanEnable(lUserID, DecChanNum, &chanNum);
//Get decoding switch of current channel, if chanNum=0, it is closed; if chanNum=1, it is open
NET_DVR_MatrixGetLoopDecEnable(lUserID, &chanNum);
//Get the decoding switch of all channels, indicated by byte: 0- closed, 1- open
// E.g. chanNum&0x01==0 means the channel no.1 is closed
// Logout
NET_DVR_Logout(lUserID);
// Release SDK resource
NET_DVR_Cleanup();
return;
}
void main() {
//---------------------------------------
11
Device Network SDK User Manual
//Initialize SDK
NET_DVR_Init();
//Set connect time and reconnect time
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
//---------------------------------------
// Login the device
NET_DVR_DEVICEINFO_V30 struDeviceInfo;
memset(&struDeviceInfo, 0, sizeof(NET_DVR_DEVICEINFO_V30));//The structure to save device information
LONG lUserID = NET_DVR_Login_V30("172.0.0.100", 8000, "admin", "12345", &struDeviceInfo);
if (lUserID < 0)
{
if (NET_DVR_GetLastError() == NET_DVR_PASSWORD_ERROR)//Password error
{
// Handle the error message
}
else if(NET_DVR_GetLastError() == NET_DVR_OVER_MAXLINK)
// The count of connection to the device over the limit
{
// Handle the error message
}
// Handle other error message
}
// Get display capability of the decoder
NET_DVR_MATRIX_ABILITY m_matrixability;
NET_DVR_GetDeviceAbility(lUserID, MATRIXDECODER_ABILITY, NULL, 0, (char*)&m_matrixability,
sizeof(NET_DVR_MATRIX_ABILITY));
//Start playback
NET_DVR_MatrixSetRemotePlayControl(lUserID, DecChanNum, NET_DVR_PLAYSTART, 0, NULL);
//Open sound
NET_DVR_MatrixSetRemotePlayControl(lUserID, DecChanNum, NET_DVR_PLAYSTARTAUDIO, 0, NULL);
NET_DVR_MatrixSetRemotePlayControl(lUserID, DecChanNum, , 0, NULL);//Other playback control
NET_DVR_MATRIX_DEC_REMOTE_PLAY_STATUS m_struState;
NET_DVR_MatrixGetRemotePlayStatus(lUserID, DecChanNum, &m_struState); //Get playback status
//Stop decoding
NET_DVR_MatrixSetRemotePlayControl(lUserID, DecChanNum, NET_DVR_PLAYSTOP, 0, NULL);
//Logout
NET_DVR_Logout(lUserID);
// Release SDK resource
NET_DVR_Cleanup();
return;
}
13
Device Network SDK User Manual
void main() {
//---------------------------------------
//Initialize SDK
NET_DVR_Init();
//Set connect time and reconnect time
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
//---------------------------------------
// Login the device
NET_DVR_DEVICEINFO_V30 struDeviceInfo;
memset(&struDeviceInfo, 0, sizeof(NET_DVR_DEVICEINFO_V30)); //The structure to save device information
LONG lUserID = NET_DVR_Login_V30("172.0.0.100", 8000, "admin", "12345", &struDeviceInfo);
if (lUserID < 0)
{
if (NET_DVR_GetLastError() == NET_DVR_PASSWORD_ERROR) //Password error
{
// Handle the error message
}
else if(NET_DVR_GetLastError() == NET_DVR_OVER_MAXLINK)
//The count of connection to the device over the limit
{
// Handle the error message
}
// Handle other error message
}
//Get display capability of the decoder
NET_DVR_MATRIX_ABILITY m_matrixability;
NET_DVR_GetDeviceAbility(lUserID, MATRIXDECODER_ABILITY, NULL, 0, (char*)&m_matrixability,
sizeof(NET_DVR_MATRIX_ABILITY));
4 API Description
Return to index
18
Device Network SDK User Manual
NET_DVR_MatrixGetDisplayCfg_V41
NET_DVR_MatrixSetDisplayCfg_V41
Return to index
20
Device Network SDK User Manual
Return to index
NET_DVR_MatrixGetDecChanCfg
NET_DVR_MatrixGetVideoStandard
NET_DVR_MatrixSetVideoStandard
NET_DVR_MatrixGetDecChanStatus
NET_DVR_MatrixGetDecChanEnable
NET_DVR_MatrixSetDecChanEnable
NET_DVR_MatrixGetLoopDecChanInfo_V30
NET_DVR_MatrixSetLoopDecChanInfo_V30
NET_DVR_MatrixGetLoopDecChanEnable
NET_DVR_MatrixSetLoopDecChanEnable
dynamic decoding. When set the switch on, it will resume to circle decoding.
Return to index
NET_DVR_MatrixGetLoopDecEnable
NET_DVR_MatrixGetDecChanInfo_V30
NET_DVR_MatrixSetRemotePlay
NET_DVR_MatrixSetRemotePlayControl
NET_DVR_PLAYPAUSE 3 Pause
NET_DVR_PLAYRESTART 4 Resume
NET_DVR_PLAYFAST 5 Fast
NET_DVR_PLAYSLOW 6 Slow
NET_DVR_MatrixGetRemotePlayStatus
NET_DVR_MatrixSendData
NET_DVR_MatrixGetPassiveDecodeStatus
NET_DVR_MatrixPassiveDecodeControl
NET_DVR_MatrixGetTranInfo_V30
most, including 232 and 485 transparent channels. It supports only one 232
full-duplex transparent channel and one 485 full-duplex transparent channel,
and it supports not to set full-duple transparent channel.
Return to index
NET_DVR_MatrixGetDeviceStatus_V41
NET_DVR_RTSP_DESCRIBESERVERERR 416 "RTSP DECRIBE" device returns the error that values
401 or 501.
NET_DVR_RTSP_OVER_MAX_CHAN 426 "RTSP SETUP" device returns the error that values
401 or 501. It exceeds the max connection number.
NET_DVR_RTSP_PLAYSERVERERR 436 "RTSP PLAY" device returns the error that values 401
or 501.
mode.
NET_PLAYM4_SUPPORT_FILE_ONLY 514 This API can be called only for file playback mode.
NET_PLAYM4_SUPPORT_STREAM_ONLY 515 This API can be called only when playing stream.
NET_PLAYM4_SYS_NOT_SUPPORT 516 Not support by the system. Decoder can only work
on the system above Pentium 3.
NET_PLAYM4_CHECK_FILE_ERROR 520 The file is too short, or the stream data is unknown.