code cleanup
This commit is contained in:
parent
1a8b049c5a
commit
93e12245fe
4 changed files with 31 additions and 120 deletions
112
src/buffer.cpp
112
src/buffer.cpp
|
@ -160,14 +160,11 @@ void CNetBufWithStats::Init ( const int iNewBlockSize,
|
||||||
// possible
|
// possible
|
||||||
iInitCounter = MAX_STATISTIC_COUNT / 4;
|
iInitCounter = MAX_STATISTIC_COUNT / 4;
|
||||||
|
|
||||||
// init auto buffer setting with a meaningful value (should not be used
|
// init auto buffer setting with a meaningful value, also init the
|
||||||
// anyway)
|
// IIR parameter with this value
|
||||||
iCurAutoBufferSizeSetting = 5;
|
iCurAutoBufferSizeSetting = 5;
|
||||||
|
|
||||||
// TEST
|
|
||||||
dCurIIRFilterResult = iCurAutoBufferSizeSetting;
|
dCurIIRFilterResult = iCurAutoBufferSizeSetting;
|
||||||
iCurDecidedResult = iCurAutoBufferSizeSetting;
|
iCurDecidedResult = iCurAutoBufferSizeSetting;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,26 +227,6 @@ void CNetBufWithStats::UpdateAutoSetting()
|
||||||
bool bDecisionFound = false;
|
bool bDecisionFound = false;
|
||||||
|
|
||||||
|
|
||||||
// TEST initialization phase
|
|
||||||
const double dInitState =
|
|
||||||
ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].InitializationState();
|
|
||||||
|
|
||||||
const bool bIsInitePhase = ( dInitState < 0.7 );
|
|
||||||
|
|
||||||
double dErrorRateBound = ERROR_RATE_BOUND;
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ( bIsInitePhase )
|
|
||||||
{
|
|
||||||
const double dCurErrRateLargestBuffer =
|
|
||||||
ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage();
|
|
||||||
|
|
||||||
dErrorRateBound = dCurErrRateLargestBuffer +
|
|
||||||
(1.0 - dCurErrRateLargestBuffer) / 500;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Get error rate decision -------------------------------------------------
|
// Get error rate decision -------------------------------------------------
|
||||||
// Use a specified error bound to identify the best buffer size for the
|
// Use a specified error bound to identify the best buffer size for the
|
||||||
// current network situation. Start with the smallest buffer and
|
// current network situation. Start with the smallest buffer and
|
||||||
|
@ -257,7 +234,7 @@ if ( bIsInitePhase )
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ )
|
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ )
|
||||||
{
|
{
|
||||||
if ( ( !bDecisionFound ) &&
|
if ( ( !bDecisionFound ) &&
|
||||||
( ErrorRateStatistic[i].GetAverage() <= dErrorRateBound ) )
|
( ErrorRateStatistic[i].GetAverage() <= ERROR_RATE_BOUND ) )
|
||||||
{
|
{
|
||||||
iCurDecision = viBufSizesForSim[i];
|
iCurDecision = viBufSizesForSim[i];
|
||||||
bDecisionFound = true;
|
bDecisionFound = true;
|
||||||
|
@ -272,53 +249,29 @@ if ( bIsInitePhase )
|
||||||
|
|
||||||
|
|
||||||
// Post calculation (filtering) --------------------------------------------
|
// Post calculation (filtering) --------------------------------------------
|
||||||
|
|
||||||
// TEST
|
|
||||||
double dWeightUp = 0.999995;
|
|
||||||
double dWeightDown = 0.9999;
|
|
||||||
|
|
||||||
if ( iInitCounter > 0 )
|
|
||||||
{
|
|
||||||
// decrease init counter
|
|
||||||
iInitCounter--;
|
|
||||||
|
|
||||||
dWeightUp = 0.9995;
|
|
||||||
dWeightDown = 0.999;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ( iInitCounter > 0 )
|
|
||||||
{
|
|
||||||
// for initialization phase, use current decision without applying
|
|
||||||
// any filtering
|
|
||||||
iCurAutoBufferSizeSetting = iCurDecision;
|
|
||||||
|
|
||||||
// decrease init counter
|
|
||||||
iInitCounter--;
|
|
||||||
|
|
||||||
if ( iInitCounter == 0 )
|
|
||||||
{
|
|
||||||
// initialization phase is at the end now, init parameters for
|
|
||||||
// regular estimation phase
|
|
||||||
dCurIIRFilterResult = iCurDecision;
|
|
||||||
iCurDecidedResult = iCurDecision;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
// Define different weigths for up and down direction. Up direction
|
// Define different weigths for up and down direction. Up direction
|
||||||
// filtering shall be slower than for down direction since we assume
|
// filtering shall be slower than for down direction since we assume
|
||||||
// that the lower value is the actual value which can be used for
|
// that the lower value is the actual value which can be used for
|
||||||
// the current network condition. If the current error rate estimation
|
// the current network condition. If the current error rate estimation
|
||||||
// is higher, it may be a temporary problem which should not change
|
// is higher, it may be a temporary problem which should not change
|
||||||
// the current jitter buffer size significantly.
|
// the current jitter buffer size significantly.
|
||||||
// const double dWeightUp = 0.999995;
|
// For the initialization phase, use lower weight values to get faster
|
||||||
// const double dWeightDown = 0.9999;
|
// adaptation.
|
||||||
|
double dWeightUp = 0.999995;
|
||||||
|
double dWeightDown = 0.9999;
|
||||||
const double dHysteresisValue = 0.1;
|
const double dHysteresisValue = 0.1;
|
||||||
|
|
||||||
|
// check for initialization phase
|
||||||
|
if ( iInitCounter > 0 )
|
||||||
|
{
|
||||||
|
// decrease init counter
|
||||||
|
iInitCounter--;
|
||||||
|
|
||||||
|
// overwrite weigth values with lower values
|
||||||
|
dWeightUp = 0.9995;
|
||||||
|
dWeightDown = 0.999;
|
||||||
|
}
|
||||||
|
|
||||||
// apply non-linear IIR filter
|
// apply non-linear IIR filter
|
||||||
LlconMath().UpDownIIR1( dCurIIRFilterResult,
|
LlconMath().UpDownIIR1( dCurIIRFilterResult,
|
||||||
static_cast<double> ( iCurDecision ),
|
static_cast<double> ( iCurDecision ),
|
||||||
|
@ -331,32 +284,3 @@ dWeightDown = 0.999;
|
||||||
iCurDecidedResult,
|
iCurDecidedResult,
|
||||||
dHysteresisValue );
|
dHysteresisValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#ifdef _WIN32
|
|
||||||
// TEST
|
|
||||||
static FILE* pFile = fopen ( "c:\\temp\\test.dat", "w" );
|
|
||||||
fprintf ( pFile, "%d %e %d\n", iCurDecision, dCurIIRFilterResult, GetAutoSetting() );
|
|
||||||
fflush ( pFile );
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// TEST for debugging
|
|
||||||
void CNetBufWithStats::StoreAllSimAverages()
|
|
||||||
{
|
|
||||||
FILE* pFile = fopen ( "c:\\temp\\test1.dat", "w" );
|
|
||||||
|
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ )
|
|
||||||
{
|
|
||||||
fprintf ( pFile, "%e, ", ErrorRateStatistic[i].GetAverage() );
|
|
||||||
}
|
|
||||||
fprintf ( pFile, "%e", ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage() );
|
|
||||||
fprintf ( pFile, "\n" );
|
|
||||||
|
|
||||||
fclose ( pFile );
|
|
||||||
|
|
||||||
// scilab:
|
|
||||||
// close;x=read('c:/temp/test.dat',-1,13);plot2d([2,3,4,5,6,7,8,9,10,11,12], x, style=-1 , logflag = 'nl');plot2d([2 20],[1 1]*0.01);plot2d([2 20],[1 1]*0.005);x
|
|
||||||
}
|
|
||||||
|
|
|
@ -402,9 +402,6 @@ public:
|
||||||
|
|
||||||
int GetAutoSetting() { return iCurAutoBufferSizeSetting; }
|
int GetAutoSetting() { return iCurAutoBufferSizeSetting; }
|
||||||
|
|
||||||
// TEST
|
|
||||||
void StoreAllSimAverages();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void UpdateAutoSetting();
|
void UpdateAutoSetting();
|
||||||
|
|
||||||
|
|
|
@ -135,11 +135,6 @@ public:
|
||||||
|
|
||||||
void CreateNetTranspPropsMessFromCurrentSettings();
|
void CreateNetTranspPropsMessFromCurrentSettings();
|
||||||
|
|
||||||
|
|
||||||
// TEST
|
|
||||||
void StoreAllSimAverages() { SockBuf.StoreAllSimAverages(); }
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool ProtocolIsEnabled();
|
bool ProtocolIsEnabled();
|
||||||
|
|
||||||
|
|
|
@ -942,11 +942,6 @@ void CLlconClientDlg::UpdateDisplay()
|
||||||
chbChat->setChecked ( true );
|
chbChat->setChecked ( true );
|
||||||
chbChat->blockSignals ( false );
|
chbChat->blockSignals ( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TEST
|
|
||||||
//pClient->GetChannel()->StoreAllSimAverages();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLlconClientDlg::SetGUIDesign ( const EGUIDesign eNewDesign )
|
void CLlconClientDlg::SetGUIDesign ( const EGUIDesign eNewDesign )
|
||||||
|
|
Loading…
Reference in a new issue