diff --git a/src/channel.cpp b/src/channel.cpp index b82ba886..eb00caa7 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -84,16 +84,20 @@ qRegisterMetaType ( "CHostAddress" ); SIGNAL ( ConClientListMesReceived ( CVector ) ), SIGNAL ( ConClientListMesReceived ( CVector ) ) ); - QObject::connect( &Protocol, SIGNAL ( ChangeChanGain ( int, double ) ), + QObject::connect ( &Protocol, SIGNAL ( ChangeChanGain ( int, double ) ), this, SLOT ( OnChangeChanGain ( int, double ) ) ); - QObject::connect( &Protocol, SIGNAL ( ChangeChanPan ( int, double ) ), + QObject::connect ( &Protocol, SIGNAL ( ChangeChanPan ( int, double ) ), this, SLOT ( OnChangeChanPan ( int, double ) ) ); - QObject::connect( &Protocol, SIGNAL ( ChangeChanInfo ( CChannelCoreInfo ) ), + QObject::connect ( &Protocol, + SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ), + SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ) ); + + QObject::connect ( &Protocol, SIGNAL ( ChangeChanInfo ( CChannelCoreInfo ) ), this, SLOT ( OnChangeChanInfo ( CChannelCoreInfo ) ) ); - QObject::connect( &Protocol, + QObject::connect ( &Protocol, SIGNAL ( ChatTextReceived ( QString ) ), SIGNAL ( ChatTextReceived ( QString ) ) ); @@ -105,7 +109,7 @@ qRegisterMetaType ( "CHostAddress" ); SIGNAL ( ReqNetTranspProps() ), this, SLOT ( OnReqNetTranspProps() ) ); - QObject::connect( &Protocol, + QObject::connect ( &Protocol, SIGNAL ( LicenceRequired ( ELicenceType ) ), SIGNAL ( LicenceRequired ( ELicenceType ) ) ); @@ -258,6 +262,16 @@ void CChannel::SetGain ( const int iChanID, // set value (make sure channel ID is in range) if ( ( iChanID >= 0 ) && ( iChanID < MAX_NUM_CHANNELS ) ) { + // signal mute change + if ( ( vecdGains[iChanID] == 0 ) && ( dNewGain > 0 ) ) + { + emit MuteStateHasChanged ( iChanID, false ); + } + if ( ( vecdGains[iChanID] > 0 ) && ( dNewGain == 0 ) ) + { + emit MuteStateHasChanged ( iChanID, true ); + } + vecdGains[iChanID] = dNewGain; } } diff --git a/src/channel.h b/src/channel.h index 0db2095c..b6cfc5bf 100755 --- a/src/channel.h +++ b/src/channel.h @@ -106,6 +106,7 @@ public: void CreateReqChanInfoMes() { Protocol.CreateReqChanInfoMes(); } void CreateVersionAndOSMes() { Protocol.CreateVersionAndOSMes(); } + void CreateMuteStateHasChangedMes ( const int iChanID, const bool bIsMuted ) { Protocol.CreateMuteStateHasChangedMes ( iChanID, bIsMuted ); } void SetGain ( const int iChanID, const double dNewGain ); double GetGain ( const int iChanID ); @@ -277,6 +278,8 @@ signals: void ReqConnClientsList(); void ConClientListMesReceived ( CVector vecChanInfo ); void ChanInfoHasChanged(); + void MuteStateHasChanged ( int iChanID, bool bIsMuted ); + void MuteStateHasChangedReceived ( int iChanID, bool bIsMuted ); void ReqChanInfo(); void ChatTextReceived ( QString strChatText ); void ReqNetTranspProps(); diff --git a/src/client.cpp b/src/client.cpp index e0bd3490..99f4f588 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -156,7 +156,11 @@ CClient::CClient ( const quint16 iPortNumber, SIGNAL ( ChatTextReceived ( QString ) ), SIGNAL ( ChatTextReceived ( QString ) ) ); - QObject::connect( &Channel, + QObject::connect ( &Channel, + SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ), + SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ) ); + + QObject::connect ( &Channel, SIGNAL ( LicenceRequired ( ELicenceType ) ), SIGNAL ( LicenceRequired ( ELicenceType ) ) ); diff --git a/src/client.h b/src/client.h index 353dbe3e..743a9ff4 100755 --- a/src/client.h +++ b/src/client.h @@ -420,6 +420,7 @@ public slots: signals: void ConClientListMesReceived ( CVector vecChanInfo ); void ChatTextReceived ( QString strChatText ); + void MuteStateHasChangedReceived ( int iChanID, bool bIsMuted ); void LicenceRequired ( ELicenceType eLicenceType ); void VersionAndOSReceived ( COSUtil::EOpSystemType eOSType, QString strVersion ); void PingTimeReceived ( int iPingTime ); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 54894b6b..0f89a794 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -466,6 +466,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP, SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceived ( QString ) ) ); + QObject::connect ( pClient, + SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ), + this, SLOT ( OnMuteStateHasChangedReceived ( int, bool ) ) ); + // This connection is a special case. On receiving a licence required message via the // protocol, a modal licence dialog is opened. Since this blocks the thread, we need // a queued connection to make sure the core protocol mechanism is not blocked, too. @@ -776,6 +780,14 @@ void CClientDlg::OnChatTextReceived ( QString strChatText ) UpdateDisplay(); } +void CClientDlg::OnMuteStateHasChangedReceived ( int iChanID, bool bIsMuted ) +{ + +// TEST +qDebug() << "mute state changed: iChanID " << iChanID << " bIsMuted " << bIsMuted; + +} + void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType ) { // right now only the creative common licence is supported diff --git a/src/clientdlg.h b/src/clientdlg.h index 3863b26c..3146aa13 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -167,6 +167,7 @@ public slots: void OnConClientListMesReceived ( CVector vecChanInfo ); void OnChatTextReceived ( QString strChatText ); + void OnMuteStateHasChangedReceived ( int iChanID, bool bIsMuted ); void OnLicenceRequired ( ELicenceType eLicenceType ); void OnChangeChanGain ( int iId, double dGain ) diff --git a/src/protocol.cpp b/src/protocol.cpp index ba279e85..b076d198 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -71,6 +71,13 @@ MESSAGES (with connection) +-------------------+-----------------+ +- PROTMESSID_MUTE_STATE_CHANGED: Mute state of your signal at another client has changed + + +-------------------+-----------------+ + | 1 byte channel ID | 1 byte is muted | + +-------------------+-----------------+ + + - PROTMESSID_CONN_CLIENTS_LIST: Information about connected clients for each connected client append following data: @@ -590,6 +597,10 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; bRet = EvaluateChanPanMes ( vecbyMesBodyData ); break; + case PROTMESSID_MUTE_STATE_CHANGED: + bRet = EvaluateMuteStateHasChangedMes ( vecbyMesBodyData ); + break; + case PROTMESSID_CONN_CLIENTS_LIST: bRet = EvaluateConClientListMes ( vecbyMesBodyData ); break; @@ -872,6 +883,43 @@ bool CProtocol::EvaluateChanPanMes ( const CVector &vecData ) return false; // no error } +void CProtocol::CreateMuteStateHasChangedMes ( const int iChanID, const bool bIsMuted ) +{ + CVector vecData ( 2 ); // 2 bytes of data + int iPos = 0; // init position pointer + + // build data vector + // channel ID + PutValOnStream ( vecData, iPos, static_cast ( iChanID ), 1 ); + + // mute state + PutValOnStream ( vecData, iPos, static_cast ( bIsMuted ), 1 ); + + CreateAndSendMessage ( PROTMESSID_MUTE_STATE_CHANGED, vecData ); +} + +bool CProtocol::EvaluateMuteStateHasChangedMes ( const CVector &vecData ) +{ + int iPos = 0; // init position pointer + + // check size + if ( vecData.Size() != 2 ) + { + return true; // return error code + } + + // channel ID + const int iCurID = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + + // mute state + const bool bIsMuted = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + + // invoke message action + emit MuteStateHasChangedReceived ( iCurID, bIsMuted ); + + return false; // no error +} + void CProtocol::CreateConClientListMes ( const CVector& vecChanInfo ) { const int iNumClients = vecChanInfo.Size(); diff --git a/src/protocol.h b/src/protocol.h index f24bba82..599368a0 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -57,6 +57,7 @@ #define PROTMESSID_REQ_CHANNEL_LEVEL_LIST 28 // request the channel level list #define PROTMESSID_VERSION_AND_OS 29 // version number and operating system #define PROTMESSID_CHANNEL_PAN 30 // set channel pan for mix +#define PROTMESSID_MUTE_STATE_CHANGED 31 // mute state of your signal at another client has changed // message IDs of connection less messages (CLM) // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID @@ -99,6 +100,7 @@ public: void CreateReqJitBufMes(); void CreateChanGainMes ( const int iChanID, const double dGain ); void CreateChanPanMes ( const int iChanID, const double dPan ); + void CreateMuteStateHasChangedMes ( const int iChanID, const bool bIsMuted ); void CreateConClientListMes ( const CVector& vecChanInfo ); void CreateReqConnClientsList(); void CreateChanInfoMes ( const CChannelCoreInfo ChanInfo ); @@ -223,6 +225,7 @@ protected: bool EvaluateReqJitBufMes(); bool EvaluateChanGainMes ( const CVector& vecData ); bool EvaluateChanPanMes ( const CVector& vecData ); + bool EvaluateMuteStateHasChangedMes ( const CVector& vecData ); bool EvaluateConClientListMes ( const CVector& vecData ); bool EvaluateReqConnClientsList(); bool EvaluateChanInfoMes ( const CVector& vecData ); @@ -283,6 +286,7 @@ signals: void ChangeNetwBlSiFact ( int iNewNetwBlSiFact ); void ChangeChanGain ( int iChanID, double dNewGain ); void ChangeChanPan ( int iChanID, double dNewPan ); + void MuteStateHasChangedReceived ( int iCurID, bool bIsMuted ); void ConClientListMesReceived ( CVector vecChanInfo ); void ServerFullMesReceived(); void ReqConnClientsList(); diff --git a/src/server.cpp b/src/server.cpp index 55d96324..5bd91477 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -497,6 +497,9 @@ inline void CServer::connectChannelSignalsToServerSlots() void ( CServer::* pOnChatTextReceivedCh )( QString ) = &CServerSlots::OnChatTextReceivedCh; + void ( CServer::* pOnMuteStateHasChangedCh )( int, bool ) = + &CServerSlots::OnMuteStateHasChangedCh; + void ( CServer::* pOnServerAutoSockBufSizeChangeCh )( int ) = &CServerSlots::OnServerAutoSockBufSizeChangeCh; @@ -516,6 +519,10 @@ inline void CServer::connectChannelSignalsToServerSlots() QObject::connect ( &vecChannels[iCurChanID], &CChannel::ChatTextReceived, this, pOnChatTextReceivedCh ); + // other mute state has changed + QObject::connect ( &vecChannels[iCurChanID], &CChannel::MuteStateHasChanged, + this, pOnMuteStateHasChangedCh ); + // auto socket buffer size change QObject::connect ( &vecChannels[iCurChanID], &CChannel::ServerAutoSockBufSizeChange, this, pOnServerAutoSockBufSizeChangeCh ); @@ -1310,6 +1317,17 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID } } +void CServer::CreateOtherMuteStateChanged ( const int iCurChanID, + const int iOtherChanID, + const bool bIsMuted ) +{ + if ( vecChannels[iCurChanID].IsConnected() ) + { + // send message + vecChannels[iCurChanID].CreateMuteStateHasChangedMes ( iOtherChanID, bIsMuted ); + } +} + int CServer::GetFreeChan() { // look for a free channel diff --git a/src/server.h b/src/server.h index 1369f8b8..47ee5d04 100755 --- a/src/server.h +++ b/src/server.h @@ -117,22 +117,27 @@ signals: }; #endif + template class CServerSlots : public CServerSlots { - public: - void OnSendProtMessCh( CVector mess ) { SendProtMessage ( slotId - 1, mess ); } + void OnSendProtMessCh ( CVector mess ) { SendProtMessage ( slotId - 1, mess ); } void OnReqConnClientsListCh() { CreateAndSendChanListForThisChan ( slotId - 1 ); } - void OnChatTextReceivedCh( QString strChatText ) + void OnChatTextReceivedCh ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( slotId - 1, strChatText ); } - void OnServerAutoSockBufSizeChangeCh( int iNNumFra ) + void OnMuteStateHasChangedCh ( int iChanID, bool bIsMuted ) { - CreateAndSendJitBufMessage( slotId - 1, iNNumFra ); + CreateOtherMuteStateChanged ( slotId - 1, iChanID, bIsMuted ); + } + + void OnServerAutoSockBufSizeChangeCh ( int iNNumFra ) + { + CreateAndSendJitBufMessage ( slotId - 1, iNNumFra ); } protected: @@ -144,6 +149,10 @@ protected: virtual void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ) = 0; + virtual void CreateOtherMuteStateChanged ( const int iCurChanID, + const int iOtherChanID, + const bool bIsMuted ) = 0; + virtual void CreateAndSendJitBufMessage ( const int iCurChanID, const int iNNumFra ) = 0; }; @@ -256,6 +265,10 @@ protected: virtual void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ); + virtual void CreateOtherMuteStateChanged ( const int iCurChanID, + const int iOtherChanID, + const bool bIsMuted ); + virtual void CreateAndSendJitBufMessage ( const int iCurChanID, const int iNNumFra );