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

Data Structures

struct  AVClientStartInConfig
 
struct  AVClientStartOutConfig
 

Typedefs

typedef struct
AVClientStartInConfig 
AVClientStartInConfig
 
typedef const
AVClientStartInConfig
LPCAVCLIENT_START_IN_CONFIG
 
typedef struct
AVClientStartOutConfig 
AVClientStartOutConfig
 
typedef AVClientStartOutConfigLPAVCLIENT_START_OUT_CONFIG
 

Functions

AVAPI_API_DEPRECATED int32_t avClientStart (int32_t nIOTCSessionID, const char *cszViewAccount, const char *cszViewPassword, uint32_t nTimeout, uint32_t *pnServType, uint8_t nIOTCChannelID)
 Start an AV client.
 
AVAPI_API_DEPRECATED int32_t avClientStart2 (int32_t nIOTCSessionID, const char *cszViewAccount, const char *cszViewPassword, uint32_t nTimeout, uint32_t *pnServType, uint8_t nIOTCChannelID, int32_t *pnResend)
 Start an AV client.
 
void avClientExit (int32_t nIOTCSessionID, uint8_t nIOTCChannelID)
 Used by an AV client exit avClientStart() process.
 
void avClientStop (int32_t nAVChannelID)
 Stop an AV client.
 
AVAPI_API_DEPRECATED int32_t avCheckAudioBuf (int32_t nAVChannelID)
 Get the frame count of audio buffer remaining in the queue.
 
AVAPI_API_DEPRECATED void avClientSetMaxBufSize (uint32_t nMaxBufSize)
 Set the maximum video frame buffer used in AV client.
 
int32_t avClientSetRecvBufMaxSize (int32_t nAVChannelID, uint32_t nMaxBufSizeKB)
 Set the maximum frame buffer size used in AV client with specific AV channel ID.
 
int32_t avClientCleanBuf (int32_t nAVChannelID)
 Clean the video/audio buffer both in client and device.
 
int32_t avClientCleanVideoBuf (int32_t nAVChannelID)
 Clean the video buffer(both in client and device) When new re-send protocal is using(avNewServStart & avNewClientStart), this function will clean both video and audio buffer.
 
int32_t avClientCleanLocalBuf (int32_t nAVChannelID)
 Clean the local video and audio buffer of the client.
 
int32_t avClientCleanLocalVideoBuf (int32_t nAVChannelID)
 Clean the local video buffer of the client.
 
int32_t avClientCleanAudioBuf (int32_t nAVChannelID)
 Clean the local audio buffer of the client.
 
float avClientRecvBufUsageRate (int32_t nAVChannelID)
 Used by an AV client, in order to know the usage rate of receive buffer.
 
int32_t avClientStartEx (LPCAVCLIENT_START_IN_CONFIG AVClientInConfig, LPAVCLIENT_START_OUT_CONFIG AVClientOutConfig)
 Start an AV client.
 
int32_t avClientRequestTokenWithIdentity (int32_t av_index, const char *identity, const char *identity_description, char *token, uint32_t token_buff_size, int32_t *status_code, uint32_t timeout_sec)
 Get token from AV server by identity.
 
int32_t avClientRequestDeleteTokenWithIdentity (int32_t av_index, const char *identity, int32_t *status_code, uint32_t timeout_sec)
 Delete token of AV server by identity.
 
int32_t avClientRequestIdentityArray (int32_t av_index, AvIdentity **identities, uint32_t *identity_count, int32_t *status_code, uint32_t timeout_sec)
 AV Client get identity list from AV server.
 
int32_t avClientFreeIdentityArray (AvIdentity *identities)
 AV Client free the identity list buffer.
 
int32_t avClientRequestServerAbility (int32_t av_index, uint8_t **ability, uint32_t *ability_size, uint32_t timeout_sec)
 AV Client request ability from server.
 
int32_t avClientFreeServerAbility (uint8_t *ability)
 AV Client free the ability buffer.
 
int32_t avClientRequestChangeServerPassword (int32_t av_index, const char *account, const char *old_password, const char *new_password, char *new_iotc_authkey, uint32_t new_iotc_authkey_buff_size, uint32_t *new_iotc_authkey_actual_length, uint32_t timeout_sec)
 AV Client request change server password.
 
int32_t avSendJSONCtrlRequest (int32_t av_index, const char *json_request, TUTKJsonObject **json_response_obj, uint32_t timeout_sec)
 Send AV JSON control.
 
int32_t avFreeJSONCtrlResponse (TUTKJsonObject *json_response_obj)
 Release response data of avSendJSONCtrlRequest.
 

Detailed Description

This file describes AV module APIs for client.

Typedef Documentation

The input configuration of avClientStartEx

