Skip to content
Snippets Groups Projects
Commit 0b7bd99f authored by Tristan Matthews's avatar Tristan Matthews
Browse files

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

parent 76639502
No related branches found
No related tags found
No related merge requests found
...@@ -272,9 +272,17 @@ AC_DEFINE_UNQUOTED([HAVE_SPEEXDSP], `if test "x$with_speexdsp" = "xyes"; then ec ...@@ -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" ) AM_CONDITIONAL(BUILD_SPEEXDSP, test "x$with_speexdsp" = "xyes" )
dnl iLBC is default-enabled, since it's included dnl iLBC is enabled if it's installed
AC_ARG_ENABLE([ilbc], AS_HELP_STRING([--disable-ilbc], [Disable iLBC codec])) AC_ARG_WITH([with-libilbc],
AM_CONDITIONAL(BUILD_ILBC, test "x$enable_ilbc" != "xno") [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 # IAX
......
#!/bin/bash #!/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 # TODO: autotools should be doing this
cd "`dirname $BASH_SOURCE`"/pjproject-2.0.1 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 ...@@ -38,13 +38,11 @@ INSTALL_SPEEX_UB_RULE = install-libcodec_speex_ub_so
endif endif
if BUILD_ILBC if BUILD_ILBC
include $(src)/libs/pjproject-2.0.1/build.mak
ILBC_LIB = libcodec_ilbc.so ILBC_LIB = libcodec_ilbc.so
libcodecdescriptor_la_CXXFLAGS = -DBUILD_ILBC libcodecdescriptor_la_CXXFLAGS = -DBUILD_ILBC
libcodec_ilbc_so_SOURCES = ilbc.cpp 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_CXXFLAGS = -fPIC -g -Wall $(libilbc_CFLAGS)
libcodec_ilbc_so_LDFLAGS = --shared -lc $(top_srcdir)/libs/pjproject-2.0.1/third_party/lib/libilbccodec-$(TARGET_NAME).a libcodec_ilbc_so_LDFLAGS = --shared -lc $(libilbc_LIBS)
libcodec_ilbc_so_LDADD = libcodecdescriptor.la libcodec_ilbc_so_LDADD = libcodecdescriptor.la
INSTALL_ILBC_RULE = install-libcodec_ilbc_so INSTALL_ILBC_RULE = install-libcodec_ilbc_so
endif endif
......
...@@ -33,16 +33,13 @@ ...@@ -33,16 +33,13 @@
#include <algorithm> #include <algorithm>
extern "C" { extern "C" {
#include "ilbc/iLBC_encode.h" #include <ilbc.h>
#include "ilbc/iLBC_decode.h"
} }
class Ilbc: public sfl::AudioCodec { class Ilbc: public sfl::AudioCodec {
public: public:
Ilbc() : Ilbc() :
sfl::AudioCodec(ILBC_PAYLOAD, "iLBC", 8000, ILBC_FRAME_SIZE, 1), sfl::AudioCodec(ILBC_PAYLOAD, "iLBC", 8000, ILBC_FRAME_SIZE, 1),
dst_float_(),
src_float_(),
ilbc_dec_(), ilbc_dec_(),
ilbc_enc_() ilbc_enc_()
{ {
...@@ -54,32 +51,19 @@ class Ilbc: public sfl::AudioCodec { ...@@ -54,32 +51,19 @@ class Ilbc: public sfl::AudioCodec {
// iLBC expects floating point data, so we have to convert // iLBC expects floating point data, so we have to convert
int decode(short *dst, unsigned char *src, size_t /*buf_size*/) { 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; const int NORMAL_MODE = 1;
iLBC_decode(dst_float_.data(), src, &ilbc_dec_, NORMAL_MODE); iLBC_decode(dst, reinterpret_cast<WebRtc_UWord16*>(src), &ilbc_dec_, NORMAL_MODE);
std::copy(dst_float_.begin(), dst_float_.end(), dst);
return frameSize_; return frameSize_;
} }
int encode(unsigned char *dst, short* src, size_t /*buf_size*/) { int encode(unsigned char *dst, short* src, size_t /*buf_size*/) {
/* zero out the buffer */ iLBC_encode(reinterpret_cast<WebRtc_UWord16*>(dst), src, &ilbc_enc_);
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_);
return frameSize_; return frameSize_;
} }
private: private:
static const int ILBC_FRAME_SIZE = 160; static const int ILBC_FRAME_SIZE = 160;
static const int ILBC_PAYLOAD = 105; 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_Dec_Inst_t ilbc_dec_;
iLBC_Enc_Inst_t ilbc_enc_; iLBC_Enc_Inst_t ilbc_enc_;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment