diff --git a/src/channel.cpp b/src/channel.cpp index 217510c0..d88ec827 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -263,6 +263,9 @@ void CChannel::SetNetwInBlSiFact ( const int iNewBlockSizeFactor ) // initial value for connection time out counter iConTimeOutStartVal = ( CON_TIME_OUT_SEC_MAX * 1000 ) / ( iNewBlockSizeFactor * MIN_BLOCK_DURATION_MS ); + + // socket buffer must be adjusted + SetSockBufSize ( GetSockBufSize() ); } void CChannel::SetNetwOutBlSiFact ( const int iNewBlockSizeFactor ) @@ -298,6 +301,8 @@ void CChannel::SetSockBufSize ( const int iNumBlocks ) /* this opperation must be done with mutex */ Mutex.lock (); { + iCurSockBufSize = iNumBlocks; + // the idea of setting the jitter buffer is as follows: // The network block size is a multiple of the internal minimal // block size. Therefore, the minimum jitter buffer size must be @@ -305,17 +310,11 @@ void CChannel::SetSockBufSize ( const int iNumBlocks ) // The actual jitter compensation are then the additional blocks of // the internal block size, which is set with SetSockBufSize SockBuf.Init ( MIN_BLOCK_SIZE_SAMPLES, - iNumBlocks + NET_BLOCK_SIZE_FACTOR ); + iNumBlocks + iCurNetwInBlSiFact ); } Mutex.unlock (); } -int CChannel::GetSockBufSize() -{ - // see comment in SetSockBufSize function - return SockBuf.GetSize() - NET_BLOCK_SIZE_FACTOR; -} - void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) { // TEST @@ -328,15 +327,10 @@ qDebug ( "new jitter buffer size: %d", iNewJitBufSize ); // network buffer size factor void CChannel::SetNetwBufSizeFact ( const int iNetNetwBlSiFact ) { - /* this opperation must be done with mutex */ - Mutex.lock (); - { - iCurNetwBlSiFact = iNetNetwBlSiFact; + iCurNetwBlSiFact = iNetNetwBlSiFact; - SetNetwInBlSiFact ( iNetNetwBlSiFact ); - SetNetwOutBlSiFact ( iNetNetwBlSiFact ); - } - Mutex.unlock (); + SetNetwInBlSiFact ( iNetNetwBlSiFact ); + SetNetwOutBlSiFact ( iNetNetwBlSiFact ); } void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact ) @@ -411,7 +405,10 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) { else { // only use protocol data if channel is connected - if ( IsConnected() ) + +// must be disabled to be able to receive network buffer size factor changes +// if ( IsConnected() ) + { // this seems not to be an audio block, parse the message if ( Protocol.ParseMessage ( vecbyData, iNumBytes ) ) @@ -474,6 +471,13 @@ CVector CChannel::PrepSendPacket(const CVector& vecsNPacke /* a packet is ready, compress audio */ vecbySendBuf.Init ( iAudComprSizeOut ); vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get () ); + } + + // if we are not connected, send network buffer size factor so that the + // server is able to process our audio packets + if ( !IsConnected() ) + { + Protocol.CreateNetwBlSiFactMes ( iCurNetwBlSiFact ); } return vecbySendBuf; diff --git a/src/channel.h b/src/channel.h index 04e54c62..5cbcc5d1 100755 --- a/src/channel.h +++ b/src/channel.h @@ -81,7 +81,7 @@ public: CHostAddress GetAddress () { return InetAddr; } void SetSockBufSize ( const int iNumBlocks ); - int GetSockBufSize(); + int GetSockBufSize() { return iCurSockBufSize; } void SetNetwBufSizeFact ( const int iNetNetwBlSiFact ); int GetNetwBufSizeFact() { return iCurNetwBlSiFact; } @@ -126,6 +126,7 @@ protected: /* network jitter-buffer */ CNetBuf SockBuf; + int iCurSockBufSize; /* network output conversion buffer */ CConvBuf ConvBuf; diff --git a/src/client.cpp b/src/client.cpp index 7e24455d..a91018ae 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -53,6 +53,15 @@ for ( int i = 0; i < vecMessage.Size (); i++ ) { // send it through the network Socket.SendPacket ( vecbyDataConv, Channel.GetAddress () ); } + +void CClient::OnReqJittBufSize() +{ + Channel.CreateJitBufMes ( Channel.GetSockBufSize() ); + +// FIXME: we set the network buffer size factor here, too -> in the +// future a separate request function for this parameter should be created + Channel.CreateNetwBlSiFactMes ( Channel.GetNetwBufSizeFact() ); +} bool CClient::SetServerAddr(QString strNAddr) { diff --git a/src/client.h b/src/client.h index 3f282e85..294a70de 100755 --- a/src/client.h +++ b/src/client.h @@ -157,7 +157,7 @@ protected: public slots: void OnSendProtMessage ( CVector vecMessage ); - void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufSize() ); } + void OnReqJittBufSize(); }; diff --git a/src/llconclientdlgbase.ui b/src/llconclientdlgbase.ui index fafcb72c..a9eb4cb6 100755 --- a/src/llconclientdlgbase.ui +++ b/src/llconclientdlgbase.ui @@ -11,8 +11,8 @@ 0 0 - 890 - 288 + 897 + 287 @@ -789,6 +789,42 @@ Both + + QLabel + + name + TextLabel2_2 + + + text + Check Ping + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + TextLabel2_3 + + + text + Time! + + + alignment + AlignCenter + + + hAlign + +