in/out network buffer size factors possible

This commit is contained in:
Volker Fischer 2006-03-13 20:23:05 +00:00
parent c86cbcabdb
commit 633fc9b72e
8 changed files with 145 additions and 104 deletions

View file

@ -241,7 +241,8 @@ CChannel::CChannel()
SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL );
// set initial input and output block size factors
SetNetwBufSizeFact ( NET_BLOCK_SIZE_FACTOR );
SetNetwBufSizeFactOut ( NET_BLOCK_SIZE_FACTOR );
SetNetwInBlSiFact ( NET_BLOCK_SIZE_FACTOR );
/* init time-out for the buffer with zero -> no connection */
iConTimeOut = 0;
@ -280,15 +281,26 @@ void CChannel::SetNetwInBlSiFact ( const int iNewBlockSizeFactor )
SetSockBufSize ( GetSockBufSize() );
}
void CChannel::SetNetwOutBlSiFact ( const int iNewBlockSizeFactor )
void CChannel::SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut )
{
// store new value
iCurNetwOutBlSiFact = iNewNetwBlSiFactOut;
/* init audio compression unit */
iAudComprSizeOut = AudioCompressionOut.Init (
iNewBlockSizeFactor * MIN_BLOCK_SIZE_SAMPLES,
iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES,
CAudioCompression::CT_IMAADPCM );
/* init conversion buffer */
ConvBuf.Init ( iNewBlockSizeFactor * MIN_BLOCK_SIZE_SAMPLES );
ConvBuf.Init ( iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES );
}
void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact )
{
// TEST
qDebug ( "new network block size factor: %d", iNewNetwBlSiFact );
SetNetwBufSizeFactOut ( iNewNetwBlSiFact );
}
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
@ -306,8 +318,6 @@ void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
}
}
// socket buffer size
void CChannel::SetSockBufSize ( const int iNumBlocks )
{
/* this opperation must be done with mutex */
@ -335,25 +345,6 @@ qDebug ( "new jitter buffer size: %d", iNewJitBufSize );
SetSockBufSize ( iNewJitBufSize );
}
// network buffer size factor
void CChannel::SetNetwBufSizeFact ( const int iNetNetwBlSiFact )
{
iCurNetwBlSiFact = iNetNetwBlSiFact;
SetNetwInBlSiFact ( iNetNetwBlSiFact );
SetNetwOutBlSiFact ( iNetNetwBlSiFact );
}
void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact )
{
// TEST
qDebug ( "new network block size factor: %d", iNewNetwBlSiFact );
SetNetwBufSizeFact ( iNewNetwBlSiFact );
}
bool CChannel::GetAddress(CHostAddress& RetAddr)
{
if (IsConnected())
@ -386,7 +377,7 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
if ( iAudComprSizeIn != vecNetwInBufSizes[i] )
{
// re-initialize to new value
SetNetwBufSizeFact ( i + 1 );
SetNetwInBlSiFact ( i + 1 );
}
}
}

View file

@ -83,8 +83,8 @@ public:
void SetSockBufSize ( const int iNumBlocks );
int GetSockBufSize() { return iCurSockBufSize; }
void SetNetwBufSizeFact ( const int iNetNetwBlSiFact );
int GetNetwBufSizeFact() { return iCurNetwBlSiFact; }
void SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut );
int GetNetwBufSizeFactOut() { return iCurNetwOutBlSiFact; }
// network protocol interface
void CreateJitBufMes ( const int iJitBufSize )
@ -107,7 +107,6 @@ public:
protected:
void SetNetwInBlSiFact ( const int iNewBlockSizeFactor );
void SetNetwOutBlSiFact ( const int iNewBlockSizeFactor );
/* audio compression */
CAudioCompression AudioCompressionIn;
@ -144,8 +143,7 @@ protected:
int vecNetwInBufSizes[NET_BLOCK_SIZE_FACTOR_MAX];
int iCurNetwInBlSiFact;
int iCurNetwBlSiFact; // TODO, will be replaced by in/out settings
int iCurNetwOutBlSiFact;
QMutex Mutex;

View file

