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

Merge branch 'recording'

parents 0cf26d56 99ad1605
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <speex/speex_preprocess.h> #include <speex/speex_preprocess.h>
class Speex : public AudioCodec{ class Speex : public AudioCodec{
public: public:
Speex(int payload=0) Speex(int payload=0)
...@@ -47,21 +48,10 @@ public: ...@@ -47,21 +48,10 @@ public:
Speex& operator=(const Speex&); Speex& operator=(const Speex&);
void initSpeex() { void initSpeex() {
int temp = 1; int enable = 1;
int temp10 = 10; int quality = 10;
int db = -10; int complex = 10;
int attenuation = -10;
int *enable;
enable = &temp;
int *quality;
quality = &temp10;
int *complex;
complex = &temp10;
int *attenuation;
attenuation = &db;
/* /*
if (_clockRate < 16000 ) { if (_clockRate < 16000 ) {
...@@ -83,20 +73,20 @@ public: ...@@ -83,20 +73,20 @@ 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_VAD, &enable);
speex_encoder_ctl(_speex_enc_state, SPEEX_SET_DTX, 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_VBR_QUALITY, &quality);
speex_encoder_ctl(_speex_enc_state, SPEEX_SET_COMPLEXITY, complex); speex_encoder_ctl(_speex_enc_state, SPEEX_SET_COMPLEXITY, &complex);
// Init the decoder struct // 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 // Init the preprocess struct
_preprocess_state = speex_preprocess_state_init(_speex_frame_size,_clockRate); _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_DENOISE, &enable);
speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, attenuation); 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_VAD, &enable);
speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_AGC, enable); speex_preprocess_ctl(_preprocess_state, SPEEX_PREPROCESS_SET_AGC, &enable);
} }
......
...@@ -41,7 +41,7 @@ Call::Call(const CallID& id, Call::CallType type) ...@@ -41,7 +41,7 @@ Call::Call(const CallID& id, Call::CallType type)
FILE_TYPE fileType = FILE_WAV; FILE_TYPE fileType = FILE_WAV;
SOUND_FORMAT soundFormat = INT16; 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"); _debug("CALL::Constructor for this clss is called \n");
} }
......
...@@ -54,7 +54,7 @@ void AudioRecord::setSndSamplingRate(int smplRate){ ...@@ -54,7 +54,7 @@ void AudioRecord::setSndSamplingRate(int smplRate){
sndSmplRate_ = 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; std::string fName;
...@@ -62,24 +62,27 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn ...@@ -62,24 +62,27 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn
sndFormat_ = format; sndFormat_ = format;
channels_ = 1; channels_ = 1;
sndSmplRate_ = sndSmplRate; sndSmplRate_ = sndSmplRate;
call_id_ = id;
fName = fileName_;
fName.append("-"+call_id_);
if (fileType_ == FILE_RAW){ if (fileType_ == FILE_RAW){
if ( strstr(fileName_, ".raw") == NULL){ if ( strstr(fileName_, ".raw") == NULL){
printf("AudioRecord::openFile::concatenate .raw file extension: name : %s \n", fileName_); printf("AudioRecord::openFile::concatenate .raw file extension: name : %s \n", fileName_);
strcat(fileName_, ".raw"); fName.append(".raw");
} }
} }
else if (fileType_ == FILE_WAV){ else if (fileType_ == FILE_WAV){
if ( strstr(fileName_, ".wav") == NULL){ if ( strstr(fileName_, ".wav") == NULL){
printf("AudioRecord::openFile::concatenate .wav file extension: name : %s \n", fileName_); printf("AudioRecord::openFile::concatenate .wav file extension: name : %s \n", fileName_);
strcat(fileName_, ".wav"); fName.append(".wav");
} }
} }
fName = fileName_;
savePath_ = path + "/"; savePath_ = path + "/";
savePath_.append(fName); savePath_.append(fName);
} }
void AudioRecord::openFile(){ void AudioRecord::openFile(){
...@@ -122,6 +125,8 @@ void AudioRecord::closeFile() { ...@@ -122,6 +125,8 @@ void AudioRecord::closeFile() {
else if (fileType_ == FILE_WAV) else if (fileType_ == FILE_WAV)
this->closeWavFile(); this->closeWavFile();
} }
...@@ -331,7 +336,7 @@ void AudioRecord::closeWavFile() ...@@ -331,7 +336,7 @@ void AudioRecord::closeWavFile()
_debug("AudioRecord:: Can't closeWavFile, a file has not yet been opened!\n"); _debug("AudioRecord:: Can't closeWavFile, a file has not yet been opened!\n");
return; return;
} }
/*
_debug("AudioRecord::closeWavFile() \n"); _debug("AudioRecord::closeWavFile() \n");
if ( fclose( fp ) != 0) if ( fclose( fp ) != 0)
...@@ -344,7 +349,7 @@ void AudioRecord::closeWavFile() ...@@ -344,7 +349,7 @@ void AudioRecord::closeWavFile()
_debug("AudioRecord::closeWavFile() : could not open WAV file rb+!\n"); _debug("AudioRecord::closeWavFile() : could not open WAV file rb+!\n");
return; return;
} }
*/
SINT32 bytes = byteCounter_ * channels_; SINT32 bytes = byteCounter_ * channels_;
fseek(fp, 40, SEEK_SET); // jump to data length fseek(fp, 40, SEEK_SET); // jump to data length
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
void setSndSamplingRate(int smplRate); 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 * Check if no otehr file is opened, then create a new one
...@@ -186,6 +186,7 @@ protected: ...@@ -186,6 +186,7 @@ protected:
*/ */
std::string savePath_; std::string savePath_;
std::string call_id_;
/** /**
* AudioDSP test (compute RMS value) * AudioDSP test (compute RMS value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment