change of network buffer size is possible now
This commit is contained in:
parent
213f71347f
commit
6c6ce5bd04
10 changed files with 217 additions and 49 deletions
|
@ -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 )
|
||||
|
@ -289,6 +291,8 @@ void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// socket buffer size
|
||||
void CChannel::SetSockBufSize ( const int iNumBlocks )
|
||||
{
|
||||
/* this opperation must be done with mutex */
|
||||
|
@ -320,6 +324,30 @@ 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();
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
@ -131,11 +142,14 @@ protected:
|
|||
|
||||
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 );
|
||||
|
|
13
src/client.h
13
src/client.h
|
@ -84,7 +84,6 @@ public:
|
|||
AudioReverb.Clear();
|
||||
}
|
||||
|
||||
|
||||
void SetSockBufSize ( const int iNumBlocks )
|
||||
{
|
||||
// set the new socket size
|
||||
|
@ -96,6 +95,18 @@ public:
|
|||
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; }
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
@ -146,8 +151,11 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
|||
this, SLOT(OnSliderSndBufInChange(int)));
|
||||
QObject::connect(SliderSndBufOut, SIGNAL(valueChanged(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)));
|
||||
|
@ -241,6 +249,12 @@ void CLlconClientDlg::OnSliderNetBuf(int value)
|
|||
TextNetBuf->setText("Size: " + QString().setNum(value));
|
||||
}
|
||||
|
||||
void CLlconClientDlg::OnSliderNetBufSiFact(int value)
|
||||
{
|
||||
pClient->SetNetwBufSizeFact ( value );
|
||||
TextNetBufSiFact->setText("Fact.: " + QString().setNum(value));
|
||||
}
|
||||
|
||||
void CLlconClientDlg::OnTimerSigMet ()
|
||||
{
|
||||
/* get current input levels */
|
||||
|
|
|
@ -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 ); }
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -49,6 +49,13 @@ MESSAGES
|
|||
|
||||
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) *
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
@ -108,6 +113,9 @@ void CSettings::WriteIniFile()
|
|||
// network jitter buffer size
|
||||
SetNumericIniSet ( ini, "Client", "jitbuf", pClient->GetSockBufSize() );
|
||||
|
||||
// network buffer size factor
|
||||
SetNumericIniSet ( ini, "Client", "netwbusifact", pClient->GetNetwBufSizeFact() );
|
||||
|
||||
|
||||
/* Save settings in init-file */
|
||||
SaveIni ( ini, LLCON_INIT_FILE_NAME );
|
||||
|
|
Loading…
Reference in a new issue