added automatic network jitter buffer setting functionality

This commit is contained in:
Volker Fischer 2009-02-12 14:48:35 +00:00
parent b0d0292314
commit f84b9673bd
6 changed files with 48 additions and 33 deletions

View file

@ -36,7 +36,7 @@ CClient::CClient ( const quint16 iPortNumber ) : bRun ( false ),
iNetwBufSizeFactIn ( DEF_NET_BLOCK_SIZE_FACTOR ),
strIPAddress ( "" ), strName ( "" ),
bOpenChatOnNewMessage ( true ),
bDoAutoSockBufSize ( false )
bDoAutoSockBufSize ( true )
{
// connection for protocol
QObject::connect ( &Channel,

View file

@ -92,8 +92,8 @@ public:
AudioReverb.Clear();
}
void SetDoAutoSockBufSize ( const bool bValue )
{ bDoAutoSockBufSize = bValue; }
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; }
void SetSockBufSize ( const int iNumBlocks )
{
if ( Channel.GetSockBufSize() != iNumBlocks )

View file

@ -83,8 +83,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
// network buffer
SliderNetBuf->setRange ( 0, MAX_NET_BUF_SIZE_NUM_BL );
const int iCurNumNetBuf = pClient->GetSockBufSize();
UpdateNetworkBufSlider ( iCurNumNetBuf );
UpdateJitterBufferFrame();
// network buffer size factor in
SliderNetBufSiFactIn->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR );
@ -144,7 +143,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
// timers
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
this, SLOT ( OnTimerStatus() ) );
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
@ -165,6 +163,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
// check boxes
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) );
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnAutoJitBuf ( int ) ) );
// combo boxes
QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ),
@ -183,10 +183,17 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
TimerStatus.start ( DISPLAY_UPDATE_TIME );
}
void CClientSettingsDlg::UpdateNetworkBufSlider ( const int iCurNumNetBuf )
void CClientSettingsDlg::UpdateJitterBufferFrame()
{
// update slider value and text
const int iCurNumNetBuf = pClient->GetSockBufSize();
SliderNetBuf->setValue ( iCurNumNetBuf );
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
// if auto setting is enabled, disable slider control
cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() );
SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
}
void CClientSettingsDlg::UpdateSndBufInSlider ( const int iCurNumInBuf )
@ -271,6 +278,12 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
UpdateDisplay();
}
void CClientSettingsDlg::OnAutoJitBuf ( int value )
{
pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
UpdateJitterBufferFrame();
}
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
{
pClient->SetOpenChatOnNewMessage ( value == Qt::Checked );
@ -353,9 +366,9 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
void CClientSettingsDlg::UpdateDisplay()
{
// update slider controls (settings might have been changed by sound interface)
UpdateSndBufInSlider ( pClient->GetSndInterface()->GetInNumBuf() );
UpdateSndBufOutSlider ( pClient->GetSndInterface()->GetOutNumBuf() );
UpdateNetworkBufSlider ( pClient->GetSockBufSize() );
UpdateSndBufInSlider ( pClient->GetSndInterface()->GetInNumBuf() );
UpdateSndBufOutSlider ( pClient->GetSndInterface()->GetOutNumBuf() );
UpdateJitterBufferFrame();
if ( !pClient->IsRunning() )
{

View file

@ -72,9 +72,9 @@ protected:
virtual void showEvent ( QShowEvent* showEvent );
virtual void hideEvent ( QHideEvent* hideEvent );
void UpdateSndBufInSlider ( const int iCurNumInBuf );
void UpdateSndBufOutSlider ( const int iCurNumOutBuf );
void UpdateNetworkBufSlider ( const int iCurNumNetBuf );
void UpdateSndBufInSlider ( const int iCurNumInBuf );
void UpdateSndBufOutSlider ( const int iCurNumOutBuf );
void UpdateJitterBufferFrame();
public slots:
void OnTimerStatus() { UpdateDisplay(); }
@ -84,6 +84,7 @@ public slots:
void OnSliderNetBuf ( int value );
void OnSliderNetBufSiFactIn ( int value );
void OnSliderNetBufSiFactOut ( int value );
void OnAutoJitBuf ( int value );
void OnOpenChatOnNewMessageStateChanged ( int value );
void OnAudioCompressionButtonGroupClicked ( QAbstractButton* button );
void OnPingTimeResult ( int iPingTime );

View file

@ -25,21 +25,13 @@
<string>Jitter Buffer</string>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QCheckBox" name="cbAutoJitBuf" >
<property name="text" >
<string>Auto</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextNetBuf" >
<property name="minimumSize" >

View file

@ -104,6 +104,12 @@ void CSettings::ReadIniFile ( const QString& sFileName )
pClient->GetSndInterface()->SetOutNumBuf ( iValue );
}
// automatic network jitter buffer size setting
if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) )
{
pClient->SetDoAutoSockBufSize ( bValue );
}
// network jitter buffer size
if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf", 0, MAX_NET_BUF_SIZE_NUM_BL, iValue ) )
{
@ -180,6 +186,9 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// sound card out number of buffers
SetNumericIniSet ( IniXMLDocument, "client", "audoutbuf", pClient->GetSndInterface()->GetOutNumBuf() );
// automatic network jitter buffer size setting
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", pClient->GetDoAutoSockBufSize() );
// network jitter buffer size
SetNumericIniSet ( IniXMLDocument, "client", "jitbuf", pClient->GetSockBufSize() );