Parameters
cb[in] The check byte of this structur.
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.
account_or_identity[in] The predefined view account
password_or_token[in] The predefined view password, the maximum length of token is 1024
resend[in] Enabling the Resend mechanism or not
security_mode[in] Enabling the DTLS mechanism or not
auth_type[in] Choose the authentication mode for av connection
sync_recv_data[in] Enabling synchronize receive video/audio data mechanism or not
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 avClientStartEx

Parameters
cb[in] The check byte of this structure.
server_type[out] The user-defined service type set when an AV server starts. Can be NULL.
resend[out] Resend mechanism is enabling or not
two_way_streaming[out] two way audio/video streaming mechanism is enabling or not
sync_recv_data[out] Synchronously receive video/audio data is enabling or not
security_mode[out] The DTLS mechanism is enabling or not

Function Documentation

AVAPI_API_DEPRECATED int32_t avCheckAudioBuf ( int32_t  nAVChannelID)

Get the frame count of audio buffer remaining in the queue.

An AV client uses this function to get the frame count of audio buffer that is still remaining in the receiving queue, then determine whether it is a right time to invoke avRecvAudioData(). Keeping audio buffer in audio queue instead of receiving immediately can greatly improve the discontinuous audio issues. However, it is not good to receive audio in a very long time since audio buffer will overflow and audio data will be lost.

Parameters
nAVChannelID[in] The channel ID of the AV channel to check audio buffer
Returns
The frame count of audio buffer
int32_t avClientCleanAudioBuf ( int32_t  nAVChannelID)

Clean the local audio buffer of the client.

A client with multiple device connection application should call this function to clean audio buffer while switch listen to speaker.

Parameters
nAVChannelID[in] The channel ID of the audio channel to clean buffer
Returns
Error code if return value < 0
Attention
(1) This API can only be used by av client.

int32_t avClientCleanBuf ( int32_t  nAVChannelID)

Clean the video/audio buffer both in client and device.

The client can invoke this function to clear old video and audio buffers before receiving the video or audio data again.

Parameters
nAVChannelID[in] The channel ID of the AV channel to clean buffer
Returns
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) This API can only be used by av client
int32_t avClientCleanLocalBuf ( int32_t  nAVChannelID)

Clean the local video and audio buffer of the client.

This function is used to clean the video and audio buffer that the client has already received

Parameters
nAVChannelID[in] The channel ID of the AV channel to clean buffer
Returns
Error code if return value < 0
Attention
(1) This API can only be used by av client.

int32_t avClientCleanLocalVideoBuf ( int32_t  nAVChannelID)

Clean the local video buffer of the client.

This function is used to clean the video buffer that the client has already received

Parameters
nAVChannelID[in] The channel ID of the AV channel to clean buffer
Returns
Error code if return value < 0
Attention
(1) This API can only be used by av client.

int32_t avClientCleanVideoBuf ( int32_t  nAVChannelID)

Clean the video buffer(both in client and device) When new re-send protocal is using(avNewServStart & avNewClientStart), this function will clean both video and audio buffer.

A client with multiple device connection application should call this function to clean video buffer while switch to another devices.

Parameters
nAVChannelID[in] The channel ID of the AV channel to clean buffer
Returns
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) This API can only be used by av client
void avClientExit ( int32_t  nIOTCSessionID,
uint8_t  nIOTCChannelID 
)

Used by an AV client exit avClientStart() process.

Since avClientStart() is a block process 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 avClientFreeIdentityArray ( AvIdentity identities)

AV Client free the identity list buffer.

This function is used by AV client to free the memory allocated by AV module. Once the AV client use avClientRequestIdentityArray() to request identity list from AV server, AV module will allocate a memory block to store the identity list. After a success call of avClientRequestIdentityArray(), AV client must use this function to free the memory, otherwise the memory leak will occur

Parameters
identities[in] The identity list buffer allocated by AV module to be free
Returns
AV_ER_NoERROR if memory free successfully
Error code if return value < 0
See Also
avClientRequestIdentityArray()
int32_t avClientFreeServerAbility ( uint8_t *  ability)

AV Client free the ability buffer.

This function is used by AV client to free the memory allocated by AV module. Once the AV client use avClientRequestServerAbility() to request ability from AV server, AV module will allocate a memory block to store the server ability. After a success call of avClientRequestServerAbility(), AV client must use this function to free the memory, otherwise the memory leak will occur

Parameters
ability[in] The server ability buffer allocated by AV module to be free
Returns
AV_ER_NoERROR if memory free successfully
Error code if return value < 0
See Also
avClientRequestServerAbility()
float avClientRecvBufUsageRate ( int32_t  nAVChannelID)

Used by an AV client, in order to know the usage rate of receive buffer.

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

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

