Commit 99ad1605 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 f1ee2b68 2b1f654d
......@@ -24,6 +24,7 @@
#include <speex/speex_preprocess.h>
class Speex : public AudioCodec{
public:
Speex(int payload=0)
......@@ -47,21 +48,10 @@ public:
Speex& operator=(const Speex&);
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;
int enable = 1;
int quality = 10;
int complex = 10;
int attenuation = -10;
/*
if (_clockRate < 16000 ) {
......@@ -83,20 +73,20 @@ public:
// 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);
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_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);
}
......
......@@ -41,7 +41,7 @@ Call::Call(const CallID& id, Call::CallType type)
FILE_TYPE fileType = FILE_WAV;
SOUND_FORMAT soundFormat = INT16;
recAudio.setRecordingOption(fileType,soundFormat,44100, Manager::instance().getConfigString (AUDIO, RECORD_PATH));
recAudio.setRecordingOption(fileType,soundFormat,44100, Manager::instance().getConfigString (AUDIO, RECORD_PATH),id);
_debug("CALL::Constructor for this clss is called \n");
}
......
......@@ -54,32 +54,35 @@ void AudioRecord::setSndSamplingRate(int smplRate){
sndSmplRate_ = smplRate;
}
void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path){
void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path, std::string id){
std::string fName;
fileType_ = type;
std::string fName;
fileType_ = type;
sndFormat_ = format;
channels_ = 1;
sndSmplRate_ = sndSmplRate;
call_id_ = id;
fName = fileName_;
fName.append("-"+call_id_);
if (fileType_ == FILE_RAW){
if ( strstr(fileName_, ".raw") == NULL){
printf("AudioRecord::openFile::concatenate .raw file extension: name : %s \n", fileName_);
strcat(fileName_, ".raw");
fName.append(".raw");
}
}
else if (fileType_ == FILE_WAV){
if ( strstr(fileName_, ".wav") == NULL){
printf("AudioRecord::openFile::concatenate .wav file extension: name : %s \n", fileName_);
strcat(fileName_, ".wav");
fName.append(".wav");
}
}
fName = fileName_;
savePath_ = path + "/";
savePath_.append(fName);
}
void AudioRecord::openFile(){
......@@ -122,6 +125,8 @@ void AudioRecord::closeFile() {
else if (fileType_ == FILE_WAV)
this->closeWavFile();
}
......@@ -331,7 +336,7 @@ void AudioRecord::closeWavFile()
_debug("AudioRecord:: Can't closeWavFile, a file has not yet been opened!\n");
return;
}
/*
_debug("AudioRecord::closeWavFile() \n");
if ( fclose( fp ) != 0)
......@@ -344,7 +349,7 @@ void AudioRecord::closeWavFile()
_debug("AudioRecord::closeWavFile() : could not open WAV file rb+!\n");
return;
}
*/
SINT32 bytes = byteCounter_ * channels_;
fseek(fp, 40, SEEK_SET); // jump to data length
......
......@@ -43,7 +43,7 @@ public:
void setSndSamplingRate(int smplRate);
void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path);
void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path, std::string id);
/**
* Check if no otehr file is opened, then create a new one
......@@ -186,6 +186,7 @@ protected:
*/
std::string savePath_;
std::string call_id_;
/**
* AudioDSP test (compute RMS value)
......
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