Skip to content

Commit

Permalink
Mumble: allow client to use SBCELT for CELT decoding via CONFIG(sbcelt).
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrautz committed Aug 9, 2012
1 parent f5bac3d commit c2655fc
Show file tree
Hide file tree
Showing 15 changed files with 353 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "opus-src"]
path = opus-src
url = git://git.xiph.org/opus.git
[submodule "sbcelt-src"]
path = sbcelt-src
url = git://github.com/mumble-voip/sbcelt.git
6 changes: 6 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ CONFIG+=no-bundled-speex (Mumble)
Note that this requires your system-installed Speex to be at least version
1.2.0.

CONFIG+=sbcelt (Mumble, Linux, OSX, FreeBSD)
Use the SBCELT library for decoding CELT frames. Enabling this option will
build Mumble in a mode that forces all CELT frames to be decoded in a
separate, sandboxed, helper process. CELT frames will still be encoded using
Mumble's bundled CELT library. This option implies CONFIG+=bundled-celt.

CONFIG+=optimize
Build a heavily optimized version, specific to the machine it's being
compiled on.
Expand Down
9 changes: 7 additions & 2 deletions celt-0.7.0-build/celt-0.7.0-build.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ TARGET = celt0
DEFINES += HAVE_CONFIG_H
TARGET_VERSION_EXT = .$$VERSION