int32_t avClientRequestChangeServerPassword ( int32_t  av_index,
const char *  account,
const char *  old_password,
const char *  new_password,
char *  new_iotc_authkey,
uint32_t  new_iotc_authkey_buff_size,
uint32_t *  new_iotc_authkey_actual_length,
uint32_t  timeout_sec 
)

AV Client request change server password.

This function is used by AV client to request AV server change password. If AV server change password successfully, IOTC new authkey would force apply on AV server, then AV client should use new IOTC auth key for the next IOTC connection, and use new password for AV Connection, otherwise the connection will fail.

Parameters
av_index[in] The channel ID of the AV channel to send change password request
account[in] The account to be sent
old_password[in] The old password to be sent
new_password[in] The new password to be sent
new_iotc_authkey[out] The buffer of new IOTC auth key to be received
new_iotc_authkey_buff_size[in] The size of new IOTC auth key buffer
new_iotc_authkey_actual_length[out] The actual length of new IOTC auth key to be received
timeout_sec[in] The timeout for this function in unit of second, blocks forever if 0
Returns
AV_ER_NoERROR if getting the server ability successfully
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs
See Also
avChangePasswordRequestFn
int32_t avClientRequestDeleteTokenWithIdentity ( int32_t  av_index,
const char *  identity,
int32_t *  status_code,
uint32_t  timeout_sec 
)

Delete token of AV server by identity.

This function is used by AV client to delete token of AV server with a specific identity

Parameters
av_index[in] The channel ID of the AV channel to send delete token request
identity[in] The identity to be sent
status_code[out] The status code returned from AV client
timeout_sec[in] The timeout for this function in unit of second, blocks forever if 0
Returns
AV_ER_NoERROR if delete token successfully
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs
See Also
avTokenDeleteFn
int32_t avClientRequestIdentityArray ( int32_t  av_index,
AvIdentity **  identities,
uint32_t *  identity_count,
int32_t *  status_code,
uint32_t  timeout_sec 
)

AV Client get identity list from AV server.

This function is used by AV client to request identity list from AV server

Parameters
av_index[in] The channel ID of the AV channel to send idenetity list request
identities[out] The buffer of the identity list to be received
identity_count[out] The identity conut of identity list
status_code[out] The status code returned from AV client
timeout_sec[in] The timeout for this function in unit of second, blocks forever if 0
Returns
AV_ER_NoERROR if get identity list successfully
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs
See Also
avServSendIdentityArray, avIdentityArrayRequestFn
int32_t avClientRequestServerAbility ( int32_t  av_index,
uint8_t **  ability,
uint32_t *  ability_size,
uint32_t  timeout_sec 
)

AV Client request ability from server.

This function is used by AV client to request ability from AV server

Parameters
av_index[in] The channel ID of the AV channel to send ability request
ability[out] The buffer of the ability to be received
ability_size[out] The size of ability to be received
timeout_sec[in] The timeout for this function in unit of second, blocks forever if 0
Returns
AV_ER_NoERROR if getting the server ability successfully
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs
See Also
avServSendAbility, avAbilityRequestFn
int32_t avClientRequestTokenWithIdentity ( int32_t  av_index,
const char *  identity,
const char *  identity_description,
char *  token,
uint32_t  token_buff_size,
int32_t *  status_code,
uint32_t  timeout_sec 
)

Get token from AV server by identity.

This function is used by AV client to request a token from AV server with a specific identity

Parameters
av_index[in] The channel ID of the AV channel to send token request
identity[in] The identity to be sent
identity_description[in] The description of identity to be sent
token[out] The buffer of the token to be received
token_buff_size[in] The max size of token buffer
status_code[out] The status code returned from AV client
timeout_sec[in] The timeout for this function in unit of second, blocks forever if 0
Returns
The token length received from avTokenRequestFn()
Error code if return value < 0
Attention
(1) This API is a blocking function.

(2) Recommended value of timeout: > 5 secs
See Also
avTokenRequestFn
AVAPI_API_DEPRECATED void avClientSetMaxBufSize ( uint32_t  nMaxBufSize)

Set the maximum video frame buffer used in AV client.

AV client sets the maximum video frame buffer by this function. The size of video frame buffer will affect the streaming fluency. The default size of video frame buffer is 1MB.

Parameters
nMaxBufSizeThe maximum video frame buffer, in unit of kilo-byte
int32_t avClientSetRecvBufMaxSize ( int32_t  nAVChannelID,
uint32_t  nMaxBufSizeKB 
)

Set the maximum frame buffer size used in AV client with specific AV channel ID.

AV client sets the maximum frame buffer size by this function. The size of frame buffer will affect the streaming fluency. The default size of frame buffer is 1MB.

