diff --git a/src/mumble/Audio.cpp b/src/mumble/Audio.cpp index ef78f81..dc2352d 100644 --- a/src/mumble/Audio.cpp +++ b/src/mumble/Audio.cpp @@ -49,6 +49,7 @@ LoopUser LoopUser::lpLoopy; CodecInit ciInit; void CodecInit::initialize() { +#ifdef USE_CELT CELTCodec *codec = NULL; codec = new CELTCodec070(QLatin1String("0.7.0")); @@ -103,12 +104,15 @@ void CodecInit::initialize() { delete codec; } } +#endif } void CodecInit::destroy() { +#ifdef USE_CELT foreach(CELTCodec *codec, g.qmCodecs) delete codec; g.qmCodecs.clear(); +#endif } #ifdef Q_CC_GNU @@ -123,6 +127,7 @@ extern "C" { }; #endif +#ifdef USE_CELT CELTCodec::CELTCodec(const QString &version) { bValid = false; cmMode = NULL; @@ -311,6 +316,7 @@ int CELTCodec011::encode(CELTEncoder *st, const celt_int16 *pcm, unsigned char * int CELTCodec011::decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm) { return celt_decode_float(st, data, len, pcm, SAMPLE_RATE / 100); } +#endif // USE_CELT LoopUser::LoopUser() { qsName = QLatin1String("Loopy"); diff --git a/src/mumble/Audio.h b/src/mumble/Audio.h index 3aa851d..d91027a 100644 --- a/src/mumble/Audio.h +++ b/src/mumble/Audio.h @@ -32,7 +32,10 @@ #define AUDIO_H_ #include + +#ifdef USE_CELT #include +#endif #include #include @@ -52,6 +55,7 @@ typedef QPair audioDevice; +#ifdef USE_CELT class CELTCodec { private: Q_DISABLE_COPY(CELTCodec) @@ -139,6 +143,7 @@ class CELTCodec011 : public CELTCodec { virtual int encode(CELTEncoder *st, const celt_int16 *pcm, unsigned char *compressed, int nbCompressedBytes); virtual int decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm); }; +#endif // USE_CELT class LoopUser : public ClientUser { private: diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp index c663c3c..624e1df 100644 --- a/src/mumble/AudioInput.cpp +++ b/src/mumble/AudioInput.cpp @@ -100,10 +100,16 @@ AudioInput::AudioInput() : opusBuffer(g.s.iFramesPerPacket * (SAMPLE_RATE / 100) g.iAudioBandwidth = getNetworkBandwidth(iAudioQuality, iAudioFrames); +#ifdef USE_CELT umtType = MessageHandler::UDPVoiceCELTAlpha; +#else + umtType = MessageHandler::UDPVoiceOpus; +#endif +#ifdef USE_CELT cCodec = NULL; ceEncoder = NULL; +#endif iSampleRate = SAMPLE_RATE; iFrameSize = SAMPLE_RATE / 100; @@ -166,9 +172,11 @@ AudioInput::~AudioInput() { opus_encoder_destroy(opusState); #endif +#ifdef USE_CELT if (ceEncoder) { cCodec->celt_encoder_destroy(ceEncoder); } +#endif foreach(short *buf, qlEchoFrames) delete [] buf; @@ -610,6 +618,7 @@ bool AudioInput::selectCodec() { } if (!useOpus) { +#ifdef USE_CELT CELTCodec *switchto = NULL; if ((!g.uiSession || (g.s.lmLoopMode == Settings::Local)) && (!g.qmCodecs.isEmpty())) { // Use latest for local loopback @@ -640,6 +649,7 @@ bool AudioInput::selectCodec() { } if (!cCodec) +#endif return false; } @@ -647,6 +657,7 @@ bool AudioInput::selectCodec() { if (useOpus) { umtType = MessageHandler::UDPVoiceOpus; } else { +#ifdef USE_CELT if (!g.uiSession) { umtType = MessageHandler::UDPVoiceCELTAlpha; } else { @@ -659,6 +670,7 @@ bool AudioInput::selectCodec() { qWarning() << "Couldn't find message type for codec version" << v; } } +#endif } if (umtType != previousType) { @@ -688,6 +700,7 @@ int AudioInput::encodeOpusFrame(short *source, int size, unsigned char *buffer) int AudioInput::encodeCELTFrame(short *psSource, unsigned char *buffer) { int len = 0; +#ifdef USE_CELT if (!cCodec) return len; @@ -699,7 +712,7 @@ int AudioInput::encodeCELTFrame(short *psSource, unsigned char *buffer) { cCodec->celt_encoder_ctl(ceEncoder, CELT_SET_VBR_RATE(iAudioQuality)); len = cCodec->encode(ceEncoder, psSource, buffer, qMin(iAudioQuality / (8 * 100), 127)); iBitrate = len * 100 * 8; - +#endif return len; } @@ -841,12 +854,15 @@ void AudioInput::encodeAudioFrame() { if (!selectCodec()) return; +#ifdef USE_CELT if (umtType == MessageHandler::UDPVoiceCELTAlpha || umtType == MessageHandler::UDPVoiceCELTBeta) { len = encodeCELTFrame(psSource, buffer); if (len == 0) return; ++iBufferedFrames; - } else if (umtType == MessageHandler::UDPVoiceOpus) { + } else +#endif + if (umtType == MessageHandler::UDPVoiceOpus) { encoded = false; opusBuffer.insert(opusBuffer.end(), psSource, psSource + iFrameSize); ++iBufferedFrames; diff --git a/src/mumble/AudioInput.h b/src/mumble/AudioInput.h index c7b8f98..1ffbf1d 100644 --- a/src/mumble/AudioInput.h +++ b/src/mumble/AudioInput.h @@ -117,8 +117,10 @@ class AudioInput : public QThread { SpeexPreprocessState *sppPreprocess; SpeexEchoState *sesEcho; +#ifdef USE_CELT CELTCodec *cCodec; CELTEncoder *ceEncoder; +#endif int iAudioQuality; int iAudioFrames; diff --git a/src/mumble/AudioOutputSpeech.cpp b/src/mumble/AudioOutputSpeech.cpp index c09dabc..5939fe6 100644 --- a/src/mumble/AudioOutputSpeech.cpp +++ b/src/mumble/AudioOutputSpeech.cpp @@ -48,8 +48,10 @@ AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, Messag umtType = type; iMixerFreq = freq; +#ifdef USE_CELT cCodec = NULL; cdDecoder = NULL; +#endif dsSpeex = NULL; opusState = NULL; @@ -113,9 +115,12 @@ AudioOutputSpeech::~AudioOutputSpeech() { if (opusState) opus_decoder_destroy(opusState); #endif +#ifdef USE_CELT if (cdDecoder) { cCodec->celt_decoder_destroy(cdDecoder); - } else if (dsSpeex) { + } else +#endif + if (dsSpeex) { speex_bits_destroy(&sbBits); speex_decoder_destroy(dsSpeex); } @@ -302,6 +307,7 @@ bool AudioOutputSpeech::needSamples(unsigned int snum) { if (! qlFrames.isEmpty()) { QByteArray qba = qlFrames.takeFirst(); +#ifdef USE_CELT if (umtType == MessageHandler::UDPVoiceCELTAlpha || umtType == MessageHandler::UDPVoiceCELTBeta) { int wantversion = (umtType == MessageHandler::UDPVoiceCELTAlpha) ? g.iCodecAlpha : g.iCodecBeta; if ((p == &LoopUser::lpLoopy) && (! g.qmCodecs.isEmpty())) { @@ -323,7 +329,9 @@ bool AudioOutputSpeech::needSamples(unsigned int snum) { cCodec->decode_float(cdDecoder, qba.isEmpty() ? NULL : reinterpret_cast(qba.constData()), qba.size(), pOut); else memset(pOut, 0, sizeof(float) * iFrameSize); - } else if (umtType == MessageHandler::UDPVoiceOpus) { + } else +#endif + if (umtType == MessageHandler::UDPVoiceOpus) { #ifdef USE_OPUS decodedSamples = opus_decode_float(opusState, qba.isEmpty() ? NULL : reinterpret_cast(qba.constData()), qba.size(), pOut, iAudioBufferSize, 0); iOutputSize = static_cast(ceilf(static_cast(decodedSamples * iMixerFreq) / static_cast(iSampleRate))); @@ -369,12 +377,15 @@ bool AudioOutputSpeech::needSamples(unsigned int snum) { if (qlFrames.isEmpty() && bHasTerminator) nextalive = false; } else { +#ifdef USE_CELT if (umtType == MessageHandler::UDPVoiceCELTAlpha || umtType == MessageHandler::UDPVoiceCELTBeta) { if (cdDecoder) cCodec->decode_float(cdDecoder, NULL, 0, pOut); else memset(pOut, 0, sizeof(float) * iFrameSize); - } else if (umtType == MessageHandler::UDPVoiceOpus) { + } else +#endif + if (umtType == MessageHandler::UDPVoiceOpus) { #ifdef USE_OPUS opus_decode_float(opusState, NULL, 0, pOut, iFrameSize, 0); #endif diff --git a/src/mumble/AudioOutputSpeech.h b/src/mumble/AudioOutputSpeech.h index d123c8a..1199585 100644 --- a/src/mumble/AudioOutputSpeech.h +++ b/src/mumble/AudioOutputSpeech.h @@ -36,14 +36,20 @@ #include #include #include + +#ifdef USE_CELT #include +#endif #include #include "AudioOutputUser.h" #include "Message.h" +#ifdef USE_CELT class CELTCodec; +#endif + class ClientUser; struct OpusDecoder; @@ -74,8 +80,10 @@ class AudioOutputSpeech : public AudioOutputUser { JitterBuffer *jbJitter; int iMissCount; +#ifdef USE_CELT CELTCodec *cCodec; CELTDecoder *cdDecoder; +#endif OpusDecoder *opusState; diff --git a/src/mumble/Global.h b/src/mumble/Global.h index f50d8dd..d4669d8 100644 --- a/src/mumble/Global.h +++ b/src/mumble/Global.h @@ -54,7 +54,9 @@ class Overlay; class LCD; class BonjourClient; class OverlayClient; +#ifdef USE_CELT class CELTCodec; +#endif class QNetworkAccessManager; @@ -92,7 +94,9 @@ public: int iMaxBandwidth; int iAudioBandwidth; QDir qdBasePath; +#ifdef USE_CELT QMap qmCodecs; +#endif int iCodecAlpha, iCodecBeta; bool bPreferAlpha; bool bOpus; diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 1ff8eb1..178f2de 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -1046,12 +1046,16 @@ static const QString currentCodec() { if (g.bOpus) return QLatin1String("Opus"); +#ifdef USE_CELT int v = g.bPreferAlpha ? g.iCodecAlpha : g.iCodecBeta; CELTCodec* cc = g.qmCodecs.value(v); if (cc) return QString::fromLatin1("CELT %1").arg(cc->version()); else return QString::fromLatin1("CELT %1").arg(QString::number(v, 16)); +#else + return QLatin1String("None"); +#endif } void MainWindow::on_qaServerInformation_triggered() { diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 8806c0d..2aabbda 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -735,6 +735,7 @@ void MainWindow::msgCodecVersion(const MumbleProto::CodecVersion &msg) { g.bOpus = msg.opus(); #endif +#ifdef USE_CELT // Workaround for broken 1.2.2 servers if (g.sh && g.sh->uiVersion == 0x010202 && alpha != -1 && alpha == beta) { if (pref) @@ -768,6 +769,7 @@ void MainWindow::msgCodecVersion(const MumbleProto::CodecVersion &msg) { } else { warned = false; } +#endif } void MainWindow::msgUserStats(const MumbleProto::UserStats &msg) { diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index b5bbc96..d0feb69 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -189,8 +189,10 @@ void ServerHandler::udpReady() { accUDP(static_cast(tTimestamp.elapsed() - t) / 1000.0); } break; +#ifdef USE_CELT case MessageHandler::UDPVoiceCELTAlpha: case MessageHandler::UDPVoiceCELTBeta: +#endif case MessageHandler::UDPVoiceSpeex: case MessageHandler::UDPVoiceOpus: handleVoicePacket(msgFlags, pds, msgType); @@ -420,8 +422,10 @@ void ServerHandler::message(unsigned int msgType, const QByteArray &qbaMsg) { PacketDataStream pds(qbaMsg.constData() + 1, qbaMsg.size()); switch (umsgType) { +#ifdef USE_CELT case MessageHandler::UDPVoiceCELTAlpha: case MessageHandler::UDPVoiceCELTBeta: +#endif case MessageHandler::UDPVoiceSpeex: handleVoicePacket(msgFlags, pds, umsgType); break; @@ -539,9 +543,11 @@ void ServerHandler::serverConnectionConnected() { foreach(const QString &qs, tokens) mpa.add_tokens(u8(qs)); +#ifdef USE_CELT QMap::const_iterator i; for (i=g.qmCodecs.constBegin(); i != g.qmCodecs.constEnd(); ++i) mpa.add_celt_versions(i.key()); +#endif #ifdef USE_OPUS mpa.set_opus(true); #else diff --git a/src/mumble/UserInformation.cpp b/src/mumble/UserInformation.cpp index af1dbe3..36fdde5 100644 --- a/src/mumble/UserInformation.cpp +++ b/src/mumble/UserInformation.cpp @@ -160,6 +160,7 @@ void UserInformation::update(const MumbleProto::UserStats &msg) { qlVersion->setText(tr("%1 (%2)").arg(MumbleVersion::toString(mpv.version())).arg(u8(mpv.release()))); qlOS->setText(tr("%1 (%2)").arg(u8(mpv.os())).arg(u8(mpv.os_version()))); } +#ifdef USE_CELT if (msg.celt_versions_size() > 0) { QStringList qsl; for (int i=0;isetText(qsl.join(tr(", "))); } +#endif if (msg.has_opus()) { qlOpus->setText(msg.opus() ? tr("Supported") : tr("Not Supported")); } diff --git a/src/mumble/mumble_pch.hpp b/src/mumble/mumble_pch.hpp index d8c4dbd..2089c94 100644 --- a/src/mumble/mumble_pch.hpp +++ b/src/mumble/mumble_pch.hpp @@ -52,8 +52,12 @@ #define __int64_t __int64 #include #undef __int64_t + +#ifdef USE_CELT #include #include +#endif + #include #include #include