change of network buffer size is possible now

This commit is contained in:
Volker Fischer 2006-03-12 11:50:35 +00:00
parent 213f71347f
commit 6c6ce5bd04
10 changed files with 217 additions and 49 deletions

View file

@ -229,8 +229,7 @@ CChannel::CChannel ()
SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL );
// set initial input and output block size factors
SetNetwInBlSiFact ( NET_BLOCK_SIZE_FACTOR );
SetNetwOutBlSiFact ( NET_BLOCK_SIZE_FACTOR );
SetNetwBufSizeFact ( NET_BLOCK_SIZE_FACTOR );
/* init time-out for the buffer with zero -> no connection */
iConTimeOut = 0;
@ -246,6 +245,9 @@ CChannel::CChannel ()
QObject::connect ( &Protocol, SIGNAL ( ReqJittBufSize() ),
SIGNAL ( ReqJittBufSize() ) );
QObject::connect ( &Protocol, SIGNAL ( ChangeNetwBlSiFact ( int ) ),
this, SLOT ( OnNetwBlSiFactChange ( int ) ) );
}
void CChannel::SetNetwInBlSiFact ( const int iNewBlockSizeFactor )
@ -288,7 +290,9 @@ void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
Protocol.DeleteSendMessQueue();
}
}
// socket buffer size
void CChannel::SetSockBufSize ( const int iNumBlocks )
{
/* this opperation must be done with mutex */
@ -319,7 +323,31 @@ qDebug ( "new jitter buffer size: %d", iNewJitBufSize );
SetSockBufSize ( iNewJitBufSize );
}
// network buffer size factor
void CChannel::SetNetwBufSizeFact ( const int iNetNetwBlSiFact )
{
/* this opperation must be done with mutex */
Mutex.lock ();
{
iCurNetwBlSiFact = iNetNetwBlSiFact;
SetNetwInBlSiFact ( iNetNetwBlSiFact );
SetNetwOutBlSiFact ( iNetNetwBlSiFact );
}
Mutex.unlock ();
}
void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact )
{
// TEST
qDebug ( "new network block size factor: %d", iNewNetwBlSiFact );
SetNetwBufSizeFact ( iNewNetwBlSiFact );
}
bool CChannel::GetAddress(CHostAddress& RetAddr)
{
if (IsConnected())
@ -403,7 +431,7 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
// TEST debug output
CHostAddress address ( GetAddress() );
qDebug ( "new connection with IP %s\n", address.InetAddr.toString().latin1() );
qDebug ( "new connection with IP %s", address.InetAddr.toString().latin1() );
emit NewConnection();
}

View file

@ -83,6 +83,9 @@ public:
void SetSockBufSize ( const int iNumBlocks );
int GetSockBufSize();
void SetNetwBufSizeFact ( const int iNetNetwBlSiFact );
int GetNetwBufSizeFact() { return iCurNetwBlSiFact; }
// network protocol interface
void CreateJitBufMes ( const int iJitBufSize )
{
@ -91,9 +94,17 @@ public:
Protocol.CreateJitBufMes ( iJitBufSize );
}
}
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
{
if ( IsConnected() )
{
Protocol.CreateNetwBlSiFactMes ( iNetwBlSiFact );
}
}
protected:
void SetNetwInBlSiFact ( const int iNewBlockSizeFactor );
void SetNetwOutBlSiFact ( const int iNewBlockSizeFactor );
@ -129,13 +140,16 @@ protected:
int iConTimeOut;
int iConTimeOutStartVal;
int iCurNetwInBlSiFact;
int iCurNetwInBlSiFact;
int iCurNetwBlSiFact; // TODO, will be replaced by in/out settings
QMutex Mutex;
public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnJittBufSizeChange ( int iNewJitBufSize );
void OnNetwBlSiFactChange ( int iNewNetwBlSiFact );
signals:
void MessReadyForSending ( CVector<uint8_t> vecMessage );

View file

