Commit 0b7bd99f authored by Tristan Matthews's avatar Tristan Matthews

* #19242: codecs: use system ilbc instead of pjsip's

parent 76639502
......@@ -272,9 +272,17 @@ AC_DEFINE_UNQUOTED([HAVE_SPEEXDSP], `if test "x$with_speexdsp" = "xyes"; then ec
AM_CONDITIONAL(BUILD_SPEEXDSP, test "x$with_speexdsp" = "xyes" )
dnl iLBC is default-enabled, since it's included
AC_ARG_ENABLE([ilbc], AS_HELP_STRING([--disable-ilbc], [Disable iLBC codec]))
AM_CONDITIONAL(BUILD_ILBC, test "x$enable_ilbc" != "xno")
dnl iLBC is enabled if it's installed
AC_ARG_WITH([with-libilbc],
[AS_HELP_STRING([--with-libilbc],
[support ilbc audio @<:@default=check@:>@])],
[],
[with_libilbc=check])
AS_CASE(["$with_libilbc"],
[yes], [PKG_CHECK_MODULES([libilbc], [libilbc], [HAVE_LIBILBC=1])],
[no], [],
[PKG_CHECK_MODULES([libilbc], [libilbc], [HAVE_LIBILBC=1], [HAVE_LIBILBC=0])])
AM_CONDITIONAL([BUILD_ILBC], [test "$with_libilbc" != no -a "$HAVE_LIBILBC" -eq 1])
# IAX
......
#!/bin/bash
OPTIONS="--disable-oss
--disable-video
--enable-ext-sound
--disable-speex-aec
--disable-g711-codec
--disable-l16-codec
--disable-gsm-codec
--disable-g722-codec
--disable-g7221-codec
--disable-speex-codec
--disable-ilbc-codec
--disable-sdl
--disable-ffmpeg
--disable-v4l2"
# TODO: autotools should be doing this
cd "`dirname $BASH_SOURCE`"/pjproject-2.0.1
CFLAGS="-fPIC" ./configure --disable-sound --disable-video && make dep && make -j1 && echo "pjsip successfully compiled"
./configure $OPTIONS && make dep && make -j1 && echo "pjsip successfully compiled"
......@@ -38,13 +38,11 @@ INSTALL_SPEEX_UB_RULE = install-libcodec_speex_ub_so
endif
if BUILD_ILBC
include $(src)/libs/pjproject-2.0.1/build.mak
ILBC_LIB = libcodec_ilbc.so
libcodecdescriptor_la_CXXFLAGS = -DBUILD_ILBC
libcodec_ilbc_so_SOURCES = ilbc.cpp
libcodec_ilbc_so_CXXFLAGS = -fPIC -g -Wall -I$(top_srcdir)/libs/pjproject-2.0.1/third_party/
libcodec_ilbc_so_LDFLAGS = --shared -lc $(top_srcdir)/libs/pjproject-2.0.1/third_party/lib/libilbccodec-$(TARGET_NAME).a
libcodec_ilbc_so_CXXFLAGS = -fPIC -g -Wall $(libilbc_CFLAGS)
libcodec_ilbc_so_LDFLAGS = --shared -lc $(libilbc_LIBS)
libcodec_ilbc_so_LDADD = libcodecdescriptor.la
INSTALL_ILBC_RULE = install-libcodec_ilbc_so
endif
......
......@@ -33,16 +33,13 @@
#include <algorithm>
extern "C" {
#include "ilbc/iLBC_encode.h"
#include "ilbc/iLBC_decode.h"
#include <ilbc.h>
}
class Ilbc: public sfl::AudioCodec {
public:
Ilbc() :
sfl::AudioCodec(ILBC_PAYLOAD, "iLBC", 8000, ILBC_FRAME_SIZE, 1),
dst_float_(),
src_float_(),
ilbc_dec_(),
ilbc_enc_()
{
......@@ -54,32 +51,19 @@ class Ilbc: public sfl::AudioCodec {
// iLBC expects floating point data, so we have to convert
int decode(short *dst, unsigned char *src, size_t /*buf_size*/) {
/* zero out the buffer */
std::fill(dst_float_.begin(), dst_float_.end(), 0);
const int NORMAL_MODE = 1;
iLBC_decode(dst_float_.data(), src, &ilbc_dec_, NORMAL_MODE);
std::copy(dst_float_.begin(), dst_float_.end(), dst);
iLBC_decode(dst, reinterpret_cast<WebRtc_UWord16*>(src), &ilbc_dec_, NORMAL_MODE);
return frameSize_;
}
int encode(unsigned char *dst, short* src, size_t /*buf_size*/) {
/* zero out the buffer */
std::fill(src_float_.begin(), src_float_.end(), 0);
std::copy(src, src + ILBC_FRAME_SIZE, src_float_.begin());
iLBC_encode(dst, src_float_.data(), &ilbc_enc_);
iLBC_encode(reinterpret_cast<WebRtc_UWord16*>(dst), src, &ilbc_enc_);
return frameSize_;
}
private:
static const int ILBC_FRAME_SIZE = 160;
static const int ILBC_PAYLOAD = 105;
std::tr1::array<float, ILBC_FRAME_SIZE> dst_float_;
std::tr1::array<float, ILBC_FRAME_SIZE> src_float_;
iLBC_Dec_Inst_t ilbc_dec_;
iLBC_Enc_Inst_t ilbc_enc_;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment