IOTC Platform  Ver: 4.3.6.2-0-ge1f616e
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
AVServer.h File Reference
#include "AVCommon.h"

Data Structures

struct  st_AvStatus
 
struct  AvPushFileObject
 
struct  AVServStartInConfig
 
struct  AVServStartOutConfig
 

Typedefs

typedef struct st_AvStatus st_AvStatus
 
typedef enum _AV_RESET_TARGET AV_RESET_TARGET
 
typedef struct AvPushFileObject AvPushFileObject
 
typedef int32_t(__stdcall * authFn )(const char *szViewAccount, const char *szViewPassword)
 
typedef int32_t(__stdcall * avPasswordAuthFn )(const char *account, char *password, uint32_t password_buf_size)
 
typedef int32_t(__stdcall * avTokenAuthFn )(const char *identity, char *token, uint32_t token_buf_size)
 
typedef int32_t(__stdcall * avTokenRequestFn )(int32_t av_index, const char *identity, const char *identity_description, char *token, uint32_t token_buf_size)
 
typedef int32_t(__stdcall * avTokenDeleteFn )(int32_t av_index, const char *identity)
 
typedef int32_t(__stdcall * avServSendIdentityArray )(int32_t av_index, const AvIdentity *identities, uint32_t identity_count, int32_t status_code)
 
typedef void(__stdcall * avIdentityArrayRequestFn )(int32_t av_index, avServSendIdentityArray send_identity_array)
 
typedef int32_t(__stdcall * avServSendAbility )(int32_t av_index, const uint8_t *ability, uint32_t ability_size)
 
typedef void(__stdcall * avAbilityRequestFn )(int32_t av_index, avServSendAbility send_ability)
 
typedef int32_t(__stdcall * avChangePasswordRequestFn )(int32_t av_index, const char *account, const char *old_password, const char *new_password, const char *new_iotc_authkey)
 
typedef int32_t(__stdcall * avRecvJSONCtrlRequestFn )(int32_t av_index, const char *func, const TUTKJsonObject *json_args_obj, TUTKJsonObject **json_response_obj)
 
typedef int32_t(__stdcall * avNotificationSettingChangeFn )(const char *setting_str)
 The prototype of push notification settings change handle callback function.
 
typedef struct AVServStartInConfig AVServStartInConfig
 
typedef const AVServStartInConfigLPCAVSERV_START_IN_CONFIG
 
typedef struct AVServStartOutConfig AVServStartOutConfig
 
typedef AVServStartOutConfigLPAVSERV_START_OUT_CONFIG
 

Enumerations

enum  _AV_RESET_TARGET { RESET_VIDEO = 0, RESET_AUDIO, RESET_ALL }
 
enum  AvPushFileType { AV_PUSH_FILE_BY_BUFFER, AV_PUSH_FILE_BY_PATH }
 

Functions

int32_t avServResetBuffer (int32_t avIndex, AV_RESET_TARGET eTarget, uint32_t Timeout_ms)
 Reset the Video or Audio buffer of AV server.
 
AVAPI_API_DEPRECATED int32_t avServStart2 (int32_t nIOTCSessionID, authFn pfxAuthFn, uint32_t nTimeout, uint32_t nServType, uint8_t nIOTCChannelID)
 Start an AV server.
 
AVAPI_API_DEPRECATED int32_t avServStart3 (int32_t nIOTCSessionID, authFn pfxAuthFn, uint32_t nTimeout, uint32_t nServType, uint8_t nIOTCChannelID, int32_t *pnResend)
 Start an AV server.
 
void avServExit (int32_t nIOTCSessionID, uint8_t nIOTCChannelID)
 Used by an AV server exit avServStart2() process.
 
void avServStop (int32_t nAVChannelID)
 Stop an AV server.
 
void avServSetResendSize (int32_t nAVChannelID, uint32_t nSize)
 Set re-send buffer size.
 
int32_t avServGetResendSize (int32_t avIndex, uint32_t *pnSize)
 Get re-send buffer size.
 
int32_t avServGetResendFrmCount (int32_t avIndex, uint32_t *pnCount)
 Get frame count of re-send buffer.
 
int32_t avServSetDelayInterval (int32_t nAVChannelID, uint16_t nPacketNum, uint16_t nDelayMs)
 Set interval of sending video data in AV server.
 
float avResendBufUsageRate (int32_t nAVChannelID)
 Used by an AV server, in order to know the usage rate of resend buffer.
 
