IOTC Platform: AVAPIs.h File Reference

| IOTC Platform Ver: 2.1.0.25 |

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Typedefs | Enumerations | Functions
AVAPIs.h File Reference

## Macros

#define | AV_MAX_IOCTRL_DATA_SIZE 1024
#define | AV_MAX_AUDIO_DATA_SIZE 1280
#define | AV_ER_NoERROR 0
#define | AV_ER_INVALID_ARG -20000
#define | AV_ER_BUFPARA_MAXSIZE_INSUFF -20001
#define | AV_ER_EXCEED_MAX_CHANNEL -20002
#define | AV_ER_MEM_INSUFF -20003
#define | AV_ER_FAIL_CREATE_THREAD -20004
#define | AV_ER_EXCEED_MAX_ALARM -20005
#define | AV_ER_EXCEED_MAX_SIZE -20006
#define | AV_ER_SERV_NO_RESPONSE -20007
#define | AV_ER_CLIENT_NO_AVLOGIN -20008
#define | AV_ER_WRONG_VIEWACCorPWD -20009
#define | AV_ER_INVALID_SID -20010
#define | AV_ER_TIMEOUT -20011
#define | AV_ER_DATA_NOREADY -20012
#define | AV_ER_INCOMPLETE_FRAME -20013
#define | AV_ER_LOSED_THIS_FRAME -20014
#define | AV_ER_SESSION_CLOSE_BY_REMOTE -20015
#define | AV_ER_REMOTE_TIMEOUT_DISCONNECT -20016
#define | AV_ER_SERVER_EXIT -20017
#define | AV_ER_CLIENT_EXIT -20018
#define | AV_ER_NOT_INITIALIZED -20019
#define | AV_ER_CLIENT_NOT_SUPPORT -20020
#define | AV_ER_SENDIOCTRL_ALREADY_CALLED -20021
#define | AV_ER_SENDIOCTRL_EXIT -20022
#define | AV_ER_NO_PERMISSION -20023
#define | AV_ER_WRONG_ACCPWD_LENGTH -20024
#define | AV_ER_IOTC_SESSION_CLOSED -20025
#define | AV_ER_IOTC_DEINITIALIZED -20026
#define | AV_ER_IOTC_CHANNEL_IN_USED -20027

## Typedefs

typedef enum _AV_RESET_TARGET | AV_RESET_TARGET
typedef int(_stdcall * | authFn )(char *szViewAccount, char *szViewPassword)

## Enumerations

enum | AVIOCtrlType { IOTYPE_INNER_SND_DATA_DELAY = 0xFF, IOTYPE_USER_DEFINED_START = 0x100 }
enum | _AV_RESET_TARGET { RESET_VIDEO = 0, RESET_AUDIO, RESET_ALL }

## Functions

int | avGetAVApiVer (void)
| Get the version of AV module.
int | avServResetBuffer (int avIndex, AV_RESET_TARGET eTarget, unsigned int Timeout_ms)
| Reset the Video or Audio buffer of AV server.
int | avInitialize (int nMaxChannelNum)
| Initialize AV module.
int | avDeInitialize (void)
| Deinitialize AV module.
int | avServStart (int nIOTCSessionID, const char *cszViewAccount, const char *cszViewPassword, unsigned int nTimeout, unsigned int nServType, unsigned char nIOTCChannelID)
| Start an AV server.
int | avServStart2 (int nIOTCSessionID, authFn pfxAuthFn, unsigned int nTimeout, unsigned int nServType, unsigned char nIOTCChannelID)
| Start an AV server.
int | avServStart3 (int nIOTCSessionID, authFn pfxAuthFn, unsigned int nTimeout, unsigned int nServType, unsigned char nIOTCChannelID, int *pnResend)
| Start an AV server.
void | avServExit (int nIOTCSessionID, unsigned char nIOTCChannelID)
| Used by an AV server exit avServStart() or avServStart2() process.
void | avServStop (int nAVChannelID)
| Stop an AV server.
void | avServSetResendSize (int nAVChannelID, unsigned int nSize)
| Set re-send buffer size.
int | avSendFrameData (int nAVChannelID, const char *cabFrameData, int nFrameDataSize, const void *cabFrameInfo, int nFrameInfoSize)
| An AV server sends frame data to an AV client.
int | avSendAudioData (int nAVChannelID, const char *cabAudioData, int nAudioDataSize, const void *cabFrameInfo, int nFrameInfoSize)
| An AV server sends audio data to an AV client.
int | avServSetDelayInterval (int nAVChannelID, unsigned short nPacketNum, unsigned short nDelayMs)
| Set interval of sending video data in AV server.
int | avClientStart (int nIOTCSessionID, const char *cszViewAccount, const char *cszViewPassword, unsigned int nTimeout, unsigned int *pnServType, unsigned char nIOTCChannelID)
| Start an AV client.
int | avClientStart2 (int nIOTCSessionID, const char *cszViewAccount, const char *cszViewPassword, unsigned int nTimeout, unsigned int *pnServType, unsigned char nIOTCChannelID, int *pnResend)
| Start an AV client.
void | avClientExit (int nIOTCSessionID, unsigned char nIOTCChannelID)
| Used by an AV client exit avClientStart() process.
void | avClientStop (int nAVChannelID)
| Stop an AV client.
int | avRecvFrameData (int nAVChannelID, char *abFrameData, int nFrameDataMaxSize, char *abFrameInfo, int nFrameInfoMaxSize, unsigned int *pnFrameIdx)
| An AV client receives frame data from an AV server.
int | avRecvFrameData2 (int nAVChannelID, char *abFrameData, int nFrameDataMaxSize, int *pnActualFrameSize, int *pnExpectedFrameSize, char *abFrameInfo, int nFrameInfoMaxSize, int *pnActualFrameInfoSize, unsigned int *pnFrameIdx)
| A new version AV client receives frame data from an AV server.
int | avRecvAudioData (int nAVChannelID, char *abAudioData, int nAudioDataMaxSize, char *abFrameInfo, int nFrameInfoMaxSize, unsigned int *pnFrameIdx)
| An AV client receives audio data from an AV server.
int | avCheckAudioBuf (int nAVChannelID)
| Get the frame count of audio buffer remaining in the queue.
void | avClientSetMaxBufSize (unsigned int nMaxBufSize)
| Set the maximum video frame buffer used in AV client.
int | avClientCleanBuf (int nAVChannelID)
| Clean the video buffer both in client and device, and clean the audio buffer of the client.
int | avClientCleanVideoBuf (int nAVChannelID)
| Clean the video buffer(both in client and device)
int | avClientCleanLocalBuf (int nAVChannelID)
| Clean the local video and audio buffer of the client.
int | avClientCleanLocalVideoBuf (int nAVChannelID)
| Clean the local video buffer of the client.
int | avClientCleanAudioBuf (int nAVChannelID)
| Clean the local audio buffer of the client.
int | avSendIOCtrl (int nAVChannelID, unsigned int nIOCtrlType, const char *cabIOCtrlData, int nIOCtrlDataSize)
| Send AV IO control.
int | avRecvIOCtrl (int nAVChannelID, unsigned int *pnIOCtrlType, char *abIOCtrlData, int nIOCtrlMaxDataSize, unsigned int nTimeout)
| Receive AV IO control.
int | avSendIOCtrlExit (int nAVChannelID)
| Used by an AV server or an AV client to exit sending IO control process.
float | avResendBufUsageRate (int nAVChannelID)
| Used by an AV server, in order to know the usage rate of resend buffer.
void | AV_Set_Log_Path (char *path, int nMaxSize)
| Set path of log file.

## Detailed Description

This file describes all the APIs of the AV module in IOTC platform. AV module is a kind of data communication modules in IOTC platform to provide fluent streaming Audio / Video data from AV servers to AV clients in unidirectional way.

Copyright
  Copyright (c) 2010 by Throughtek Co., Ltd. All Rights Reserved.

Revision Table

