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

View file

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

View file

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

View file

@ -95,16 +95,20 @@ public:
int GetSockBufSize() { return Channel.GetSockBufSize (); } 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 // set the new socket size
Channel.SetNetwBufSizeFact ( iNetNetwBlSiFact ); Channel.SetNetwBufSizeFactOut ( iNetNetwBlSiFact );
// tell the server that size has changed
Channel.CreateNetwBlSiFactMes ( iNetNetwBlSiFact );
} }
int GetNetwBufSizeFact() { return Channel.GetNetwBufSizeFact(); } int GetNetwBufSizeFactOut() { return Channel.GetNetwBufSizeFactOut(); }
CSound* GetSndInterface() { return &Sound; } CSound* GetSndInterface() { return &Sound; }
@ -136,6 +140,8 @@ protected:
int iSndCrdBlockSizeSam; int iSndCrdBlockSizeSam;
int iBlockSizeSam; int iBlockSizeSam;
int iNetwBufSizeFactIn;
CVector<short> vecsAudioSndCrd; CVector<short> vecsAudioSndCrd;
CVector<double> vecdAudioSndCrdL; CVector<double> vecdAudioSndCrdL;
CVector<double> vecdAudioSndCrdR; CVector<double> vecdAudioSndCrdR;

View file

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

View file

@ -90,7 +90,8 @@ public slots:
void OnSliderSndBufInChange ( int value ); void OnSliderSndBufInChange ( int value );
void OnSliderSndBufOutChange ( int value ); void OnSliderSndBufOutChange ( int value );
void OnSliderNetBuf ( 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 OnSliderAudInFader ( int value ) { pClient->SetAudioInFader(value); }
void OnSliderAudReverb ( int value ) void OnSliderAudReverb ( int value )
{ pClient->SetReverbLevel ( AUD_REVERB_MAX - value ); } { pClient->SetReverbLevel ( AUD_REVERB_MAX - value ); }

View file

@ -11,7 +11,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>897</width> <width>914</width>
<height>287</height> <height>287</height>
</rect> </rect>
</property> </property>
@ -756,7 +756,14 @@
<class>QLabel</class> <class>QLabel</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <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>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
@ -774,7 +781,51 @@
<class>QSlider</class> <class>QSlider</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <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>
<property stdset="1"> <property stdset="1">
<name>pageStep</name> <name>pageStep</name>
@ -1095,7 +1146,7 @@
<name>title</name> <name>title</name>
<string>Measurement Results</string> <string>Measurement Results</string>
</property> </property>
<hbox> <vbox>
<property stdset="1"> <property stdset="1">
<name>margin</name> <name>margin</name>
<number>11</number> <number>11</number>
@ -1110,7 +1161,7 @@
<name>name</name> <name>name</name>
<cstring>Layout17</cstring> <cstring>Layout17</cstring>
</property> </property>
<vbox> <hbox>
<property stdset="1"> <property stdset="1">
<name>margin</name> <name>margin</name>
<number>0</number> <number>0</number>
@ -1130,34 +1181,6 @@
<string>StdDev:</string> <string>StdDev:</string>
</property> </property>
</widget> </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> <widget>
<class>QLabel</class> <class>QLabel</class>
<property stdset="1"> <property stdset="1">
@ -1169,20 +1192,9 @@
<string>val</string> <string>val</string>
</property> </property>
</widget> </widget>
<widget> </hbox>
<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>
</widget> </widget>
</hbox> </vbox>
</widget> </widget>
</hbox> </hbox>
</widget> </widget>

View file

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