some code cleanup -> removed code which is not used right now
This commit is contained in:
parent
56f528b13e
commit
d0fc1353f4
3 changed files with 40 additions and 258 deletions
|
@ -184,10 +184,7 @@ void CNetBuf::Clear ( const EClearType eClearType )
|
||||||
if ( eClearType == CT_GET )
|
if ( eClearType == CT_GET )
|
||||||
{
|
{
|
||||||
// clear buffer since we had a buffer underrun
|
// clear buffer since we had a buffer underrun
|
||||||
if ( !bIsSimulation )
|
|
||||||
{
|
|
||||||
vecMemory.Reset ( 0 );
|
vecMemory.Reset ( 0 );
|
||||||
}
|
|
||||||
|
|
||||||
// reset buffer pointers so that they are at maximum distance after
|
// reset buffer pointers so that they are at maximum distance after
|
||||||
// the get operation (assign new fill level value to the get pointer)
|
// the get operation (assign new fill level value to the get pointer)
|
||||||
|
@ -237,99 +234,3 @@ void CNetBuf::Clear ( const EClearType eClearType )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Network buffer with statistic calculations implementation ******************/
|
|
||||||
/*
|
|
||||||
CNetBufWithStats::CNetBufWithStats() :
|
|
||||||
CNetBuf ( false ) // base class init: no simulation mode
|
|
||||||
{
|
|
||||||
// define the sizes of the simulation buffers,
|
|
||||||
// must be NUM_STAT_SIMULATION_BUFFERS elements!
|
|
||||||
viBufSizesForSim[0] = 2;
|
|
||||||
viBufSizesForSim[1] = 3;
|
|
||||||
viBufSizesForSim[2] = 4;
|
|
||||||
viBufSizesForSim[3] = 5;
|
|
||||||
viBufSizesForSim[4] = 6;
|
|
||||||
viBufSizesForSim[5] = 7;
|
|
||||||
viBufSizesForSim[6] = 8;
|
|
||||||
viBufSizesForSim[7] = 10;
|
|
||||||
viBufSizesForSim[8] = 12;
|
|
||||||
|
|
||||||
// set all simulation buffers in simulation mode
|
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
|
||||||
{
|
|
||||||
SimulationBuffer[i].SetIsSimulation ( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNetBufWithStats::Init ( const int iNewBlockSize,
|
|
||||||
const int iNewNumBlocks,
|
|
||||||
const bool bPreserve )
|
|
||||||
{
|
|
||||||
// call base class Init
|
|
||||||
CNetBuf::Init ( iNewBlockSize, iNewNumBlocks, bPreserve );
|
|
||||||
|
|
||||||
// inits for statistics calculation
|
|
||||||
if ( !bPreserve )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
|
||||||
{
|
|
||||||
// init simulation buffers with the correct size
|
|
||||||
SimulationBuffer[i].Init ( iNewBlockSize, viBufSizesForSim[i] );
|
|
||||||
|
|
||||||
// init statistics
|
|
||||||
ErrorRateStatistic[i].Init ( MAX_STATISTIC_COUNT );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CNetBufWithStats::Put ( const CVector<uint8_t>& vecbyData,
|
|
||||||
const int iInSize )
|
|
||||||
{
|
|
||||||
// call base class Put
|
|
||||||
const bool bPutOK = CNetBuf::Put ( vecbyData, iInSize );
|
|
||||||
|
|
||||||
// update statistics calculations
|
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
|
||||||
{
|
|
||||||
ErrorRateStatistic[i].Update (
|
|
||||||
!SimulationBuffer[i].Put ( vecbyData, iInSize ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return bPutOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CNetBufWithStats::Get ( CVector<uint8_t>& vecbyData )
|
|
||||||
{
|
|
||||||
// call base class Get
|
|
||||||
const bool bGetOK = CNetBuf::Get ( vecbyData );
|
|
||||||
|
|
||||||
// update statistics calculations
|
|
||||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
|
||||||
{
|
|
||||||
ErrorRateStatistic[i].Update (
|
|
||||||
!SimulationBuffer[i].Get ( vecbyData ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return bGetOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TEST for debugging
|
|
||||||
void CNetBufWithStats::StoreAllSimAverages()
|
|
||||||
{
|
|
||||||
FILE* pFile = fopen ( "c:\\temp\\test.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,9);plot2d( [2, 3, 4, 5, 6, 7, 8, 10, 12], x, style=-1 , logflag = 'nl');plot2d([2 12],[1 1]*0.01);plot2d([2 12],[1 1]*0.005);x
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
84
src/buffer.h
84
src/buffer.h
|
@ -29,32 +29,18 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
|
||||||
// each regular buffer access lead to a count for put and get, assuming 2.33 ms
|
|
||||||
// blocks we have 30 s / 2.33 ms * 2 = 25714
|
|
||||||
#define MAX_STATISTIC_COUNT 25714
|
|
||||||
|
|
||||||
// number of simulation network jitter buffers for evaluating the statistic
|
|
||||||
#define NUM_STAT_SIMULATION_BUFFERS 9
|
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
// Buffer base class -----------------------------------------------------------
|
// Buffer base class -----------------------------------------------------------
|
||||||
template<class TData> class CBufferBase
|
template<class TData> class CBufferBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBufferBase ( const bool bNIsSim = false ) :
|
CBufferBase() : bIsInitialized ( false ) {}
|
||||||
bIsSimulation ( bNIsSim ), bIsInitialized ( false ) {}
|
|
||||||
|
|
||||||
void SetIsSimulation ( const bool bNIsSim ) { bIsSimulation = bNIsSim; }
|
|
||||||
|
|
||||||
virtual void Init ( const int iNewMemSize,
|
virtual void Init ( const int iNewMemSize,
|
||||||
const bool bPreserve = false )
|
const bool bPreserve = false )
|
||||||
{
|
{
|
||||||
// in simulation mode the size is not changed during operation -> we do
|
|
||||||
// not have to implement special code for this case
|
|
||||||
// only enter the "preserve" branch, if object was already initialized
|
// only enter the "preserve" branch, if object was already initialized
|
||||||
if ( bPreserve && ( !bIsSimulation ) && bIsInitialized )
|
if ( bPreserve && bIsInitialized )
|
||||||
{
|
{
|
||||||
// copy old data in new vector using get pointer as zero per
|
// copy old data in new vector using get pointer as zero per
|
||||||
// definition
|
// definition
|
||||||
|
@ -157,10 +143,7 @@ public:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// allocate memory for actual data buffer
|
// allocate memory for actual data buffer
|
||||||
if ( !bIsSimulation )
|
|
||||||
{
|
|
||||||
vecMemory.Init ( iNewMemSize );
|
vecMemory.Init ( iNewMemSize );
|
||||||
}
|
|
||||||
|
|
||||||
// init buffer pointers and buffer state (empty buffer)
|
// init buffer pointers and buffer state (empty buffer)
|
||||||
iGetPos = 0;
|
iGetPos = 0;
|
||||||
|
@ -177,18 +160,6 @@ public:
|
||||||
|
|
||||||
virtual bool Put ( const CVector<TData>& vecData,
|
virtual bool Put ( const CVector<TData>& vecData,
|
||||||
const int iInSize )
|
const int iInSize )
|
||||||
{
|
|
||||||
if ( bIsSimulation )
|
|
||||||
{
|
|
||||||
// in this simulation only the buffer pointers and the buffer state
|
|
||||||
// is updated, no actual data is transferred
|
|
||||||
iPutPos += iInSize;
|
|
||||||
if ( iPutPos >= iMemSize )
|
|
||||||
{
|
|
||||||
iPutPos -= iMemSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// copy new data in internal buffer
|
// copy new data in internal buffer
|
||||||
int iCurPos = 0;
|
int iCurPos = 0;
|
||||||
|
@ -217,7 +188,6 @@ public:
|
||||||
vecMemory[iPutPos++] = vecData[iCurPos++];
|
vecMemory[iPutPos++] = vecData[iCurPos++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// set buffer state flag
|
// set buffer state flag
|
||||||
if ( iPutPos == iGetPos )
|
if ( iPutPos == iGetPos )
|
||||||
|
@ -237,18 +207,6 @@ public:
|
||||||
// get size of data to be get from the buffer
|
// get size of data to be get from the buffer
|
||||||
const int iInSize = vecData.Size();
|
const int iInSize = vecData.Size();
|
||||||
|
|
||||||
if ( bIsSimulation )
|
|
||||||
{
|
|
||||||
// in this simulation only the buffer pointers and the buffer state
|
|
||||||
// is updated, no actual data is transferred
|
|
||||||
iGetPos += iInSize;
|
|
||||||
if ( iGetPos >= iMemSize )
|
|
||||||
{
|
|
||||||
iGetPos -= iMemSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// copy data from internal buffer in output buffer
|
// copy data from internal buffer in output buffer
|
||||||
int iCurPos = 0;
|
int iCurPos = 0;
|
||||||
if ( iGetPos + iInSize > iMemSize )
|
if ( iGetPos + iInSize > iMemSize )
|
||||||
|
@ -276,7 +234,6 @@ public:
|
||||||
vecData[iCurPos++] = vecMemory[iGetPos++];
|
vecData[iCurPos++] = vecMemory[iGetPos++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// set buffer state flag
|
// set buffer state flag
|
||||||
if ( iPutPos == iGetPos )
|
if ( iPutPos == iGetPos )
|
||||||
|
@ -341,7 +298,6 @@ protected:
|
||||||
int iGetPos;
|
int iGetPos;
|
||||||
int iPutPos;
|
int iPutPos;
|
||||||
EBufState eBufState;
|
EBufState eBufState;
|
||||||
bool bIsSimulation;
|
|
||||||
bool bIsInitialized;
|
bool bIsInitialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -350,9 +306,6 @@ protected:
|
||||||
class CNetBuf : public CBufferBase<uint8_t>
|
class CNetBuf : public CBufferBase<uint8_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CNetBuf ( const bool bNewIsSim = false ) :
|
|
||||||
CBufferBase<uint8_t> ( bNewIsSim ) {}
|
|
||||||
|
|
||||||
virtual void Init ( const int iNewBlockSize,
|
virtual void Init ( const int iNewBlockSize,
|
||||||
const int iNewNumBlocks,
|
const int iNewNumBlocks,
|
||||||
const bool bPreserve = false );
|
const bool bPreserve = false );
|
||||||
|
@ -372,39 +325,6 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// This is a test class which provides statistic for a certain number of
|
|
||||||
// simulation buffers -> was intended to improve the auto jitter buffer
|
|
||||||
// setting but we stick to the old auto mechanism because of some draw backs
|
|
||||||
// of the simulated jitter buffers like that if burst errors occur, we would
|
|
||||||
// have to exclude it to not to effect the error rate too much and others...
|
|
||||||
|
|
||||||
// Network buffer (jitter buffer) with statistic calculations ------------------
|
|
||||||
class CNetBufWithStats : public CNetBuf
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CNetBufWithStats();
|
|
||||||
|
|
||||||
virtual void Init ( const int iNewBlockSize,
|
|
||||||
const int iNewNumBlocks,
|
|
||||||
const bool bPreserve = false );
|
|
||||||
|
|
||||||
virtual bool Put ( const CVector<uint8_t>& vecbyData, const int iInSize );
|
|
||||||
virtual bool Get ( CVector<uint8_t>& vecbyData );
|
|
||||||
|
|
||||||
// TEST
|
|
||||||
void StoreAllSimAverages();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// statistic (do not use the vector class since the classes do not have
|
|
||||||
// appropriate copy constructor/operator)
|
|
||||||
CErrorRate ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS];
|
|
||||||
CNetBuf SimulationBuffer[NUM_STAT_SIMULATION_BUFFERS];
|
|
||||||
int viBufSizesForSim[NUM_STAT_SIMULATION_BUFFERS];
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Conversion buffer (very simple buffer) --------------------------------------
|
// Conversion buffer (very simple buffer) --------------------------------------
|
||||||
// For this very simple buffer no wrap around mechanism is implemented. We
|
// For this very simple buffer no wrap around mechanism is implemented. We
|
||||||
// assume here, that the applied buffers are an integer fraction of the total
|
// assume here, that the applied buffers are an integer fraction of the total
|
||||||
|
|
39
src/util.h
39
src/util.h
|
@ -796,43 +796,4 @@ protected:
|
||||||
int iNewValueBoundFactor;
|
int iNewValueBoundFactor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Error rate measurement ------------------------------------------------------
|
|
||||||
class CErrorRate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CErrorRate() {}
|
|
||||||
|
|
||||||
void Init ( const int iHistoryLength )
|
|
||||||
{
|
|
||||||
// initialize buffer
|
|
||||||
ErrorsMovAvBuf.Init ( iHistoryLength );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Reset()
|
|
||||||
{
|
|
||||||
ErrorsMovAvBuf.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update ( const bool bState )
|
|
||||||
{
|
|
||||||
// add errors as values 0 and 1 to get correct error rate average
|
|
||||||
if ( bState )
|
|
||||||
{
|
|
||||||
ErrorsMovAvBuf.Add ( 1.0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ErrorsMovAvBuf.Add ( 0.0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the standard deviation, for that we need to calculate
|
|
||||||
// the sqaure root
|
|
||||||
double GetAverage() { return ErrorsMovAvBuf.GetAverage(); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
CMovingAv<double> ErrorsMovAvBuf;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|
#endif /* !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||||
|
|
Loading…
Reference in a new issue