Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
iNetwFrameSizeFact = NetworkTransportProps.iBlockSizeFact;
iNetwFrameSize = static_cast<int> ( NetworkTransportProps.iBaseNetworkPacketSize );
bUseSequenceNumber = ( NetworkTransportProps.eFlags == NF_WITH_COUNTER );
iAudioCodingArg = NetworkTransportProps.iAudioCodingArg;

if ( bUseSequenceNumber )
{
Expand Down Expand Up @@ -522,7 +523,7 @@ CNetworkTransportProps CChannel::GetNetworkTransportPropsFromCurrentSettings()
SYSTEM_SAMPLE_RATE_HZ,
eAudioCompressionType,
eFlags,
0 );
iAudioCodingArg );
}

void CChannel::Disconnect()
Expand Down
3 changes: 3 additions & 0 deletions src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class CChannel : public QObject

EAudComprType GetAudioCompressionType() { return eAudioCompressionType; }
int GetNumAudioChannels() const { return iNumAudioChannels; }
int GetAudioCodingArg() const { return iAudioCodingArg; }
void SetAudioCodingArg ( int iNAudioCodingArg ) { iAudioCodingArg = iNAudioCodingArg; }

// network protocol interface
void CreateJitBufMes ( const int iJitBufSize )
Expand Down Expand Up @@ -245,6 +247,7 @@ class CChannel : public QObject
int iNetwFrameSize;
int iCeltNumCodedBytes;
int iAudioFrameSizeSamples;
int iAudioCodingArg;

EAudComprType eAudioCompressionType;
int iNumAudioChannels;
Expand Down
2 changes: 2 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,8 @@ void CClient::Init()
}
}

Channel.SetAudioCodingArg ( eAudioQuality );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the server aware of the audio quality set in the client. Before that we had to guess by the packet sizes.


// calculate stereo (two channels) buffer size
iStereoBlockSizeSam = 2 * iMonoBlockSizeSam;

Expand Down
8 changes: 6 additions & 2 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ CServer::CServer ( const int iNewMaxNumChan,
vecNumFrameSizeConvBlocks.Init ( iMaxNumChannels );
vecUseDoubleSysFraSizeConvBuf.Init ( iMaxNumChannels );
vecAudioComprType.Init ( iMaxNumChannels );
vecAudioCodingArg.Init ( iMaxNumChannels );

for ( i = 0; i < iMaxNumChannels; i++ )
{
Expand Down Expand Up @@ -844,6 +845,7 @@ void CServer::DecodeReceiveData ( const int iChanCnt, const int iNumClients )
// get and store number of audio channels and compression type
vecNumAudioChannels[iChanCnt] = vecChannels[iCurChanID].GetNumAudioChannels();
vecAudioComprType[iChanCnt] = vecChannels[iCurChanID].GetAudioCompressionType();
vecAudioCodingArg[iChanCnt] = vecChannels[iCurChanID].GetAudioCodingArg();

// get info about required frame size conversion properties
vecUseDoubleSysFraSizeConvBuf[iChanCnt] = ( !bUseDoubleSystemFrameSize && ( vecAudioComprType[iChanCnt] == CT_OPUS ) );
Expand Down Expand Up @@ -974,7 +976,8 @@ void CServer::DecodeReceiveData ( const int iChanCnt, const int iNumClients )
// sizeof ( int16_t ) is the size in bytes for the raw pcm audio data = 2
// Sizes other than that are considered OPUS coded because those depend on hardcoded sizes in client.h
const bool bIsRawAudio =
( iCeltNumCodedBytes == static_cast<int> ( sizeof ( int16_t ) * iClientFrameSizeSamples * vecNumAudioChannels[iChanCnt] ) );
( vecAudioCodingArg[iChanCnt] == AQ_RAW ||
iCeltNumCodedBytes == static_cast<int> ( sizeof ( int16_t ) * iClientFrameSizeSamples * vecNumAudioChannels[iChanCnt] ) );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this in for backwards compatibility. We could deprecate this with a TODO: to be removed, same for the transmitting side.


const int iOffset = iB * SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[iChanCnt];

Expand Down Expand Up @@ -1263,7 +1266,8 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, const int iNumClients
DoubleFrameSizeConvBufOut[iCurChanID].GetAll ( vecsSendData, DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[iChanCnt] );
}

if ( iCeltNumCodedBytes != static_cast<int> ( sizeof ( int16_t ) * iClientFrameSizeSamples * vecNumAudioChannels[iChanCnt] ) )
if ( vecAudioCodingArg[iChanCnt] != AQ_RAW &&
iCeltNumCodedBytes != static_cast<int> ( sizeof ( int16_t ) * iClientFrameSizeSamples * vecNumAudioChannels[iChanCnt] ) )
{
// OPUS encoding
if ( CurOpusEncoder != nullptr )
Expand Down
1 change: 1 addition & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class CServer : public QObject, public CServerSlots<MAX_NUM_CHANNELS>
CVector<int> vecNumFrameSizeConvBlocks;
CVector<int> vecUseDoubleSysFraSizeConvBuf;
CVector<EAudComprType> vecAudioComprType;
CVector<int> vecAudioCodingArg;
CVector<CVector<int16_t>> vecvecsSendData;
CVector<CVector<float>> vecvecfIntermediateProcBuf;
CVector<CVector<uint8_t>> vecvecbyCodedData;
Expand Down
Loading