Commit 0a606ed4 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

Fixing bug for recording when leaving a message for SIP (not IAX)

parent 35e4f0d6
......@@ -131,6 +131,7 @@ AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym) : time(new ost::Time()), _
_sessionRecv = NULL;
_sessionSend = NULL;
}
}
AudioRtpRTX::~AudioRtpRTX () {
......@@ -168,7 +169,7 @@ AudioRtpRTX::initBuffers()
{
converter = new SamplerateConverter( _layerSampleRate , _layerFrameSize );
int nbSamplesMax = (int) (_layerSampleRate * _layerFrameSize /1000);
nbSamplesMax = (int) (_layerSampleRate * _layerFrameSize /1000);
micData = new SFLDataFormat[nbSamplesMax];
micDataConverted = new SFLDataFormat[nbSamplesMax];
......@@ -314,12 +315,15 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
if (_ca == 0) { return; }
//try {
AudioLayer* audiolayer = Manager::instance().getAudioDriver();
if (!audiolayer) { return; }
const ost::AppDataUnit* adu = NULL;
// Get audio data stream
// printf("AudioRtpRTX::receiveSessionForSpkr() %i \n",_session->getFirstTimestamp());
if (!_sym) {
adu = _sessionRecv->getData(_sessionRecv->getFirstTimestamp());
} else {
......@@ -330,10 +334,14 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
return;
}
//int payload = adu->getType(); // codec type
unsigned char* spkrData = (unsigned char*)adu->getData(); // data in char
unsigned int size = adu->getSize(); // size in char
// printf("AudioRtpRTX::receiveSessionForSpkr() Size of data from %i \n",size);
// Decode data with relevant codec
unsigned int max = (unsigned int)(_codecSampleRate * _layerFrameSize / 1000);
......@@ -344,7 +352,6 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime)
}
if (_audiocodec != NULL) {
int expandedSize = _audiocodec->codecDecode( spkrDataDecoded , spkrData , size );
//buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes
......@@ -409,7 +416,7 @@ AudioRtpRTX::run () {
//encoding before sending
AudioLayer *audiolayer = Manager::instance().getAudioDriver();
_layerFrameSize = audiolayer->getFrameSize(); // en ms
_layerSampleRate = audiolayer->getSampleRate();
_layerSampleRate = audiolayer->getSampleRate();
initBuffers();
int step;
......@@ -435,6 +442,11 @@ AudioRtpRTX::run () {
_start.post();
_debug("- ARTP Action: Start\n");
while (!testCancel()) {
// printf("AudioRtpRTX::run() _session->getFirstTimestamp() %i \n",_session->getFirstTimestamp());
// printf("AudioRtpRTX::run() _session->isWaiting() %i \n",_session->isWaiting());
/////////////////////
////////////////////////////
// Send session
////////////////////////////
......@@ -446,7 +458,10 @@ AudioRtpRTX::run () {
receiveSessionForSpkr(countTime);
// Let's wait for the next transmit cycle
_ca->recAudio.recData(spkrDataConverted,micData,_nSamplesSpkr,_nSamplesMic);
if(_session->isWaiting())
_ca->recAudio.recData(spkrDataConverted,micData,_nSamplesSpkr,_nSamplesMic);
else
_ca->recAudio.recData(micData,_nSamplesMic);
Thread::sleep(TimerPort::getTimer());
TimerPort::incTimer(_layerFrameSize); // 'frameSize' ms
......
......@@ -128,7 +128,10 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort {
*/
int _nSamplesMic;
/**
* Maximum number of sample for audio buffers (mic and spkr)
*/
int nbSamplesMax;
/**
* Init the RTP session. Create either symmetric or double sessions to manage data transport
......
......@@ -89,7 +89,7 @@ IAXVoIPLink::init()
return false;
bool returnValue = false;
//_localAddress = "127.0.0.1";
// _localAddress = "127.0.0.1";
// port 0 is default
// iax_enable_debug(); have to enable debug when compiling iax...
int port = IAX_DEFAULT_PORTNO;
......@@ -207,6 +207,8 @@ IAXVoIPLink::getEvent()
iaxHandlePrecallEvent(event);
}
// _debug("IAXVoIPLink::getEvent() : timestamp %i \n",event->ts);
iax_event_free(event);
}
_mutexIAX.leaveMutex();
......@@ -218,6 +220,7 @@ IAXVoIPLink::getEvent()
if (_nextRefreshStamp && _nextRefreshStamp - 2 < time(NULL)) {
sendRegister("");
}
if(call){
call->recAudio.recData(spkrDataConverted,micData,nbSampleForRec_,nbSampleForRec_);
}
......
......@@ -434,7 +434,7 @@ void AudioRecord::recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int
if ( sndFormat_ == INT16 ) { // TODO change INT16 to SINT16
for (int k=0; k<nSamples_1; k++){
mixBuffer_[k] = (buffer_1[k]+buffer_2[k])/2;
mixBuffer_[k] = (buffer_1[k]+buffer_2[k]);
// dsp.getRMS(mixBuffer_[k]);
......
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