diff --git a/ChangeLog b/ChangeLog index d98ac5f4..8080c7ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,10 +11,12 @@ - display recorder state and latest recording directory in the server GUI, allow a new recording to be requested, by pljones (#228) +- New Client Level now also applies if you enter a server + - bug fix: audio fader sliders cannot be moved if the main windows is too small (#292) -TODO create protocol message to inform client about its ID at the server +TODO honour own fader and Mute button in Mute Myself (#148) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index c27062c8..9515a661 100644 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -613,6 +613,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : bDisplayPans ( false ), bIsPanSupported ( false ), bNoFaderVisible ( true ), + iMyChannelID ( INVALID_INDEX ), strServerName ( "" ) { // add group box and hboxlayout @@ -756,6 +757,7 @@ void CAudioMixerBoard::HideAll() // set flags bIsPanSupported = false; bNoFaderVisible = true; + iMyChannelID = INVALID_INDEX; // emit status of connected clients emit NumClientsChanged ( 0 ); // -> no clients connected @@ -796,9 +798,13 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf // Set the default initial fader level. Check first that // this is not the initialization (i.e. previously there // were no faders visible) to avoid that our own level is - // adjusted. The fader level of 100 % is the default in the + // adjusted. If we have received our own channel ID, then + // we can adjust the level even if no fader was visible. + // The fader level of 100 % is the default in the // server, in that case we do not have to do anything here. - if ( !bNoFaderVisible && ( iNewClientFaderLevel != 100 ) ) + if ( ( !bNoFaderVisible || + ( ( iMyChannelID != INVALID_INDEX ) && ( iMyChannelID != i ) ) ) && + ( iNewClientFaderLevel != 100 ) ) { // the value is in percent -> convert range vecpChanFader[i]->SetFaderLevel ( static_cast ( diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index c072239f..29a5fdc2 100644 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -147,6 +147,7 @@ public: void SetDisplayPans ( const bool eNDP ); void SetPanIsSupported(); void SetRemoteFaderIsMute ( const int iChannelIdx, const bool bIsMute ); + void SetMyChannelID ( const int iChanID ) { iMyChannelID = iChanID; } void SetFaderLevel ( const int iChannelIdx, const int iValue ); @@ -196,6 +197,7 @@ protected: bool bDisplayPans; bool bIsPanSupported; bool bNoFaderVisible; + int iMyChannelID; QString strServerName; virtual void UpdateGainValue ( const int iChannelIdx, diff --git a/src/channel.cpp b/src/channel.cpp index eb00caa7..4e6aa136 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -90,6 +90,10 @@ qRegisterMetaType ( "CHostAddress" ); QObject::connect ( &Protocol, SIGNAL ( ChangeChanPan ( int, double ) ), this, SLOT ( OnChangeChanPan ( int, double ) ) ); + QObject::connect ( &Protocol, + SIGNAL ( ClientIDReceived ( int ) ), + SIGNAL ( ClientIDReceived ( int ) ) ); + QObject::connect ( &Protocol, SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ), SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ) ); diff --git a/src/channel.h b/src/channel.h index b6cfc5bf..ec62e84a 100755 --- a/src/channel.h +++ b/src/channel.h @@ -157,6 +157,7 @@ public: Protocol.CreateJitBufMes ( iJitBufSize ); } } + void CreateClientIDMes ( const int iChanID ) { Protocol.CreateClientIDMes ( iChanID ); } void CreateReqNetwTranspPropsMes() { Protocol.CreateReqNetwTranspPropsMes(); } void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } @@ -278,6 +279,7 @@ signals: void ReqConnClientsList(); void ConClientListMesReceived ( CVector vecChanInfo ); void ChanInfoHasChanged(); + void ClientIDReceived ( int iChanID ); void MuteStateHasChanged ( int iChanID, bool bIsMuted ); void MuteStateHasChangedReceived ( int iChanID, bool bIsMuted ); void ReqChanInfo(); diff --git a/src/client.cpp b/src/client.cpp index 7792591b..9d22c818 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -157,6 +157,10 @@ CClient::CClient ( const quint16 iPortNumber, SIGNAL ( ChatTextReceived ( QString ) ), SIGNAL ( ChatTextReceived ( QString ) ) ); + QObject::connect ( &Channel, + SIGNAL ( ClientIDReceived ( int ) ), + SIGNAL ( ClientIDReceived ( int ) ) ); + QObject::connect ( &Channel, SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ), SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ) ); diff --git a/src/client.h b/src/client.h index b405bb4a..368edd9d 100755 --- a/src/client.h +++ b/src/client.h @@ -424,6 +424,7 @@ public slots: signals: void ConClientListMesReceived ( CVector vecChanInfo ); void ChatTextReceived ( QString strChatText ); + void ClientIDReceived ( int iChanID ); void MuteStateHasChangedReceived ( int iChanID, bool bIsMuted ); void LicenceRequired ( ELicenceType eLicenceType ); void VersionAndOSReceived ( COSUtil::EOpSystemType eOSType, QString strVersion ); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index a4f33257..3bfb457b 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -461,6 +461,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP, SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceived ( QString ) ) ); + QObject::connect ( pClient, + SIGNAL ( ClientIDReceived ( int ) ), + this, SLOT ( OnClientIDReceived ( int ) ) ); + QObject::connect ( pClient, SIGNAL ( MuteStateHasChangedReceived ( int, bool ) ), this, SLOT ( OnMuteStateHasChangedReceived ( int, bool ) ) ); diff --git a/src/clientdlg.h b/src/clientdlg.h index 06f8298b..ffddbf0e 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -198,6 +198,9 @@ public slots: CVector vecChanInfo ) { ConnectDlg.SetConnClientsList ( InetAddr, vecChanInfo ); } + void OnClientIDReceived ( int iChanID ) + { MainMixerBoard->SetMyChannelID ( iChanID ); } + void OnMuteStateHasChangedReceived ( int iChanID, bool bIsMuted ) { MainMixerBoard->SetRemoteFaderIsMute ( iChanID, bIsMuted ); } diff --git a/src/protocol.cpp b/src/protocol.cpp index d4921857..4c33607f 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -57,6 +57,13 @@ MESSAGES (with connection) note: does not have any data -> n = 0 +- PROTMESSID_CLIENT_ID: Sends the current client ID to the client + + +---------------------------------+ + | 1 byte channel ID of the client | + +---------------------------------+ + + - PROTMESSID_CHANNEL_GAIN: Gain of channel +-------------------+--------------+ @@ -168,6 +175,7 @@ MESSAGES (with connection) | 1 byte licence type | +---------------------+ + - PROTMESSID_REQ_CHANNEL_LEVEL_LIST: Opt in or out of the channel level list +---------------+ @@ -176,6 +184,7 @@ MESSAGES (with connection) option is boolean, true to opt in, false to opt out + - PROTMESSID_VERSION_AND_OS: Version number and operating system +-------------------------+------------------+------------------------------+ @@ -589,6 +598,10 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; bRet = EvaluateReqJitBufMes(); break; + case PROTMESSID_CLIENT_ID: + bRet = EvaluateClientIDMes ( vecbyMesBodyData ); + break; + case PROTMESSID_CHANNEL_GAIN: bRet = EvaluateChanGainMes ( vecbyMesBodyData ); break; @@ -798,6 +811,37 @@ bool CProtocol::EvaluateReqJitBufMes() return false; // no error } +void CProtocol::CreateClientIDMes ( const int iChanID ) +{ + CVector vecData ( 1 ); // 1 byte of data + int iPos = 0; // init position pointer + + // build data vector + // channel ID + PutValOnStream ( vecData, iPos, static_cast ( iChanID ), 1 ); + + CreateAndSendMessage ( PROTMESSID_CLIENT_ID, vecData ); +} + +bool CProtocol::EvaluateClientIDMes ( const CVector& vecData ) +{ + int iPos = 0; // init position pointer + + // check size + if ( vecData.Size() != 1 ) + { + return true; // return error code + } + + // channel ID + const int iCurID = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + + // invoke message action + emit ClientIDReceived ( iCurID ); + + return false; // no error +} + void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain ) { CVector vecData ( 3 ); // 3 bytes of data diff --git a/src/protocol.h b/src/protocol.h index 599368a0..962d3f79 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -58,6 +58,7 @@ #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 +#define PROTMESSID_CLIENT_ID 32 // current user ID and server status // message IDs of connection less messages (CLM) // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID @@ -98,6 +99,7 @@ public: void CreateJitBufMes ( const int iJitBufSize ); void CreateReqJitBufMes(); + void CreateClientIDMes ( const int iChanID ); void CreateChanGainMes ( const int iChanID, const double dGain ); void CreateChanPanMes ( const int iChanID, const double dPan ); void CreateMuteStateHasChangedMes ( const int iChanID, const bool bIsMuted ); @@ -223,6 +225,7 @@ protected: bool EvaluateJitBufMes ( const CVector& vecData ); bool EvaluateReqJitBufMes(); + bool EvaluateClientIDMes ( const CVector& vecData ); bool EvaluateChanGainMes ( const CVector& vecData ); bool EvaluateChanPanMes ( const CVector& vecData ); bool EvaluateMuteStateHasChangedMes ( const CVector& vecData ); @@ -284,6 +287,7 @@ signals: void ChangeJittBufSize ( int iNewJitBufSize ); void ReqJittBufSize(); void ChangeNetwBlSiFact ( int iNewNetwBlSiFact ); + void ClientIDReceived ( int iChanID ); void ChangeChanGain ( int iChanID, double dNewGain ); void ChangeChanPan ( int iChanID, double dNewPan ); void MuteStateHasChangedReceived ( int iCurID, bool bIsMuted ); diff --git a/src/server.cpp b/src/server.cpp index 1b8d72e9..ff469f4d 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -466,7 +466,7 @@ CServer::CServer ( const int iNewMaxNumChan, QObject::connect ( &ServerListManager, SIGNAL ( SvrRegStatusChanged() ), - this, SLOT ( OnSvrRegStatusChanged() ) ); + SIGNAL ( SvrRegStatusChanged() ) ); QObject::connect( &JamRecorder, SIGNAL ( RecordingSessionStarted ( QString ) ), @@ -553,6 +553,10 @@ void CServer::SendProtMessage ( int iChID, CVector vecMessage ) void CServer::OnNewConnection ( int iChID, CHostAddress RecHostAddr ) { + // inform the client about its own ID at the server (note that this + // must be the first message to be sent for a new connection) + vecChannels[iChID].CreateClientIDMes ( iChID ); + // on a new connection we query the network transport properties for the // audio packets (to use the correct network block size and audio // compression properties, etc.) diff --git a/src/server.h b/src/server.h index 241fe119..8c401304 100755 --- a/src/server.h +++ b/src/server.h @@ -450,8 +450,6 @@ public slots: ServerListManager.StoreRegistrationResult ( eResult ); } - void OnSvrRegStatusChanged() { emit SvrRegStatusChanged(); } - void OnCLUnregisterServerReceived ( CHostAddress InetAddr ) { ServerListManager.CentralServerUnregisterServer ( InetAddr );