123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- #ifndef __SYS_VOICECHATMGR_H__
- #define __SYS_VOICECHATMGR_H__
- #include "sys_lobby_backend.h"
- class idVoiceChatMgr {
- public:
- idVoiceChatMgr() : activeLobbyType( -1 ), activeGroupIndex( 0 ), sendFrame( 0 ), disableVoiceReasons( 0 ), sendGlobal( false ) {}
-
- virtual void Init( void * pXAudio2 );
- virtual void Shutdown();
- 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 );
- void SetActiveLobby( int lobbyType );
- void SetActiveChatGroup( int groupIndex );
- int FindTalkerByUserId( lobbyUserID_t lobbyUserID, int lobbyType );
- bool GetLocalChatData( int talkerIndex, byte * data, int & dataSize );
- void SubmitIncomingChatData( const byte * data, int dataSize );
- voiceState_t GetVoiceState( const lobbyUser_t * user );
- bool CanSendVoiceTo( int talkerFromIndex, int talkerToIndex );
- bool IsRestrictedByPrivleges();
- void SetHeadsetState( int talkerIndex, bool state );
- bool GetHeadsetState( int talkerIndex ) const { return talkers[ talkerIndex ].hasHeadset; }
- bool HasHeadsetStateChanged( int talkerIndex );
- enum disableVoiceReason_t {
- REASON_GENERIC = BIT( 0 ),
- REASON_PRIVILEGES = BIT( 1 ),
- };
- void SetDisableVoiceReason( disableVoiceReason_t reason );
- void ClearDisableVoiceReason( disableVoiceReason_t reason );
- virtual bool GetLocalChatDataInternal( int talkerIndex, byte * data, int & dataSize ) = 0;
- virtual void SubmitIncomingChatDataInternal( int talkerIndex, const byte * data, int dataSize ) = 0;
- virtual bool TalkerHasData( int talkerIndex ) = 0;
- virtual void Pump() {}
- virtual void FlushBuffers() {}
- virtual void ToggleMuteLocal( const lobbyUser_t * src, const lobbyUser_t * target );
- protected:
- struct remoteMachine_t {
- int lobbyType;
- lobbyAddress_t address;
- int refCount;
- int sendFrame;
- };
- struct talker_t {
- talker_t() :
- user( NULL ),
- isLocal( false ),
- lobbyType( -1 ),
- groupIndex( -1 ),
- registered( false ),
- registeredSuccess( false ),
- machineIndex( -1 ),
- isMuted( false ),
- hasHeadset( true ),
- hasHeadsetChanged( false ),
- talking( false ),
- talkingGlobal( false ),
- talkingTime( 0 )
- {}
- lobbyUser_t * user;
- bool isLocal;
- int lobbyType;
- int groupIndex;
- bool registered;
- bool registeredSuccess;
- int machineIndex;
- bool isMuted;
- bool hasHeadset;
- bool hasHeadsetChanged;
- bool talking;
- bool talkingGlobal;
- int talkingTime;
- bool IsLocal() const { return isLocal; }
- };
- virtual bool RegisterTalkerInternal( int index ) = 0;
- virtual void UnregisterTalkerInternal( int index ) = 0;
- int FindTalkerIndex( const lobbyUser_t * user, int lobbyType );
- int FindMachine( const lobbyAddress_t & address, int lobbyType );
- int AddMachine( const lobbyAddress_t & address, int lobbyType );
- void RemoveMachine( int machineIndex, int lobbyType );
- void UpdateRegisteredTalkers();
-
- idStaticList< talker_t, MAX_PLAYERS * 2 > talkers;
- idStaticList< remoteMachine_t, MAX_PLAYERS * 2 > remoteMachines;
-
- int activeLobbyType;
- int activeGroupIndex;
- int sendFrame;
- uint32 disableVoiceReasons;
- bool sendGlobal;
- };
- #endif
|