@ -57,34 +57,33 @@ class CClient : public QObject, public QThread
public:
CClient();
virtual ~CClient () {}
virtual ~CClient() {}
void Init ();
bool Stop ();
bool IsRunning () { return bRun; }
void Init();
bool Stop();
bool IsRunning() { return bRun; }
bool SetServerAddr ( QString strNAddr );
double MicLevelL () { return SignalLevelMeterL.MicLevel (); }
double MicLevelR () { return SignalLevelMeterR.MicLevel (); }
bool IsConnected () { return Channel.IsConnected (); }
double MicLevelL() { return SignalLevelMeterL.MicLevel(); }
double MicLevelR() { return SignalLevelMeterR.MicLevel(); }
bool IsConnected() { return Channel.IsConnected(); }
/* we want to return the standard deviation. For that we need to calculate
the sqaure root */
double GetTimingStdDev () { return sqrt ( RespTimeMoAvBuf.GetAverage () ); }
double GetTimingStdDev() { return sqrt ( RespTimeMoAvBuf.GetAverage() ); }
int GetAudioInFader () { return iAudioInFader; }
int GetAudioInFader() { return iAudioInFader; }
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
int GetReverbLevel () { return iReverbLevel; }
int GetReverbLevel() { return iReverbLevel; }
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
bool IsReverbOnLeftChan () { return bReverbOnLeftChan; }
bool IsReverbOnLeftChan() { return bReverbOnLeftChan; }
void SetReverbOnLeftChan ( const bool bIL )
{
bReverbOnLeftChan = bIL;
AudioReverb.Clear ();
AudioReverb.Clear();
}
void SetSockBufSize ( const int iNumBlocks )
{
// set the new socket size
@ -93,11 +92,23 @@ public:
// tell the server that size has changed
Channel.CreateJitBufMes ( iNumBlocks );
}
int GetSockBufSize () { return Channel.GetSockBufSize (); }
int GetSockBufSize() { return Channel.GetSockBufSize (); }
void SetNetwBufSizeFact ( const int iNetNetwBlSiFact )
{
// set the new socket size
Channel.SetNetwBufSizeFact ( iNetNetwBlSiFact );
// tell the server that size has changed
Channel.CreateNetwBlSiFactMes ( iNetNetwBlSiFact );
}
int GetNetwBufSizeFact() { return Channel.GetNetwBufSizeFact(); }
CSound* GetSndInterface () { return &Sound; }
CChannel* GetChannel () { return &Channel; }
CSound* GetSndInterface() { return &Sound; }
CChannel* GetChannel() { return &Channel; }
// settings

View file