Parameters
nAVChannelID[in] The channel ID of the AV channel to setup max buffer size
nMaxBufSizeKBThe maximum frame buffer size, in unit of kilo-byte
AVAPI_API_DEPRECATED int32_t avClientStart ( int32_t  nIOTCSessionID,
const char *  cszViewAccount,
const char *  cszViewPassword,
uint32_t  nTimeout,
uint32_t *  pnServType,
uint8_t  nIOTCChannelID 
)

Start an AV client.

Start an AV client by providing view account and password. It shall pass the authentication of the AV server before receiving AV data.

Parameters
nIOTCSessionID[in] The session ID of the IOTC session to start AV client
cszViewAccount[in] The view account for authentication
cszViewPassword[in] The view password for authentication
nTimeout[in] The timeout for this function in unit of second Specify it as 0 will make this AV client try connection once and this process will exit immediately.
pnServType[out] The user-defined service type set when an AV server starts. Can be NULL.
nIOTCChannelID[in] The channel ID of the channel to start AV client
Returns
AV channel ID if return value >= 0
Error code if return value < 0
See Also
avClientStop(), avClientExit()
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 avClientStart(). (4) This API has been deprecated and might be removed in the next version, please replace it with avClientStartEx
AVAPI_API_DEPRECATED int32_t avClientStart2 ( int32_t  nIOTCSessionID,
const char *  cszViewAccount,
const char *  cszViewPassword,
uint32_t  nTimeout,
uint32_t *  pnServType,
uint8_t  nIOTCChannelID,
int32_t *  pnResend 
)

Start an AV client.

Start an AV re-send supported client by providing view account and password. It shall pass the authentication of the AV server before receiving AV data. Whether the re-send mechanism is enabled or not depends on AV server settings and will set the result into pnResend parameter.

Parameters
nIOTCSessionID[in] The session ID of the IOTC session to start AV client
cszViewAccount[in] The view account for authentication
cszViewPassword[in] The view password for authentication
nTimeout[in] The timeout for this function in unit of second Specify it as 0 will make this AV client try connection once and this process will exit immediately.
pnServType[out] The user-defined service type set when an AV server starts. Can be NULL.
nIOTCChannelID[in] The channel ID of the channel to start AV client
pnResend[out] The re-send is enabled or not.
Returns
AV channel ID if return value >= 0
Error code if return value < 0
See Also
avClientStop(), avClientExit()
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 avClientStart2().

(4) If AV client uses avClientStart2() to enable AV re-send mechanism, it has to use avRecvFrameData2() to receive video data. (5) This API has been deprecated and might be removed in the next version, please replace it with avClientStartEx
int32_t avClientStartEx ( LPCAVCLIENT_START_IN_CONFIG  AVClientInConfig,
LPAVCLIENT_START_OUT_CONFIG  AVClientOutConfig 
)

Start an AV client.

Start an AV re-send and DTLS supported client by providing input configuration and output configuration. It shall pass the authentication of the AV server before receiving AV data. Whether the re-send mechanism is enabled or not depends on AV server settings and will set the result into pnResend parameter in LPAVSERV_START_OUT_CONFIG. It'll return Error if client enable DTLS but server don't.

Parameters
AVClientInConfig[in] a pointer to structure which store all input parameters
AVClientOutConfig[out] a pointer to structure which store all output parameters more detail see AVClientStartInConfig and AVClientStartOUTConfig
Returns
AV channel ID if return value >= 0
Error code if return value < 0
See Also
avClientStop(), avClientExit()
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 avClientStartEx().

void avClientStop ( int32_t  nAVChannelID)

Stop an AV client.

An AV client 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.

int32_t avFreeJSONCtrlResponse ( TUTKJsonObject json_response_obj)

Release response data of avSendJSONCtrlRequest.

This function is used to release response data from avSendJSONCtrlRequest, you must call it after you got the JSON response data from avSendJSONCtrlRequest

Parameters
json_response_obj[in] This json response data pointer
Returns
AV_ER_NoERROR if sending successfully
Error code if return value < 0
Attention
This function is not support for av server now.
int32_t avSendJSONCtrlRequest ( int32_t  av_index,
const char *  json_request,
TUTKJsonObject **  json_response_obj,
uint32_t  timeout_sec 
)

Send AV JSON control.

This function is used by AV to send a AV IO control in json format. You can get JSON respones from this API. This function is not support for av server currently.

Parameters
av_index[in] The channel ID of the AV channel to send IO control
json_request[in] The json data that need to send to AV server.
json_response_obj[out] The pointer of av response, please do not allocate memory of this parameter
timeout_sec[in] The timeout for this function in unit of second, blocks forever if 0.
Returns
AV_ER_NoERROR if sending successfully
Error code if return value < 0
Attention
This function is not support for av server now.
This API is a blocking function and it will wait until having response from the receiver.