@ -29,7 +29,8 @@
CClient::CClient () : bRun ( false ), Socket ( &Channel ),
iAudioInFader ( AUD_FADER_IN_MAX / 2 ),
iReverbLevel ( AUD_REVERB_MAX / 6 ),
bReverbOnLeftChan ( false )
bReverbOnLeftChan ( false ),
iNetwBufSizeFactIn ( NET_BLOCK_SIZE_FACTOR )
{
// connection for protocol
QObject::connect ( &Channel, SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
@ -57,6 +58,10 @@ for ( int i = 0; i < vecMessage.Size (); i++ ) {
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 ( iNetwBufSizeFactIn );
}
bool CClient::SetServerAddr(QString strNAddr)

View file

@ -95,16 +95,20 @@ public:
int GetSockBufSize() { return Channel.GetSockBufSize (); }
void SetNetwBufSizeFactIn ( const int iNewNetNetwBlSiFactIn )
{
// store value and tell the server about new value
iNetwBufSizeFactIn = iNewNetNetwBlSiFactIn;
Channel.CreateNetwBlSiFactMes ( iNewNetNetwBlSiFactIn );
}
int GetNetwBufSizeFactIn() { return iNetwBufSizeFactIn; }
void SetNetwBufSizeFact ( const int iNetNetwBlSiFact )
void SetNetwBufSizeFactOut ( const int iNetNetwBlSiFact )
{
// set the new socket size
Channel.SetNetwBufSizeFact ( iNetNetwBlSiFact );
// tell the server that size has changed
Channel.CreateNetwBlSiFactMes ( iNetNetwBlSiFact );
Channel.SetNetwBufSizeFactOut ( iNetNetwBlSiFact );
}
int GetNetwBufSizeFact() { return Channel.GetNetwBufSizeFact(); }
int GetNetwBufSizeFactOut() { return Channel.GetNetwBufSizeFactOut(); }
CSound* GetSndInterface() { return &Sound; }
@ -136,6 +140,8 @@ protected:
int iSndCrdBlockSizeSam;
int iBlockSizeSam;
int iNetwBufSizeFactIn;
CVector<short> vecsAudioSndCrd;
CVector<double> vecdAudioSndCrdL;
CVector<double> vecdAudioSndCrdR;

View file

@ -98,11 +98,21 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
SliderNetBuf->setValue(iCurNumNetBuf);
TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf));
/* network buffer size factor */
SliderNetBufSiFact->setRange(1, NET_BLOCK_SIZE_FACTOR_MAX);
const int iCurNetBufSiFact = pClient->GetNetwBufSizeFact();
SliderNetBufSiFact->setValue(iCurNetBufSiFact);
TextNetBufSiFact->setText("Fact.: " + QString().setNum(iCurNetBufSiFact));
/* network buffer size factor in */
SliderNetBufSiFactIn->setRange(1, NET_BLOCK_SIZE_FACTOR_MAX);
const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn();
SliderNetBufSiFactIn->setValue(iCurNetBufSiFactIn);
TextNetBufSiFactIn->setText("Len: " + QString().setNum(
double(iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS), 'f', 2) +
" ms");
/* network buffer size factor out */
SliderNetBufSiFactOut->setRange(1, NET_BLOCK_SIZE_FACTOR_MAX);
const int iCurNetBufSiFactOut = pClient->GetNetwBufSizeFactOut();
SliderNetBufSiFactOut->setValue(iCurNetBufSiFactOut);
TextNetBufSiFactOut->setText("Len: " + QString().setNum(
double(iCurNetBufSiFactOut * MIN_BLOCK_DURATION_MS), 'f', 2) +
" ms");
/* audio in fader */
SliderAudInFader->setRange(0, AUD_FADER_IN_MAX);
@ -154,8 +164,11 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect(SliderNetBuf, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderNetBuf(int)));
QObject::connect(SliderNetBufSiFact, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderNetBufSiFact(int)));
QObject::connect(SliderNetBufSiFactIn, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderNetBufSiFactIn(int)));
QObject::connect(SliderNetBufSiFactOut, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderNetBufSiFactOut(int)));
QObject::connect(SliderAudInFader, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderAudInFader(int)));
@ -252,10 +265,21 @@ void CLlconClientDlg::OnSliderNetBuf(int value)
UpdateDisplay();
}
void CLlconClientDlg::OnSliderNetBufSiFact(int value)
void CLlconClientDlg::OnSliderNetBufSiFactIn(int value)
{
pClient->SetNetwBufSizeFact ( value );
TextNetBufSiFact->setText("Fact.: " + QString().setNum(value));
pClient->SetNetwBufSizeFactIn ( value );
TextNetBufSiFactIn->setText("Len: " + QString().setNum(
double(value * MIN_BLOCK_DURATION_MS), 'f', 2) +
" ms");
UpdateDisplay();
}
void CLlconClientDlg::OnSliderNetBufSiFactOut(int value)
{
pClient->SetNetwBufSizeFactOut ( value );
TextNetBufSiFactOut->setText("Len: " + QString().setNum(
double(value * MIN_BLOCK_DURATION_MS), 'f', 2) +
" ms");
UpdateDisplay();
}
@ -307,10 +331,6 @@ void CLlconClientDlg::UpdateDisplay()
/* response time */
TextLabelStdDevTimer->setText(QString().
setNum(pClient->GetTimingStdDev(), 'f', 2) + " ms");
// current network buffer size
TextLabelActNetwBufSize->setText(QString().
setNum(double(pClient->GetNetwBufSizeFact() * MIN_BLOCK_DURATION_MS), 'f', 2) + " ms");
}
void CLlconClientDlg::customEvent(QCustomEvent* Event)

