Skip to content
Snippets Groups Projects
Commit f1ee2b68 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'recording' of git+ssh://repos-sflphone-git@sflphone.org/~/sflphone into recording

parents 37a9bdbe 1668ba97
No related branches found
No related tags found
No related merge requests found
...@@ -308,6 +308,7 @@ sflphone_pick_up() ...@@ -308,6 +308,7 @@ sflphone_pick_up()
(void) time(&selectedCall->_stop); (void) time(&selectedCall->_stop);
break; break;
case CALL_STATE_CURRENT: case CALL_STATE_CURRENT:
case CALL_STATE_RECORD:
sflphone_new_call(); sflphone_new_call();
break; break;
case CALL_STATE_RINGING: case CALL_STATE_RINGING:
......
...@@ -14,7 +14,7 @@ SPEEX_LIB = libcodec_speex.so ...@@ -14,7 +14,7 @@ SPEEX_LIB = libcodec_speex.so
libcodec_speex_so_SOURCES = speexcodec.cpp libcodec_speex_so_SOURCES = speexcodec.cpp
libcodec_speex_so_CFLAGS = -fPIC -g -Wall libcodec_speex_so_CFLAGS = -fPIC -g -Wall
libcodec_speex_so_CXXFLAGS = -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 INSTALL_SPEEX_RULE = install-libcodec_speex_so
endif endif
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
virtual ~Alaw(){} virtual ~Alaw(){}
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) virtual int codecDecode (short *dst, unsigned char *src, unsigned int size)
{ {
// _debug("Decoded by alaw \n");
int16* end = dst+size; int16* end = dst+size;
while(dst<end) while(dst<end)
*dst++ = ALawDecode(*src++); *dst++ = ALawDecode(*src++);
...@@ -44,6 +45,7 @@ public: ...@@ -44,6 +45,7 @@ public:
virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) virtual int codecEncode (unsigned char *dst, short *src, unsigned int size)
{ {
// _debug("Encoded by alaw \n");
size >>= 1; size >>= 1;
uint8* end = dst+size; uint8* end = dst+size;
while(dst<end) while(dst<end)
......
...@@ -52,6 +52,7 @@ public: ...@@ -52,6 +52,7 @@ public:
} }
virtual int codecDecode (short * dst, unsigned char * src, unsigned int size){ virtual int codecDecode (short * dst, unsigned char * src, unsigned int size){
// _debug("Decoded by gsm \n");
(void)size; (void)size;
if(gsm_decode(_decode_gsmhandle, (gsm_byte*)src, (gsm_signal*)dst) < 0) if(gsm_decode(_decode_gsmhandle, (gsm_byte*)src, (gsm_signal*)dst) < 0)
printf("ERROR: gsm_decode\n"); printf("ERROR: gsm_decode\n");
...@@ -59,6 +60,8 @@ public: ...@@ -59,6 +60,8 @@ public:
} }
virtual int codecEncode (unsigned char * dst, short * src, unsigned int size){ virtual int codecEncode (unsigned char * dst, short * src, unsigned int size){
// _debug("Encoded by gsm \n");
(void)size; (void)size;
gsm_encode(_encode_gsmhandle, (gsm_signal*)src, (gsm_byte*) dst); gsm_encode(_encode_gsmhandle, (gsm_signal*)src, (gsm_byte*) dst);
return 33; return 33;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "audiocodec.h" #include "audiocodec.h"
#include <cstdio> #include <cstdio>
#include <speex/speex.h> #include <speex/speex.h>
#include <speex/speex_preprocess.h>
class Speex : public AudioCodec{ class Speex : public AudioCodec{
...@@ -32,7 +33,8 @@ public: ...@@ -32,7 +33,8 @@ public:
_speex_enc_bits(), _speex_enc_bits(),
_speex_dec_state(), _speex_dec_state(),
_speex_enc_state(), _speex_enc_state(),
_speex_frame_size() _speex_frame_size(),
_preprocess_state()
{ {
_clockRate = 8000; _clockRate = 8000;
_channel = 1; _channel = 1;
...@@ -45,6 +47,22 @@ public: ...@@ -45,6 +47,22 @@ public:
Speex& operator=(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 ) { if (_clockRate < 16000 ) {
_speexModePtr = &speex_nb_mode; _speexModePtr = &speex_nb_mode;
...@@ -65,8 +83,21 @@ public: ...@@ -65,8 +83,21 @@ public:
// Init the encoder struct // Init the encoder struct
speex_bits_init(&_speex_enc_bits); speex_bits_init(&_speex_enc_bits);
_speex_enc_state = speex_encoder_init(_speexModePtr); _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); 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() ~Speex()
...@@ -91,6 +122,7 @@ public: ...@@ -91,6 +122,7 @@ public:
int ratio = 320 / _speex_frame_size; int ratio = 320 / _speex_frame_size;
speex_bits_read_from(&_speex_dec_bits, (char*)src, size); speex_bits_read_from(&_speex_dec_bits, (char*)src, size);
speex_decode_int(_speex_dec_state, &_speex_dec_bits, dst); speex_decode_int(_speex_dec_state, &_speex_dec_bits, dst);
return _speex_frame_size * ratio; return _speex_frame_size * ratio;
} }
...@@ -98,7 +130,7 @@ public: ...@@ -98,7 +130,7 @@ public:
{ {
speex_bits_reset(&_speex_enc_bits); speex_bits_reset(&_speex_enc_bits);
speex_encoder_ctl(_speex_enc_state,SPEEX_SET_SAMPLING_RATE,&_clockRate); 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); speex_encode_int(_speex_enc_state, src, &_speex_enc_bits);
int nbBytes = speex_bits_write(&_speex_enc_bits, (char*)dst, size); int nbBytes = speex_bits_write(&_speex_enc_bits, (char*)dst, size);
return nbBytes; return nbBytes;
...@@ -111,6 +143,7 @@ private: ...@@ -111,6 +143,7 @@ private:
void *_speex_dec_state; void *_speex_dec_state;
void *_speex_enc_state; void *_speex_enc_state;
int _speex_frame_size; int _speex_frame_size;
SpeexPreprocessState *_preprocess_state;
}; };
// the class factories // the class factories
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
} }
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) { virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
// _debug("Decoded by ulaw");
int16* end = dst+size; int16* end = dst+size;
while(dst<end) while(dst<end)
*dst++ = ULawDecode(*src++); *dst++ = ULawDecode(*src++);
...@@ -43,6 +44,7 @@ public: ...@@ -43,6 +44,7 @@ public:
} }
virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) { virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) {
// _debug("Encoded by ulaw \n");
size >>= 1; size >>= 1;
uint8* end = dst+size; uint8* end = dst+size;
while(dst<end) while(dst<end)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment