#include <RakVoice.h>
Inheritance diagram for RakVoice:
Public Member Functions | |
RakVoice () | |
Default constructor. | |
virtual | ~RakVoice () |
Destructor. | |
void | Init (int samplingRate, int bitsPerSample, RakPeerInterface *_peer) |
int | GetFrameSize (void) const |
void | Disconnect (PlayerID id) |
void | SetBlockSize (int _blockSize) |
void | Deinit (void) |
Frees all memory used. Call this before shutting down. | |
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][MAX_FRAME_SIZE] |
int | writeCursor |
int | readCursor |
unsigned char | bps |
int | frame_size |
BasicDataStructures::Queue< PCMDataStruct * > | PCMQueue |
Queue of PCMDataStruct , which is the data waiting to be copied to the user for playback. | |
BasicDataStructures::Queue< PCMDataStruct * > | PCMQueuePool |
Queue of PCMDataStruct, used to prevent needless reallocations of PCMDataStruct. | |
BasicDataStructures::List< CoderStateWithPlayerIDMapStruct * > | coderStateList |
All the coders and decoders, oen per player. | |
SimpleMutex | PCMQueueMutex |
Used to lock PCMQueue. | |
SimpleMutex | coderStateListMutex |
RakPeerInterface * | peer |
Copy of _peer passed to Init(). | |
unsigned short | sampleRate |
Copy of samplingRate passed to Init(). | |
int | blockSize |
Must be a multiple of frame_size. | |
SpeexBits | bits |
Friends | |
void * | rakVoiceThread (void *arguments) |
Thread that will continually run, processing voice data. | |
Classes | |
struct | PCMDataStruct |
RakVoice is a set of functions that uses an instance of RakPeer to transfer, encode, and decode voice packets. I use speex to handle the encoding and decoding part. The sample uses port-audio for record and playback. You can use anything you want and the system is not tied to port-audio in any way. Bandwidth usage is extraordinarily low, in the hundreds of bytes per second. If you were to use this with RakNet's secure communication capability, you can have secure peer to peer voice communications over the internet.
|
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
Implements RakVoiceInterface. |
|
Whenever a player disconnects RakVoice needs to know about it. Otherwise we will be using old values for our encoding.
Implements RakVoiceInterface. |
|
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.
Implements RakVoiceInterface. |
|
Implements RakVoiceInterface. |
|
Returns 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 waiting to be copied out via the function DecodeAndQueueSoundPacket()
Implements RakVoiceInterface. |
|
This will get the next sound packet and copy it to output. By sound packet, I mean decompressed sound data, not network datagram
Implements RakVoiceInterface. |
|
Call this first.
Implements RakVoiceInterface. |
|
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.
Implements RakVoiceInterface. |