RakVoiceInterface Class Reference
[RakVoice Subsystem]

Define the user interface of the RakVoice module. More...

#include <RakVoiceInterface.h>

Inheritance diagram for RakVoiceInterface:

RakVoice List of all members.

Public Member Functions

virtual ~RakVoiceInterface ()
 Destructor.
virtual void Init (int samplingRate, int bitsPerSample, RakPeerInterface *_peer)=0
virtual int GetFrameSize (void) const =0
virtual void Disconnect (PlayerID id)=0
virtual void SetBlockSize (int _blockSize)=0
virtual void Deinit (void)=0
 Frees all memory used. Call this before shutting down.
virtual void EncodeSoundPacket (char *input, PlayerID recipient)=0
virtual void DecodeAndQueueSoundPacket (char *data, int length)=0
virtual bool GetSoundPacket (char *output, PlayerID *sender)=0
virtual int GetNextSoundPacketSize (void)=0
virtual int GetOutputBufferSize (void)=0

Detailed Description

Define the user interface of the RakVoice module.

Users should only use the function provided by this interface while using the RakVoice Subsystem.


Member Function Documentation

virtual void RakVoiceInterface::DecodeAndQueueSoundPacket char *  data,
int  length
[pure virtual]
 

When you get a packet with the type ID_VOICE_PACKET, pass the packet data and length to this function. This function will decode the data and put it in the internal queue, or simply relay the data if this is the server and the target is not the server

Parameters:
[in] data Packet::data
[in] length Packet::length
See also:
NetworkTypes.h

Implemented in RakVoice.

virtual void RakVoiceInterface::Disconnect PlayerID  id  )  [pure virtual]
 

Whenever a player disconnects RakVoice needs to know about it. Otherwise we will be using old values for our encoding.

Parameters:
[in] id PlayerID of the player who has disconnected.

Implemented in RakVoice.

virtual void RakVoiceInterface::EncodeSoundPacket char *  input,
PlayerID  recipient
[pure virtual]
 

Pass your raw sound data to this function. This function will encode and send in another thread the data as a packet Because of the way encoding works, you cannot broadcast voice data.

Parameters:
[in] input A byte array of block size containing the raw voice data. this must be equal in size to the current blockSize, whatever you passed to SetBlockSize()
[in] recipient The targeted peer or UNASSIGNED_PLAYER_ID if you want to send to the server as a client.

Implemented in RakVoice.

virtual int RakVoiceInterface::GetFrameSize void   )  const [pure virtual]
 

Precondition:
You must have called Init first Gets the frame size.
Note:
It is best to send input to EncodeSoundData that matches this frame size
Returns:
The frame size used by the encoder, in bytes

Implemented in RakVoice.

virtual int RakVoiceInterface::GetNextSoundPacketSize void   )  [pure virtual]
 

Returns the size, in bytes, of the next sound packet, or 0 for nothing left

Returns:
The size, in bytes, of the next sound packet, or 0 for nothing left

Implemented in RakVoice.

virtual int RakVoiceInterface::GetOutputBufferSize void   )  [pure virtual]
 

This will tell you the total number of bytes waiting to be copied out via the function DecodeAndQueueSoundPacket()

Returns:
Returns the number of remaining byte in the buffer.

Implemented in RakVoice.

virtual bool RakVoiceInterface::GetSoundPacket char *  output,
PlayerID sender
[pure virtual]
 

This will get the next sound packet and copy it to output. By sound packet, I mean decompressed sound data, not network datagram

Parameters:
[out] output The resulting raw sound voice data
[in] sender Who sent this voice data
Return values:
true Data was copied to output, of the same length you passed to SetBlockSize
false No sound packets are waiting.

Implemented in RakVoice.

virtual void RakVoiceInterface::Init int  samplingRate,
int  bitsPerSample,
RakPeerInterface _peer
[pure virtual]
 

Call this first.

Parameters:
[in] samplingRate Self-explanatory
[in] bitsPerSample Self-explanatory
[in] _peer The instance of RakPeer to use for sends

Implemented in RakVoice.

virtual void RakVoiceInterface::SetBlockSize int  _blockSize  )  [pure virtual]
 

Sets the block size that EncodeSoundPacket will read and GetSoundPacket will write. If you don't call this, it will default to GetFrameSize(). It is reset every call to Init.

Precondition:
Must have called Init first
Parameters:
[in] _blockSize The size of each block that you want to process at a time. Each network packet will have this size before compression. It must be a multiple of frame_size. The best _blockSize is what would be compressed to slightly under your MTU. You can safely assume the compression rate is 50% (actually it's closer to 75%).

Implemented in RakVoice.


The documentation for this class was generated from the following file:
Generated on Wed May 3 09:11:55 2006 for RakNet by  doxygen 1.4.6-NO