Calculate voip levels for other clients

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5343 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-11-22 03:02:36 +00:00
parent 36eb350dc9
commit 79689474b6
3 changed files with 24 additions and 1 deletions

View file

@ -3890,7 +3890,7 @@ static const char *PF_cs_getplayerkey_internal (unsigned int pnum, const char *k
if (pnum == csqc_playerview->playernum)
sprintf(ret, "%i", S_Voip_Loudness(false));
else
*ret = 0;
sprintf(ret, "%i", S_Voip_ClientLoudness(pnum));
}
#endif
else

View file

@ -327,6 +327,7 @@ static struct
unsigned int encsamplerate;
void *decoder[MAX_CLIENTS];
float declevel[MAX_CLIENTS];
unsigned char deccodec[MAX_CLIENTS];
unsigned char decseq[MAX_CLIENTS]; /*sender's sequence, to detect+cover minor packetloss*/
unsigned char decgen[MAX_CLIENTS]; /*last generation. if it changes, we flush speex to reset packet loss*/
@ -787,6 +788,7 @@ void S_Voip_Decode(unsigned int sender, unsigned int codec, unsigned int gen, un
s_voip.deccodec[sender] = codec;
s_voip.decgen[sender] = gen;
s_voip.decseq[sender] = seq;
s_voip.declevel[sender] = 0;
}
@ -913,7 +915,19 @@ void S_Voip_Decode(unsigned int sender, unsigned int codec, unsigned int gen, un
Con_DPrintf("%i dropped audio frames\n", drops);
if (decodesamps > 0)
{ //calculate levels of other people. eukara demanded this.
float level;
float f;
for (len = 0; len < decodesamps; len++)
{
f = decodebuf[len];
level += f*f;
}
level = (3000*level) / (32767.0f*32767*decodesamps);
s_voip.declevel[sender] = (s_voip.declevel[sender]*7 + level)/8;
S_RawAudio(sender, (qbyte*)decodebuf, s_voip.decsamplerate[sender], decodesamps, 1, 2, snd_voip_play.value);
}
}
#ifdef SUPPORT_ICE
@ -1612,6 +1626,14 @@ int S_Voip_Loudness(qboolean ignorevad)
return -1;
return s_voip.voiplevel;
}
int S_Voip_ClientLoudness(unsigned int plno)
{
if (plno >= MAX_CLIENTS)
return 0;
if (s_voip.lastspoke[plno] > realtime)
return s_voip.declevel[plno];
return -1;
}
qboolean S_Voip_Speaking(unsigned int plno)
{
if (plno >= MAX_CLIENTS)

View file

@ -232,6 +232,7 @@ extern cvar_t snd_voip_showmeter;
void S_Voip_Transmit(unsigned char clc, sizebuf_t *buf);
void S_Voip_MapChange(void);
int S_Voip_Loudness(qboolean ignorevad); //-1 for not capturing, otherwise between 0 and 100
int S_Voip_ClientLoudness(unsigned int plno);
qboolean S_Voip_Speaking(unsigned int plno);
void S_Voip_Ignore(unsigned int plno, qboolean ignore);
#else