Xrasher/engine/client/voice.h

71 lines
1.5 KiB
C
Raw Normal View History

2021-05-09 16:32:53 +03:00
#ifndef VOICE_H
#define VOICE_H
#include <opus.h>
#include "common.h"
#include "client.h"
#include "sound.h"
#include "soundlib/soundlib.h"
#include "library.h"
extern convar_t voice_scale;
typedef struct voice_state_s
{
2022-08-15 11:42:06 +04:00
qboolean initialized;
2021-05-09 16:32:53 +03:00
qboolean is_recording;
float start_time;
qboolean talking_ack;
float talking_timeout;
struct {
qboolean talking_ack;
float talking_timeout;
} players_status[32];
2021-05-09 16:32:53 +03:00
// opus stuff
OpusEncoder *encoder;
OpusDecoder *decoder;
// audio info
uint channels;
uint width;
uint samplerate;
uint frame_size;
2022-08-15 11:42:06 +04:00
// buffers
byte input_buffer[MAX_RAW_SAMPLES];
byte output_buffer[MAX_RAW_SAMPLES];
byte decompress_buffer[MAX_RAW_SAMPLES];
fs_offset_t input_buffer_pos;
// automatic gain control
struct {
int block_size;
float current_gain;
float next_gain;
float gain_multiplier;
} autogain;
2021-05-09 16:32:53 +03:00
} voice_state_t;
extern voice_state_t voice;
void CL_AddVoiceToDatagram( void );
void Voice_RegisterCvars( void );
qboolean Voice_Init( const char *pszCodecName, int quality );
void Voice_DeInit( void );
uint Voice_GetCompressedData( byte *out, uint maxsize, uint *frames );
void Voice_Idle( float frametime );
qboolean Voice_IsRecording( void );
void Voice_RecordStop( void );
void Voice_RecordStart( void );
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames );
2021-05-09 16:32:53 +03:00
qboolean Voice_GetLoopback( void );
void Voice_LocalPlayerTalkingAck( void );
void Voice_PlayerTalkingAck( int playerIndex );
2021-05-09 16:32:53 +03:00
void Voice_StartChannel( uint samples, byte *data, int entnum );
2022-08-15 11:42:06 +04:00
#endif // VOICE_H