diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 4f5e911a52a0d6e32584a4d8c7dbf6744d265a06..3d50dfc375c59be2e5bf636ce5f8a5dc4d88ec66 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -308,6 +308,7 @@ sflphone_pick_up() (void) time(&selectedCall->_stop); break; case CALL_STATE_CURRENT: + case CALL_STATE_RECORD: sflphone_new_call(); break; case CALL_STATE_RINGING: diff --git a/src/audio/codecs/Makefile.am b/src/audio/codecs/Makefile.am index 0f790f478ad395c5c42227946489f383320df0f0..6f8b16559c518a1c2da8832b4befa607b1282a67 100644 --- a/src/audio/codecs/Makefile.am +++ b/src/audio/codecs/Makefile.am @@ -14,7 +14,7 @@ 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 +libcodec_speex_so_LDFLAGS = --shared -lc -lspeex -lspeexdsp -lm INSTALL_SPEEX_RULE = install-libcodec_speex_so endif diff --git a/src/audio/codecs/alaw.cpp b/src/audio/codecs/alaw.cpp index d8b69d03593318a9f368eb63762ebf1f86373d24..807d518bab0880b579c09f9ba5505f607d27af54 100644 --- a/src/audio/codecs/alaw.cpp +++ b/src/audio/codecs/alaw.cpp @@ -36,6 +36,7 @@ public: virtual ~Alaw(){} virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) { + // _debug("Decoded by alaw \n"); int16* end = dst+size; while(dst<end) *dst++ = ALawDecode(*src++); @@ -44,6 +45,7 @@ public: virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) { + // _debug("Encoded by alaw \n"); size >>= 1; uint8* end = dst+size; while(dst<end) diff --git a/src/audio/codecs/gsmcodec.cpp b/src/audio/codecs/gsmcodec.cpp index 1ab85f23886324ae5a05523e6144c88ffd04c58f..896b3a0009fd994d5d968c710f1712363764a684 100644 --- a/src/audio/codecs/gsmcodec.cpp +++ b/src/audio/codecs/gsmcodec.cpp @@ -52,6 +52,7 @@ public: } virtual int codecDecode (short * dst, unsigned char * src, unsigned int size){ + // _debug("Decoded by gsm \n"); (void)size; if(gsm_decode(_decode_gsmhandle, (gsm_byte*)src, (gsm_signal*)dst) < 0) printf("ERROR: gsm_decode\n"); @@ -59,6 +60,8 @@ public: } virtual int codecEncode (unsigned char * dst, short * src, unsigned int size){ + + // _debug("Encoded by gsm \n"); (void)size; gsm_encode(_encode_gsmhandle, (gsm_signal*)src, (gsm_byte*) dst); return 33; diff --git a/src/audio/codecs/speexcodec.cpp b/src/audio/codecs/speexcodec.cpp index f89d73b9387da010362f59c74b76dbd14d029a18..1400e0c2069108bd2776015a21e13f4a26a468c7 100644 --- a/src/audio/codecs/speexcodec.cpp +++ b/src/audio/codecs/speexcodec.cpp @@ -21,6 +21,7 @@ #include "audiocodec.h" #include <cstdio> #include <speex/speex.h> +#include <speex/speex_preprocess.h> class Speex : public AudioCodec{ @@ -32,7 +33,8 @@ public: _speex_enc_bits(), _speex_dec_state(), _speex_enc_state(), - _speex_frame_size() + _speex_frame_size(), + _preprocess_state() { _clockRate = 8000; _channel = 1; @@ -44,7 +46,23 @@ public: Speex( const Speex& ); Speex& operator=(const Speex&); - void initSpeex() { + void initSpeex() { + int temp = 1; + int temp10 = 10; + int db = -10; + + int *enable; + enable = &temp; + + int *quality; + quality = &temp10; + + int *complex; + complex = &temp10; + + int *attenuation; + attenuation = &db; + /* if (_clockRate < 16000 ) { _speexModePtr = &speex_nb_mode; @@ -60,14 +78,27 @@ public: // Init the decoder struct speex_bits_init(&_speex_dec_bits); - _speex_dec_state = speex_decoder_init(_speexModePtr); - - // Init the encoder struct + _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_decoder_ctl(_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size); - } + 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); + + } ~Speex() { @@ -91,6 +122,7 @@ public: 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; } @@ -98,8 +130,8 @@ public: { speex_bits_reset(&_speex_enc_bits); speex_encoder_ctl(_speex_enc_state,SPEEX_SET_SAMPLING_RATE,&_clockRate); - - speex_encode_int(_speex_enc_state, src, &_speex_enc_bits); + 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; } @@ -111,6 +143,7 @@ private: void *_speex_dec_state; void *_speex_enc_state; int _speex_frame_size; + SpeexPreprocessState *_preprocess_state; }; // the class factories diff --git a/src/audio/codecs/ulaw.cpp b/src/audio/codecs/ulaw.cpp index 2a53c81a04b8587c12a2499f7fa77f761882691c..6d44bff13c0ff27272a39d45e0c913fdb985619a 100644 --- a/src/audio/codecs/ulaw.cpp +++ b/src/audio/codecs/ulaw.cpp @@ -36,6 +36,7 @@ public: } virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) { + // _debug("Decoded by ulaw"); int16* end = dst+size; while(dst<end) *dst++ = ULawDecode(*src++); @@ -43,7 +44,8 @@ public: } virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) { - size >>= 1; + // _debug("Encoded by ulaw \n"); + size >>= 1; uint8* end = dst+size; while(dst<end) *dst++ = ULawEncode(*src++);