int32_t avServStartEx (LPCAVSERV_START_IN_CONFIG AVServerInConfig, LPAVSERV_START_OUT_CONFIG AVServerOutConfig)
 Start an AV server support re-send and DTLS.
 
int32_t avStatusCheck (int32_t nAVChannelID, st_AvStatus *psAvStatus)
 Get status of the connected AV channel.
 

Detailed Description

This file describes AV module APIs for server.

Typedef Documentation

typedef int32_t(__stdcall * authFn)(const char *szViewAccount, const char *szViewPassword)

The prototype of authentication function used for an AV server. The authentication function is set when an AV server starts by avServStart2(). The AV server will call back authentication function when an AV client wants to connect with szViewAccount and szViewAccount

Parameters
szViewAccount[in] The view account provided by AV clients for authentication
szViewPassword[in] The view password provided by AV clients for authentication
Returns
true if authentication passes and false if fails.
typedef void(__stdcall * avAbilityRequestFn)(int32_t av_index, avServSendAbility send_ability)

The prototype of ability request function used for an AV server. The ability request function is set when an AV server starts by avServStartEx(). The AV server will call back avAbilityRequestFn function when an AV client use avClientRequestServerAbility() to request the ability of AV server

Parameters
av_index[in] The channel ID of the AV channel who request the AV server ability
send_ability[in] The function pointer of avServSendAbility function, used for send server ability to AV client.
See Also
avClientRequestServerAbility()
typedef int32_t(__stdcall * avChangePasswordRequestFn)(int32_t av_index, const char *account, const char *old_password, const char *new_password, const char *new_iotc_authkey)

The prototype of change password request function used for an AV server. The change password function is set when an AV server starts by avServStartEx(). The AV server will call back avChangePasswordRequestFn function when an AV client use avClientRequestChangeServerPassword() to request change password. This function is only supported with IOTC authkey enabled, AV server should verify the correctness of account and old password provide by AV client, once the account/password authentication succeed and the new password is applied, AV server should save the new IOTC auth key, and this new IOTC auth key must be applied in the next call of IOTC_Device_LoginEx()

Parameters
av_index[in] The channel ID of the AV channel who request change password
account[in] The account provide by AV client
old_password[in] The old password provide by AV client
new_password[in] The new password provide by AV client
new_iotc_authkey[in] The new IOTC auth key provide by AV module
Returns
0 if change password success, then AV module will apply new IOTC auth key to IOTC login process immediately, and login to server with this new IOTC key until the AV server restart whole proccess.
See Also
avClientRequestChangeServerPassword()
typedef void(__stdcall * avIdentityArrayRequestFn)(int32_t av_index, avServSendIdentityArray send_identity_array)

The prototype of identity array request function used for an AV server. The identity array request function is set when an AV server starts by avServStartEx(). The AV server will call back avIdentityArrayRequestFn function when an AV client use avClientRequestIdentityArray() to request the identity array stored in AV server

Parameters
av_index[in] The channel ID of the AV channel who request the identity array
send_identity_array[in] The function pointer of avServSendIdentityArray function, used for send identity array to AV client.
See Also
avClientRequestIdentityArray(), avServSendIdentityArray
typedef int32_t(__stdcall * avNotificationSettingChangeFn)(const char *setting_str)

The prototype of push notification settings change handle callback function.

This callback function is called when settings of push notification changed. AV device should have a safekeeping of this setting string and should use avServEnablePushNotification() to load the settings when AV device restart next time.

Parameters
setting_str[in] the encrypted string of push notification settings
See Also
avServEnablePushNotification()
typedef int32_t(__stdcall * avPasswordAuthFn)(const char *account, char *password, uint32_t password_buf_size)

The prototype of account/password authentication function used for an AV server. The authentication function is set when an AV server starts by avServStartEx(). The AV server will call back avPasswordAuthFn function when an AV client wants to connect with account and password

Parameters
account[in] The account provided by AV clients for authentication
password[out] The buffer that server need to fill in the password string for authentication
password_buf_size[in] The size of password buffer
Returns
0 if account/password authentication passes.
typedef int32_t(__stdcall * avRecvJSONCtrlRequestFn)(int32_t av_index, const char *func, const TUTKJsonObject *json_args_obj, TUTKJsonObject **json_response_obj)

The prototype of recv json control request function used for an AV server. The recv json control request function is set when an AV server starts by avServStartEx(). The AV server will call back avRecvJSONCtrlRequestFn function when an AV client use avSendJSONCtrlRequest() to send json control request.

Parameters
av_index[in] The channel ID of the AV channel who send json control request
func[in] The function name of the json control request
json_args_obj[in] The json args of the json control request
json_response_obj[out] The json response of the josn control request
Returns
200 if json control request success, 400 if json args missed or invalid, 500 if server side internal error
See Also
avSendJSONCtrlRequest()
typedef int32_t(__stdcall * avServSendAbility)(int32_t av_index, const uint8_t *ability, uint32_t ability_size)

The prototype of send ability function used for an AV server. The send ability function must be called in avAbilityRequestFn call back function to send ability to AV client

Parameters
av_index[in] The channel ID of the target AV channel
ability[in] The ability buffer to be sent
ability_size[in] The size of ability
Returns
AV_ER_NoERROR if valid ablility
Error code if return value < 0
See Also
avAbilityRequestFn()
typedef int32_t(__stdcall * avServSendIdentityArray)(int32_t av_index, const AvIdentity *identities, uint32_t identity_count, int32_t status_code)

The prototype of send identity array function used for an AV server. The send identity array function must be called in avIdentityArrayRequestFn call back function to send identity array to AV client

Parameters
av_index[in] The channel ID of the target AV channel
identities[in] The identity array to be sent
identity_count[in] The identity count to be sent
status_code[in] The status_code avClientRequestIdentityArray() receives.
Returns
AV_ER_NoERROR if send identity array successfully
Error code if return value < 0
See Also
avIdentityArrayRequestFn

The input configuration of avServStartEx

Parameters
cb[in] The check byte of this structure.
iotc_session_id[in] The session ID of the IOTC session to create AV server
iotc_channel_id[in] The channel ID of the channel to create AV server
timeout_sec[in] The timeout for this function in unit of second. Specify it as 0 will make AV server start process wait until an AV client connects successfully.
server_type[in] The user-defined service type. An AV client will get this value when it invokes avClientStart() successfully.
resend[in] Enabling the Resend mechanism or not
security_mode[in] Security mode with options
password_auth[in] The function pointer of password authentication function
token_auth[in] The function pointer of token authentication function
token_request[in] The function pointer will be called if avClientRequestTokenWithIdentity is called in client side to request a token
token_delete[in] The function pointer will be called if avClientRequestDeleteTokenWithIdentity is called in client side to delete a token
identity_array_request[in] The function pointer will be called if avClientRequestIdentityArray is called in client side to request the identity list
ability_request[in] The function pointer will be called if avClientRequestServerAbility is called in client side to request server ability
change_password_request[in] The function pointer will be called if avClientRequestChangeServerPassword is called in client side to request server change password
dtls_cipher_suites[in] Setup DTLS cipher suites. Please use the name of cipher suites from OpenSSL and ":" to separate each cipher suite. If you are using mbedtls as 3rd party library, currently, we only support setting it as "PSK-AES128-CBC-SHA256".

The output configuration of avServStartEx

Parameters
cb[in] The check byte of this structure.
resend[out] Resend mechanism is enable or not
two_way_streaming[out] two way audio/video streaming mechanism is enabling or not 1: enabled, 0: disabled
auth_type[out] The connection is authenticated with password or token
account_or_identity[out] The client identity or account name
typedef int32_t(__stdcall * avTokenAuthFn)(const char *identity, char *token, uint32_t token_buf_size)

The prototype of identity/token authentication function used for an AV server. The authentication function is set when an AV server starts by avServStartEx(). The AV server will call back avTokenAuthFn function when an AV client wants to connect with identity and token

Parameters
identity[in] The identity provided by AV clients for authentication
token[out] The buffer that AV server need to fill in the token string for authentication
token_buf_size[in] The size of token buffer
Returns
0 if identity/token authentication passes.
typedef int32_t(__stdcall * avTokenDeleteFn)(int32_t av_index, const char *identity)

The prototype of token delete function used for an AV server. The token delete function is set when an AV server starts by avServStartEx(). The AV server will call back avTokenDeleteFn function when an AV client use avClientRequestDeleteTokenWithIdentity() to delete a token with a specific identity

Parameters
av_index[in] The channel ID of the AV channel who request to delete token
identity[in] The identity provided by AV clients for delete token
Returns
0 if delete token success.
See Also
avClientRequestDeleteTokenWithIdentity()
typedef int32_t(__stdcall * avTokenRequestFn)(int32_t av_index, const char *identity, const char *identity_description, char *token, uint32_t token_buf_size)

The prototype of token request function used for an AV server. The token request function is set when an AV server starts by avServStartEx(). The AV server will call back avTokenRequestFn function when an AV client use avClientRequestTokenWithIdentity() to request a token with a specific identity

Parameters
av_index[in] The channel ID of the AV channel who request the token
identity[in] The identity provided by AV clients for request token
identity_description[in] The identity description provided by AV clients that describes the identity
token[out] The buffer that AV server need to fill in the token string
token_buf_size[in] The buffer size provided by AV client who called avClientRequestTokenWithIdentity
Returns
The status_code avClientRequestTokenWithIdentity() receives.
See Also
avClientRequestTokenWithIdentity()
typedef struct st_AvStatus st_AvStatus
Parameters
AvVersionThe avapi version
RoundTripTimeThe round trip time in milliseconds
LostRateThe packet lost rate (0 ~ 100)
BandWidthThe estimated bandwidth (Kbyte/second)
MinRTTThe minimum round trip time in milliseconds
LastBwThe last estimated bandwidth (Kbyte/second)
LastRttThe last round trip time in milliseconds
LastCwndThe last congestion window in bytes
InFlightThe total non-acked data size in bytes

Enumeration Type Documentation

Enumerator:
RESET_VIDEO 
RESET_AUDIO 
RESET_ALL 
Enumerator:
AV_PUSH_FILE_BY_BUFFER 
AV_PUSH_FILE_BY_PATH 

Function Documentation

float avResendBufUsageRate ( int32_t  nAVChannelID)

Used by an AV server, in order to know the usage rate of resend buffer.

AV server calls this function to know the usage rate of resend buffer. It will return a float value between 0 and 1. 0 means that resend buffer is empty, 1 means that resend buffer is full. The others mean usage rate.

Parameters
nAVChannelID[in] The channel ID of the AV channel
Returns
Usage rate of resend buffer, if return value >= 0.
Error code if return value < 0
Attention
(1) This API can only be used by av server.

void avServExit ( int32_t  nIOTCSessionID,
uint8_t  nIOTCChannelID 
)

Used by an AV server exit avServStart2() process.

Since avServStart2() is block processes and that means the caller has to wait for AV start or specified timeout expires before these two functions return. In some cases, caller may want to exit AV start process immediately by this function in another thread.

Parameters
nIOTCSessionID[in] The session ID of the IOTC session to exit AV start process
nIOTCChannelID[in] The channel ID of the channel to exit AV start process
int32_t avServGetResendFrmCount ( int32_t  avIndex,
uint32_t *  pnCount 
)

Get frame count of re-send buffer.

Use this API to get the frame count of re-send buffer if re-send mechanism is enabled.

Parameters
nAVChannelID[in] The channel ID of the AV channel to be set.
pnCount[out] The frame count of re-send buffer.
Returns
AV_ER_NoERROR if sending successfully
Error code if return value < 0
Attention
(1) This API can only be used by av server
int32_t avServGetResendSize ( int32_t  avIndex,
uint32_t *  pnSize 
)

Get re-send buffer size.

Use this API to get the re-send buffer size if re-send mechanism is enabled.

Parameters
nAVChannelID[in] The channel ID of the AV channel to be set.
pnSize[out] The size of re-send buffer, in unit of kilo-byte.
Returns
AV_ER_NoERROR if sending successfully
Error code if return value < 0
Attention
(1) This API can only be used by av server
int32_t avServResetBuffer ( int32_t  avIndex,
AV_RESET_TARGET  eTarget,
uint32_t  Timeout_ms 
)

Reset the Video or Audio buffer of AV server.

This function returns AV_ER_NoERROR if no error

Parameters
avIndex[in] The target avIndex
eTarget[in] Reset type could be RESET_VDEIO, RESET_AUDIO, RESET_ALL
Timeout_ms[in] The timeout value in ms to execute this function, set value 0 to wait forever
Returns
This function returns AV_ER_NoERROR if no error
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5000 millisecond (3) This API can only be used by av server
int32_t avServSetDelayInterval ( int32_t  nAVChannelID,
uint16_t  nPacketNum,
uint16_t  nDelayMs 
)

Set interval of sending video data in AV server.

An AV server how to send video data to AV client. It determined the delay time at regular interval between how many packets. The default value of nPacketNum is 1 and nDelayMs is 0, so the default behavior is to send frame packets without any delay.

Parameters
nAVChannelID[in] The channel ID of the AV channel to be sent
nPacketNum[in] How many number of packet as a regular interval
nDelayMs[in] Delay time in unit of million-second
Returns
AV_ER_NoERROR if set successfully
Error code if return value < 0
void avServSetResendSize ( int32_t  nAVChannelID,
uint32_t  nSize 
)

