fixes the network data rate indicator and the time-out counter of the channel

This commit is contained in:
Volker Fischer 2020-04-13 18:46:04 +02:00
parent d9562ea525
commit e0c9ea5b6d
2 changed files with 27 additions and 16 deletions

View file

@ -27,12 +27,13 @@
// CChannel implementation *****************************************************
CChannel::CChannel ( const bool bNIsServer ) :
vecdGains ( MAX_NUM_CHANNELS, 1.0 ),
bDoAutoSockBufSize ( true ),
iFadeInCnt ( 0 ),
iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ),
bIsEnabled ( false ),
bIsServer ( bNIsServer )
vecdGains ( MAX_NUM_CHANNELS, 1.0 ),
bDoAutoSockBufSize ( true ),
iFadeInCnt ( 0 ),
iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ),
bIsEnabled ( false ),
bIsServer ( bNIsServer ),
iAudioFrameSizeSamples ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES )
{
// reset network transport properties
ResetNetworkTransportProperties();
@ -158,6 +159,16 @@ void CChannel::SetAudioStreamProperties ( const EAudComprType eNewAudComprType,
iNetwFrameSize = iNewNetwFrameSize;
iNetwFrameSizeFact = iNewNetwFrameSizeFact;
// update audio frame size
if ( eAudioCompressionType == CT_OPUS )
{
iAudioFrameSizeSamples = DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES;
}
else
{
iAudioFrameSizeSamples = SYSTEM_FRAME_SIZE_SAMPLES_SMALL;
}
MutexSocketBuf.lock();
{
// init socket buffer
@ -366,14 +377,17 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
iNetwFrameSizeFact = NetworkTransportProps.iBlockSizeFact;
iNetwFrameSize = static_cast<int> ( NetworkTransportProps.iBaseNetworkPacketSize );
// update maximum number of frames for fade in counter
// update maximum number of frames for fade in counter (only needed for server)
// and audio frame size
if ( eAudioCompressionType == CT_OPUS )
{
iFadeInCntMax = FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE;
iFadeInCntMax = FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE;
iAudioFrameSizeSamples = DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES;
}
else
{
iFadeInCntMax = FADE_IN_NUM_FRAMES;
iFadeInCntMax = FADE_IN_NUM_FRAMES;
iAudioFrameSizeSamples = SYSTEM_FRAME_SIZE_SAMPLES_SMALL;
}
MutexSocketBuf.lock();
@ -533,12 +547,8 @@ EGetDataStat CChannel::GetData ( CVector<uint8_t>& vecbyData,
// subtract the number of samples of the current block since the
// time out counter is based on samples not on blocks (definition:
// always one atomic block is get by using the GetData() function
// where the atomic block size is "SYSTEM_FRAME_SIZE_SAMPLES")
// TODO this code only works with the above assumption -> better
// implementation so that we are not depending on assumptions
iConTimeOut -= SYSTEM_FRAME_SIZE_SAMPLES;
// where the atomic block size is "iAudioFrameSizeSamples")
iConTimeOut -= iAudioFrameSizeSamples;
if ( iConTimeOut <= 0 )
{
@ -597,7 +607,7 @@ void CChannel::PrepAndSendPacket ( CHighPrioSocket* pSocket,
int CChannel::GetUploadRateKbps()
{
const int iAudioSizeOut = iNetwFrameSizeFact * SYSTEM_FRAME_SIZE_SAMPLES;
const int iAudioSizeOut = iNetwFrameSizeFact * iAudioFrameSizeSamples;
// we assume that the UDP packet which is transported via IP has an
// additional header size of ("Network Music Performance (NMP) in narrow

View file

@ -212,6 +212,7 @@ protected:
int iNetwFrameSizeFact;
int iNetwFrameSize;
int iAudioFrameSizeSamples;
EAudComprType eAudioCompressionType;
int iNumAudioChannels;