2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#ifndef __SYS_VOICECHATMGR_H__
|
|
|
|
#define __SYS_VOICECHATMGR_H__
|
|
|
|
|
|
|
|
#include "sys_lobby_backend.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
idVoiceChatMgr
|
|
|
|
================================================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
class idVoiceChatMgr
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idVoiceChatMgr() : activeLobbyType( -1 ), activeGroupIndex( 0 ), sendFrame( 0 ), disableVoiceReasons( 0 ), sendGlobal( false ) {}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( void* pXAudio2 );
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual void Shutdown();
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void RegisterTalker( lobbyUser_t* user, int lobbyType, bool isLocal );
|
|
|
|
void UnregisterTalker( lobbyUser_t* user, int lobbyType, bool isLocal );
|
|
|
|
void GetActiveLocalTalkers( idStaticList< int, MAX_PLAYERS >& localTalkers );
|
|
|
|
void GetRecipientsForTalker( int talkerIndex, idStaticList< const lobbyAddress_t*, MAX_PLAYERS >& recipients );
|
|
|
|
|
|
|
|
void SetTalkerGroup( const lobbyUser_t* user, int lobbyType, int groupIndex );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void SetActiveLobby( int lobbyType );
|
|
|
|
void SetActiveChatGroup( int groupIndex );
|
|
|
|
int FindTalkerByUserId( lobbyUserID_t lobbyUserID, int lobbyType );
|
2012-11-28 15:47:07 +00:00
|
|
|
bool GetLocalChatData( int talkerIndex, byte* data, int& dataSize );
|
|
|
|
void SubmitIncomingChatData( const byte* data, int dataSize );
|
|
|
|
voiceState_t GetVoiceState( const lobbyUser_t* user );
|
2012-11-26 18:58:24 +00:00
|
|
|
bool CanSendVoiceTo( int talkerFromIndex, int talkerToIndex );
|
|
|
|
bool IsRestrictedByPrivleges();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void SetHeadsetState( int talkerIndex, bool state );
|
2012-11-28 15:47:07 +00:00
|
|
|
bool GetHeadsetState( int talkerIndex ) const
|
|
|
|
{
|
|
|
|
return talkers[ talkerIndex ].hasHeadset;
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
bool HasHeadsetStateChanged( int talkerIndex );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
enum disableVoiceReason_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
REASON_GENERIC = BIT( 0 ),
|
|
|
|
REASON_PRIVILEGES = BIT( 1 ),
|
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void SetDisableVoiceReason( disableVoiceReason_t reason );
|
|
|
|
void ClearDisableVoiceReason( disableVoiceReason_t reason );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual bool GetLocalChatDataInternal( int talkerIndex, byte* data, int& dataSize ) = 0;
|
|
|
|
virtual void SubmitIncomingChatDataInternal( int talkerIndex, const byte* data, int dataSize ) = 0;
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual bool TalkerHasData( int talkerIndex ) = 0;
|
|
|
|
virtual void Pump() {}
|
|
|
|
virtual void FlushBuffers() {}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ToggleMuteLocal( const lobbyUser_t* src, const lobbyUser_t* target );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
struct remoteMachine_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int lobbyType;
|
|
|
|
lobbyAddress_t address;
|
|
|
|
int refCount;
|
|
|
|
int sendFrame;
|
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
struct talker_t
|
|
|
|
{
|
|
|
|
talker_t() :
|
|
|
|
user( NULL ),
|
|
|
|
isLocal( false ),
|
|
|
|
lobbyType( -1 ),
|
|
|
|
groupIndex( -1 ),
|
|
|
|
registered( false ),
|
2012-11-26 18:58:24 +00:00
|
|
|
registeredSuccess( false ),
|
|
|
|
machineIndex( -1 ),
|
|
|
|
isMuted( false ),
|
|
|
|
hasHeadset( true ),
|
|
|
|
hasHeadsetChanged( false ),
|
|
|
|
talking( false ),
|
|
|
|
talkingGlobal( false ),
|
|
|
|
talkingTime( 0 )
|
|
|
|
{}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
lobbyUser_t* user;
|
2012-11-26 18:58:24 +00:00
|
|
|
bool isLocal;
|
|
|
|
int lobbyType;
|
|
|
|
int groupIndex;
|
|
|
|
bool registered; // True if this user is currently registered with the XHV engine
|
|
|
|
bool registeredSuccess; // True if this user is currently successfully registered with the XHV engine
|
|
|
|
int machineIndex; // Index into remote machines array (-1 if this is a local talker)
|
|
|
|
bool isMuted; // This machine is not allowed to hear or talk to this player
|
|
|
|
bool hasHeadset; // This user has a headset connected
|
|
|
|
bool hasHeadsetChanged; // This user's headset state has changed
|
|
|
|
bool talking;
|
|
|
|
bool talkingGlobal;
|
|
|
|
int talkingTime;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
bool IsLocal() const
|
|
|
|
{
|
|
|
|
return isLocal;
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual bool RegisterTalkerInternal( int index ) = 0;
|
|
|
|
virtual void UnregisterTalkerInternal( int index ) = 0;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
int FindTalkerIndex( const lobbyUser_t* user, int lobbyType );
|
|
|
|
int FindMachine( const lobbyAddress_t& address, int lobbyType );
|
|
|
|
int AddMachine( const lobbyAddress_t& address, int lobbyType );
|
2012-11-26 18:58:24 +00:00
|
|
|
void RemoveMachine( int machineIndex, int lobbyType );
|
|
|
|
void UpdateRegisteredTalkers();
|
|
|
|
|
2014-02-23 14:19:11 +00:00
|
|
|
idStaticList< talker_t, MAX_PLAYERS * 2 > talkers; // * 2 to account for handling both session types
|
|
|
|
idStaticList< remoteMachine_t, MAX_PLAYERS * 2 > remoteMachines; // * 2 to account for handling both session types
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
int activeLobbyType;
|
|
|
|
int activeGroupIndex;
|
|
|
|
int sendFrame;
|
|
|
|
uint32 disableVoiceReasons;
|
|
|
|
bool sendGlobal;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __SYS_VOICECHATMGR_H__
|