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:
Volker Fischer 2014-07-26 06:07:50 +00:00
parent afa2f0e812
commit 7918416054
4 changed files with 56 additions and 14 deletions

View File

@ -66,16 +66,18 @@ CClient::CClient ( const quint16 iPortNumber ) :
int iOpusError; int iOpusError;
// init audio encoder/decoder (mono) // init audio encoder/decoder (mono)
#ifdef USE_LEGACY_CELT
CeltModeMono = cc6_celt_mode_create ( CeltModeMono = cc6_celt_mode_create (
SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderMono = cc6_celt_encoder_create ( CeltModeMono ); CeltEncoderMono = cc6_celt_encoder_create ( CeltModeMono );
CeltDecoderMono = cc6_celt_decoder_create ( CeltModeMono ); CeltDecoderMono = cc6_celt_decoder_create ( CeltModeMono );
#ifdef USE_LOW_COMPLEXITY_CELT_ENC # ifdef USE_LOW_COMPLEXITY_CELT_ENC
// set encoder low complexity // set encoder low complexity
cc6_celt_encoder_ctl ( CeltEncoderMono, cc6_celt_encoder_ctl ( CeltEncoderMono,
cc6_CELT_SET_COMPLEXITY ( 1 ) ); cc6_CELT_SET_COMPLEXITY ( 1 ) );
# endif
#endif #endif
OpusMode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, OpusMode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
@ -105,16 +107,18 @@ CClient::CClient ( const quint16 iPortNumber ) :
#endif #endif
// init audio encoder/decoder (stereo) // init audio encoder/decoder (stereo)
#ifdef USE_LEGACY_CELT
CeltModeStereo = cc6_celt_mode_create ( CeltModeStereo = cc6_celt_mode_create (
SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderStereo = cc6_celt_encoder_create ( CeltModeStereo ); CeltEncoderStereo = cc6_celt_encoder_create ( CeltModeStereo );
CeltDecoderStereo = cc6_celt_decoder_create ( CeltModeStereo ); CeltDecoderStereo = cc6_celt_decoder_create ( CeltModeStereo );
#ifdef USE_LOW_COMPLEXITY_CELT_ENC # ifdef USE_LOW_COMPLEXITY_CELT_ENC
// set encoder low complexity // set encoder low complexity
cc6_celt_encoder_ctl ( CeltEncoderStereo, cc6_celt_encoder_ctl ( CeltEncoderStereo,
cc6_CELT_SET_COMPLEXITY ( 1 ) ); cc6_CELT_SET_COMPLEXITY ( 1 ) );
# endif
#endif #endif
OpusEncoderStereo = opus_custom_encoder_create ( OpusMode, OpusEncoderStereo = opus_custom_encoder_create ( OpusMode,
@ -179,8 +183,10 @@ CClient::CClient ( const quint16 iPortNumber ) :
SIGNAL ( ChatTextReceived ( QString ) ) ); SIGNAL ( ChatTextReceived ( QString ) ) );
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### // #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
#ifdef USE_LEGACY_CELT
QObject::connect ( &Channel, SIGNAL ( OpusSupported() ), QObject::connect ( &Channel, SIGNAL ( OpusSupported() ),
this, SLOT ( OnOpusSupported() ) ); this, SLOT ( OnOpusSupported() ) );
#endif
QObject::connect ( &ConnLessProtocol, QObject::connect ( &ConnLessProtocol,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ), SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
@ -419,6 +425,7 @@ void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
} }
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### // #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
#ifdef USE_LEGACY_CELT
void CClient::OnOpusSupported() void CClient::OnOpusSupported()
{ {
if ( eAudioCompressionType != CT_OPUS ) if ( eAudioCompressionType != CT_OPUS )
@ -429,8 +436,10 @@ void CClient::OnOpusSupported()
// inform the GUI about the change of the network rate // inform the GUI about the change of the network rate
emit UpstreamRateChanged(); emit UpstreamRateChanged();
} }
#endif
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### // #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
#ifdef USE_LEGACY_CELT
void CClient::SetAudoCompressiontype ( const EAudComprType eNAudCompressionType ) void CClient::SetAudoCompressiontype ( const EAudComprType eNAudCompressionType )
{ {
// init with new parameter, if client was running then first // init with new parameter, if client was running then first
@ -450,6 +459,7 @@ void CClient::SetAudoCompressiontype ( const EAudComprType eNAudCompressionType
Sound.Start(); Sound.Start();
} }
} }
#endif
void CClient::SetAudioQuality ( const EAudioQuality eNAudioQuality ) void CClient::SetAudioQuality ( const EAudioQuality eNAudioQuality )
{ {
@ -637,8 +647,12 @@ void CClient::Start()
{ {
// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### // #### COMPATIBILITY OLD VERSION, TO BE REMOVED ####
#ifdef USE_LEGACY_CELT
// our first attempt is always to use the old code // our first attempt is always to use the old code
eAudioCompressionType = CT_CELT; eAudioCompressionType = CT_CELT;
#else
eAudioCompressionType = CT_OPUS;
#endif
// init object // init object
Init(); Init();
@ -771,6 +785,7 @@ void CClient::Init()
AudioReverbR.Init ( SYSTEM_SAMPLE_RATE_HZ ); AudioReverbR.Init ( SYSTEM_SAMPLE_RATE_HZ );
// inits for audio coding // inits for audio coding
#ifdef USE_LEGACY_CELT
if ( eAudioCompressionType == CT_CELT ) if ( eAudioCompressionType == CT_CELT )
{ {
if ( eAudioChannelConf == CC_MONO ) if ( eAudioChannelConf == CC_MONO )
@ -797,6 +812,7 @@ void CClient::Init()
} }
} }
else else
#endif
{ {
if ( eAudioChannelConf == CC_MONO ) if ( eAudioChannelConf == CC_MONO )
{ {
@ -1069,6 +1085,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
if ( eAudioChannelConf == CC_MONO ) if ( eAudioChannelConf == CC_MONO )
{ {
// encode current audio frame // encode current audio frame
#ifdef USE_LEGACY_CELT
if ( eAudioCompressionType == CT_CELT ) if ( eAudioCompressionType == CT_CELT )
{ {
cc6_celt_encode ( CeltEncoderMono, cc6_celt_encode ( CeltEncoderMono,
@ -1078,6 +1095,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
iCeltNumCodedBytes ); iCeltNumCodedBytes );
} }
else else
#endif
{ {
opus_custom_encode ( OpusEncoderMono, opus_custom_encode ( OpusEncoderMono,
&vecsStereoSndCrd[i * SYSTEM_FRAME_SIZE_SAMPLES], &vecsStereoSndCrd[i * SYSTEM_FRAME_SIZE_SAMPLES],
@ -1089,6 +1107,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
else else
{ {
// encode current audio frame // encode current audio frame
#ifdef USE_LEGACY_CELT
if ( eAudioCompressionType == CT_CELT ) if ( eAudioCompressionType == CT_CELT )
{ {
cc6_celt_encode ( CeltEncoderStereo, cc6_celt_encode ( CeltEncoderStereo,
@ -1098,6 +1117,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
iCeltNumCodedBytes ); iCeltNumCodedBytes );
} }
else else
#endif
{ {
opus_custom_encode ( OpusEncoderStereo, opus_custom_encode ( OpusEncoderStereo,
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES], &vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
@ -1136,6 +1156,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
if ( eAudioChannelConf == CC_MONO ) if ( eAudioChannelConf == CC_MONO )
{ {
#ifdef USE_LEGACY_CELT
if ( eAudioCompressionType == CT_CELT ) if ( eAudioCompressionType == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderMono, cc6_celt_decode ( CeltDecoderMono,
@ -1144,6 +1165,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] ); &vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderMono, opus_custom_decode ( OpusDecoderMono,
&vecbyNetwData[0], &vecbyNetwData[0],
@ -1154,6 +1176,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
} }
else else
{ {
#ifdef USE_LEGACY_CELT
if ( eAudioCompressionType == CT_CELT ) if ( eAudioCompressionType == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderStereo, cc6_celt_decode ( CeltDecoderStereo,
@ -1162,6 +1185,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] ); &vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderStereo, opus_custom_decode ( OpusDecoderStereo,
&vecbyNetwData[0], &vecbyNetwData[0],
@ -1176,6 +1200,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
// lost packet // lost packet
if ( eAudioChannelConf == CC_MONO ) if ( eAudioChannelConf == CC_MONO )
{ {
#ifdef USE_LEGACY_CELT
if ( eAudioCompressionType == CT_CELT ) if ( eAudioCompressionType == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderMono, cc6_celt_decode ( CeltDecoderMono,
@ -1184,6 +1209,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] ); &vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderMono, opus_custom_decode ( OpusDecoderMono,
NULL, NULL,
@ -1194,6 +1220,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
} }
else else
{ {
#ifdef USE_LEGACY_CELT
if ( eAudioCompressionType == CT_CELT ) if ( eAudioCompressionType == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderStereo, cc6_celt_decode ( CeltDecoderStereo,
@ -1202,6 +1229,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] ); &vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderStereo, opus_custom_decode ( OpusDecoderStereo,
NULL, NULL,

View File

@ -74,17 +74,19 @@
// audio reverberation range // audio reverberation range
#define AUD_REVERB_MAX 100 #define AUD_REVERB_MAX 100
#ifdef USE_LEGACY_CELT
// CELT number of coded bytes per audio packet // CELT number of coded bytes per audio packet
// 24: mono low quality 156 kbps (128) / 114 kbps (256) // 24: mono low quality 156 kbps (128) / 114 kbps (256)
// 44: mono normal quality 216 kbps (128) / 174 kbps (256) // 44: mono normal quality 216 kbps (128) / 174 kbps (256)
// NOTE: Must be > CELT_MINIMUM_NUM_BYTES (greater, not equal to!) // NOTE: Must be > CELT_MINIMUM_NUM_BYTES (greater, not equal to!)
#define CELT_NUM_BYTES_MONO_LOW_QUALITY 24 # define CELT_NUM_BYTES_MONO_LOW_QUALITY 24
#define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 44 # define CELT_NUM_BYTES_MONO_NORMAL_QUALITY 44
// 46: stereo low quality 222 kbps (128) / 180 kbps (256) // 46: stereo low quality 222 kbps (128) / 180 kbps (256)
// 70: stereo normal quality 294 kbps (128) / 252 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_LOW_QUALITY 46
#define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 70 # define CELT_NUM_BYTES_STEREO_NORMAL_QUALITY 70
#endif
// OPUS number of coded bytes per audio packet // OPUS number of coded bytes per audio packet
// TODO we have to use new numbers for OPUS to avoid that old CELT packets // TODO we have to use new numbers for OPUS to avoid that old CELT packets

View File

@ -181,8 +181,10 @@ public slots:
void OnConnectDlgAccepted(); void OnConnectDlgAccepted();
void OnDisconnected(); void OnDisconnected();
#ifdef USE_LEGACY_CELT
void OnUpstreamRateChanged() void OnUpstreamRateChanged()
{ ClientSettingsDlg.UpdateDisplay(); } { ClientSettingsDlg.UpdateDisplay(); }
#endif
void OnGUIDesignChanged() void OnGUIDesignChanged()
{ SetGUIDesign ( pClient->GetGUIDesign() ); } { SetGUIDesign ( pClient->GetGUIDesign() ); }

View File

@ -228,16 +228,18 @@ CServer::CServer ( const int iNewMaxNumChan,
for ( i = 0; i < iMaxNumChannels; i++ ) for ( i = 0; i < iMaxNumChannels; i++ )
{ {
// init audio endocder/decoder (mono) // init audio endocder/decoder (mono)
#ifdef USE_LEGACY_CELT
CeltModeMono[i] = cc6_celt_mode_create ( CeltModeMono[i] = cc6_celt_mode_create (
SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderMono[i] = cc6_celt_encoder_create ( CeltModeMono[i] ); CeltEncoderMono[i] = cc6_celt_encoder_create ( CeltModeMono[i] );
CeltDecoderMono[i] = cc6_celt_decoder_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 // set encoder low complexity
cc6_celt_encoder_ctl ( CeltEncoderMono[i], cc6_celt_encoder_ctl ( CeltEncoderMono[i],
cc6_CELT_SET_COMPLEXITY ( 1 ) ); cc6_CELT_SET_COMPLEXITY ( 1 ) );
# endif
#endif #endif
OpusMode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, OpusMode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
@ -267,16 +269,18 @@ CServer::CServer ( const int iNewMaxNumChan,
#endif #endif
// init audio endocder/decoder (stereo) // init audio endocder/decoder (stereo)
#ifdef USE_LEGACY_CELT
CeltModeStereo[i] = cc6_celt_mode_create ( CeltModeStereo[i] = cc6_celt_mode_create (
SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL );
CeltEncoderStereo[i] = cc6_celt_encoder_create ( CeltModeStereo[i] ); CeltEncoderStereo[i] = cc6_celt_encoder_create ( CeltModeStereo[i] );
CeltDecoderStereo[i] = cc6_celt_decoder_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 // set encoder low complexity
cc6_celt_encoder_ctl ( CeltEncoderStereo[i], cc6_celt_encoder_ctl ( CeltEncoderStereo[i],
cc6_CELT_SET_COMPLEXITY ( 1 ) ); cc6_CELT_SET_COMPLEXITY ( 1 ) );
# endif
#endif #endif
OpusEncoderStereo[i] = opus_custom_encoder_create ( OpusMode[i], OpusEncoderStereo[i] = opus_custom_encoder_create ( OpusMode[i],
@ -747,7 +751,7 @@ void CServer::OnTimer()
if ( iCurNumAudChan == 1 ) if ( iCurNumAudChan == 1 )
{ {
// mono // mono
#ifdef USE_LEGACY_CELT
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT ) if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderMono[iCurChanID], cc6_celt_decode ( CeltDecoderMono[iCurChanID],
@ -756,6 +760,7 @@ void CServer::OnTimer()
&vecvecsData[i][0] ); &vecvecsData[i][0] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderMono[iCurChanID], opus_custom_decode ( OpusDecoderMono[iCurChanID],
&vecbyCodedData[0], &vecbyCodedData[0],
@ -767,7 +772,7 @@ void CServer::OnTimer()
else else
{ {
// stereo // stereo
#ifdef USE_LEGACY_CELT
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT ) if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderStereo[iCurChanID], cc6_celt_decode ( CeltDecoderStereo[iCurChanID],
@ -776,6 +781,7 @@ void CServer::OnTimer()
&vecvecsData[i][0] ); &vecvecsData[i][0] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderStereo[iCurChanID], opus_custom_decode ( OpusDecoderStereo[iCurChanID],
&vecbyCodedData[0], &vecbyCodedData[0],
@ -791,7 +797,7 @@ void CServer::OnTimer()
if ( iCurNumAudChan == 1 ) if ( iCurNumAudChan == 1 )
{ {
// mono // mono
#ifdef USE_LEGACY_CELT
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT ) if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderMono[iCurChanID], cc6_celt_decode ( CeltDecoderMono[iCurChanID],
@ -800,6 +806,7 @@ void CServer::OnTimer()
&vecvecsData[i][0] ); &vecvecsData[i][0] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderMono[iCurChanID], opus_custom_decode ( OpusDecoderMono[iCurChanID],
NULL, NULL,
@ -811,7 +818,7 @@ void CServer::OnTimer()
else else
{ {
// stereo // stereo
#ifdef USE_LEGACY_CELT
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT ) if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
{ {
cc6_celt_decode ( CeltDecoderStereo[iCurChanID], cc6_celt_decode ( CeltDecoderStereo[iCurChanID],
@ -820,6 +827,7 @@ void CServer::OnTimer()
&vecvecsData[i][0] ); &vecvecsData[i][0] );
} }
else else
#endif
{ {
opus_custom_decode ( OpusDecoderStereo[iCurChanID], opus_custom_decode ( OpusDecoderStereo[iCurChanID],
NULL, NULL,
@ -871,7 +879,7 @@ void CServer::OnTimer()
if ( vecChannels[iCurChanID].GetNumAudioChannels() == 1 ) if ( vecChannels[iCurChanID].GetNumAudioChannels() == 1 )
{ {
// mono: // mono:
#ifdef USE_LEGACY_CELT
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT ) if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
{ {
cc6_celt_encode ( CeltEncoderMono[iCurChanID], cc6_celt_encode ( CeltEncoderMono[iCurChanID],
@ -881,6 +889,7 @@ void CServer::OnTimer()
iCeltNumCodedBytes ); iCeltNumCodedBytes );
} }
else else
#endif
{ {
// TODO find a better place than this: the setting does not change all the time // 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 else
{ {
// stereo: // stereo:
#ifdef USE_LEGACY_CELT
if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT ) if ( vecChannels[iCurChanID].GetAudioCompressionType() == CT_CELT )
{ {
cc6_celt_encode ( CeltEncoderStereo[iCurChanID], cc6_celt_encode ( CeltEncoderStereo[iCurChanID],
@ -909,6 +918,7 @@ opus_custom_encoder_ctl ( OpusEncoderMono[iCurChanID],
iCeltNumCodedBytes ); iCeltNumCodedBytes );
} }
else else
#endif
{ {
// TODO find a better place than this: the setting does not change all the time // TODO find a better place than this: the setting does not change all the time