Version | Name | Date | Description
--- | --- | --- | ---
0.1.0.1 | Joshua | 2010-12-06 | Trial Version
0.1.0.4 | Joshua | 2011-05-16 | modified avRecvFrameData2
0.1.1.0 | Kevin | 2011-05-27 | Add send/resend audio capability
0.1.2.0 | Kevin | 2011-06-30 | Adapt to IOTC multi-channel session mechanism
1.0.0.0 | Kevin | 2011-07-12 | Formal version, stability testing
1.0.1.0 | Kevin | 2011-08-02 | Fix Bug : avServStart() when check IOTC error code(-14,-22,-23) not release AvInfo
1.0.2.0 | Kevin | 2011-08-08 | Fix Bug : 1.linux thread not reclaim so must detach thread 2.avoid avServStop() and avClientStop() to be called repeatedly
1.1.0.0 | Kevin | 2011-09-14 | Modify : 1.allow set send frame delay time to 0, when set 0 will delay 1ms in every 100 frame interval 2.Max fifo size 256KB->2MB, max frame divided 256->512. Fix Bug : avRecvFrameData() and avRecvAudioData() if pnFrameIdx is NULL will crash. Custom : reduce static memory usage for ARC
1.2.1.0 | Kevin | 2011-11-24 | Fix Bug : block_FifoExist() mutex dead lock. Add : 1. avServExit() to exit avServStart() anytime. 2. avClientExit() to exit avClientStart() anytime.
1.2.2.0 | Kevin | 2011-12-29 | Fix Bug : 1.avSendIOCtrl() packet lost because not judge ack by frameNo. 2.Success in avServStart() and failed in avClientStart() when packet lost. Add : 1.avServStart2() use call back function for authentication. 2.avRecvIOCtrl() error code AV_ER_INVALID_ARG means give buf size not enough. 3.avSendIOCtrl() error code AV_ER_SENDIOCTRL_ALREADY_CALLED means cant use the same avIndex to multi-call. 4.avSendIOCtrlExit() force to exit avSendIOCtrl().
1.2.3.0 | Kevin | 2012-02-22 | Fix Bug : avSendIOCtrl() packet lost because send and receive frameNo confuse.
1.2.4.0 | Kevin | 2012-03-08 | Add : Big-endian SOC support.
1.2.5.0 | Kevin | 2012-03-21 | Improve : av session can exceed 128, not limited.
1.2.6.0 | Kevin | 2012-04-18 | Fix Bug : When create _AVthreadServRecv and _AVthreadServSendFrame thread pass local variable to it not thread-safe instead of alloc a variable to pass.
1.2.7.0 | Kevin | 2012-05-22 | Fix Bug : avServStart() crash when connection failed because double tutk_platform_free "idx". Modify : TIME_DELAY_INITIAL 4->0 for video not delay.
1.2.8.0 | Kevin | 2012-08-16 | + Add deinitialization function: avDeInitialize() + Add error code AV_ER_CLIENT_NO_AVLOGIN returned by avSendAudioData() o Re-arrange error codes to distinguish from the ones defined by IOTC modules
1.2.8.1 | Kevin | 2012-11-22 | o Add const modifier for input parameters in function prototype

1.3.1.0

Kevin, Harry

2013-03-04

+ Add new mechanism for receive frame function: avRecvFrameData2().
+ Add avClientCleanBuf() to clean audio and video buffer.
+ Add avServSetDelayInterval() for setting packets delay time of video frames.
o Fix avCheckAudioBuf() may returns wrong audio frames count.
o Fix the bug of avSendIOCtrl() returns AV_ER_SENDIOCTRL_ALREADY_CALLED after avSendIOCtrlExit() called.
o Fix memory leak in avServStop().
o Fix memory leak in avClientStop().
o Fix memory leak in avSendFrameData().

1.3.2.0 | Kevin, Harry | 2013-03-28 | o Fix avServStart(), avServStart2() and avClientStart() may return wrong channel ID. o Fix avDeInitialize() bug.
1.3.3.0 | Kevin | 2013-04-10 | o Avoid avServStart(), avServStart2() and avClientStart() re-assign an AV channel ID for a pair of IOTC session ID and IOTC channel ID.
1.4.0.0 | Kevin, Harry | 2013-05-17 | + Add avServStart3(), avClientStart2() and avServSetResendSize() for AV re-send supporting. + avClientCleanVideoBuf() to clean video buffer. + avClientCleanAudioBuf() to clean audio buffer.
1.4.1.0 | Kevin | 2013-06-25 | o Fix re-send mechanism sometimes halt and cause client can't receive video data anymore. o Remove send and receive thread for server and client to improve performance.

1.4.2.0

Kevin, Victor

2013-07-26

o Fix resend mechanism sometimes halt forever and makes client can't receive video data anymore.
o Improve performance by remove send and receive thread for server and client.
o Fix argument type error.
o Fix Big-endian algorithm in avSendFrameData().
o Fix crash issue.

1.4.2.3

Alex, Victor

2013-10-28

o Fix avServStart2() and avServStart3() may blocks.
o Fix algorithm of avSendFrameData() on uCOSII.
o Fix critical session in uCOSII.
o Stop usage of AV_ER_EXCEED_MAX_ALARM (-20005).
o Fix big endian bugs.
o Add Lite UID support and AV_ER_NO_PERMISSION(-20023) error code.

1.4.3.0 | Victor | 2013-11-19 | o Fix variables conflict error.
1.4.4.0 | Victor | 2014-02-17 | + Add new api avResendBufUsageRate() to know usage rate of resend buffer.
1.4.5.0 | TUTK RD team | 2014-08-28 | o Fix crash bug on Win32. o Fix client connection failed when packet lost. - Remove include platform_config.h
1.5.0.0 | TUTK RD team | 2014-09-22 | + Add 64-bit library.
1.5.1.0 | TUTK RD team | 2014-09-30 | + Add new API avServResetBuffer to reset resend buffer.

## Macro Definition Documentation

#define AV_ER_BUFPARA_MAXSIZE_INSUFF -20001

The buffer to receive is too small to store

#define AV_ER_CLIENT_EXIT -20018

The AV client start process is terminated by avClientExit()

