uint32_t v3_send_audio(uint16_t send_type, uint32_t rate, uint8_t *pcm, uint32_t length, uint8_t celt_stereo)Send an audio data packet to the server. You must be careful when sending audio data. Each packet must be roughly the same size or the client will be banned for a long period of time (usually more than 400 minutes). The server expects to receive approximately .115 seconds of audio in each packet. Sending too much or too little data will also get the client banned.
Note: If your client does get banned, the only way to remove the ban is to restart the server.
Additionally, the PCM length must be a multiple of the encoder's expected frame size. This can be determined by requesting the codec structure in the pcmframesize variable (see v3_get_codec()).
For example, the Speex encoder at 32kHz has a pcm frame size of 1280 bytes (640 samples). The server expects to receive approximately 7680 bytes of PCM data.
7680 bytes / 2 bytes per sample / 32000 samples per second = 0.12 seconds of audio
Note that this is not a hard rule. You can send 8960 bytes of PCM data (0.14 seconds) as well.
Lastly, this function does not do proper error checking on data you are sending. This function will only check if the sample rate specified as an argument do not match with the current channel's sample rate when send_type is user to current channel. If they do not match, the function will return the current channel's sample rate and the data is not sent.
If you send data that is not a multiple of the frame size, the results are undefined.
Arguments
| Type | Description |
| uint16_t send_type | The type of transmission |
| uint32_t rate | The rate in kHz of the PCM data |
| uint8_t *pcm | A pointer to the PCM data the client is sending |
| uint32_t length | The amount of data in bytes pointed to by *pcm |
| uint8_t celt_stereo | More information on this argument to come later. Set as 0 for false. |
send_type can be any of the following:
| V3_AUDIO_SENDTYPE_UNK0 | possibly broadcast? |
| V3_AUDIO_SENDTYPE_UNK1 | possibly broadcast to lobby? |
| V3_AUDIO_SENDTYPE_U2CCUR | user to current channel |
| V3_AUDIO_SENDTYPE_U2C | user to specific channel |
| V3_AUDIO_SENDTYPE_U2CSUB | user to channel and all subchannels |
| V3_AUDIO_SENDTYPE_U2U | user to user |
| V3_AUDIO_SENDTYPE_U2TARG | user to voice target |
