Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mumble/Audio.cpp10
-rw-r--r--src/mumble/CELTCodec.h11
-rw-r--r--src/mumble/CELTCodec_sbcelt.cpp99
-rw-r--r--src/mumble/main.cpp9
-rw-r--r--src/mumble/mumble.pro26
-rw-r--r--src/mumble/mumble_pch.hpp3
6 files changed, 148 insertions, 10 deletions
diff --git a/src/mumble/Audio.cpp b/src/mumble/Audio.cpp
index 6ecac3bef..86758f065 100644
--- a/src/mumble/Audio.cpp
+++ b/src/mumble/Audio.cpp
@@ -57,6 +57,15 @@ void CodecInit::initialize() {
return;
}
+#ifdef USE_SBCELT
+ codec = new CELTCodecSBCELT();
+ if (codec->isValid()) {
+ codec->report();
+ g.qmCodecs.insert(codec->bitstreamVersion(), codec);
+ } else {
+ delete codec;
+ }
+#else
codec = new CELTCodec070(QLatin1String("0.7.0"));
if (codec->isValid()) {
codec->report();
@@ -86,6 +95,7 @@ void CodecInit::initialize() {
delete codec;
}
}
+#endif
}
void CodecInit::destroy() {
diff --git a/src/mumble/CELTCodec.h b/src/mumble/CELTCodec.h
index 2a87725bc..cdcf6bd19 100644
--- a/src/mumble/CELTCodec.h
+++ b/src/mumble/CELTCodec.h
@@ -111,4 +111,15 @@ class CELTCodec011 : public CELTCodec {
virtual int decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm);
};
+class CELTCodecSBCELT : public CELTCodec {
+ protected:
+ const CELTMode *cmSBCELTMode;
+ public:
+ CELTCodecSBCELT();
+ virtual CELTEncoder *encoderCreate();
+ virtual CELTDecoder *decoderCreate();
+ 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 // CELTCODEC_H_
diff --git a/src/mumble/CELTCodec_sbcelt.cpp b/src/mumble/CELTCodec_sbcelt.cpp
new file mode 100644
index 000000000..c6877c783
--- /dev/null
+++ b/src/mumble/CELTCodec_sbcelt.cpp
@@ -0,0 +1,99 @@
+/* Copyright (C) 2005-2011, Thorvald Natvig <thorvald@natvig.com>
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the Mumble Developers nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "mumble_pch.hpp"
+
+#include "CELTCodec.h"
+
+#include "Audio.h"
+#include "Version.h"
+
+CELTCodec::CELTCodec(const QString &version) {
+ bValid = true;
+ cmMode = NULL;
+ qsVersion = version;
+ iBitstreamVersion = INT_MIN;
+
+ this->celt_encoder_destroy = ::celt_encoder_destroy;
+ this->celt_encoder_ctl = ::celt_encoder_ctl;
+
+ this->celt_decoder_destroy = ::celt_decoder_destroy;
+ this->celt_decoder_ctl = ::celt_decoder_ctl;
+}
+
+CELTCodec::~CELTCodec() {
+ if (cmMode)
+ ::celt_mode_destroy(const_cast<CELTMode *>(cmMode));
+}
+
+bool CELTCodec::isValid() const {
+ return bValid;
+}
+
+int CELTCodec::bitstreamVersion() const {
+ if (cmMode && iBitstreamVersion == INT_MIN)
+ ::celt_mode_info(cmMode, CELT_GET_BITSTREAM_VERSION, reinterpret_cast<celt_int32 *>(&iBitstreamVersion));
+
+ return iBitstreamVersion;
+}
+
+QString CELTCodec::version() const {
+ return qsVersion;
+}
+
+void CELTCodec::report() const {
+ qWarning("CELT bitstream %08x from internal CELT with SBCELT decoding", bitstreamVersion());
+}
+
+CELTCodecSBCELT::CELTCodecSBCELT() : CELTCodec(QLatin1String("0.7.0")) {
+ if (bValid) {
+ cmMode = ::celt_mode_create(SAMPLE_RATE, SAMPLE_RATE / 100, NULL);
+ cmSBCELTMode = ::sbcelt_mode_create(SAMPLE_RATE, SAMPLE_RATE / 100, NULL);
+
+ this->celt_decoder_destroy = ::sbcelt_decoder_destroy;
+ this->celt_decoder_ctl = ::sbcelt_decoder_ctl;
+ }
+}
+
+CELTEncoder *CELTCodecSBCELT::encoderCreate() {
+ return ::celt_encoder_create(cmMode, 1, NULL);
+}
+
+CELTDecoder *CELTCodecSBCELT::decoderCreate() {
+ return ::sbcelt_decoder_create(cmSBCELTMode, 1, NULL);
+}
+
+int CELTCodecSBCELT::encode(CELTEncoder *st, const celt_int16 *pcm, unsigned char *compressed, int nbCompressedBytes) {
+ return ::celt_encode(st, pcm, NULL, compressed, nbCompressedBytes);
+}
+
+int CELTCodecSBCELT::decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm) {
+ return ::sbcelt_decode_float(st, data, len, pcm);
+} \ No newline at end of file
diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp
index 109cbc362..0368a1a88 100644
--- a/src/mumble/main.cpp
+++ b/src/mumble/main.cpp
@@ -153,6 +153,15 @@ int main(int argc, char **argv) {
a.setOrganizationDomain(QLatin1String("mumble.sourceforge.net"));
a.setQuitOnLastWindowClosed(false);
+ #ifdef USE_SBCELT
+ {
+ // For now, force Mumble to use sbcelt-helper from the same directory as the 'mumble' executable.
+ QDir d(a.applicationDirPath());
+ QString helper = d.absoluteFilePath(QString::fromLatin1("sbcelt-helper"));
+ setenv("SBCELT_HELPER_BINARY", helper.toUtf8().constData(), 1);
+ }
+#endif
+
Global::g_global_struct = new Global();
qsrand(QDateTime::currentDateTime().toTime_t());
diff --git a/src/mumble/mumble.pro b/src/mumble/mumble.pro
index 74fa9eb42..02d2383f2 100644
--- a/src/mumble/mumble.pro
+++ b/src/mumble/mumble.pro
@@ -45,16 +45,22 @@ CONFIG(no-bundled-speex) {
LIBS *= -lspeex
}
-unix:!CONFIG(bundled-celt):system(pkg-config --atleast-version=0.7.0 celt) {
- CONFIG *= no-bundled-celt
-}
-
-CONFIG(no-bundled-celt) {
- INCLUDEPATH *= /usr/include/celt
-}
-
-!CONFIG(no-bundled-celt) {
- INCLUDEPATH *= ../../celt-0.7.0-src/libcelt
+CONFIG(sbcelt) {
+ SOURCES -= CELTCodec.cpp
+ SOURCES += CELTCodec_sbcelt.cpp
+ INCLUDEPATH *= ../../celt-0.7.0-src/libcelt ../../sbcelt-src
+ LIBS *= -lcelt -lsbcelt
+ DEFINES *= SBCELT_PREFIX_API SBCELT_COMPAT_API USE_SBCELT
+} else {
+ unix:!CONFIG(bundled-celt):system(pkg-config --atleast-version=0.7.0 celt) {
+ CONFIG *= no-bundled-celt
+ }
+ CONFIG(no-bundled-celt) {
+ INCLUDEPATH *= /usr/include/celt
+ }
+ !CONFIG(no-bundled-celt) {
+ INCLUDEPATH *= ../../celt-0.7.0-src/libcelt
+ }
}
!win32 {
diff --git a/src/mumble/mumble_pch.hpp b/src/mumble/mumble_pch.hpp
index 71f735163..fc5358a80 100644
--- a/src/mumble/mumble_pch.hpp
+++ b/src/mumble/mumble_pch.hpp
@@ -53,6 +53,9 @@
#include <sndfile.h>
#undef __int64_t
#include <celt.h>
+#ifdef USE_SBCELT
+#include <sbcelt.h>
+#endif
#include <speex/speex.h>
#include <speex/speex_jitter.h>
#include <speex/speex_preprocess.h>