10.3. Migrating From VCT to PiaChat

Introduction

This section describes the work required to add support for PiaChat to an application that previously used VCT for voice chat.

 

Required Work

  • The PiaChat module does not require the VCT library. so change any instances of #include vct.h in your code to #include pia/chat.h.
  • Remove the link to the VCT library's vct.a archive file, and instead link to the libpia_chat.fast.a archive file in $CTRPIA_ROOT/libraries/CTR-TS.Process.MPCore/(noopt|verbose|release).
  • The PiaChat module does not have any public functions equivalent to VCT_HandleData() and VCT_Main(). These processes are handled internally by Pia dispatches. Remove any calls to these functions in your code.
  • The application does not need to have a VCTEventCallback-typed callback function.
  • The PiaChat module uses the memory allocated for the Pia library when the nn::pia::common::Initialize() function is called. Instead of allocating memory for VCT in the VCTConfig structure, just increase the amount of memory you allocate for the Pia library.
  • In your source code, update calls to the earlier VCT API functions to calls to the latest PiaChat API functions. The following section details the function calls you need to replace.

 

Replacing VCT API Calls

Object Naming Convention

The PiaChat API replaces the various types, functions, and constants of the VCT API. The new object names simply drop the VCT_ prefix used for objects in the VCT API. See the following examples.

VCT API PiaChat
VCTCodec enum nn::pia::chat::Codec
VCT_SetCodec(VCTCodec) nn::pia::chat::VoiceProtocol::SetCodec(enum Codec)
VCT_CODEC_4BIT_ADPCM nn::pia::chat::CODEC_4BIT_ADPCM
VCT_AUDIO_FRAME_LENGTH_DEFAULT nn::pia::chat::VoiceProtocol::AUDIO_FRAME_LENGTH_DEFAULT

Exceptions to This Convention

Some of the functions in the PiaChat API do not follow this naming convention. The following table lists the exceptions.

VCT API PiaChat API
VCT_Init() nn::pia::chat::VoiceProtocol::Initialize()
VCT_Cleanup() nn::pia::chat::VoiceProtocol::Finalize()
VCT_SendAudioEx() nn::pia::chat::VoiceProtocol::Send()
VCT_ReceiveAudio() nn::pia::chat::VoiceProtocol::Receive()
VCT_GetAudioInfoFromCid() nn::pia::chat::VoiceProtocol::GetAudioInfo()

PiaChat Initialization

First initialize and set up the PiaSession module and then initialize and set up the PiaChat module. Create an instance of VoiceProtocol using the CreateProtocol() function, and then call the VoiceProtocol::Initialize() function. For more information, see the VoiceProtocol sample demo.

The PiaChat module internally uses nn::pia::transport::UnreliableProtocol. For the UnreliableProtocol port number, the PiaChat module uses the value of the port member variable of the Setting structure passed to the nn::pia::chat::VoiceProtocol::Initialize() function. If your application is already using an instance of UnreliableProtocol for something else, make sure to specify a different port number for the port member variable.

Differences Between VCT and PiaChat

  • The VCT library could only handle a maximum of eight simultaneously connected stations, but the PiaChat module can handle up to 12 stations.
  • VCT was written in C while PiaChat is written in C++.
  • VCT API functions that returned BOOL-typed values now return bool-typed values (or nn::Result values) in their new implementations in PiaChat.
  • Some of the less-used VCT API functions have been removed entirely and are not present anywhere in PiaChat.