CONFIG(static) {
CONFIG -= static
CONFIG(sbcelt) {
TARGET = celt
CONFIG += static
} else {
CONFIG(static) {
CONFIG -= static
}
}

QMAKE_CFLAGS -= -fPIE -pie
Expand Down
44 changes: 21 additions & 23 deletions macx/scripts/osxdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,15 @@ def copy_murmur(self):
dst = os.path.join(self.bundle, 'Contents', 'MacOS', 'murmur.ini')
shutil.copy('scripts/murmur.ini.osx', dst)

def copy_g15helper(self):
def copy_helper(self, fn):
'''
Copy the Mumble G15 helper daemon into our Mumble app bundle.
Copy a helper binary into the Mumble app bundle.
'''
if os.path.exists(os.path.join(self.bundle, '..', 'mumble-g15-helper')):
print ' * Copying G15 helper'
src = os.path.join(self.bundle, '..', 'mumble-g15-helper')
dst = os.path.join(self.bundle, 'Contents', 'MacOS', 'mumble-g15-helper')
if os.path.exists(os.path.join(self.bundle, '..', fn)):
print ' * Copying helper binary: %s' % fn
src = os.path.join(self.bundle, '..', fn)
dst = os.path.join(self.bundle, 'Contents', 'MacOS', fn)
shutil.copy(src, dst)
else:
print ' * No G15 helper found, skipping...'

def copy_resources(self, rsrcs):
'''
Expand All @@ -135,13 +133,15 @@ def copy_resources(self, rsrcs):

def copy_codecs(self):
'''
Copy over dynamic CELT libraries.
Try to copy the dynamic CELT libraries into the App Bundle.
'''
print ' * Copying CELT libraries.'
print ' * Attempting to copy CELT libraries into App Bundle'
dst = os.path.join(self.bundle, 'Contents', 'Codecs')
os.makedirs(dst)
shutil.copy('release/libcelt0.0.7.0.dylib', dst)
shutil.copy('release/libcelt0.0.11.0.dylib', dst)
codecs = ('release/libcelt0.0.7.0.dylib', 'release/libcelt0.0.11.0.dylib')
for codec in codecs:
if os.path.exists(codec):
shutil.copy(codec, dst)

def copy_plugins(self):
'''
Expand Down Expand Up @@ -323,7 +323,8 @@ def create(self):
a = AppBundle('release/Mumble.app', ver)
if not options.no_server:
a.copy_murmur()
a.copy_g15helper()
a.copy_helper('mumble-g15-helper')
a.copy_helper('sbcelt-helper')
a.copy_codecs()
a.copy_plugins()
a.copy_resources(['icons/mumble.icns'])
Expand All @@ -338,21 +339,18 @@ def create(self):
# Sign our binaries, etc.
if options.developer_id:
print ' * Signing binaries with Developer ID `%s\'' % options.developer_id
binaries = [
# 1.2.x
binaries = (
'release/Mumble.app',
'release/Mumble.app/Contents/Plugins/liblink.dylib',
'release/Mumble.app/Contents/Plugins/libmanual.dylib',
'release/Mumble.app/Contents/Codecs/libcelt0.0.7.0.dylib',
'release/Mumble.app/Contents/Codecs/libcelt0.0.11.0.dylib',
]
g15path = 'release/Mumble.app/Contents/MacOS/mumble-g15-helper'
if os.path.exists(g15path):
binaries.append(g15path)
if not options.no_server:
binaries.append('release/Mumble.app/Contents/MacOS/murmurd')

codesign(binaries)
'release/Mumble.app/Contents/MacOS/mumble-g15-helper',
'release/Mumble.app/Contents/MacOS/sbcelt-helper',
'release/Mumble.app/Contents/MacOS/murmurd',
)
availableBinaries = [bin for bin in binaries if os.path.exists(bin)]
codesign(availableBinaries)
print ''

if options.only_appbundle:
Expand Down
15 changes: 10 additions & 5 deletions main.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ CONFIG *= ordered debug_and_release
unix:!CONFIG(bundled-speex):system(pkg-config --atleast-version=1.2 speexdsp) {
CONFIG *= no-bundled-speex
}
unix:!CONFIG(bundled-celt):system(pkg-config --atleast-version=0.7.0 celt) {
CONFIG *= no-bundled-celt
}
!CONFIG(no-bundled-speex) {
SUBDIRS *= speexbuild
}
!CONFIG(no-bundled-celt) {
SUBDIRS *= celt-0.7.0-build celt-0.11.0-build

CONFIG(sbcelt) {
SUBDIRS *= celt-0.7.0-build sbcelt-lib-build sbcelt-helper-build
} else {
unix:!CONFIG(bundled-celt):system(pkg-config --atleast-version=0.7.0 celt) {
CONFIG *= no-bundled-celt
}
!CONFIG(no-bundled-celt) {
SUBDIRS *= celt-0.7.0-build celt-0.11.0-build
}
}

!CONFIG(no-opus) {
Expand Down
5 changes: 4 additions & 1 deletion opus-build/opus-build.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ win32 {
}
}

unix:INCLUDEPATH += ../$$BUILDDIR
unix {
QMAKE_CFLAGS += -x c++
INCLUDEPATH += ../$$BUILDDIR
}

DIST = config.h

Expand Down
84 changes: 84 additions & 0 deletions sbcelt-helper-build/sbcelt-helper-build.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
include (../compiler.pri)

BUILDDIR=$$basename(PWD)
SOURCEDIR=$$replace(BUILDDIR,-helper-build,-src)
CELTDIR=../celt-0.7.0-src/libcelt

!exists($$CELTDIR/../COPYING) {
message("The $$CELTDIR/ directory was not found. You need to do the following:")
message("")
message("Use CELT Git:")
message("git submodule init")
message("git submodule update")
message("")
error("Aborting configuration")
}

!exists(../$$SOURCEDIR/LICENSE) {
message("The $$SOURCEDIR/ directory was not found. You need to do the following:")
message("")
message("Use SBCELT Git:")
message("git submodule init")
message("git submodule update")
message("")
error("Aborting configuration")
}

TEMPLATE = app
CONFIG -= qt app_bundle
CONFIG *= debug_and_release
CONFIG -= warn-on
VPATH = ../$$SOURCEDIR/helper
TARGET = sbcelt-helper
DEFINES += HAVE_CONFIG_H
INCLUDEPATH += ../$$SOURCEDIR/helper ../$$SOURCEDIR/lib ../$$SOURCEDIR $$CELTDIR
LIBS += -lpthread

SOURCES = \
$$CELTDIR/bands.c \
$$CELTDIR/celt.c \
$$CELTDIR/cwrs.c \
$$CELTDIR/entcode.c \
$$CELTDIR/entdec.c \
$$CELTDIR/entenc.c \
$$CELTDIR/header.c \
$$CELTDIR/kiss_fft.c \
$$CELTDIR/kiss_fftr.c \
$$CELTDIR/laplace.c \
$$CELTDIR/mdct.c \
$$CELTDIR/modes.c \
$$CELTDIR/pitch.c \
$$CELTDIR/psy.c \
$$CELTDIR/quant_bands.c \
$$CELTDIR/rangedec.c \
$$CELTDIR/rangeenc.c \
$$CELTDIR/rate.c \
$$CELTDIR/vq.c \
sbcelt-helper.c \
alloc.c

unix:!macx {
UNAME=$$system(uname -s)
contains(UNAME, Linux) {
SOURCES *= ../lib/futex-linux.c seccomp-sandbox.c sbcelt-sandbox-linux.c pdeath-linux.c
LIBS += -lrt
}
contains(UNAME, FreeBSD) {
SOURCES *= ../lib/futex-freebsd.c sbcelt-sandbox-freebsd.c pdeath-kqueue.c
}
}

macx {
SOURCES *= ../lib/futex-stub.c sbcelt-sandbox-darwin.c pdeath-kqueue.c
}

CONFIG(release, debug|release) {
DESTDIR = ../release
}

CONFIG(debug, debug|release) {
DEFINES *= USE_LOGFILE
DESTDIR = ../debug/
}

include(../symbols.pri)
69 changes: 69 additions & 0 deletions sbcelt-lib-build/sbcelt-lib-build.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
include(../compiler.pri)

BUILDDIR=$$basename(PWD)
SOURCEDIR=$$replace(BUILDDIR,-lib-build,-src)
CELTDIR=../celt-0.7.0-src

!exists($$CELTDIR/COPYING) {
message("The $$CELTDIR/ directory was not found. You need to do the following:")
message("")
message("Use CELT Git:")
message("git submodule init")
message("git submodule update")
message("")
error("Aborting configuration")
}

!exists(../$$SOURCEDIR/LICENSE) {
message("The $$SOURCEDIR/ directory was not found. You need to do the following:")
message("")
message("Use SBCELT Git:")
message("git submodule init")
message("git submodule update")
message("")
error("Aborting configuration")
}

TEMPLATE = lib
CONFIG -= qt
CONFIG += debug_and_release
CONFIG -= warn_on
CONFIG += warn_off
CONFIG += static
VPATH = ../$$SOURCEDIR/lib
TARGET = sbcelt
INCLUDEPATH = $$CELTDIR/libcelt
DEFINES += SBCELT_PREFIX_API

QMAKE_CFLAGS -= -fPIE -pie

unix {
INCLUDEPATH += ../$$BUILDDIR
}

SOURCES *= libsbcelt.c mtime.c stub.c

unix:!macx {
UNAME=$$system(uname -s)
contains(UNAME, Linux) {
SOURCES *= futex-linux.c closefrom.c
}
contains(UNAME, FreeBSD) {
SOURCES *= futex-freebsd.c closefrom-sys.c
}
}

macx {
SOURCES *= futex-stub.c closefrom.c
}

CONFIG(debug, debug|release) {
CONFIG += console
DESTDIR = ../debug
}

CONFIG(release, debug|release) {
DESTDIR = ../release
}

include(../symbols.pri)
1 change: 1 addition & 0 deletions sbcelt-src
Submodule sbcelt-src added at a2ce9c
10 changes: 10 additions & 0 deletions src/mumble/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -86,6 +95,7 @@ void CodecInit::initialize() {
delete codec;
}
}
#endif
}

void CodecInit::destroy() {
Expand Down
11 changes: 11 additions & 0 deletions src/mumble/CELTCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Loading

0 comments on commit c2655fc

Please sign in to comment.