#include <RakVoice.h>
Inheritance diagram for RakVoice:
Public Member Functions | |
RakVoice () | |
virtual | ~RakVoice () |
void | Init (int samplingRate, int bitsPerSample, RakPeerInterface *_peer) |
int | GetFrameSize (void) const |
void | Disconnect (PlayerID id) |
void | SetBlockSize (int _blockSize) |
void | Deinit (void) |
void | EncodeSoundPacket (char *input, PlayerID recipient) |
void | DecodeAndQueueSoundPacket (char *data, int length) |
bool | GetSoundPacket (char *output, PlayerID *sender) |
int | GetNextSoundPacketSize (void) |
int | GetOutputBufferSize (void) |
Private Member Functions | |
void | Init (int samplingRate, int bitsPerSample) |
CoderStateWithPlayerIDMapStruct * | CreateCoderStateWithPlayerIDMapStruct (int samplingRate, PlayerID playerId, bool decoder) |
void * | CreateCoderState (int samplingRate, bool decoder) |
CoderStateWithPlayerIDMapStruct * | GetCoderFromPlayerID (unsigned short sr, PlayerID id, bool decoder) |
Private Attributes | |
bool | init |
PlayerID | targetedSendRecipient [RAK_VOICE_INPUT_LIST_BUFFER_SIZE] |
speex_encoding_type | inputList [RAK_VOICE_INPUT_LIST_BUFFER_SIZE][160] |
int | writeCursor |
int | readCursor |
unsigned char | bps |
SpeexBits | bits |
int | frame_size |
BasicDataStructures::Queue< PCMDataStruct * > | PCMQueue |
BasicDataStructures::Queue< PCMDataStruct * > | PCMQueuePool |
BasicDataStructures::List< CoderStateWithPlayerIDMapStruct * > | coderStateList |
SimpleMutex | PCMQueueMutex |
SimpleMutex | coderStateListMutex |
RakPeerInterface * | peer |
unsigned short | sampleRate |
int | blockSize |
Friends | |
void * | rakVoiceThread (void *arguments) |
Classes | |
struct | PCMDataStruct |
Raw Data to encode or to play. More... |
The RakVoice class provide services for the RakVoice subsystem. You will not directly used RakVoice object. Instead you will use RakVoiceInterface object provided by the RakVoiceFactory class.
|
Default constructor |
|
Destructor |
|
Creates encoders and decoders |
|
Creates encoders and decoders |
|
When you get a packet with the type ID_VOICE_PACKET, Pass the data and length to this function. This 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
Implements RakVoiceInterface. |
|
Call this before shutting down Implements RakVoiceInterface. |
|
Whenever a player disconnects we need to know about it. Otherwise we will be using old values for our encoding. Passing an id that has never been used is ok, it will be ignored.
Implements RakVoiceInterface. |
|
When you have raw sound data, pass it to this function. Input must be of size blockSize that you specified in Init This will encode and send in another thread the data as a packet Because of the way encoding works, you cannot broadcast voice data. You must specify a recipient If you want to send to everyone, you have to call this once for each recipient Use UNASSIGNED_PLAYER_ID to send to the server (if you are a client).
Implements RakVoiceInterface. |
|
Retrieve the coder struct for a player |
|
Valid to call after a call to Init. Returns the frame size used by the encoder in bytes It is best to send input to EncodeSoundData that matches this frame size
Implements RakVoiceInterface. |
|
Gives you the size, in bytes, of the next sound packet, or 0 for nothing left
Implements RakVoiceInterface. |
|
This will tell you the total number of bytes in the output buffer
Implements RakVoiceInterface. |
|
This will get the next sound data packet and write it to output Returns false if no packets are waiting. The originator of the packet is written to sender
Implements RakVoiceInterface. |
|
Internal initialisation procedure
|
|
Call this before using voice packets. Use the server version to send packets through the server, client version to send packets through the client _blockSize is 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%).
Implements RakVoiceInterface. |
|
Set the block size that EncodeSoundPacket will read and GetSoundPacket will write. If you don't call this, it will default to GetFrameSize() You should only call this after calling Init. It is reset every call to Init. This must be a multiple of GetFrameSize().
Implements RakVoiceInterface. |
|
RakVoice Thread function to use |
|
|
|
Must be a multiple of frame_size |
|
bits per sample |
|
List of coder. Each party involved in the voice communication requires one coder state |
|
Prevent multiple access to the PCM pool |
|
Frame size |
|
true if a previous call to init occured |
|
|
|
Store PCM Data |
|
Prevent multiple access at the same time to PCM queue |
|
Pool of PCM Data ready to be used |
|
Communication end point to use |
|
The position of the next reading operation |
|
ample rate |
|
Encoding calls are buffered to this input list The thread will then parse this list to actually create the encoded data and send it through the network |
|
The position of the next writing operation |