RakNet  4.0
Public Member Functions | List of all members
RakNet::RakVoice Class Reference

Voice compression and transmission interface. More...

#include <RakVoice.h>

Inheritance diagram for RakNet::RakVoice:
RakNet::PluginInterface2

Public Member Functions

void Init (unsigned short speexSampleRate, unsigned bufferSizeBytes)
 Starts RakVoice.
 
void SetEncoderComplexity (int complexity)
 Changes encoder complexity Specifying higher values might help when encoding non-speech sounds.
 
void SetVAD (bool enable)
 Enables or disables VAD (Voice Activity Detection) Enabling VAD can help reduce the amount of data transmitted, by automatically disabling outgoing data, when no voice is detected. Don't turn this off or the receive buffer fills up and you eventually get very long delays!!
 
void SetNoiseFilter (bool enable)
 Enables or disables the noise filter.
 
void SetVBR (bool enable)
 Enables or disables VBR VBR is variable bitrate. Uses less bandwidth but more CPU if on.
 
int GetEncoderComplexity (void)
 Returns the complexity of the encoder.
 
bool IsVADActive (void)
 Returns current state of VAD.
 
bool IsNoiseFilterActive ()
 Returns the current state of the noise filter.
 
bool IsVBRActive ()
 Returns the current state of VBR.
 
void Deinit (void)
 Shuts down RakVoice.
 
void RequestVoiceChannel (RakNetGUID recipient)
 Opens a channel to another connected system You will get ID_RAKVOICE_OPEN_CHANNEL_REPLY on success.
 
void CloseVoiceChannel (RakNetGUID recipient)
 Closes an existing voice channel. Other system will get ID_RAKVOICE_CLOSE_CHANNEL.
 
void CloseAllChannels (void)
 Closes all existing voice channels Other systems will get ID_RAKVOICE_CLOSE_CHANNEL.
 
bool SendFrame (RakNetGUID recipient, void *inputBuffer)
 Sends voice data to a system on an open channel.
 
bool IsSendingVoiceDataTo (RakNetGUID recipient)
 Returns if we are currently sending voice data, accounting for voice activity detection.
 
void ReceiveFrame (void *outputBuffer)
 Gets decoded voice data, from one or more remote senders.
 
int GetSampleRate (void) const
 
int GetBufferSizeBytes (void) const
 
bool IsInitialized (void) const
 
RakPeerInterfaceGetRakPeerInterface (void) const
 
unsigned GetBufferedBytesToSend (RakNetGUID guid) const
 
unsigned GetBufferedBytesToReturn (RakNetGUID guid) const
 
void SetLoopbackMode (bool enabled)
 
bool IsLoopbackMode (void) const
 
virtual void Update (void)
 Update is called every time a packet is checked for .
 
virtual PluginReceiveResult OnReceive (Packet *packet)
 
virtual void OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
 
- Public Member Functions inherited from RakNet::PluginInterface2
virtual void OnAttach (void)
 Called when the interface is attached.
 
virtual void OnDetach (void)
 Called when the interface is detached.
 
virtual void OnRakPeerStartup (void)
 Called when RakPeer is initialized.
 
virtual void OnRakPeerShutdown (void)
 Called when RakPeer is shutdown.
 
virtual void OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
 
virtual void OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
 
virtual bool UsesReliabilityLayer (void) const
 
virtual void OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 
virtual void OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 
virtual void OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError)
 
virtual void OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time, int isSend)
 
virtual void OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time)
 
virtual void OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 

Detailed Description

Voice compression and transmission interface.

Member Function Documentation

void RakNet::RakVoice::CloseVoiceChannel ( RakNetGUID  recipient)

Closes an existing voice channel. Other system will get ID_RAKVOICE_CLOSE_CHANNEL.

Parameters
[in]recipientWhich system to close a channel with
unsigned RakNet::RakVoice::GetBufferedBytesToReturn ( RakNetGUID  guid) const

How many bytes are on the read buffer, waiting to be passed to a call to ReceiveFrame This should remain at a fairly small near-constant size as incoming data is read out at the same rate as outgoing data from the remote system

Parameters
[in]guidThe system to query, or RakNet::UNASSIGNED_SYSTEM_ADDRESS for the sum of all channels.
Returns
Number of bytes on the read buffer.
unsigned RakNet::RakVoice::GetBufferedBytesToSend ( RakNetGUID  guid) const

How many bytes are on the write buffer, waiting to be passed to a call to RakPeer::Send (internally) This should remain at a fairly small near-constant size as outgoing data is sent to the Send function

Parameters
[in]guidThe system to query, or RakNet::UNASSIGNED_SYSTEM_ADDRESS for the sum of all channels.
Returns
Number of bytes on the write buffer
int RakNet::RakVoice::GetBufferSizeBytes ( void  ) const

