jitter buffer settings only allow settings for buffers larger than the network buffer block size

This commit is contained in:
Volker Fischer 2006-03-12 10:43:48 +00:00
parent 47f60d317e
commit 24680bbab4
4 changed files with 38 additions and 27 deletions

View file

@ -293,12 +293,25 @@ void CChannel::SetSockBufSize ( const int iNumBlocks )
{
/* this opperation must be done with mutex */
Mutex.lock ();
{
SockBuf.Init ( MIN_BLOCK_SIZE_SAMPLES, 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
// so that it can take one network buffer -> NET_BLOCK_SIZE_FACTOR.
// 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 );
}
Mutex.unlock ();
}
int CChannel::GetSockBufSize()
{
// see comment in SetSockBufSize function
return SockBuf.GetSize() - NET_BLOCK_SIZE_FACTOR;
}
void CChannel::OnJittBufSizeChange ( int iNewJitBufSize )
{
// TEST
@ -324,16 +337,19 @@ bool CChannel::GetAddress(CHostAddress& RetAddr)
EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
int iNumBytes )
{
EPutDataStat eRet = PS_GEN_ERROR;
EPutDataStat eRet = PS_GEN_ERROR;
bool bNewConnection = false;
/* only process if packet has correct size */
if ( iNumBytes == iAudComprSizeIn )
{
/* decompress audio */
CVector<short> vecsDecomprAudio ( AudioCompressionIn.Decode ( vecbyData ) );
Mutex.lock ();
{
/* decompress audio */
CVector<short> vecsDecomprAudio ( AudioCompressionIn.Decode ( vecbyData ) );
/* do resampling to compensate for sample rate offsets in the
different sound cards of the clients */
/* do resampling to compensate for sample rate offsets in the
different sound cards of the clients */
/*
for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++)
vecdResInData[i] = (double) vecsData[i];
@ -347,9 +363,6 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
vecdResOutData[i] = (double) vecsDecomprAudio[i];
}
Mutex.lock (); /* put mutex lock */
{
if ( SockBuf.Put ( vecdResOutData ) )
{
eRet = PS_AUDIO_OK;
@ -358,21 +371,14 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
{
eRet = PS_AUDIO_ERR;
}
}
Mutex.unlock (); /* put mutex unlock */
// check if channel was not connected
const bool bChanWasNotConnected = !IsConnected();
// check if channel was not connected, this is a new connection
bNewConnection = !IsConnected();
// reset time-out counter
iConTimeOut = iConTimeOutStartVal;
// if channel was not connected, emit signal to inform that new
// connection was established
if ( bChanWasNotConnected )
{
emit NewConnection();
// reset time-out counter
iConTimeOut = iConTimeOutStartVal;
}
Mutex.unlock ();
}
else
{
@ -389,7 +395,13 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
eRet = PS_PROT_ERR;
}
}
}
}
// inform other objects that new connection was established
if ( bNewConnection )
{
emit NewConnection();
}
return eRet;
}

View file

@ -81,7 +81,7 @@ public:
CHostAddress GetAddress () { return InetAddr; }
void SetSockBufSize ( const int iNumBlocks );
int GetSockBufSize() { return SockBuf.GetSize(); }
int GetSockBufSize();
// network protocol interface
void CreateJitBufMes ( const int iJitBufSize )

View file

@ -72,8 +72,7 @@
#define NET_BLOCK_SIZE_FACTOR_MAX 10
/* maximum network buffer size (which can be chosen by slider) */
#define MAX_NET_BUF_SIZE_NUM_BL 12 /* number of blocks */
#define MIN_NET_BUF_SIZE_NUM_BL NET_BLOCK_SIZE_FACTOR
#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */
/* default network buffer size */
#define DEF_NET_BUF_SIZE_NUM_BL 5 /* number of blocks */

View file

@ -94,7 +94,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
TextSndBufOut->setText("Out: " + QString().setNum(iCurNumOutBuf));
/* network buffer */
SliderNetBuf->setRange(MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL);
SliderNetBuf->setRange(0, MAX_NET_BUF_SIZE_NUM_BL);
const int iCurNumNetBuf = pClient->GetSockBufSize();
SliderNetBuf->setValue(iCurNumNetBuf);
TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf));