diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index 785078c0c8c18eafe02286f71da6689dbb2c73c7..8e4a1ef17168dfd05e4c941fcd420c7533e7e347 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -100,10 +100,9 @@ AudioRtp::closeRtpSession () { void AudioRtp::setRecording() { - _debug("AudioRtp::setRecording"); - // _RTXThread->recAudio.setRecording(); + _debug("AudioRtp::setRecording\n"); _RTXThread->_ca->setRecording(); - + } @@ -192,24 +191,6 @@ AudioRtpRTX::initAudioRtpSession (void) return; } - // Initialization - printf("AudioRTPX::initAudioRtpSession: CallID to be used: %s \n",_ca->getCallId().c_str()); - - printf("AudioRTPX::initAudioRtpSession: Account %s \n",Manager::instance().getAccountFromCall(_ca->getCallId()).c_str()); - - printf("AudioRTPX::initAudioSRtpSession: FileName from call class: %s \n", _ca->getFileName().c_str()); - - - _debug("Opening the wave file\n"); - FILE_TYPE ft = FILE_WAV; - SOUND_FORMAT sf = INT16; - recAudio.setSndSamplingRate(44100); - recAudio.openFile(_ca->getFileName(),ft,sf); - - //_debug("Opening the wave file in call nstance\n"); - //_ca->recAudio.setSndSamplingRate(44100); - //_ca->recAudio.openFile("testRecFromCall",ft,sf,_ca->getCallId()); - if (!_sym) { _sessionRecv->setSchedulingTimeout (10000); @@ -463,40 +444,23 @@ AudioRtpRTX::run () { receiveSessionForSpkr(countTime); // Let's wait for the next transmit cycle - recAudio.recData(spkrDataConverted,micData,_nSamplesSpkr,_nSamplesMic); _ca->recAudio.recData(spkrDataConverted,micData,_nSamplesSpkr,_nSamplesMic); Thread::sleep(TimerPort::getTimer()); TimerPort::incTimer(_layerFrameSize); // 'frameSize' ms } - _debug("Close wave file\n"); - recAudio.closeFile(); - - //_debug("Close wave file in call instance\n"); - //_ca->recAudio.closeFile(); - // _debug("stop stream for audiortp loop\n"); audiolayer->stopStream(); } catch(std::exception &e) { _start.post(); _debug("! ARTP: Stop %s\n", e.what()); - _debug("! Close wave file\n"); - recAudio.closeFile(); - - //_debug("Close wave file in call instance\n"); - //_ca->recAudio.closeFile(); throw; } catch(...) { _start.post(); _debugException("* ARTP Action: Stop"); - _debug("* Close wave file\n"); - recAudio.closeFile(); - - //_debug("Close wave file in call instance\n"); - //_ca->recAudio.closeFile(); throw; } diff --git a/src/audio/audiortp.h b/src/audio/audiortp.h index 89b0f257905823cb8954e20c8f7c92c862fa9f60..fe75441c0ee6ad36a84f77a103707e5daf2c8064 100644 --- a/src/audio/audiortp.h +++ b/src/audio/audiortp.h @@ -112,7 +112,7 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort { /** Variables to process audio stream: sample rate for playing sound (typically 44100HZ) */ int _layerSampleRate; - /** Sample rate of the codec we use to encode and decode (most of time 8000HZ) */ + /** Sample rate of te codec we use to encode and decode (most of time 8000HZ) */ int _codecSampleRate; /** Length of the sound frame we capture in ms(typically 20ms) */ diff --git a/src/call.cpp b/src/call.cpp index 3e0074532594260036b28a3748f5ee7dde0b2f65..a0a9942acd28c52c964fef30486d101cfb9853ed 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -51,24 +51,31 @@ Call::Call(const CallID& id, Call::CallType type) if (timeinfo->tm_mday < 10) // 01 02 03, not 1 2 3 out << 0; out << timeinfo->tm_mday; - - _filename = out.str(); - - printf("Call::constructor filename for tis call %s \n",_filename.c_str()); + if (timeinfo->tm_hour < 10) // 01 02 03, not 1 2 3 + out << 0; + out << timeinfo->tm_hour; + if (timeinfo->tm_min < 10) // 01 02 03, not 1 2 3 + out << 0; + out << timeinfo->tm_min; + if (timeinfo->tm_sec < 10) // 01 02 03, not 1 2 3 + out << 0; + out << timeinfo->tm_sec; + _filename = out.str(); + printf("Call::constructor filename for this call %s \n",_filename.c_str()); + + FILE_TYPE fileType = FILE_WAV; + SOUND_FORMAT soundFormat = INT16; + recAudio.setRecordingOption(_filename.c_str(),fileType,soundFormat,44100); - FILE_TYPE ft = FILE_WAV; - SOUND_FORMAT sf = INT16; - _debug("CALL::Opening the wave file in call nstance\n"); - recAudio.setSndSamplingRate(44100); - recAudio.openFile("testRecFromCall",ft,sf); + _debug("CALL::Constructor for this clss is called \n"); } Call::~Call() { - _debug("CALL::Close wave file in call instance\n"); + _debug("CALL::Destructor for this clss is called \n"); recAudio.closeFile(); } diff --git a/src/call.h b/src/call.h index e14e01712e664fc2e388ffdb1d24ba914f25c655..4fa6744383b5ae85440c95eeda1e05e4627ab1a4 100644 --- a/src/call.h +++ b/src/call.h @@ -216,7 +216,7 @@ class Call{ std::string getFileName() {return _filename;} /** - * A recorder fro this call + * A recorder for this call */ AudioRecord recAudio; @@ -275,6 +275,7 @@ class Call{ private: + /** Unique ID of the call */ CallID _id; diff --git a/src/plug-in/audiorecorder/audiorecord.cpp b/src/plug-in/audiorecorder/audiorecord.cpp index e05f3af1a1784c42994c338da2813a54f9c82b99..dab527f0eab710a407a6f1190e039b26a98d6794 100644 --- a/src/plug-in/audiorecorder/audiorecord.cpp +++ b/src/plug-in/audiorecorder/audiorecord.cpp @@ -27,6 +27,7 @@ AudioRecord::AudioRecord(){ channels_ = 1; byteCounter_ = 0; recordingEnabled_ = false; + fp = 0; } @@ -35,17 +36,16 @@ void AudioRecord::setSndSamplingRate(int smplRate){ sndSmplRate_ = smplRate; } +void AudioRecord::setRecordingOption(std::string name, FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate){ -void AudioRecord::openFile(std::string name, FILE_TYPE type, SOUND_FORMAT format){ - - _debug("AudioRecord::openFile()\n"); - - bool result = false; - - strncpy(fileName_, name.c_str(), 8192); - fileType_ = type; + strncpy(fileName_, name.c_str(), 8192); + + fileType_ = type; + sndFormat_ = format; + channels_ = 1; + sndSmplRate_ = sndSmplRate; - if (fileType_ == FILE_RAW){ + if (fileType_ == FILE_RAW){ if ( strstr(fileName_, ".raw") == NULL){ printf("AudioRecord::openFile::concatenate .raw file extension: name : %s \n", fileName_); strcat(fileName_, ".raw"); @@ -57,31 +57,34 @@ void AudioRecord::openFile(std::string name, FILE_TYPE type, SOUND_FORMAT format strcat(fileName_, ".wav"); } } +} + +void AudioRecord::openFile(){ + + _debug("AudioRecord::openFile()\n"); + + bool result = false; if(isFileExist()) { - _debug("AudioRecord::Filename does not exist, creating one \n"); - channels_ = 1; - byteCounter_ = 0; - sndFormat_ = format; + _debug("AudioRecord::Filename does not exist, creating one \n"); + byteCounter_ = 0; - if(fileType_ == FILE_RAW){ - result = setRawFile(); - } - else if (fileType_ == FILE_WAV){ - result = setWavFile(); - } - } - else { - fileType_ = type; - _debug("AudioRecord::Filename already exist opening it \n"); - if(fileType_ == FILE_RAW){ - result = openExistingRawFile(); - } - else if (fileType_ == FILE_WAV){ - result = openExistingWavFile(); - } - } - + if(fileType_ == FILE_RAW){ + result = setRawFile(); + } + else if (fileType_ == FILE_WAV){ + result = setWavFile(); + } + } + else { + _debug("AudioRecord::Filename already exist opening it \n"); + if(fileType_ == FILE_RAW){ + result = openExistingRawFile(); + } + else if (fileType_ == FILE_WAV){ + result = openExistingWavFile(); + } + } } @@ -99,10 +102,14 @@ void AudioRecord::closeFile() { bool AudioRecord::isOpenFile() { - if(fp) + if(fp){ + _debug("AudioRecord::isOpenFile(): file already openend\n"); return true; - else + } + else { + _debug("AudioRecord::isOpenFIle(): file not openend \n"); return false; + } } @@ -118,12 +125,21 @@ bool AudioRecord::isFileExist() { bool AudioRecord::setRecording() { - _debug("AudioRecord::setRecording()"); + _debug("AudioRecord::setRecording()\n"); - if(!recordingEnabled_) - recordingEnabled_ = true; - else - recordingEnabled_ = false; + if (isOpenFile()){ + _debug("AuioRecord::setRecording()::file already opened\n"); + if(!recordingEnabled_) + recordingEnabled_ = true; + else + recordingEnabled_ = false; + } + else { + _debug("AudioRecord::setRecording():Opening the wave file in call during call instantiation\n"); + openFile(); + + recordingEnabled_ = true; // once opend file, start recording + } } diff --git a/src/plug-in/audiorecorder/audiorecord.h b/src/plug-in/audiorecorder/audiorecord.h index a15e8a1c78093893ed7e812e86e28ac416db36bf..45a3875bef42c3f024a0ef33abeb3ed662e485cd 100644 --- a/src/plug-in/audiorecorder/audiorecord.h +++ b/src/plug-in/audiorecorder/audiorecord.h @@ -55,13 +55,15 @@ public: void setSndSamplingRate(int smplRate); + void setRecordingOption(std::string name, FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate); + /** * Check if no otehr file is opened, then create a new one * @param fileName A string containing teh file (with/without extension) * @param type The sound file format (FILE_RAW, FILE_WAVE) * @param format Internal sound format (INT16 / INT32) */ - void openFile(std::string fileName, FILE_TYPE type, SOUND_FORMAT format); + void openFile(); /** * Close the opend recording file. If wave: cout the number of byte diff --git a/src/sipcall.cpp b/src/sipcall.cpp index 0e53bdd013d066744d80db93204ffbf14a46549f..f67369240868495d2376c0ed8ddf69bc287c4d75 100644 --- a/src/sipcall.cpp +++ b/src/sipcall.cpp @@ -39,10 +39,13 @@ SIPCall::SIPCall(const CallID& id, Call::CallType type) : Call(id, type) , _xferSub(NULL) , _invSession(NULL) { + _debug("SIPCALL::Constructor for this clss is called \n"); } SIPCall::~SIPCall() { + + _debug("SIPCALL::Destructor for this clss is called \n"); } diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index facd029e9c5dc579cdd0b87f126fa1f685516ed7..c20a68b838813577c967ec63f9639c260e94b369 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -88,6 +88,7 @@ SIPVoIPLink::terminateSIPCall() call = dynamic_cast<SIPCall*>(iter->second); if (call) { //TODO terminate the sip call + _debug("SIPVOIP::the call is deleted, should close recording file \n"); delete call; call = 0; } iter++; @@ -348,9 +349,7 @@ SIPVoIPLink::refuse (const CallID& id) void SIPVoIPLink::setRecording(const CallID& id) { - // _debug("SIPVoIPLink::setRecording!"); - // printf("SIPVoIPLink:: CallID: %s", id); - + _audiortp->setRecording(); }