@ -58,8 +58,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
/* set text for version and application name */
TextLabelNameVersion->
setText(QString(APP_NAME) + tr(" client ") + QString(VERSION) +
" (" + QString().setNum(MIN_BLOCK_DURATION_MS * NET_BLOCK_SIZE_FACTOR) + " ms)");
setText(QString(APP_NAME) + tr(" client ") + QString(VERSION));
/* init server address line edit */
LineEditServerAddr->setText ( pClient->strIPAddress.c_str () );
@ -99,6 +98,12 @@ 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));
/* audio in fader */
SliderAudInFader->setRange(0, AUD_FADER_IN_MAX);
const int iCurAudInFader = pClient->GetAudioInFader();
@ -145,9 +150,12 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect(SliderSndBufIn, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderSndBufInChange(int)));
QObject::connect(SliderSndBufOut, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderSndBufOutChange(int)));
this, SLOT(OnSliderSndBufOutChange(int)));
QObject::connect(SliderNetBuf, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderNetBuf(int)));
QObject::connect(SliderNetBufSiFact, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderNetBufSiFact(int)));
QObject::connect(SliderAudInFader, SIGNAL(valueChanged(int)),
this, SLOT(OnSliderAudInFader(int)));
@ -240,6 +248,12 @@ void CLlconClientDlg::OnSliderNetBuf(int value)
pClient->SetSockBufSize ( value );
TextNetBuf->setText("Size: " + QString().setNum(value));
}
void CLlconClientDlg::OnSliderNetBufSiFact(int value)
{
pClient->SetNetwBufSizeFact ( value );
TextNetBufSiFact->setText("Fact.: " + QString().setNum(value));
}
void CLlconClientDlg::OnTimerSigMet ()
{

View file

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

View file

@ -11,8 +11,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>814</width>
<height>287</height>
<width>890</width>
<height>288</height>
</rect>
</property>
<property stdset="1">
@ -733,6 +733,64 @@
</widget>
</vbox>
</widget>
<widget>
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
<cstring>GroupBoxNetwBuf</cstring>
</property>
<property stdset="1">
<name>title</name>
<string>Block Size</string>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextNetBufSiFact</cstring>
</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>SliderNetBufSiFact</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>
</vbox>
</widget>
<widget>
<class>QGroupBox</class>
<property stdset="1">

View file

@ -32,8 +32,7 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent,
{
/* set text for version and application name */
TextLabelNameVersion->
setText(QString(APP_NAME) + tr(" server ") + QString(VERSION) +
" (" + QString().setNum(MIN_BLOCK_DURATION_MS * NET_BLOCK_SIZE_FACTOR) + " ms)");
setText(QString(APP_NAME) + tr(" server ") + QString(VERSION));
/* Create bitmaps */
/* Define size of the bitmaps */

View file

@ -30,7 +30,7 @@ MAIN FRAME
MESSAGES
--------
- Acknowledgement message: PROTMESSID_ACKN
- Acknowledgement message: PROTMESSID_ACKN
+-----------------------------------+
| 2 bytes ID of message to be ackn. |
@ -39,16 +39,23 @@ MESSAGES
note: the cnt value is the same as of the message to be acknowledged
- Jitter buffer size: PROTMESSID_JITT_BUF_SIZE
- Jitter buffer size: PROTMESSID_JITT_BUF_SIZE
+--------------------------+
| 2 bytes number of blocks |
+--------------------------+
- Request jitter buffer size: PROTMESSID_REQ_JITT_BUF_SIZE
- Request jitter buffer size: PROTMESSID_REQ_JITT_BUF_SIZE
note: does not have any data -> n = 0
- network buffer block size factor PROTMESSID_NET_BLSI_FACTOR
note: size, relative to minimum block size
+----------------+
| 2 bytes factor |
+----------------+
@ -297,6 +304,20 @@ vecbyDataConv[i] = static_cast<uint8_t> ( vecbyData[i] );
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
case PROTMESSID_NET_BLSI_FACTOR:
// extract data from stream and emit signal for received value
iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action
emit ChangeNetwBlSiFact ( iData );
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
}
}
@ -333,6 +354,17 @@ void CProtocol::CreateReqJitBufMes()
CreateAndSendMessage ( PROTMESSID_REQ_JITT_BUF_SIZE, CVector<uint8_t> ( 0 ) );
}
void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
{
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
unsigned int iPos = 0; // init position pointer
// build data vector
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iNetwBlSiFact ), 2 );
CreateAndSendMessage ( PROTMESSID_NET_BLSI_FACTOR, vecData );
}
/******************************************************************************\
* Message generation (parsing) *

View file

@ -40,6 +40,7 @@
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size
#define PROTMESSID_PING 12 // for measuring ping time
#define PROTMESSID_NET_BLSI_FACTOR 13 // network buffer size factor
// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
@ -60,6 +61,7 @@ public:
void CreateJitBufMes ( const int iJitBufSize );
void CreateReqJitBufMes();
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact );
void CreateAndSendAcknMess ( const int& iID, const int& iCnt );
@ -137,6 +139,7 @@ signals:
// receiving
void ChangeJittBufSize ( int iNewJitBufSize );
void ChangeNetwBlSiFact ( int iNewNetwBlSiFact );
void ReqJittBufSize();
};

View file

@ -26,16 +26,16 @@
/* Implementation *************************************************************/
void CSettings::Load ()
void CSettings::Load()
{
/* load settings from init-file */
ReadIniFile ();
ReadIniFile();
}
void CSettings::Save()
{
/* write settings in init-file */
WriteIniFile ();
WriteIniFile();
}
@ -81,6 +81,11 @@ void CSettings::ReadIniFile()
if ( GetNumericIniSet(ini, "Client", "jitbuf", 0, MAX_NET_BUF_SIZE_NUM_BL, iValue ) == TRUE ) {
pClient->SetSockBufSize ( iValue );
}
// network buffer size factor
if ( GetNumericIniSet(ini, "Client", "netwbusifact", 1, NET_BLOCK_SIZE_FACTOR_MAX, iValue ) == TRUE ) {
pClient->SetNetwBufSizeFact ( iValue );
}
}
void CSettings::WriteIniFile()
@ -91,22 +96,25 @@ void CSettings::WriteIniFile()
PutIniSetting ( ini, "Client", "ipaddress", pClient->strIPAddress.c_str() );
// audio fader
SetNumericIniSet ( ini, "Client", "audfad", pClient->GetAudioInFader () );
SetNumericIniSet ( ini, "Client", "audfad", pClient->GetAudioInFader() );
// reverberation level
SetNumericIniSet ( ini, "Client", "revlev", pClient->GetReverbLevel () );
SetNumericIniSet ( ini, "Client", "revlev", pClient->GetReverbLevel() );
// reverberation channel assignment
SetFlagIniSet ( ini, "Client", "reverblchan", pClient->IsReverbOnLeftChan () );
SetFlagIniSet ( ini, "Client", "reverblchan", pClient->IsReverbOnLeftChan() );
// sound card in number of buffers
SetNumericIniSet ( ini, "Client", "audinbuf", pClient->GetSndInterface()->GetInNumBuf () );
SetNumericIniSet ( ini, "Client", "audinbuf", pClient->GetSndInterface()->GetInNumBuf() );
// sound card out number of buffers
SetNumericIniSet ( ini, "Client", "audoutbuf", pClient->GetSndInterface()->GetOutNumBuf () );
SetNumericIniSet ( ini, "Client", "audoutbuf", pClient->GetSndInterface()->GetOutNumBuf() );
// network jitter buffer size
SetNumericIniSet ( ini, "Client", "jitbuf", pClient->GetSockBufSize () );
SetNumericIniSet ( ini, "Client", "jitbuf", pClient->GetSockBufSize() );
// network buffer size factor
SetNumericIniSet ( ini, "Client", "netwbusifact", pClient->GetNetwBufSizeFact() );
/* Save settings in init-file */
@ -121,7 +129,7 @@ bool CSettings::GetNumericIniSet ( INIFile& theINI, string strSection,
bool bReturn = FALSE;
const string strGetIni =
GetIniSetting ( theINI, strSection.c_str (), strKey.c_str () );
GetIniSetting ( theINI, strSection.c_str(), strKey.c_str() );
/* Check if it is a valid parameter */
if ( !strGetIni.empty () )
@ -144,7 +152,7 @@ void CSettings::SetNumericIniSet ( INIFile& theINI, string strSection,
char cString[256];
sprintf ( cString, "%d", iValue );
PutIniSetting ( theINI, strSection.c_str (), strKey.c_str (), cString );
PutIniSetting ( theINI, strSection.c_str(), strKey.c_str(), cString );
}
bool CSettings::GetFlagIniSet ( INIFile& theINI, string strSection,
@ -154,11 +162,11 @@ bool CSettings::GetFlagIniSet ( INIFile& theINI, string strSection,
bool bReturn = FALSE;
const string strGetIni =
GetIniSetting ( theINI, strSection.c_str (), strKey.c_str () );
GetIniSetting ( theINI, strSection.c_str(), strKey.c_str() );
if ( !strGetIni.empty () )
if ( !strGetIni.empty() )
{
if ( atoi ( strGetIni.c_str () ) )
if ( atoi ( strGetIni.c_str() ) )
{
bValue = TRUE;
}
@ -178,11 +186,11 @@ void CSettings::SetFlagIniSet ( INIFile& theINI, string strSection, string strKe
{
if ( bValue == TRUE )
{
PutIniSetting ( theINI, strSection.c_str (), strKey.c_str (), "1" );
PutIniSetting ( theINI, strSection.c_str(), strKey.c_str(), "1" );
}
else
{
PutIniSetting ( theINI, strSection.c_str (), strKey.c_str (), "0" );
PutIniSetting ( theINI, strSection.c_str(), strKey.c_str(), "0" );
}
}