From b949e776ca74e15d78e597fbcb86630cc6c257f7 Mon Sep 17 00:00:00 2001 From: icculus Date: Wed, 4 Jun 2008 21:49:15 +0000 Subject: VoIP: client can now specify targets for voice transmission. git-svn-id: svn://svn.icculus.org/quake3/trunk@1365 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/client/cl_cgame.c | 1 + code/client/cl_main.c | 16 ++++++++++++++++ code/client/cl_parse.c | 4 +++- code/client/client.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) (limited to 'code/client') diff --git a/code/client/cl_cgame.c b/code/client/cl_cgame.c index 7ea1b1d..56d824f 100644 --- a/code/client/cl_cgame.c +++ b/code/client/cl_cgame.c @@ -928,6 +928,7 @@ void CL_FirstSnapshot( void ) { speex_bits_reset(&clc.speexDecoderBits[i]); clc.speexDecoder[i] = speex_decoder_init(&speex_nb_mode); clc.voipIgnore[i] = qfalse; + clc.voipGain[i] = 1.0f; } speex_encoder_ctl(clc.speexEncoder, SPEEX_GET_FRAME_SIZE, &clc.speexFrameSize); diff --git a/code/client/cl_main.c b/code/client/cl_main.c index 6c45298..43c2d65 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -190,6 +190,20 @@ void CL_UpdateVoipIgnore(const char *idstr, qboolean ignore) } } +static +void CL_UpdateVoipGain(const char *idstr, float gain) +{ + if ((*idstr >= '0') && (*idstr <= '9')) { + const int id = atoi(idstr); + if (gain < 0.0f) + gain = 0.0f; + if ((id >= 0) && (id < MAX_CLIENTS)) { + clc.voipGain[id] = gain; + Com_Printf("VoIP: player #%d gain now set to %f\n", id, gain); + } + } +} + void CL_Voip_f( void ) { const char *cmd = Cmd_Argv(1); @@ -213,6 +227,8 @@ void CL_Voip_f( void ) CL_UpdateVoipIgnore(Cmd_Argv(2), qtrue); } else if (strcmp(cmd, "unignore") == 0) { CL_UpdateVoipIgnore(Cmd_Argv(2), qfalse); + } else if (strcmp(cmd, "gain") == 0) { + CL_UpdateVoipGain(Cmd_Argv(2), atof(Cmd_Argv(3))); } else if (strcmp(cmd, "muteall") == 0) { Com_Printf("VoIP: muting incoming voice\n"); CL_AddReliableCommand("voip muteall"); diff --git a/code/client/cl_parse.c b/code/client/cl_parse.c index 294e46e..9e6d5f9 100644 --- a/code/client/cl_parse.c +++ b/code/client/cl_parse.c @@ -647,6 +647,8 @@ qboolean CL_ShouldIgnoreVoipSender(int sender) return qtrue; // all channels are muted with extreme prejudice. else if (clc.voipIgnore[sender]) return qtrue; // just ignoring this guy. + else if (clc.voipGain[sender] == 0.0f) + return qtrue; // too quiet to play. return qfalse; // !!! FIXME: implement per-channel muting. } @@ -758,7 +760,7 @@ void CL_ParseVoip ( msg_t *msg ) { Com_DPrintf("VoIP: playback %d bytes, %d samples, %d frames\n", written * 2, written, i); S_RawSamples(sender + 1, written, 8000, 2, 1, - (const byte *) decoded, 1.0f); // !!! FIXME: hardcoding! + (const byte *) decoded, clc.voipGain[sender]); // !!! FIXME: hardcoding! written = 0; } diff --git a/code/client/client.h b/code/client/client.h index 802e99f..fb15f45 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -239,6 +239,7 @@ typedef struct { void *speexDecoder[MAX_CLIENTS]; byte voipIncomingGeneration[MAX_CLIENTS]; int voipIncomingSequence[MAX_CLIENTS]; + float voipGain[MAX_CLIENTS]; qboolean voipIgnore[MAX_CLIENTS]; qboolean voipMuteAll; -- cgit v1.2.3