View file

@ -90,7 +90,8 @@ public slots:
void OnSliderSndBufInChange ( int value );
void OnSliderSndBufOutChange ( int value );
void OnSliderNetBuf ( int value );
void OnSliderNetBufSiFact ( int value );
void OnSliderNetBufSiFactIn ( int value );
void OnSliderNetBufSiFactOut ( int value );
void OnSliderAudInFader ( int value ) { pClient->SetAudioInFader(value); }
void OnSliderAudReverb ( int value )
{ pClient->SetReverbLevel ( AUD_REVERB_MAX - value ); }

View file

@ -11,7 +11,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>897</width>
<width>914</width>
<height>287</height>
</rect>
</property>
@ -756,7 +756,14 @@
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextNetBufSiFact</cstring>
<cstring>TextNetBufSiFactIn</cstring>
</property>
<property stdset="1">
<name>minimumSize</name>
<size>
<width>72</width>
<height>0</height>
</size>
</property>
<property stdset="1">
<name>text</name>
@ -774,7 +781,51 @@
<class>QSlider</class>
<property stdset="1">
<name>name</name>
<cstring>SliderNetBufSiFact</cstring>
<cstring>SliderNetBufSiFactIn</cstring>
</property>
<property stdset="1">
<name>pageStep</name>
<number>1</number>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>tickmarks</name>
<enum>Both</enum>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextNetBufSiFactOut</cstring>
</property>
<property stdset="1">
<name>minimumSize</name>
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property stdset="1">
<name>text</name>
<string>Size</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
</widget>
<widget>
<class>QSlider</class>
<property stdset="1">
<name>name</name>
<cstring>SliderNetBufSiFactOut</cstring>
</property>
<property stdset="1">
<name>pageStep</name>
@ -1095,7 +1146,7 @@
<name>title</name>
<string>Measurement Results</string>
</property>
<hbox>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
@ -1110,7 +1161,7 @@
<name>name</name>
<cstring>Layout17</cstring>
</property>
<vbox>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
@ -1130,34 +1181,6 @@
<string>StdDev:</string>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelActNetwBufSizeLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Netw. Buf. Size:</string>
</property>
</widget>
</vbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout18</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
@ -1169,20 +1192,9 @@
<string>val</string>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelActNetwBufSize</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>val</string>
</property>
</widget>
</vbox>
</hbox>
</widget>
</hbox>
</vbox>
</widget>
</hbox>
</widget>

View file

@ -82,9 +82,14 @@ void CSettings::ReadIniFile()
pClient->SetSockBufSize ( iValue );
}
// network buffer size factor
if ( GetNumericIniSet(ini, "Client", "netwbusifact", 1, NET_BLOCK_SIZE_FACTOR_MAX, iValue ) == TRUE ) {
pClient->SetNetwBufSizeFact ( iValue );
// network buffer size factor in
if ( GetNumericIniSet(ini, "Client", "netwbusifactin", 1, NET_BLOCK_SIZE_FACTOR_MAX, iValue ) == TRUE ) {
pClient->SetNetwBufSizeFactIn ( iValue );
}
// network buffer size factor out
if ( GetNumericIniSet(ini, "Client", "netwbusifactout", 1, NET_BLOCK_SIZE_FACTOR_MAX, iValue ) == TRUE ) {
pClient->SetNetwBufSizeFactOut ( iValue );
}
}
@ -113,8 +118,11 @@ void CSettings::WriteIniFile()
// network jitter buffer size
SetNumericIniSet ( ini, "Client", "jitbuf", pClient->GetSockBufSize() );
// network buffer size factor
SetNumericIniSet ( ini, "Client", "netwbusifact", pClient->GetNetwBufSizeFact() );
// network buffer size factor in
SetNumericIniSet ( ini, "Client", "netwbusifactin", pClient->GetNetwBufSizeFactIn() );
// network buffer size factor out
SetNumericIniSet ( ini, "Client", "netwbusifactout", pClient->GetNetwBufSizeFactOut() );
/* Save settings in init-file */