bug fix: use OPUS custom interface instead of the normal one
This commit is contained in:
parent
dcbfba2fd9
commit
694ee2fae2
5 changed files with 129 additions and 130 deletions
|
@ -134,6 +134,7 @@ HEADERS += src/audiomixerboard.h \
|
|||
libs/celt/cc6_vq.h \
|
||||
libs/opus/include/opus.h \
|
||||
libs/opus/include/opus_multistream.h \
|
||||
libs/opus/include/opus_custom.h \
|
||||
libs/opus/src/opus_private.h \
|
||||
libs/opus/celt/arch.h \
|
||||
libs/opus/celt/bands.h \
|
||||
|
|
|
@ -67,22 +67,25 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
|
||||
#endif
|
||||
|
||||
OpusEncoderMono = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
1,
|
||||
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
|
||||
OpusMode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
&iOpusError );
|
||||
|
||||
OpusDecoderMono = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
OpusEncoderMono = opus_custom_encoder_create ( OpusMode,
|
||||
1,
|
||||
&iOpusError );
|
||||
|
||||
OpusDecoderMono = opus_custom_decoder_create ( OpusMode,
|
||||
1,
|
||||
&iOpusError );
|
||||
|
||||
// we require a constant bit rate
|
||||
opus_encoder_ctl ( OpusEncoderMono,
|
||||
opus_custom_encoder_ctl ( OpusEncoderMono,
|
||||
OPUS_SET_VBR ( 0 ) );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
opus_encoder_ctl ( OpusEncoderMono,
|
||||
opus_custom_encoder_ctl ( OpusEncoderMono,
|
||||
OPUS_SET_COMPLEXITY ( 1 ) );
|
||||
#endif
|
||||
|
||||
|
@ -99,22 +102,21 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
|
||||
#endif
|
||||
|
||||
OpusEncoderStereo = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
OpusEncoderStereo = opus_custom_encoder_create ( OpusMode,
|
||||
2,
|
||||
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
|
||||
&iOpusError );
|
||||
|
||||
OpusDecoderStereo = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
OpusDecoderStereo = opus_custom_decoder_create ( OpusMode,
|
||||
2,
|
||||
&iOpusError );
|
||||
|
||||
// we require a constant bit rate
|
||||
opus_encoder_ctl ( OpusEncoderStereo,
|
||||
opus_custom_encoder_ctl ( OpusEncoderStereo,
|
||||
OPUS_SET_VBR ( 0 ) );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
opus_encoder_ctl ( OpusEncoderStereo,
|
||||
opus_custom_encoder_ctl ( OpusEncoderStereo,
|
||||
OPUS_SET_COMPLEXITY ( 1 ) );
|
||||
#endif
|
||||
|
||||
|
@ -731,12 +733,12 @@ void CClient::Init()
|
|||
|
||||
if ( bUseStereo )
|
||||
{
|
||||
opus_encoder_ctl ( OpusEncoderStereo,
|
||||
opus_custom_encoder_ctl ( OpusEncoderStereo,
|
||||
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
opus_encoder_ctl ( OpusEncoderMono,
|
||||
opus_custom_encoder_ctl ( OpusEncoderMono,
|
||||
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
|
||||
}
|
||||
|
||||
|
@ -971,7 +973,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_encode ( OpusEncoderStereo,
|
||||
opus_custom_encode ( OpusEncoderStereo,
|
||||
&vecsNetwork[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
&vecCeltData[0],
|
||||
|
@ -991,7 +993,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_encode ( OpusEncoderMono,
|
||||
opus_custom_encode ( OpusEncoderMono,
|
||||
&vecsNetwork[i * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
&vecCeltData[0],
|
||||
|
@ -1035,12 +1037,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderStereo,
|
||||
opus_custom_decode ( OpusDecoderStereo,
|
||||
&vecbyNetwData[0],
|
||||
iCeltNumCodedBytes,
|
||||
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1054,12 +1055,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderMono,
|
||||
opus_custom_decode ( OpusDecoderMono,
|
||||
&vecbyNetwData[0],
|
||||
iCeltNumCodedBytes,
|
||||
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1077,12 +1077,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderStereo,
|
||||
opus_custom_decode ( OpusDecoderStereo,
|
||||
NULL,
|
||||
iCeltNumCodedBytes,
|
||||
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1096,12 +1095,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderMono,
|
||||
opus_custom_decode ( OpusDecoderMono,
|
||||
NULL,
|
||||
iCeltNumCodedBytes,
|
||||
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
src/client.h
11
src/client.h
|
@ -31,7 +31,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include "cc6_celt.h"
|
||||
#include "opus.h"
|
||||
#include "opus_custom.h"
|
||||
#include "global.h"
|
||||
#include "socket.h"
|
||||
#include "channel.h"
|
||||
|
@ -275,10 +275,11 @@ void SetAudoCompressiontype ( const EAudComprType eNAudCompressionType );
|
|||
cc6_CELTMode* CeltModeStereo;
|
||||
cc6_CELTEncoder* CeltEncoderStereo;
|
||||
cc6_CELTDecoder* CeltDecoderStereo;
|
||||
OpusEncoder* OpusEncoderMono;
|
||||
OpusDecoder* OpusDecoderMono;
|
||||
OpusEncoder* OpusEncoderStereo;
|
||||
OpusDecoder* OpusDecoderStereo;
|
||||
OpusCustomMode* OpusMode;
|
||||
OpusCustomEncoder* OpusEncoderMono;
|
||||
OpusCustomDecoder* OpusDecoderMono;
|
||||
OpusCustomEncoder* OpusEncoderStereo;
|
||||
OpusCustomDecoder* OpusDecoderStereo;
|
||||
EAudComprType eAudioCompressionType;
|
||||
int iCeltNumCodedBytes;
|
||||
bool bCeltDoHighQuality;
|
||||
|
|
|
@ -207,22 +207,25 @@ CServer::CServer ( const int iNewNumChan,
|
|||
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
|
||||
#endif
|
||||
|
||||
OpusEncoderMono[i] = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
1,
|
||||
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
|
||||
OpusMode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
&iOpusError );
|
||||
|
||||
OpusDecoderMono[i] = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
OpusEncoderMono[i] = opus_custom_encoder_create ( OpusMode[i],
|
||||
1,
|
||||
&iOpusError );
|
||||
|
||||
OpusDecoderMono[i] = opus_custom_decoder_create ( OpusMode[i],
|
||||
1,
|
||||
&iOpusError );
|
||||
|
||||
// we require a constant bit rate
|
||||
opus_encoder_ctl ( OpusEncoderMono[i],
|
||||
opus_custom_encoder_ctl ( OpusEncoderMono[i],
|
||||
OPUS_SET_VBR ( 0 ) );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
opus_encoder_ctl ( OpusEncoderMono[i],
|
||||
opus_custom_encoder_ctl ( OpusEncoderMono[i],
|
||||
OPUS_SET_COMPLEXITY ( 1 ) );
|
||||
#endif
|
||||
|
||||
|
@ -239,22 +242,21 @@ CServer::CServer ( const int iNewNumChan,
|
|||
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
|
||||
#endif
|
||||
|
||||
OpusEncoderStereo[i] = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
OpusEncoderStereo[i] = opus_custom_encoder_create ( OpusMode[i],
|
||||
2,
|
||||
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
|
||||
&iOpusError );
|
||||
|
||||
OpusDecoderStereo[i] = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
OpusDecoderStereo[i] = opus_custom_decoder_create ( OpusMode[i],
|
||||
2,
|
||||
&iOpusError );
|
||||
|
||||
// we require a constant bit rate
|
||||
opus_encoder_ctl ( OpusEncoderStereo[i],
|
||||
opus_custom_encoder_ctl ( OpusEncoderStereo[i],
|
||||
OPUS_SET_VBR ( 0 ) );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
opus_encoder_ctl ( OpusEncoderStereo[i],
|
||||
opus_custom_encoder_ctl ( OpusEncoderStereo[i],
|
||||
OPUS_SET_COMPLEXITY ( 1 ) );
|
||||
#endif
|
||||
}
|
||||
|
@ -633,12 +635,11 @@ void CServer::OnTimer()
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderMono[iCurChanID],
|
||||
opus_custom_decode ( OpusDecoderMono[iCurChanID],
|
||||
&vecbyData[0],
|
||||
iCeltNumCodedBytes,
|
||||
&vecvecsData[i][0],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -654,12 +655,11 @@ void CServer::OnTimer()
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderStereo[iCurChanID],
|
||||
opus_custom_decode ( OpusDecoderStereo[iCurChanID],
|
||||
&vecbyData[0],
|
||||
iCeltNumCodedBytes,
|
||||
&vecvecsData[i][0],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -679,12 +679,11 @@ void CServer::OnTimer()
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderMono[iCurChanID],
|
||||
opus_custom_decode ( OpusDecoderMono[iCurChanID],
|
||||
NULL,
|
||||
iCeltNumCodedBytes,
|
||||
&vecvecsData[i][0],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -700,12 +699,11 @@ void CServer::OnTimer()
|
|||
}
|
||||
else
|
||||
{
|
||||
opus_decode ( OpusDecoderStereo[iCurChanID],
|
||||
opus_custom_decode ( OpusDecoderStereo[iCurChanID],
|
||||
NULL,
|
||||
iCeltNumCodedBytes,
|
||||
&vecvecsData[i][0],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
0 );
|
||||
SYSTEM_FRAME_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -784,10 +782,10 @@ const int iCeltBitRateBitsPerSec =
|
|||
// TODO find a better place than this: the setting does not change all the time
|
||||
// so for speed optimization it would be better to set it only if the network
|
||||
// frame size is changed
|
||||
opus_encoder_ctl ( OpusEncoderMono[iCurChanID],
|
||||
opus_custom_encoder_ctl ( OpusEncoderMono[iCurChanID],
|
||||
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
|
||||
|
||||
opus_encode ( OpusEncoderMono[iCurChanID],
|
||||
opus_custom_encode ( OpusEncoderMono[iCurChanID],
|
||||
&vecsSendData[0],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
&vecCeltData[0],
|
||||
|
@ -811,10 +809,10 @@ opus_encoder_ctl ( OpusEncoderMono[iCurChanID],
|
|||
// TODO find a better place than this: the setting does not change all the time
|
||||
// so for speed optimization it would be better to set it only if the network
|
||||
// frame size is changed
|
||||
opus_encoder_ctl ( OpusEncoderStereo[iCurChanID],
|
||||
opus_custom_encoder_ctl ( OpusEncoderStereo[iCurChanID],
|
||||
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
|
||||
|
||||
opus_encode ( OpusEncoderStereo[iCurChanID],
|
||||
opus_custom_encode ( OpusEncoderStereo[iCurChanID],
|
||||
&vecsSendData[0],
|
||||
SYSTEM_FRAME_SIZE_SAMPLES,
|
||||
&vecCeltData[0],
|
||||
|
|
11
src/server.h
11
src/server.h
|
@ -30,7 +30,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QHostAddress>
|
||||
#include "cc6_celt.h"
|
||||
#include "opus.h"
|
||||
#include "opus_custom.h"
|
||||
#include "global.h"
|
||||
#include "socket.h"
|
||||
#include "channel.h"
|
||||
|
@ -214,10 +214,11 @@ protected:
|
|||
cc6_CELTMode* CeltModeStereo[MAX_NUM_CHANNELS];
|
||||
cc6_CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS];
|
||||
cc6_CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS];
|
||||
OpusEncoder* OpusEncoderMono[MAX_NUM_CHANNELS];
|
||||
OpusDecoder* OpusDecoderMono[MAX_NUM_CHANNELS];
|
||||
OpusEncoder* OpusEncoderStereo[MAX_NUM_CHANNELS];
|
||||
OpusDecoder* OpusDecoderStereo[MAX_NUM_CHANNELS];
|
||||
OpusCustomMode* OpusMode[MAX_NUM_CHANNELS];
|
||||
OpusCustomEncoder* OpusEncoderMono[MAX_NUM_CHANNELS];
|
||||
OpusCustomDecoder* OpusDecoderMono[MAX_NUM_CHANNELS];
|
||||
OpusCustomEncoder* OpusEncoderStereo[MAX_NUM_CHANNELS];
|
||||
OpusCustomDecoder* OpusDecoderStereo[MAX_NUM_CHANNELS];
|
||||
|
||||
CVector<QString> vstrChatColors;
|
||||
|
||||
|
|
Loading…
Reference in a new issue