diff --git a/Jamulus.pro b/Jamulus.pro index 2bc04dc4..7ce25219 100755 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -8,9 +8,11 @@ QT += widgets \ network \ xml -INCLUDEPATH += src \ - libs/celt \ - libs/opus/include \ +INCLUDEPATH += src + +INCLUDEPATH_CELT = libs/celt + +INCLUDEPATH_OPUS = libs/opus/include \ libs/opus/celt \ libs/opus/silk \ libs/opus/silk/float @@ -114,8 +116,9 @@ HEADERS += src/audiomixerboard.h \ src/soundbase.h \ src/testbench.h \ src/util.h \ - src/analyzerconsole.h \ - libs/celt/cc6_celt.h \ + src/analyzerconsole.h + +HEADERS_CELT = libs/celt/cc6_celt.h \ libs/celt/cc6_celt_types.h \ libs/celt/cc6_celt_header.h \ libs/celt/cc6__kiss_fft_guts.h \ @@ -145,8 +148,9 @@ HEADERS += src/audiomixerboard.h \ libs/celt/cc6_quant_bands.h \ libs/celt/cc6_rate.h \ libs/celt/cc6_stack_alloc.h \ - libs/celt/cc6_vq.h \ - libs/opus/include/opus.h \ + libs/celt/cc6_vq.h + +HEADERS_OPUS = libs/opus/include/opus.h \ libs/opus/include/opus_multistream.h \ libs/opus/include/opus_custom.h \ libs/opus/include/opus_types.h \ @@ -238,8 +242,9 @@ SOURCES += src/audiomixerboard.cpp \ src/socket.cpp \ src/soundbase.cpp \ src/util.cpp \ - src/analyzerconsole.cpp \ - libs/celt/cc6_bands.c \ + src/analyzerconsole.cpp + +SOURCES_CELT = libs/celt/cc6_bands.c \ libs/celt/cc6_celt.c \ libs/celt/cc6_cwrs.c \ libs/celt/cc6_entcode.c \ @@ -258,8 +263,9 @@ SOURCES += src/audiomixerboard.cpp \ libs/celt/cc6_rangedec.c \ libs/celt/cc6_rangeenc.c \ libs/celt/cc6_rate.c \ - libs/celt/cc6_vq.c \ - libs/opus/src/opus.c \ + libs/celt/cc6_vq.c + +SOURCES_OPUS = libs/opus/src/opus.c \ libs/opus/src/opus_decoder.c \ libs/opus/src/opus_encoder.c \ libs/opus/src/opus_multistream.c \ @@ -404,22 +410,6 @@ DISTFILES += AUTHORS \ NEWS \ README \ TODO \ - libs/celt/AUTHORS \ - libs/celt/ChangeLog \ - libs/celt/COPYING \ - libs/celt/INSTALL \ - libs/celt/NEWS \ - libs/celt/README \ - libs/celt/README_LLCON \ - libs/celt/TODO \ - libs/opus/AUTHORS \ - libs/opus/ChangeLog \ - libs/opus/COPYING \ - libs/opus/INSTALL \ - libs/opus/NEWS \ - libs/opus/README \ - libs/opus/celt/arm/armopts.s.in \ - libs/opus/celt/arm/celt_pitch_xcorr_arm.s \ src/res/CLEDBlack.png \ src/res/CLEDBlackSmall.png \ src/res/CLEDDisabledSmall.png \ @@ -497,3 +487,47 @@ DISTFILES += AUTHORS \ src/res/instrtuba.png \ src/res/instrviolin.png \ src/res/instrvocal.png + +DISTFILES_CELT += libs/celt/AUTHORS \ + libs/celt/ChangeLog \ + libs/celt/COPYING \ + libs/celt/INSTALL \ + libs/celt/NEWS \ + libs/celt/README \ + libs/celt/README_LLCON \ + libs/celt/TODO + +DISTFILES_OPUS += libs/opus/AUTHORS \ + libs/opus/ChangeLog \ + libs/opus/COPYING \ + libs/opus/INSTALL \ + libs/opus/NEWS \ + libs/opus/README \ + libs/opus/celt/arm/armopts.s.in \ + libs/opus/celt/arm/celt_pitch_xcorr_arm.s \ + +# exclude CELT support if requested +!contains(CONFIG, "nocelt") { + message(Legacy support for CELT enabled.) + + INCLUDEPATH += $$INCLUDEPATH_CELT + HEADERS += $$HEADERS_CELT + SOURCES += $$SOURCES_CELT + DISTFILES += $$DISTFILES_CELT + DEFINES += USE_LEGACY_CELT +} + +# use external OPUS library if requested +contains(CONFIG, "opus_shared_lib") { + message(OPUS codec is used from a shared library.) + + unix { + LIBS += -llibopus + DEFINES += USE_OPUS_SHARED_LIB + } +} else { + INCLUDEPATH += $$INCLUDEPATH_OPUS + HEADERS += $$HEADERS_OPUS + SOURCES += $$SOURCES_OPUS + DISTFILES += $$DISTFILES_OPUS +} diff --git a/src/channel.cpp b/src/channel.cpp index 7648da14..01c76002 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -98,9 +98,11 @@ qRegisterMetaType ( "CHostAddress" ); SIGNAL ( ChatTextReceived ( QString ) ) ); // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +#ifdef USE_LEGACY_CELT QObject::connect ( &Protocol, SIGNAL ( OpusSupported() ), SIGNAL ( OpusSupported() ) ); +#endif QObject::connect ( &Protocol, SIGNAL ( NetTranspPropsReceived ( CNetworkTransportProps ) ), @@ -380,6 +382,24 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor // only the server shall act on network transport properties message if ( bIsServer ) { +// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### + // if old CELT codec is used, inform the client that the new OPUS codec + // is supported + if ( NetworkTransportProps.eAudioCodingType != CT_OPUS ) + { + Protocol.CreateOpusSupportedMes(); + } + +#ifndef USE_LEGACY_CELT + // in case legacy support for CELT is not enabled, we refuse the + // complete network transport properties if the audio coding type + // is set to CELT + if ( NetworkTransportProps.eAudioCodingType == CT_CELT ) + { + return; + } +#endif + Mutex.lock(); { // store received parameters @@ -405,13 +425,6 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor MutexConvBuf.unlock(); } Mutex.unlock(); - - // if old CELT codec is used, inform the client that the new OPUS codec - // is supported - if ( NetworkTransportProps.eAudioCodingType != CT_OPUS ) - { - Protocol.CreateOpusSupportedMes(); - } } } diff --git a/src/client.h b/src/client.h index 912201c9..9b61aa94 100755 --- a/src/client.h +++ b/src/client.h @@ -30,8 +30,14 @@ #include #include #include -#include "cc6_celt.h" -#include "opus_custom.h" +#ifdef USE_LEGACY_CELT +# include "cc6_celt.h" +#endif +#ifdef USE_OPUS_SHARED_LIB +# include "opus/opus_custom.h" +#else +# include "opus_custom.h" +#endif #include "global.h" #include "socket.h" #include "channel.h" @@ -304,19 +310,23 @@ protected: void CreateServerJitterBufferMessage(); // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +#ifdef USE_LEGACY_CELT void SetAudoCompressiontype ( const EAudComprType eNAudCompressionType ); +#endif // only one channel is needed for client application CChannel Channel; CProtocol ConnLessProtocol; // audio encoder/decoder +#ifdef USE_LEGACY_CELT cc6_CELTMode* CeltModeMono; cc6_CELTEncoder* CeltEncoderMono; cc6_CELTDecoder* CeltDecoderMono; cc6_CELTMode* CeltModeStereo; cc6_CELTEncoder* CeltEncoderStereo; cc6_CELTDecoder* CeltDecoderStereo; +#endif OpusCustomMode* OpusMode; OpusCustomEncoder* OpusEncoderMono; OpusCustomDecoder* OpusDecoderMono; @@ -397,7 +407,9 @@ public slots: void OnSndCrdReinitRequest ( int iSndCrdResetType ); // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +#ifdef USE_LEGACY_CELT void OnOpusSupported(); +#endif signals: void ConClientListNameMesReceived ( CVector vecChanInfo ); @@ -421,7 +433,9 @@ signals: void Disconnected(); // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +#ifdef USE_LEGACY_CELT void UpstreamRateChanged(); +#endif }; #endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */ diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 57c54a1c..3352f3d0 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -458,9 +458,11 @@ CClientDlg::CClientDlg ( CClient* pNCliP, this, SLOT ( OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString ) ) ); #endif +#ifdef USE_LEGACY_CELT QObject::connect ( pClient, SIGNAL ( UpstreamRateChanged() ), this, SLOT ( OnUpstreamRateChanged() ) ); +#endif QObject::connect ( QCoreApplication::instance(), SIGNAL ( aboutToQuit() ), this, SLOT ( OnAboutToQuit() ) ); diff --git a/src/protocol.cpp b/src/protocol.cpp index b1dd22b9..3a106319 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -554,9 +554,11 @@ case PROTMESSID_CHANNEL_NAME: break; // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +#ifdef USE_LEGACY_CELT case PROTMESSID_OPUS_SUPPORTED: bRet = EvaluateOpusSupportedMes(); break; +#endif } // immediately send acknowledge message @@ -1282,8 +1284,9 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) const int iRecCodingType = static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); - if ( ( iRecCodingType != CT_NONE ) && - ( iRecCodingType != CT_CELT ) && + // note that CT_NONE is not a valid setting but only used for server + // initialization + if ( ( iRecCodingType != CT_CELT ) && ( iRecCodingType != CT_OPUS ) ) { return true; @@ -1326,6 +1329,7 @@ void CProtocol::CreateOpusSupportedMes() CVector ( 0 ) ); } +#ifdef USE_LEGACY_CELT bool CProtocol::EvaluateOpusSupportedMes() { // invoke message action @@ -1333,6 +1337,7 @@ bool CProtocol::EvaluateOpusSupportedMes() return false; // no error } +#endif // Connection less messages ---------------------------------------------------- diff --git a/src/protocol.h b/src/protocol.h index eb973cfc..82f759c9 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -213,7 +213,9 @@ protected: bool EvaluateChatTextMes ( const CVector& vecData ); bool EvaluateNetwTranspPropsMes ( const CVector& vecData ); bool EvaluateReqNetwTranspPropsMes(); +#ifdef USE_LEGACY_CELT bool EvaluateOpusSupportedMes(); +#endif bool EvaluateCLPingMes ( const CHostAddress& InetAddr, const CVector& vecData ); diff --git a/src/server.h b/src/server.h index ca62ca60..7780216b 100755 --- a/src/server.h +++ b/src/server.h @@ -29,8 +29,14 @@ #include #include #include -#include "cc6_celt.h" -#include "opus_custom.h" +#ifdef USE_LEGACY_CELT +# include "cc6_celt.h" +#endif +#ifdef USE_OPUS_SHARED_LIB +# include "opus/opus_custom.h" +#else +# include "opus_custom.h" +#endif #include "global.h" #include "socket.h" #include "channel.h" @@ -221,12 +227,14 @@ protected: QMutex Mutex; // audio encoder/decoder +#ifdef USE_LEGACY_CELT cc6_CELTMode* CeltModeMono[MAX_NUM_CHANNELS]; cc6_CELTEncoder* CeltEncoderMono[MAX_NUM_CHANNELS]; cc6_CELTDecoder* CeltDecoderMono[MAX_NUM_CHANNELS]; cc6_CELTMode* CeltModeStereo[MAX_NUM_CHANNELS]; cc6_CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS]; cc6_CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS]; +#endif OpusCustomMode* OpusMode[MAX_NUM_CHANNELS]; OpusCustomEncoder* OpusEncoderMono[MAX_NUM_CHANNELS]; OpusCustomDecoder* OpusDecoderMono[MAX_NUM_CHANNELS];