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
......@@ -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:
......
......@@ -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
......
......@@ -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)
......
......@@ -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;
......
......@@ -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
......
......@@ -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++);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment