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

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

View file

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