added configurations "CONFIG+=opus_shared_lib" for using OPUS as a shared lib and "CONFIG+=nocelt" to disable legacy support for the old CELT library
This commit is contained in:
parent
afa2f0e812
commit
7918416054
4 changed files with 56 additions and 14 deletions
|
@ -66,16 +66,18 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
int iOpusError;
|
||||
|
||||
// init audio encoder/decoder (mono)
|
||||
#ifdef USE_LEGACY_CELT
|
||||
CeltModeMono = cc6_celt_mode_create (
|
||||
SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
|
||||
|
||||
CeltEncoderMono = cc6_celt_encoder_create ( CeltModeMono );
|
||||
CeltDecoderMono = cc6_celt_decoder_create ( CeltModeMono );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
# ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
cc6_celt_encoder_ctl ( CeltEncoderMono,
|
||||
cc6_CELT_SET_COMPLEXITY ( 1 ) );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
OpusMode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
|
@ -105,16 +107,18 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
#endif
|
||||
|
||||
// init audio encoder/decoder (stereo)
|
||||
#ifdef USE_LEGACY_CELT
|
||||
CeltModeStereo = cc6_celt_mode_create (
|
||||
SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
|
||||
|
||||
CeltEncoderStereo = cc6_celt_encoder_create ( CeltModeStereo );
|
||||
CeltDecoderStereo = cc6_celt_decoder_create ( CeltModeStereo );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
# ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
cc6_celt_encoder_ctl ( CeltEncoderStereo,
|
||||
cc6_CELT_SET_COMPLEXITY ( 1 ) );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
OpusEncoderStereo = opus_custom_encoder_create ( OpusMode,
|
||||
|
@ -179,8 +183,10 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
SIGNAL ( ChatTextReceived ( QString ) ) );
|
||||
|
||||
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
|
||||
#ifdef USE_LEGACY_CELT
|
||||
QObject::connect ( &Channel, SIGNAL ( OpusSupported() ),
|
||||
this, SLOT ( OnOpusSupported() ) );
|
||||
#endif
|
||||
|
||||
QObject::connect ( &ConnLessProtocol,
|
||||
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
|
||||
|
@ -419,6 +425,7 @@ void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
|
|||
}
|
||||
|
||||
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
|
||||
#ifdef USE_LEGACY_CELT
|
||||
void CClient::OnOpusSupported()
|
||||
{
|
||||
if ( eAudioCompressionType != CT_OPUS )
|
||||
|
@ -429,8 +436,10 @@ void CClient::OnOpusSupported()
|
|||
// inform the GUI about the change of the network rate
|
||||
emit UpstreamRateChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
|
||||
#ifdef USE_LEGACY_CELT
|
||||
void CClient::SetAudoCompressiontype ( const EAudComprType eNAudCompressionType )
|
||||
{
|
||||
// init with new parameter, if client was running then first
|
||||
|
@ -450,6 +459,7 @@ void CClient::SetAudoCompressiontype ( const EAudComprType eNAudCompressionType
|
|||
Sound.Start();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CClient::SetAudioQuality ( const EAudioQuality eNAudioQuality )
|
||||
{
|
||||
|
@ -637,8 +647,12 @@ void CClient::Start()
|
|||
{
|
||||
|
||||
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
|
||||
#ifdef USE_LEGACY_CELT
|
||||
// our first attempt is always to use the old code
|
||||
eAudioCompressionType = CT_CELT;
|
||||
#else
|
||||
eAudioCompressionType = CT_OPUS;
|
||||
#endif
|
||||
|
||||
// init object
|
||||
Init();
|
||||
|
@ -771,6 +785,7 @@ void CClient::Init()
|
|||
AudioReverbR.Init ( SYSTEM_SAMPLE_RATE_HZ );
|
||||
|
||||
// inits for audio coding
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( eAudioCompressionType == CT_CELT )
|
||||
{
|
||||
if ( eAudioChannelConf == CC_MONO )
|
||||
|
@ -797,6 +812,7 @@ void CClient::Init()
|
|||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if ( eAudioChannelConf == CC_MONO )
|
||||
{
|
||||
|
@ -1069,6 +1085,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
if ( eAudioChannelConf == CC_MONO )
|
||||
{
|
||||
// encode current audio frame
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( eAudioCompressionType == CT_CELT )
|
||||
{
|
||||
cc6_celt_encode ( CeltEncoderMono,
|
||||
|
@ -1078,6 +1095,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
iCeltNumCodedBytes );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_encode ( OpusEncoderMono,
|
||||
&vecsStereoSndCrd[i * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
|
@ -1089,6 +1107,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
else
|
||||
{
|
||||
// encode current audio frame
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( eAudioCompressionType == CT_CELT )
|
||||
{
|
||||
cc6_celt_encode ( CeltEncoderStereo,
|
||||
|
@ -1098,6 +1117,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
iCeltNumCodedBytes );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_encode ( OpusEncoderStereo,
|
||||
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
|
||||
|
@ -1136,6 +1156,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
|
||||
if ( eAudioChannelConf == CC_MONO )
|
||||
{
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( eAudioCompressionType == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderMono,
|
||||
|
@ -1144,6 +1165,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderMono,
|
||||
&vecbyNetwData[0],
|
||||
|
@ -1154,6 +1176,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( eAudioCompressionType == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderStereo,
|
||||
|
@ -1162,6 +1185,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderStereo,
|
||||
&vecbyNetwData[0],
|
||||
|
@ -1176,6 +1200,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
// lost packet
|
||||
if ( eAudioChannelConf == CC_MONO )
|
||||
{
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( eAudioCompressionType == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderMono,
|
||||
|
@ -1184,6 +1209,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderMono,
|
||||
NULL,
|
||||
|
@ -1194,6 +1220,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( eAudioCompressionType == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderStereo,
|
||||
|
@ -1202,6 +1229,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderStereo,
|
||||
NULL,
|
||||
|
|
10
src/client.h
10
src/client.h
|
@ -74,17 +74,19 @@
|
|||
// audio reverberation range
|
||||
#define AUD_REVERB_MAX 100
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
// CELT number of coded bytes per audio packet
|
||||
// 24: mono low quality 156 kbps (128) / 114 kbps (256)
|
||||
// 44: mono normal quality 216 kbps (128) / 174 kbps (256)
|
||||
// NOTE: Must be > CELT_MINIMUM_NUM_BYTES (greater, not equal to!)
|
||||
#define CELT_NUM_BYTES_MONO_LOW_QUALITY 24
|
||||
#define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 44
|
||||
# define CELT_NUM_BYTES_MONO_LOW_QUALITY 24
|
||||
# define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 44
|
||||
|
||||
// 46: stereo low quality 222 kbps (128) / 180 kbps (256)
|
||||
// 70: stereo normal quality 294 kbps (128) / 252 kbps (256)
|
||||
#define CELT_NUM_BYTES_STEREO_LOW_QUALITY 46
|
||||
#define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 70
|
||||
# define CELT_NUM_BYTES_STEREO_LOW_QUALITY 46
|
||||
# define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 70
|
||||
#endif
|
||||
|
||||
// OPUS number of coded bytes per audio packet
|
||||
// TODO we have to use new numbers for OPUS to avoid that old CELT packets
|
||||
|
|
|
@ -181,8 +181,10 @@ public slots:
|
|||
void OnConnectDlgAccepted();
|
||||
void OnDisconnected();
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
void OnUpstreamRateChanged()
|
||||
{ ClientSettingsDlg.UpdateDisplay(); }
|
||||
#endif
|
||||
|
||||
void OnGUIDesignChanged()
|
||||
{ SetGUIDesign ( pClient->GetGUIDesign() ); }
|
||||
|
|
|
@ -228,16 +228,18 @@ CServer::CServer ( const int iNewMaxNumChan,
|
|||
for ( i = 0; i < iMaxNumChannels; i++ )
|
||||
{
|
||||
// init audio endocder/decoder (mono)
|
||||
#ifdef USE_LEGACY_CELT
|
||||
CeltModeMono[i] = cc6_celt_mode_create (
|
||||
SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
|
||||
|
||||
CeltEncoderMono[i] = cc6_celt_encoder_create ( CeltModeMono[i] );
|
||||
CeltDecoderMono[i] = cc6_celt_decoder_create ( CeltModeMono[i] );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
# ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
cc6_celt_encoder_ctl ( CeltEncoderMono[i],
|
||||
cc6_CELT_SET_COMPLEXITY ( 1 ) );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
OpusMode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
|
||||
|
@ -267,16 +269,18 @@ CServer::CServer ( const int iNewMaxNumChan,
|
|||
#endif
|
||||
|
||||
// init audio endocder/decoder (stereo)
|
||||
#ifdef USE_LEGACY_CELT
|
||||
CeltModeStereo[i] = cc6_celt_mode_create (
|
||||
SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
|
||||
|
||||
CeltEncoderStereo[i] = cc6_celt_encoder_create ( CeltModeStereo[i] );
|
||||
CeltDecoderStereo[i] = cc6_celt_decoder_create ( CeltModeStereo[i] );
|
||||
|
||||
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
# ifdef USE_LOW_COMPLEXITY_CELT_ENC
|
||||
// set encoder low complexity
|
||||
cc6_celt_encoder_ctl ( CeltEncoderStereo[i],
|
||||
cc6_CELT_SET_COMPLEXITY ( 1 ) );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
OpusEncoderStereo[i] = opus_custom_encoder_create ( OpusMode[i],
|
||||
|
@ -747,7 +751,7 @@ void CServer::OnTimer()
|
|||
if ( iCurNumAudChan == 1 )
|
||||
{
|
||||
// mono
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderMono[iCurChanID],
|
||||
|
@ -756,6 +760,7 @@ void CServer::OnTimer()
|
|||
&vecvecsData[i][0] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderMono[iCurChanID],
|
||||
&vecbyCodedData[0],
|
||||
|
@ -767,7 +772,7 @@ void CServer::OnTimer()
|
|||
else
|
||||
{
|
||||
// stereo
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderStereo[iCurChanID],
|
||||
|
@ -776,6 +781,7 @@ void CServer::OnTimer()
|
|||
&vecvecsData[i][0] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderStereo[iCurChanID],
|
||||
&vecbyCodedData[0],
|
||||
|
@ -791,7 +797,7 @@ void CServer::OnTimer()
|
|||
if ( iCurNumAudChan == 1 )
|
||||
{
|
||||
// mono
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderMono[iCurChanID],
|
||||
|
@ -800,6 +806,7 @@ void CServer::OnTimer()
|
|||
&vecvecsData[i][0] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderMono[iCurChanID],
|
||||
NULL,
|
||||
|
@ -811,7 +818,7 @@ void CServer::OnTimer()
|
|||
else
|
||||
{
|
||||
// stereo
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
|
||||
{
|
||||
cc6_celt_decode ( CeltDecoderStereo[iCurChanID],
|
||||
|
@ -820,6 +827,7 @@ void CServer::OnTimer()
|
|||
&vecvecsData[i][0] );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
opus_custom_decode ( OpusDecoderStereo[iCurChanID],
|
||||
NULL,
|
||||
|
@ -871,7 +879,7 @@ void CServer::OnTimer()
|
|||
if ( vecChannels[iCurChanID].GetNumAudioChannels() == 1 )
|
||||
{
|
||||
// mono:
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
|
||||
{
|
||||
cc6_celt_encode ( CeltEncoderMono[iCurChanID],
|
||||
|
@ -881,6 +889,7 @@ void CServer::OnTimer()
|
|||
iCeltNumCodedBytes );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
// TODO find a better place than this: the setting does not change all the time
|
||||
|
@ -899,7 +908,7 @@ opus_custom_encoder_ctl ( OpusEncoderMono[iCurChanID],
|
|||
else
|
||||
{
|
||||
// stereo:
|
||||
|
||||
#ifdef USE_LEGACY_CELT
|
||||
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
|
||||
{
|
||||
cc6_celt_encode ( CeltEncoderStereo[iCurChanID],
|
||||
|
@ -909,6 +918,7 @@ opus_custom_encoder_ctl ( OpusEncoderMono[iCurChanID],
|
|||
iCeltNumCodedBytes );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
// TODO find a better place than this: the setting does not change all the time
|
||||
|
|
Loading…
Reference in a new issue