diff --git a/configure.ac b/configure.ac index e09abd63487dd9b2ef7b53b8c6cb69ebdc2bfbe1..9a3b2af982a7ef54cd7c9bfe71f990190dbea888 100644 --- a/configure.ac +++ b/configure.ac @@ -223,7 +223,6 @@ AC_ARG_WITH([speex], [], [with_speex=yes]) -LIBSPEEX= AS_IF([test "x$with_speex" != xno], [AC_CHECK_HEADER([speex/speex.h], , AC_MSG_FAILURE([Unable to find the libspeex headers (you may need to install the dev package). You may use --without-speex to compile without speex codec support.]))] [AC_CHECK_HEADER([speex/speex_preprocess.h], , AC_MSG_FAILURE([Unable to find the libspeexdsp headers (you may need to install the libspeexdsp-dev package). You may use --without-speex to compile without speex codec support.]))] @@ -232,11 +231,20 @@ AS_IF([test "x$with_speex" != xno], [AC_MSG_FAILURE( [libspeex link test failed. You may use --without-speex to compile without speex codec support.])] ) - ] - ) - + ] +dnl More advanced check in case the libspeexdsp is not installed +AC_SEARCH_LIBS(speex_preprocess_run, speexdsp, HAVE_SPEEXDSP="yes", HAVE_SPEEXDSP="no", []) + +if test $HAVE_SPEEXDSP="no"; then + echo $HAVE_SPEEXDSP; + AC_MSG_WARN([The silence detection in speex could not have been enabled]) +fi + +) + AC_DEFINE([HAVE_SPEEX], test "x$with_speex" = "xyes", [Define if you have libspeex]) AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" ) +AM_CONDITIONAL(ENABLE_SPEEXDSP, test $HAVE_SPEEXDSP = yes) dnl Check for ilbc support AC_ARG_WITH([ilbc], diff --git a/src/audio/codecs/Makefile.am b/src/audio/codecs/Makefile.am index 6f8b16559c518a1c2da8832b4befa607b1282a67..8c7d4803848e93c0e4f47ee9f40ebfbe4d0dafc5 100644 --- a/src/audio/codecs/Makefile.am +++ b/src/audio/codecs/Makefile.am @@ -9,12 +9,16 @@ libcodec_gsm_so_LDFLAGS = --shared -lc -lgsm INSTALL_GSM_RULE = install-libcodec_gsm_so endif +if ENABLE_SPEEXDSP +SPEEXDSP= -DHAVE_SPEEXDSP_LIB +endif + if BUILD_SPEEX SPEEX_LIB = libcodec_speex.so libcodec_speex_so_SOURCES = speexcodec.cpp libcodec_speex_so_CFLAGS = -fPIC -g -Wall -libcodec_speex_so_CXXFLAGS = -fPIC -g -Wall -libcodec_speex_so_LDFLAGS = --shared -lc -lspeex -lspeexdsp -lm +libcodec_speex_so_CXXFLAGS = -fPIC -g -Wall $(SPEEXDSP) +libcodec_speex_so_LDFLAGS = --shared -lc -lspeex $(SPEEX_NIMP) INSTALL_SPEEX_RULE = install-libcodec_speex_so endif diff --git a/src/audio/codecs/speexcodec.cpp b/src/audio/codecs/speexcodec.cpp index c9a350fcdb3208b58296b01d96f5bb130de7342b..a2442cbfe869a26af242f4f6b67cbf7ec0326c3b 100644 --- a/src/audio/codecs/speexcodec.cpp +++ b/src/audio/codecs/speexcodec.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005 Savoir-Faire Linux inc. - * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Jerome Oufella <jerome.oufella@savoirfairelinux.com> + * 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 @@ -23,116 +23,114 @@ #include <speex/speex.h> #include <speex/speex_preprocess.h> - - class Speex : public AudioCodec{ -public: - Speex(int payload=0) - : AudioCodec(payload, "speex"), - _speexModePtr(NULL), - _speex_dec_bits(), - _speex_enc_bits(), - _speex_dec_state(), - _speex_enc_state(), - _speex_frame_size(), - _preprocess_state() - { - _clockRate = 8000; - _channel = 1; - _bitrate = 0; - _bandwidth = 0; - initSpeex(); - } + public: + Speex(int payload=0) + : AudioCodec(payload, "speex"), + _speexModePtr(NULL), + _speex_dec_bits(), + _speex_enc_bits(), + _speex_dec_state(), + _speex_enc_state(), + _speex_frame_size(), + _preprocess_state() + { + _clockRate = 8000; + _channel = 1; + _bitrate = 0; + _bandwidth = 0; + initSpeex(); + } Speex( const Speex& ); Speex& operator=(const Speex&); - void initSpeex() { - int enable = 1; - int quality = 10; - int complex = 10; - int attenuation = -10; - - /* - if (_clockRate < 16000 ) { - _speexModePtr = &speex_nb_mode; - } else if (_clockRate < 32000) { - _speexModePtr = &speex_wb_mode; - } else { - _speexModePtr = &speex_uwb_mode; - } - */ - // 8000 HZ --> Narrow-band mode - // TODO Manage the other modes - _speexModePtr = &speex_nb_mode; - - // Init the decoder struct - speex_bits_init(&_speex_dec_bits); - _speex_dec_state = speex_decoder_init(_speexModePtr); - - // Init the encoder struct - speex_bits_init(&_speex_enc_bits); - _speex_enc_state = speex_encoder_init(_speexModePtr); - speex_encoder_ctl(_speex_enc_state, SPEEX_SET_VAD, &enable); - speex_encoder_ctl(_speex_enc_state, SPEEX_SET_DTX, &enable); - speex_encoder_ctl(_speex_enc_state, SPEEX_SET_VBR_QUALITY, &quality); - speex_encoder_ctl(_speex_enc_state, SPEEX_SET_COMPLEXITY, &complex); - - // Init the decoder struct - speex_decoder_ctl(_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size); - - // Init the preprocess struct - _preprocess_state = speex_preprocess_state_init(_speex_frame_size,_clockRate); - speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_DENOISE, &enable); - speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &attenuation); - speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_VAD, &enable); - speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_AGC, &enable); - + void initSpeex() { + + // 8000 HZ --> Narrow-band mode + // TODO Manage the other modes + _speexModePtr = &speex_nb_mode; + + // Init the decoder struct + speex_bits_init(&_speex_dec_bits); + _speex_dec_state = speex_decoder_init(_speexModePtr); + + // Init the encoder struct + speex_bits_init(&_speex_enc_bits); + _speex_enc_state = speex_encoder_init(_speexModePtr); + +#ifdef HAVE_SPEEXDSP_LIB + + int enable = 1; + int quality = 10; + int complex = 10; + int attenuation = -10; + + speex_encoder_ctl(_speex_enc_state, SPEEX_SET_VAD, &enable); + speex_encoder_ctl(_speex_enc_state, SPEEX_SET_DTX, &enable); + speex_encoder_ctl(_speex_enc_state, SPEEX_SET_VBR_QUALITY, &quality); + speex_encoder_ctl(_speex_enc_state, SPEEX_SET_COMPLEXITY, &complex); + + // Init the decoder struct + speex_decoder_ctl(_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size); + + // Init the preprocess struct + _preprocess_state = speex_preprocess_state_init(_speex_frame_size,_clockRate); + speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_DENOISE, &enable); + speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &attenuation); + speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_VAD, &enable); + speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_AGC, &enable); +#endif + + } + + ~Speex() + { + terminateSpeex(); + } + + void terminateSpeex() { + // Destroy the decoder struct + speex_bits_destroy(&_speex_dec_bits); + speex_decoder_destroy(_speex_dec_state); + _speex_dec_state = 0; + + // Destroy the encoder struct + speex_bits_destroy(&_speex_enc_bits); + speex_encoder_destroy(_speex_enc_state); + _speex_enc_state = 0; + } + + virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) + { + int ratio = 320 / _speex_frame_size; + speex_bits_read_from(&_speex_dec_bits, (char*)src, size); + speex_decode_int(_speex_dec_state, &_speex_dec_bits, dst); + + return _speex_frame_size * ratio; + } + + virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) + { + speex_bits_reset(&_speex_enc_bits); + +#ifdef HAVE_SPEEXDSP_LIB + speex_encoder_ctl(_speex_enc_state,SPEEX_SET_SAMPLING_RATE,&_clockRate); + speex_preprocess_run(_preprocess_state, src); +#endif + + speex_encode_int(_speex_enc_state, src, &_speex_enc_bits); + int nbBytes = speex_bits_write(&_speex_enc_bits, (char*)dst, size); + return nbBytes; } - ~Speex() - { - terminateSpeex(); - } - - void terminateSpeex() { - // Destroy the decoder struct - speex_bits_destroy(&_speex_dec_bits); - speex_decoder_destroy(_speex_dec_state); - _speex_dec_state = 0; - - // Destroy the encoder struct - speex_bits_destroy(&_speex_enc_bits); - speex_encoder_destroy(_speex_enc_state); - _speex_enc_state = 0; - } - - virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) - { - int ratio = 320 / _speex_frame_size; - speex_bits_read_from(&_speex_dec_bits, (char*)src, size); - speex_decode_int(_speex_dec_state, &_speex_dec_bits, dst); - - return _speex_frame_size * ratio; - } - - virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) - { - speex_bits_reset(&_speex_enc_bits); - speex_encoder_ctl(_speex_enc_state,SPEEX_SET_SAMPLING_RATE,&_clockRate); - speex_preprocess_run(_preprocess_state, src); - speex_encode_int(_speex_enc_state, src, &_speex_enc_bits); - int nbBytes = speex_bits_write(&_speex_enc_bits, (char*)dst, size); - return nbBytes; - } - -private: - const SpeexMode* _speexModePtr; - SpeexBits _speex_dec_bits; - SpeexBits _speex_enc_bits; - void *_speex_dec_state; - void *_speex_enc_state; - int _speex_frame_size; + private: + const SpeexMode* _speexModePtr; + SpeexBits _speex_dec_bits; + SpeexBits _speex_enc_bits; + void *_speex_dec_state; + void *_speex_enc_state; + int _speex_frame_size; SpeexPreprocessState *_preprocess_state; }; diff --git a/www/features.php b/www/features.php index 0b00373b6823c6bcb724272f56ab9ff551ff611d..fec0febdfdfb90eb168c5a6223ea1a7e3e303498 100644 --- a/www/features.php +++ b/www/features.php @@ -21,7 +21,7 @@ include('include/header.php'); <a href="http://www.pulseaudio.org">PulseAudio</a> sound server so you could experience the great possibilities it offers (sound mixing, per application volume control, ...). <br/> - The GTK+ graphical user interface provides you an intuitiv and easy way to phone, and, thanks to the integration of the GNOME desktop notification, you will never miss a call. + The GTK+ graphical user interface provides you an intuitive and easy way to phone, and, thanks to the integration of the GNOME desktop notification, you will never miss a call. <br/> </p> </td> diff --git a/www/index.php b/www/index.php index 782b184a8306d0d4e40374c06db49adf5c48676b..6b102c0091b0ea5ae8da4cd70b5d67f63980f083 100644 --- a/www/index.php +++ b/www/index.php @@ -47,7 +47,7 @@ include('include/header.php'); <li>SIP and IAX2 compatible softphone</li> <li>Robust enterprise-class desktop phone for Linux</li> <li>Provide support of unlimited number of calls, multi-accounts, call transfer and hold.</li> - <li>Enjoy a perfect audio quality</li> + <li>Enjoy perfect audio quality</li> </ul> <br> <div class="float_it_middle">