Returns the buffer size in bytes, as passed to Init

Returns
buffer size in bytes
int RakNet::RakVoice::GetEncoderComplexity ( void  )

Returns the complexity of the encoder.

Precondition
Only applies to encoder.
Returns
a value from 0 to 10.
RakPeerInterface* RakNet::RakVoice::GetRakPeerInterface ( void  ) const

Returns the RakPeerInterface that the object is attached to.

Returns
the respective RakPeerInterface, or NULL not attached.
int RakNet::RakVoice::GetSampleRate ( void  ) const

Returns the value sample rate, as passed to Init

Returns
the sample rate
void RakNet::RakVoice::Init ( unsigned short  speexSampleRate,
unsigned  bufferSizeBytes 
)

Starts RakVoice.

Parameters
[in]speexSampleRate8000, 16000, or 32000
[in]bufferSizeBytesHow many bytes long inputBuffer and outputBuffer are in SendFrame and ReceiveFrame are. Should be your sample size * the number of samples to encode at once.
bool RakNet::RakVoice::IsInitialized ( void  ) const

Returns true or false, indicating if the object has been initialized

Returns
true if initialized, false otherwise.
bool RakNet::RakVoice::IsLoopbackMode ( void  ) const

Returns true or false, indicating if the loopback mode is enabled

Returns
true if enabled, false otherwise.
bool RakNet::RakVoice::IsNoiseFilterActive ( )

Returns the current state of the noise filter.

Precondition
Only applies to encoder.
Returns
true if the noise filter is active, false otherwise.
bool RakNet::RakVoice::IsSendingVoiceDataTo ( RakNetGUID  recipient)

Returns if we are currently sending voice data, accounting for voice activity detection.

Parameters
[in]Whichsystem to check
Returns
If we are sending voice data for the specified system
bool RakNet::RakVoice::IsVADActive ( void  )

Returns current state of VAD.

Precondition
Only applies to encoder.
Returns
true if VAD is enable, false otherwise
bool RakNet::RakVoice::IsVBRActive ( )

Returns the current state of VBR.

Precondition
Only applies to encoder.
Returns
true if VBR is active, false otherwise.
virtual void RakNet::RakVoice::OnClosedConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
PI2_LostConnectionReason  lostConnectionReason 
)
virtual

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters
[in]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::RakVoice::OnReceive ( Packet packet)
virtual

OnReceive is called for every packet.

Parameters
[in]packetthe packet that is being returned to the user
Returns
True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from RakNet::PluginInterface2.

void RakNet::RakVoice::ReceiveFrame ( void *  outputBuffer)

Gets decoded voice data, from one or more remote senders.

Parameters
[out]outputBufferThe voice data. The size of outputBuffer should be what was specified as bufferSizeBytes in Init
void RakNet::RakVoice::RequestVoiceChannel ( RakNetGUID  recipient)

Opens a channel to another connected system You will get ID_RAKVOICE_OPEN_CHANNEL_REPLY on success.

Parameters
[in]recipientWhich system to open a channel to
bool RakNet::RakVoice::SendFrame ( RakNetGUID  recipient,
void *  inputBuffer 
)

Sends voice data to a system on an open channel.

Precondition
recipient must refer to a system with an open channel via RequestVoiceChannel
Parameters
[in]recipientThe system to send voice data to
[in]inputBufferThe voice data. The size of inputBuffer should be what was specified as bufferSizeBytes in Init
void RakNet::RakVoice::SetEncoderComplexity ( int  complexity)

Changes encoder complexity Specifying higher values might help when encoding non-speech sounds.

Parameters
[in]complexity0 to 10. The higher the value, the more CPU it needs. Recommended values are from 2 to 4.
void RakNet::RakVoice::SetLoopbackMode ( bool  enabled)

Enables/disables loopback mode

Parameters
[in]trueto enable, false to disable
void RakNet::RakVoice::SetNoiseFilter ( bool  enable)

Enables or disables the noise filter.

Precondition
Only applies to encoder.
Parameters
[in]enabletrue to enable, false to disable.
void RakNet::RakVoice::SetVAD ( bool  enable)

Enables or disables VAD (Voice Activity Detection) Enabling VAD can help reduce the amount of data transmitted, by automatically disabling outgoing data, when no voice is detected. Don't turn this off or the receive buffer fills up and you eventually get very long delays!!

Precondition
Only applies to encoder.
Parameters
[in]enabletrue to enable, false to disable. True by default
void RakNet::RakVoice::SetVBR ( bool  enable)

Enables or disables VBR VBR is variable bitrate. Uses less bandwidth but more CPU if on.

Precondition
Only applies to encoder.
Parameters
[in]enabletrue to enable VBR, false to disable

The documentation for this class was generated from the following file: