fixes for network buffer size factor setting
This commit is contained in:
parent
6c6ce5bd04
commit
fd51ba29f4
5 changed files with 70 additions and 20 deletions
|
@ -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<unsigned char> CChannel::PrepSendPacket(const CVector<short>& 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -157,7 +157,7 @@ protected:
|
|||
|
||||
public slots:
|
||||
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
||||
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufSize() ); }
|
||||
void OnReqJittBufSize();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>890</width>
|
||||
<height>288</height>
|
||||
<width>897</width>
|
||||
<height>287</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
|
@ -789,6 +789,42 @@
|
|||
<enum>Both</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>TextLabel2_2</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Check Ping</string>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>alignment</name>
|
||||
<set>AlignCenter</set>
|
||||
</property>
|
||||
<property>
|
||||
<name>hAlign</name>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>TextLabel2_3</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Time!</string>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>alignment</name>
|
||||
<set>AlignCenter</set>
|
||||
</property>
|
||||
<property>
|
||||
<name>hAlign</name>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget>
|
||||
|
|
Loading…
Reference in a new issue