#define AV_ER_CLIENT_NO_AVLOGIN -20008

An AV client does not call avClientStart() yet

#define AV_ER_CLIENT_NOT_SUPPORT -20020

By design, an AV client cannot send frame and audio data to an AV server

#define AV_ER_DATA_NOREADY -20012

The data is not ready for receiving yet.

#define AV_ER_EXCEED_MAX_ALARM -20005

A warning error code to indicate that the sending queue of video frame of an AV server is almost full, probably caused by slow handling of an AV client or network issue. Please note that this is just a warning, the video frame is actually put in the queue.

#define AV_ER_EXCEED_MAX_CHANNEL -20002

The number of AV channels has reached maximum. The maximum number of AV channels is determined by the passed-in argument of avInitialize()

#define AV_ER_EXCEED_MAX_SIZE -20006

The frame to be sent exceeds the currently remaining video frame buffer. The maximum of video frame buffer is controlled by avServSetMaxBufSize()

#define AV_ER_FAIL_CREATE_THREAD -20004

AV fails to create threads. Please check if OS has ability to create threads for AV.

#define AV_ER_INCOMPLETE_FRAME -20013

Some parts of a frame are lost during receiving

#define AV_ER_INVALID_ARG -20000

The passed-in arguments for the function are incorrect

#define AV_ER_INVALID_SID -20010

The IOTC session of specified AV channel is not valid

#define AV_ER_IOTC_CHANNEL_IN_USED -20027

IOTC channel is used by other av channel

#define AV_ER_IOTC_DEINITIALIZED -20026

IOTC is deinitialized

#define AV_ER_IOTC_SESSION_CLOSED -20025

IOTC session has been closed

#define AV_ER_LOSED_THIS_FRAME -20014

The whole frame is lost during receiving

#define AV_ER_MEM_INSUFF -20003

Insufficient memory for allocation

#define AV_ER_NO_PERMISSION -20023

The UID is a lite UID

#define AV_ER_NoERROR 0

The function is performed successfully.

#define AV_ER_NOT_INITIALIZED -20019

AV module has not been initialized

#define AV_ER_REMOTE_TIMEOUT_DISCONNECT -20016

This IOTC session is disconnected because remote site has no any response after a specified timeout expires.

#define AV_ER_SENDIOCTRL_ALREADY_CALLED -20021

The AV channel of specified AV channel ID is already in sending IO control process

#define AV_ER_SENDIOCTRL_EXIT -20022

The sending IO control process is terminated by avSendIOCtrlExit()

#define AV_ER_SERV_NO_RESPONSE -20007

The specified AV server has no response

#define AV_ER_SERVER_EXIT -20017

The AV server start process is terminated by avServExit()

#define AV_ER_SESSION_CLOSE_BY_REMOTE -20015

The remote site already closes the IOTC session. Please call IOTC_Session_Close() to release local IOTC session resource

#define AV_ER_TIMEOUT -20011

The specified timeout has expired during some operation

#define AV_ER_WRONG_ACCPWD_LENGTH -20024

The length of password is wrong

#define AV_ER_WRONG_VIEWACCorPWD -20009

The client fails in authentication due to incorrect view account or password

#define AV_MAX_AUDIO_DATA_SIZE 1280

The maximum size of audio data to be sent, in unit of byte.

#define AV_MAX_IOCTRL_DATA_SIZE 1024

The maximum size of AV IO Control data to be sent, in unit of byte.

## Typedef Documentation

typedef int(_stdcall * authFn)(char *szViewAccount, 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 enum _AV_RESET_TARGET AV_RESET_TARGET

## Enumeration Type Documentation

enum _AV_RESET_TARGET

Enumerator:

  RESET_VIDEO |
  RESET_AUDIO |
  RESET_ALL |

enum AVIOCtrlType

The types for AV IO control. AV IO control are used for AV servers and AV clients to communicate control message with each other. The types contains system defined types and user defined ones. The range of system defined types is from 0x00 to 0xFF, while user defined ones is starting from 0x100.

Enumerator:

  IOTYPE_INNER_SND_DATA_DELAY | Used by AV clients to tell AV servers to change the time interval of sending packets by avSendFrameData() when AV clients are too slow to handle frame data.
  IOTYPE_USER_DEFINED_START | The starting enum value of user defined IO types. It is suggested to assign this to the first one of user defined types, like enum IOTYPE_USER_DEFINED { IOTYPE_USER_PLAY = IOTYPE_USER_DEFINED_START, IOTYPE_USER_STOP }

## Function Documentation

void AV_Set_Log_Path | ( | char * | path,
|  | int | nMaxSize
| ) |  |

Set path of log file.

Set the absolute path of log file

Parameters

  path | [in] The path of log file, NULL = disable Log
  nMaxSize | [in] The maximum size of log file in Bytes, 0 = unlimit

int avCheckAudioBuf | ( | int | 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

int avClientCleanAudioBuf | ( | int | 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
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null

int avClientCleanBuf | ( | int | nAVChannelID | ) |

Clean the video buffer both in client and device, and clean the audio buffer of the client.

A client with multiple device connection application should call this function to clean AV 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
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null

int avClientCleanLocalBuf | ( | int | 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
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null

int avClientCleanLocalVideoBuf | ( | int | 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
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null

int avClientCleanVideoBuf | ( | int | nAVChannelID | ) |

Clean the video buffer(both in client and device)

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
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null

void avClientExit | ( | int | nIOTCSessionID,
|  | unsigned char | 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

void avClientSetMaxBufSize | ( | unsigned int | 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

  nMaxBufSize | The maximum video frame buffer, in unit of kilo-byte

int avClientStart | ( | int | nIOTCSessionID,
|  | const char * | cszViewAccount,
|  | const char * | cszViewPassword,
|  | unsigned int | nTimeout,
|  | unsigned int * | pnServType,
|  | unsigned char | 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 if not connection is unsuccessful.
  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
  - AV_ER_INVALID_ARG The IOTC session ID is incorrect or reuse of IOTC session ID and IOTC channel ID.
  - AV_ER_NOT_INITIALIZED AV module is not initialized yet
  - AV_ER_EXCEED_MAX_CHANNEL The number of AV channels has reached maximum
  - AV_ER_FAIL_CREATE_THREAD Fails to create threads
  - AV_ER_SERV_NO_RESPONSE The AV server has no response
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session ID is not valid
  - AV_ER_CLIENT_EXIT Users stop this function with avClientExit() in another thread
  - AV_ER_TIMEOUT The timeout specified by nTimeout expires before AV start is performed completely
  - AV_ER_WRONG_VIEWACCorPWD The client fails in authentication due to incorrect view account or password
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avClientStop(), avClientExit()

Attention
  (1) This function is a block process.
  (2) The IOTC channel of specified channel ID will be turned on automatically by avClientStart().

int avClientStart2 | ( | int | nIOTCSessionID,
|  | const char * | cszViewAccount,
|  | const char * | cszViewPassword,
|  | unsigned int | nTimeout,
|  | unsigned int * | pnServType,
|  | unsigned char | nIOTCChannelID,
|  | int * | 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 if not connection is unsuccessful.
  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
  - AV_ER_INVALID_ARG The IOTC session ID is incorrect or reuse of IOTC session ID and IOTC channel ID.
  - AV_ER_NOT_INITIALIZED AV module is not initialized yet
  - AV_ER_EXCEED_MAX_CHANNEL The number of AV channels has reached maximum
  - AV_ER_FAIL_CREATE_THREAD Fails to create threads
  - AV_ER_SERV_NO_RESPONSE The AV server has no response
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session ID is not valid
  - AV_ER_CLIENT_EXIT Users stop this function with avClientExit() in another thread
  - AV_ER_TIMEOUT The timeout specified by nTimeout expires before AV start is performed completely
  - AV_ER_WRONG_VIEWACCorPWD The client fails in authentication due to incorrect view account or password
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avClientStop(), avClientExit()

Attention
  (1) This function is a block process.
  (2) The IOTC channel of specified channel ID will be turned on automatically by avClientStart2().
  (3) If AV client uses avClientStart2() to enable AV re-send mechanism, it has to use avRecvFrameData2() to receive video data.

void avClientStop | ( | int | 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

int avDeInitialize | ( | void |  | ) |

Deinitialize AV module.

This function will deinitialize AV module.

Returns
  AV_ER_NoERROR if deinitialize successfully
  Error code if return value < 0
  - AV_ER_NOT_INITIALIZED the AV module is not initialized yet

Attention
  AV module shall be deinitialized before IOTC module is deinitialized.

int avGetAVApiVer | ( | void |  | ) |

Get the version of AV module.

This function returns the version of AV module.

Returns
  The version of AV module from high byte to low byte, for example, 0x01020304 means the version is 1.2.3.4

See Also
  IOTC_Get_Version(), RDT_GetRDTApiVer()

int avInitialize | ( | int | nMaxChannelNum | ) |

Initialize AV module.

This function is used by AV servers or AV clients to initialize AV module and shall be called before any AV module related function is invoked.

Parameters

  nMaxChannelNum | [in] The max number of AV channels. If it is specified less than 1, AV will set max number of AV channels as 1.

Returns
  The actual maximum number of AV channels to be set.
  Error code if return value < 0
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

int avRecvAudioData | ( | int | nAVChannelID,
|  | char * | abAudioData,
|  | int | nAudioDataMaxSize,
|  | char * | abFrameInfo,
|  | int | nFrameInfoMaxSize,
|  | unsigned int * | pnFrameIdx
| ) |  |

An AV client receives audio data from an AV server.

An AV client uses this function to receive audio data from AV server

Parameters

  nAVChannelID | [in] The channel ID of the AV channel to be received
  abAudioData | [out] The audio data to be received
  nAudioDataMaxSize | [in] The max size of the audio data
  abFrameInfo | [out] The audio frame information to be received
  nFrameInfoMaxSize | [in] The max size of the audio frame information
  pnFrameIdx | [out] The index of current receiving audio frame

Returns
  The actual length of received result stored in abAudioData if successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session of this AV channel is not valid
  - AV_ER_DATA_NOREADY The data is not ready for receiving yet.
  - AV_ER_LOSED_THIS_FRAME The whole frame is lost during receiving
  - AV_ER_BUFPARA_MAXSIZE_INSUFF The data and frame info to be received exceeds the size of abAudioData and abFrameInfo, respectively.
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avRecvFrameData()

int avRecvFrameData | ( | int | nAVChannelID,
|  | char * | abFrameData,
|  | int | nFrameDataMaxSize,
|  | char * | abFrameInfo,
|  | int | nFrameInfoMaxSize,
|  | unsigned int * | pnFrameIdx
| ) |  |

An AV client receives frame data from an AV server.

An AV client uses this function to receive frame data from AV server

Parameters

  nAVChannelID | [in] The channel ID of the AV channel to be received
  abFrameData | [out] The frame data to be received
  nFrameDataMaxSize | [in] The max size of the frame data
  abFrameInfo | [out] The video frame information to be received
  nFrameInfoMaxSize | [in] The max size of the video frame information
  pnFrameIdx | [out] The index of current receiving video frame

Returns
  The actual length of received result stored in abFrameData if successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session of this AV channel is not valid
  - AV_ER_DATA_NOREADY The data is not ready for receiving yet.
  - AV_ER_LOSED_THIS_FRAME The whole frame is lost during receiving
  - AV_ER_BUFPARA_MAXSIZE_INSUFF The frame to be received exceeds the size of abFrameData, i.e. nFrameDataMaxSize
  - AV_ER_MEM_INSUFF Insufficient memory for allocation
  - AV_ER_INCOMPLETE_FRAME Some parts of a frame are lost during receiving
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avRecvAudioData()

int avRecvFrameData2 | ( | int | nAVChannelID,
|  | char * | abFrameData,
|  | int | nFrameDataMaxSize,
|  | int * | pnActualFrameSize,
|  | int * | pnExpectedFrameSize,
|  | char * | abFrameInfo,
|  | int | nFrameInfoMaxSize,
|  | int * | pnActualFrameInfoSize,
|  | unsigned int * | pnFrameIdx
| ) |  |

A new version AV client receives frame data from an AV server.

An AV client uses this function to receive frame data from AV server

Parameters

  nAVChannelID | [in] The channel ID of the AV channel to be received
  abFrameData | [out] The frame data to be received
  nFrameDataMaxSize | [in] The max size of the frame data
  pnActualFrameSize | [in] The actual size of frame data to be received, maybe less than expected size
  pnExpectedFrameSize | [in] The size of frame data expect to be received that sent from av server
  abFrameInfo | [out] The video frame information to be received
  nFrameInfoMaxSize | [in] The max size of the video frame information
  pnActualFrameInfoSize | [in] The actual size of the video frame information to be received
  pnFrameIdx | [out] The index of current receiving video frame

Returns
  The actual length of received result stored in abFrameData if successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session of this AV channel is not valid
  - AV_ER_DATA_NOREADY The data is not ready for receiving yet.
  - AV_ER_LOSED_THIS_FRAME The whole frame is lost during receiving
  - AV_ER_BUFPARA_MAXSIZE_INSUFF The frame to be received exceeds the size of abFrameData, i.e. nFrameDataMaxSize
  - AV_ER_MEM_INSUFF Insufficient memory for allocation
  - AV_ER_INCOMPLETE_FRAME Some parts of a frame are lost during receiving
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avRecvAudioData()

int avRecvIOCtrl | ( | int | nAVChannelID,
|  | unsigned int * | pnIOCtrlType,
|  | char * | abIOCtrlData,
|  | int | nIOCtrlMaxDataSize,
|  | unsigned int | nTimeout
| ) |  |

Receive AV IO control.

This function is used by AV servers or AV clients to receive a AV IO control.

Parameters

  nAVChannelID | [in] The channel ID of the AV channel to receive IO control
  pnIOCtrlType | [out] The type of received IO control
  abIOCtrlData | [out] The buffer of received IO control data
  nIOCtrlMaxDataSize | [in] The max length of buffer of received IO control data
  nTimeout | [in] The timeout for this function in unit of million-second, give 0 means return immediately

Returns
  The actual length of received result stored in abIOCtrlData if receiving IO control successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid or IO control type / data is null
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session of this AV channel is not valid
  - AV_ER_DATA_NOREADY The IO control is not ready for receiving yet.
  - AV_ER_TIMEOUT The timeout specified by nTimeout expires before receiving IO control process is performed completely
  - AV_ER_BUFPARA_MAXSIZE_INSUFF The IO control data to be received exceeds the size of abIOCtrlData, i.e. nIOCtrlMaxDataSize
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avSendIOCtrl()

float avResendBufUsageRate | ( | int | 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
  - AV_ER_INVALID_ARG The AV channel ID is not valid

int avSendAudioData | ( | int | nAVChannelID,
|  | const char * | cabAudioData,
|  | int | nAudioDataSize,
|  | const void * | cabFrameInfo,
|  | int | nFrameInfoSize
| ) |  |

An AV server sends audio data to an AV client.

An AV server uses this function to send audio data to AV client

Parameters

  nAVChannelID | [in] The channel ID of the AV channel to be sent
  cabAudioData | [in] The audio data to be sent
  nAudioDataSize | [in] The size of the audio data
  cabFrameInfo | [in] The audio frame information to be sent
  nFrameInfoSize | [in] The size of the audio frame information

Returns
  AV_ER_NoERROR if sending successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null
  - AV_ER_CLIENT_NOT_SUPPORT An AV client uses this function to send frame data
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session of this AV channel is not valid
  - AV_ER_CLIENT_NO_AVLOGIN An AV client does not pass authentication yet
  - AV_ER_MEM_INSUFF Insufficient memory for allocation
  - AV_ER_EXCEED_MAX_SIZE The audio data and frame info to be sent exceeds AV_MAX_AUDIO_DATA_SIZE
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avSendFrameData()

int avSendFrameData | ( | int | nAVChannelID,
|  | const char * | cabFrameData,
|  | int | nFrameDataSize,
|  | const void * | cabFrameInfo,
|  | int | nFrameInfoSize
| ) |  |

An AV server sends frame data to an AV client.

An AV server uses this function to send frame data to AV client

Parameters

  nAVChannelID | [in] The channel ID of the AV channel to be sent
  cabFrameData | [in] The frame data to be sent
  nFrameDataSize | [in] The size of the frame data
  cabFrameInfo | [in] The video frame information to be sent
  nFrameInfoSize | [in] The size of the video frame information

Returns
  AV_ER_NoERROR if sending successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid or frame data is null
  - AV_ER_CLIENT_NOT_SUPPORT An AV client uses this function to send frame data
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session of this AV channel is not valid
  - AV_ER_CLIENT_NO_AVLOGIN An AV client does not pass authentication yet
  - AV_ER_EXCEED_MAX_SIZE The frame data and frame info to be sent exceeds currently remaining video frame buffer. The max size of video frame buffer is determined by avServSetMaxBufSize()
  - AV_ER_MEM_INSUFF Insufficient memory for allocation
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avSendAudioData()

int avSendIOCtrl | ( | int | nAVChannelID,
|  | unsigned int | nIOCtrlType,
|  | const char * | cabIOCtrlData,
|  | int | nIOCtrlDataSize
| ) |  |

Send AV IO control.

This function is used by AV servers or AV clients to send a AV IO control.

Parameters

  nAVChannelID | [in] The channel ID of the AV channel to send IO control
  nIOCtrlType | [in] The type of IO control
  cabIOCtrlData | [in] The buffer of IO control data
  nIOCtrlDataSize | [in] The length of IO control data

Returns
  AV_ER_NoERROR if sending successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid
  - AV_ER_SENDIOCTRL_ALREADY_CALLED This AV channel is already in sending IO control process
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session of this AV channel is not valid
  - AV_ER_SENDIOCTRL_EXIT avSendIOCtrlExit() is called before this function is returned
  - AV_ER_EXCEED_MAX_SIZE The IO control data and type to be sent exceeds AV_MAX_IOCTRL_DATA_SIZE
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avRecvIOCtrl(), avSendIOCtrlExit()

Attention
  This function is a block process and it will return until having acknowledgment from the receiver.

int avSendIOCtrlExit | ( | int | nAVChannelID | ) |

Used by an AV server or an AV client to exit sending IO control process.

Since avSendIOCtrl() process is a block process and that means the caller has to wait for the acknowledgment from the receipt before avSendIOCtrl() returns. In some cases, caller may want to exit sending immediately by this function in another thread.

Parameters

  nAVChannelID | [in] The channel ID of the AV channel in sending IO control

Returns
  AV_ER_NoERROR if sending successfully
  Error code if return value < 0
  - AV_ER_INVALID_ARG The AV channel ID is not valid

void avServExit | ( | int | nIOTCSessionID,
|  | unsigned char | nIOTCChannelID
| ) |  |

Used by an AV server exit avServStart() or avServStart2() process.

Since avServStart() and avServStart2() are 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

int avServResetBuffer | ( | int | avIndex,
|  | AV_RESET_TARGET | eTarget,
|  | unsigned int | 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

int avServSetDelayInterval | ( | int | nAVChannelID,
|  | unsigned short | nPacketNum,
|  | unsigned short | 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.

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
  - AV_ER_INVALID_ARG The AV channel ID is not valid

void avServSetResendSize | ( | int | nAVChannelID,
|  | unsigned int | 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.

int avServStart | ( | int | nIOTCSessionID,
|  | const char * | cszViewAccount,
|  | const char * | cszViewPassword,
|  | unsigned int | nTimeout,
|  | unsigned int | nServType,
|  | unsigned char | nIOTCChannelID
| ) |  |

Start an AV server.

Start an AV server with predefined view account and password. Any AV client wanting to connect with this AV server shall provide matched view account and password.

Parameters

  nIOTCSessionID | [in] The session ID of the IOTC session to start AV server
  cszViewAccount | [in] The predefined view account
  cszViewPassword | [in] The predefined view password
  nTimeout | [in] The timeout for this function in unit of second Specify it as 0 will make AV server start process return 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 start AV server

Returns
  AV channel ID if return value >= 0
  Error code if return value < 0
  - AV_ER_INVALID_ARG The IOTC session ID is incorrect or reuse of IOTC session ID and IOTC channel ID.
  - AV_ER_NOT_INITIALIZED AV module is not initialized yet
  - AV_ER_EXCEED_MAX_CHANNEL The number of AV channels has reached maximum
  - AV_ER_FAIL_CREATE_THREAD Fails to create threads
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session ID is not valid
  - AV_ER_SERVER_EXIT Users stop this function with avServExit() in another thread
  - AV_ER_TIMEOUT The timeout specified by nTimeout expires before AV start is performed completely
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avServStart2(), avServExit(), avServStop()

Attention
  (1) This function is a block process.
  (2) The IOTC channel of specified channel ID will be turned on automatically by avServStart()

int avServStart2 | ( | int | nIOTCSessionID,
|  | authFn | pfxAuthFn,
|  | unsigned int | nTimeout,
|  | unsigned int | nServType,
|  | unsigned char | 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 return 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
  - AV_ER_INVALID_ARG The IOTC session ID is incorrect or reuse of IOTC session ID and IOTC channel ID.
  - AV_ER_NOT_INITIALIZED AV module is not initialized yet
  - AV_ER_EXCEED_MAX_CHANNEL The number of AV channels has reached maximum
  - AV_ER_FAIL_CREATE_THREAD Fails to create threads
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session ID is not valid
  - AV_ER_SERVER_EXIT Users stop this function with avServExit() in another thread
  - AV_ER_TIMEOUT The timeout specified by nTimeout expires before AV start is performed completely
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avServStart(), avServExit(), avServStop()

Attention
  (1) This function is a block process.
  (2) The IOTC channel of specified channel ID will be turned on automatically by avServStart2()

int avServStart3 | ( | int | nIOTCSessionID,
|  | authFn | pfxAuthFn,
|  | unsigned int | nTimeout,
|  | unsigned int | nServType,
|  | unsigned char | nIOTCChannelID,
|  | int * | 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 return 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
  - AV_ER_INVALID_ARG The IOTC session ID is incorrect or reuse of IOTC session ID and IOTC channel ID.
  - AV_ER_NOT_INITIALIZED AV module is not initialized yet
  - AV_ER_EXCEED_MAX_CHANNEL The number of AV channels has reached maximum
  - AV_ER_FAIL_CREATE_THREAD Fails to create threads
  - AV_ER_SESSION_CLOSE_BY_REMOTE The remote site already closes this IOTC session
  - AV_ER_REMOTE_TIMEOUT_DISCONNECT The timeout expires because remote site has no response.
  - AV_ER_INVALID_SID The IOTC session ID is not valid
  - AV_ER_SERVER_EXIT Users stop this function with avServExit() in another thread
  - AV_ER_TIMEOUT The timeout specified by nTimeout expires before AV start is performed completely
  - AV_ER_NO_PERMISSION the AV module does not support Lite UID

See Also
  avServStart(), avServStart2(), avServExit(), avServStop()

Attention
  (1) This function is a block process.
  (2) The IOTC channel of specified channel ID will be turned on automatically by avServStart3()

void avServStop | ( | int | 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