Set re-send buffer size.

Use this API to set the re-send buffer size if re-send mechanism is enabled. Default re-send buffer size is 256KB and recommend size is 1 second data.

Parameters
nAVChannelID[in] The channel ID of the AV channel to be set.
nSize[in] The size of re-send buffer, in unit of kilo-byte.
Attention
(1) This API can only be used by av server
AVAPI_API_DEPRECATED int32_t avServStart2 ( int32_t  nIOTCSessionID,
authFn  pfxAuthFn,
uint32_t  nTimeout,
uint32_t  nServType,
uint8_t  nIOTCChannelID 
)

Start an AV server.

Start an AV server with user defined authentication function. Any AV client wanting to connect with this AV server shall pass the authentication with view account and password.

Parameters
nIOTCSessionID[in] The session ID of the IOTC session to create AV server
pfxAuthFn[in] The function pointer to an authentication function
nTimeout[in] The timeout for this function in unit of second. Specify it as 0 will make AV server start process wait until an AV client connects successfully.
nServType[in] The user-defined service type. An AV client will get this value when it invokes avClientStart() successfully.
nIOTCChannelID[in] The channel ID of the channel to create AV server
Returns
AV channel ID if return value >= 0
Error code if return value < 0
See Also
avServExit(), avServStop()
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs (3) The IOTC channel of specified channel ID will be turned on automatically by avServStart2() (4) This API has been deprecated and might be removed in the next version, please replace it with avServStartEX
AVAPI_API_DEPRECATED int32_t avServStart3 ( int32_t  nIOTCSessionID,
authFn  pfxAuthFn,
uint32_t  nTimeout,
uint32_t  nServType,
uint8_t  nIOTCChannelID,
int32_t *  pnResend 
)

Start an AV server.

Start an AV re-send supported server with user defined authentication function. Any AV client wanting to connect with this AV server shall pass the authentication with view account and password. Whether the re-send mechanism is enabled or not depends on AV client settings and will set the result into pnResend parameter.

Parameters
nIOTCSessionID[in] The session ID of the IOTC session to create AV server
pfxAuthFn[in] The function pointer to an authentication function
nTimeout[in] The timeout for this function in unit of second. Specify it as 0 will make AV server start process wait until an AV client connects successfully.
nServType[in] The user-defined service type. An AV client will get this value when it invokes avClientStart() successfully.
nIOTCChannelID[in] The channel ID of the channel to create AV server
pnResend[out] Set the re-send is enabled or not.
Returns
AV channel ID if return value >= 0
Error code if return value < 0
See Also
avServStart2(), avServExit(), avServStop()
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs (3) The IOTC channel of specified channel ID will be turned on automatically by avServStart3() (4) This API has been deprecated and might be removed in the next version, please replace it with avServStartEX
int32_t avServStartEx ( LPCAVSERV_START_IN_CONFIG  AVServerInConfig,
LPAVSERV_START_OUT_CONFIG  AVServerOutConfig 
)

Start an AV server support re-send and DTLS.

Start an AV re-send and DTLS supported server by providing input configuration and output configuration. Whether the re-send mechanism is enabled or not depends on AV client settings and will set the result into output configuration. It'll return Error if server enable DTLS but client don't.

Parameters
AVServerInConfig[in] a pointer to structure which store all input parameters
AVServerOutConfig[out] a pointer to structure which store all output parameters more detail see AVServStartInConfig and AVServStartOUTConfig
Returns
AV channel ID if return value >= 0
Error code if return value < 0
See Also
avServStart2(), avServStart3(), avServExit(), avServStop()
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs (3) The IOTC channel of specified channel ID will be turned on automatically by avNewServStart()
void avServStop ( int32_t  nAVChannelID)

Stop an AV server.

An AV server stop AV channel by this function if this channel is no longer required.

Parameters
nAVChannelID[in] The channel ID of the AV channel to be stopped
Attention
(1) This API is a blocking function.

(2) This API can only be used by av server
int32_t avStatusCheck ( int32_t  nAVChannelID,
st_AvStatus psAvStatus 
)

Get status of the connected AV channel.

An AV server may use this function to get information of the connected AV channel

Parameters
nAVChannelID[in] The channel ID of the AV channel to be checked
psAvStatus[out] The connection info of specified AV channel
Returns
AV_ER_NoERROR if getting the information successfully
Error code if return value < 0