1. Initializing and Finalizing the Library

The VCT library must be initialized with the VCT_Init function before any library functions can be used.

During initialization, you must use the VCTConfig structure to specify the various parameters. The following table shows the members of the VCTConfig structure.

Table 1-1 The VCTConfig Structure

Variable Name

Description

session

Specifies the region where the VCTSession structure is saved.

numSession

Specifies the size of the region specified by session.

mode

Specifies the chat mode. (Be sure to specify VCT_MODE_CONFERENCE.)

ecMode Specifies echo canceller's operating mode.

cid

Specifies the CID of terminals.

codec

Specifies the codec for the main packet. (Be sure to specify VCT_CODEC_4BIT_ADPCM.)

frameLength

Specifies the audio frame length in milliseconds.

flag

Enables or disables the VAD, spare packet, drop recovery, high-pass filter, and echo cancellation features.

audioBuffer

Specifies the receiving buffer for the audio stream. (It must be 32-byte aligned.)

audioBufferSize

Specifies the size of the buffer specified by audioBuffer.

callback

Specifies the callback function for when events occur.

sendCallback

Specifies the callback function for when data is sent.

userData

Specifies the user data to pass upon calling the callback function.

 

The following code shows an example of conference mode initialization.

Code 1-1 Example of Initialization in Conference Mode
static VCTSession s_vctSession[VCT_MAX_SESSION];
static u8         s_audioBuffer[8 * 8 * VCT_AUDIO_BUFFER_SIZE] NN_ATTRIBUTE_ALIGN (32);
static VCTConfig  s_vctConfig;

s_vctConfig.session           = s_vctSession;
s_vctConfig.numSession        = VCT_MAX_SESSION;
s_vctConfig.mode              = VCT_MODE_CONFERENCE;
s_vctConfig.ecMode            = VT_EC_STANDARD;
s_vctConfig.cid               = MyCID; 
s_vctConfig.codec             = VCT_CODEC_4BIT_ADPCM;
s_vctConfig.frameLength       = VCT_AUDIO_FRAME_LENGTH_DEFAULT;
s_vctConfig.flag              = VCT_CONFIG_FLAG_DEFAULT;
s_vctConfig.audioBuffer       = s_audioBuffer;
s_vctConfig.audioBufferSize   = 8 * 8 * VCT_AUDIO_BUFFER_SIZE;
s_vctConfig.callback          = VoiceChatEventCallback;
s_vctConfig.sendCallback      = VoiceChatSendDataCallBack;
s_vctConfig.userData          = myData;

VCT_Init (&s_vctConfig);

 

In this sample code, exactly VCT_MAX_SESSION number of sessions are allocated. In conference mode, the required number of sessions is (maximum_number_of_participants -1).

 

Specify the chat mode and the CID of the local host, followed by the buffer for audio streaming.

Specify an audio stream buffer that is large enough for at least (audio frame length x 2) milliseconds of audio, so that there are no breaks in audio playback. The recommended size is at least (audio frame length x 4) milliseconds.

The buffer size is specified in terms of units of audio packet length. In this sample code, a buffer of size (8 * VCT_AUDIO_BUFFER_SIZE) is allocated.

In conference mode, the buffer size must be increased in proportion to the number of clients participating in the conference.

For example, if there is a conference with four participants and you want to provide this amount of buffer for each client, you would allocate a buffer of size (3 * (8 * VCT_AUDIO_BUFFER_SIZE)). Increasing the buffer size does not cause any delay in audio playback. The actual buffer size is determined automatically by the dynamic jitter buffer by measuring jitter on the network.

The pointer to the audio streaming buffer must be aligned to 32 bytes, and audioBufferSize must be an integral multiple of VCT_AUDIO_BUFFER_SIZE.

Specify the callback function and the parameter passed to that function, and then specify the codec for the main packet. The only codec currently supported for main packets is 4-bit ADPCM.

 

Next, specify the audio frame length. VCT_AUDIO_FRAME_LENGTH_DEFAULT has a value of 144 milliseconds.

Finally, specify whether to enable or disable VAD, spare packets, and the other individual features of the VCT library.

For more information about how to specify these values and more information about the various features, see the function reference manual.

 

When you are finished using the VCT library, call the VCT_Cleanup function.


CONFIDENTIAL