Skip to content
Snippets Groups Projects
Commit 366a9f6b authored by Alexandre Savard's avatar Alexandre Savard
Browse files

Add CELT codec (#1143)

Modified the configure.ac and Makefile so that sflphoned can be compiled
with or without CELT functionnality

Still need to try it ip-to-ip
parent 4a847c01
No related branches found
No related tags found
No related merge requests found
...@@ -317,6 +317,29 @@ AC_DEFINE([HAVE_SPEEX], test "x$with_speex" = "xyes", [Define if you have libspe ...@@ -317,6 +317,29 @@ AC_DEFINE([HAVE_SPEEX], test "x$with_speex" = "xyes", [Define if you have libspe
AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" ) AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" )
AM_CONDITIONAL(ENABLE_SPEEXDSP, test $HAVE_SPEEXDSP = yes) AM_CONDITIONAL(ENABLE_SPEEXDSP, test $HAVE_SPEEXDSP = yes)
# check for libgsm1 (doesn't use pkg-config)
dnl Check for libgsm
AC_ARG_WITH([celt],
[AS_HELP_STRING([--without-celt],
[disable support for celt codec])],
[],
[with_celt=yes])
LIBCELT=
AS_IF([test "x$with_celt" != xno],
[AC_CHECK_HEADER([celt/celt.h], , AC_MSG_FAILURE([Unable to find the libcelt headers. You may use --without-celt to compile without celt codec support.]))]
[AC_CHECK_LIB([celt], [celt_decode],
[],
[AC_MSG_FAILURE(
[libcelt link test failed. You may use --without-celt to compile without celt codec support.])]
)
]
)
AC_DEFINE([HAVE_CELT], test "x$with_celt" = "xyes", [Define if you have libcelt])
AM_CONDITIONAL(BUILD_CELT, test "x$with_celt" = "xyes" )
dnl Check for ilbc support dnl Check for ilbc support
AC_ARG_WITH([ilbc], AC_ARG_WITH([ilbc],
[AS_HELP_STRING([--without-ilbc], [AS_HELP_STRING([--without-ilbc],
......
...@@ -31,6 +31,15 @@ libcodec_speex_wb_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP) ...@@ -31,6 +31,15 @@ libcodec_speex_wb_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP)
INSTALL_SPEEX_WB_RULE = install-libcodec_speex_wb_so INSTALL_SPEEX_WB_RULE = install-libcodec_speex_wb_so
endif endif
if BUILD_CELT
CELT_LIB = libcodec_celt.so
libcodec_celt_so_SOURCES = celtcodec.cpp
libcodec_celt_so_CFLAGS = -fPIC -g -Wall
libcodec_celt_so_CXXFLAGS = -fPIC -g -Wall
libcodec_celt_so_LDFLAGS = --shared -lc -lcelt $(CELT_NIMP)
INSTALL_CELT_RULE = install-libcodec_celt_so
endif
if BUILD_ILBC if BUILD_ILBC
ILBC_LIB = libcodec_ilbc.so ILBC_LIB = libcodec_ilbc.so
libcodec_ilbc_so_SOURCES = ilbc.cpp libcodec_ilbc_so_SOURCES = ilbc.cpp
...@@ -41,7 +50,7 @@ INSTALL_ILBC_RULE = install-libcodec_ilbc_so ...@@ -41,7 +50,7 @@ INSTALL_ILBC_RULE = install-libcodec_ilbc_so
SUBDIRS = ilbc SUBDIRS = ilbc
endif endif
noinst_PROGRAMS = libcodec_ulaw.so libcodec_alaw.so $(GSM_LIB) $(SPEEX_NB_LIB) $(SPEEX_WB_LIB) $(ILBC_LIB) noinst_PROGRAMS = libcodec_ulaw.so libcodec_alaw.so $(GSM_LIB) $(SPEEX_NB_LIB) $(SPEEX_WB_LIB) $(CELT_LIB) $(ILBC_LIB)
noinst_HEADERS = audiocodec.h noinst_HEADERS = audiocodec.h
...@@ -57,8 +66,8 @@ libcodec_alaw_so_LDFLAGS = --shared -lc ...@@ -57,8 +66,8 @@ libcodec_alaw_so_LDFLAGS = --shared -lc
install-exec-local: install-libcodec_ulaw_so install-libcodec_alaw_so $(INSTALL_GSM_RULE) $(INSTALL_SPEEX_NB_RULE) $(INSTALL_SPEEX_WB_RULE) $(INSTALL_ILBC_RULE) install-exec-local: install-libcodec_ulaw_so install-libcodec_alaw_so $(INSTALL_GSM_RULE) $(INSTALL_SPEEX_NB_RULE) $(INSTALL_SPEEX_WB_RULE) $(INSTALL_CELT_RULE) $(INSTALL_ILBC_RULE)
uninstall-local: uninstall-libcodec_ulaw_so uninstall-libcodec_alaw_so uninstall-libcodec_gsm_so uninstall-libcodec_speex_nb_so uninstall-libcodec_speex_wb_so uninstall-local: uninstall-libcodec_ulaw_so uninstall-libcodec_alaw_so uninstall-libcodec_gsm_so uninstall-libcodec_speex_nb_so uninstall-libcodec_speex_wb_so uninstall-libcodec_celt_so
install-libcodec_ulaw_so: libcodec_ulaw.so install-libcodec_ulaw_so: libcodec_ulaw.so
mkdir -p $(sflcodecdir) mkdir -p $(sflcodecdir)
...@@ -71,6 +80,8 @@ install-libcodec_speex_nb_so: libcodec_speex_nb.so ...@@ -71,6 +80,8 @@ install-libcodec_speex_nb_so: libcodec_speex_nb.so
$(INSTALL_PROGRAM) libcodec_speex_nb.so $(sflcodecdir) $(INSTALL_PROGRAM) libcodec_speex_nb.so $(sflcodecdir)
install-libcodec_speex_wb_so: libcodec_speex_wb.so install-libcodec_speex_wb_so: libcodec_speex_wb.so
$(INSTALL_PROGRAM) libcodec_speex_wb.so $(sflcodecdir) $(INSTALL_PROGRAM) libcodec_speex_wb.so $(sflcodecdir)
install-libcodec_celt_so: libcodec_celt.so
$(INSTALL_PROGRAM) libcodec_celt.so $(sflcodecdir)
install-libcodec_ilbc_so: libcodec_ilbc.so install-libcodec_ilbc_so: libcodec_ilbc.so
$(INSTALL_PROGRAM) libcodec_ilbc.so $(sflcodecdir) $(INSTALL_PROGRAM) libcodec_ilbc.so $(sflcodecdir)
...@@ -85,6 +96,8 @@ uninstall-libcodec_speex_nb_so: ...@@ -85,6 +96,8 @@ uninstall-libcodec_speex_nb_so:
rm -f $(sflcodecdir)/libcodec_speex_nb.so rm -f $(sflcodecdir)/libcodec_speex_nb.so
uninstall-libcodec_speex_wb_so: uninstall-libcodec_speex_wb_so:
rm -f $(sflcodecdir)/libcodec_speex_wb.so rm -f $(sflcodecdir)/libcodec_speex_wb.so
uninstall-libcodec_celt_so:
rm -f $(sflcodecdir)/libcodec_celt.so
rm -rf $(sflcodecdir) rm -rf $(sflcodecdir)
uninstall-libcodec_ilbc_so: uninstall-libcodec_ilbc_so:
rm -f $(sflcodecdir)/libcodec_ilbc.so rm -f $(sflcodecdir)/libcodec_ilbc.so
......
/*
* Copyright (C) 2007-2009 Savoir-Faire Linux inc.
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "audiocodec.h"
#include <cstdio>
#include <celt/celt.h>
class Celt : public AudioCodec{
public:
Celt(int payload=0)
: AudioCodec(payload, "celt"),
_celt_frame_size(512)
{
_clockRate = 44100;
_channel = 1;
_bitrate = 0;
_bandwidth = 0;
initCelt();
}
Celt( const Celt& );
Celt& operator=(const Celt&);
void initCelt() {
printf("init celt");
mode = celt_mode_create(_clockRate, _channel, _celt_frame_size, NULL);
// celt_mode_info(mode, CELT_GET_LOOKAHEAD, &skip);
if (mode == NULL)
{
printf("failed to create a mode\n");
}
// bytes_per_packet = 1024;
// if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)
// {
// printf ("bytes per packet must be between 0 and %d\n");
// }
// celt_mode_info(mode, CELT_GET_FRAME_SIZE, &frame_size);
// celt_mode_info(mode, CELT_GET_NB_CHANNELS, &_channel);
enc = celt_encoder_create(mode);
dec = celt_decoder_create(mode);
}
~Celt()
{
terminateCelt();
}
void terminateCelt() {
celt_encoder_destroy(enc);
celt_decoder_destroy(dec);
}
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size)
{
int len = 0;
len = celt_decode(dec, src, size, (celt_int16_t*)dst);
return len;
}
virtual int codecEncode (unsigned char *dst, short *src, unsigned int size)
{
int len = 0;
len = celt_encode(enc, (celt_int16_t *)src, NULL, dst, size);
return len;
}
private:
CELTMode *mode;
CELTEncoder *enc;
CELTDecoder *dec;
celt_int32_t _celt_frame_size;
celt_int32_t skip;
};
// the class factories
extern "C" AudioCodec* create() {
return new Celt(115);
}
extern "C" void destroy(AudioCodec* a) {
delete a;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment