mirror of
https://github.com/ioquake/ioq3.git
synced 2025-05-30 00:20:59 +00:00
Use Opus for VoIP
Server/client VoIP protocol is handled by adding new cvars cl_voipProtocol and sv_voipProtocol, sv_voip and cl_voip are used to auto set/clear them. All users need to touch are cl/sv_voip as 0 or 1 just like before. Old Speex VoIP packets in demos are skipped. New VoIP packets are skipped in demos if sv_voipProtocol doesn't match cl_voipProtocol. Notable difference between usage of speex and opus codecs, when using Speex client would be sent 80ms at a time. Using Opus, 60ms is sent at a time. This was changed because the Opus codec supports encoding up to 60ms at a time. (Simpler to send only one codec frame in a packet.)
This commit is contained in:
parent
fe619680f8
commit
615b73288f
13 changed files with 167 additions and 240 deletions
|
@ -1459,8 +1459,8 @@ void SV_UserinfoChanged( client_t *cl ) {
|
|||
else
|
||||
#endif
|
||||
{
|
||||
val = Info_ValueForKey(cl->userinfo, "cl_voip");
|
||||
cl->hasVoip = atoi(val);
|
||||
val = Info_ValueForKey(cl->userinfo, "cl_voipProtocol");
|
||||
cl->hasVoip = !Q_stricmp( val, "opus" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1794,7 +1794,7 @@ static qboolean SV_ShouldIgnoreVoipSender(const client_t *cl)
|
|||
}
|
||||
|
||||
static
|
||||
void SV_UserVoip(client_t *cl, msg_t *msg)
|
||||
void SV_UserVoip(client_t *cl, msg_t *msg, qboolean ignoreData)
|
||||
{
|
||||
int sender, generation, sequence, frames, packetsize;
|
||||
uint8_t recips[(MAX_CLIENTS + 7) / 8];
|
||||
|
@ -1829,12 +1829,12 @@ void SV_UserVoip(client_t *cl, msg_t *msg)
|
|||
|
||||
MSG_ReadData(msg, encoded, packetsize);
|
||||
|
||||
if (SV_ShouldIgnoreVoipSender(cl))
|
||||
if (ignoreData || SV_ShouldIgnoreVoipSender(cl))
|
||||
return; // Blacklisted, disabled, etc.
|
||||
|
||||
// !!! FIXME: see if we read past end of msg...
|
||||
|
||||
// !!! FIXME: reject if not speex narrowband codec.
|
||||
// !!! FIXME: reject if not opus data.
|
||||
// !!! FIXME: decide if this is bogus data?
|
||||
|
||||
// decide who needs this VoIP packet sent to them...
|
||||
|
@ -1983,10 +1983,18 @@ void SV_ExecuteClientMessage( client_t *cl, msg_t *msg ) {
|
|||
}
|
||||
} while ( 1 );
|
||||
|
||||
// read optional voip data
|
||||
if ( c == clc_voip ) {
|
||||
// skip legacy speex voip data
|
||||
if ( c == clc_voipSpeex ) {
|
||||
#ifdef USE_VOIP
|
||||
SV_UserVoip( cl, msg );
|
||||
SV_UserVoip( cl, msg, qtrue );
|
||||
c = MSG_ReadByte( msg );
|
||||
#endif
|
||||
}
|
||||
|
||||
// read optional voip data
|
||||
if ( c == clc_voipOpus ) {
|
||||
#ifdef USE_VOIP
|
||||
SV_UserVoip( cl, msg, qfalse );
|
||||
c = MSG_ReadByte( msg );
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue