diff --git a/sflphone-common/src/audio/audiortp/AudioRtpRecordHandler.cpp b/sflphone-common/src/audio/audiortp/AudioRtpRecordHandler.cpp index 0d326bbc4d0353701d7b30db356dff17644ee0d7..ce88e94b2cfb1bd899a079cd7c8cbbf21ae5b081 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpRecordHandler.cpp +++ b/sflphone-common/src/audio/audiortp/AudioRtpRecordHandler.cpp @@ -260,7 +260,6 @@ int AudioRtpRecordHandler::processDataEncode (void) { SFLDataFormat *micData = _audioRtpRecord._micData; unsigned char *micDataEncoded = _audioRtpRecord._micDataEncoded; - //SFLDataFormat *micDataEchoCancelled = _audioRtpRecord._micDataEchoCancelled; SFLDataFormat *micDataConverted = _audioRtpRecord._micDataConverted; int codecFrameSize = getCodecFrameSize(); @@ -303,11 +302,9 @@ int AudioRtpRecordHandler::processDataEncode (void) _audioRtpRecord.audioProcessMutex.enter(); if (Manager::instance().audioPreference.getNoiseReduce()) { - // _audioRtpRecord._audioProcess->processAudio (micDataEchoCancelled, nbSample * sizeof (SFLDataFormat)); _audioRtpRecord._audioProcess->processAudio (micDataConverted, nbSample * sizeof (SFLDataFormat)); } - // echoCanceller.process(micDataConverted, micDataEchoCancelled, nbSample * sizeof(SFLDataFormat)); if(Manager::instance().getEchoCancelState() == "enabled") { echoCanceller.getData(micData); } @@ -317,7 +314,6 @@ int AudioRtpRecordHandler::processDataEncode (void) _audioRtpRecord.audioCodecMutex.enter(); compSize = _audioRtpRecord._audioCodec->encode (micDataEncoded, micData, nbSample * sizeof (SFLDataFormat)); - // compSize = _audioRtpRecord._audioCodec->encode (micDataEncoded, micDataConverted, nbSample * sizeof (SFLDataFormat)); _audioRtpRecord.audioCodecMutex.leave(); @@ -327,11 +323,8 @@ int AudioRtpRecordHandler::processDataEncode (void) if (Manager::instance().audioPreference.getNoiseReduce()) { _audioRtpRecord._audioProcess->processAudio (micData, nbSample * sizeof (SFLDataFormat)); - // _audioRtpRecord._audioProcess->processAudio (micDataEchoCancelled, nbSample * sizeof (SFLDataFormat)); } - // echoCanceller.process(micData, micDataEchoCancelled, nbSample * sizeof(SFLDataFormat)); - // echoCanceller.process(micData, micDataEchoCancelled, nbSample * sizeof(SFLDataFormat)); if(Manager::instance().getEchoCancelState() == "enabled") { echoCanceller.getData(micData); } @@ -346,7 +339,6 @@ int AudioRtpRecordHandler::processDataEncode (void) _audioRtpRecord.audioCodecMutex.enter(); // no resampling required - // compSize = _audioRtpRecord._audioCodec->encode (micDataEncoded, micData, nbSample * sizeof (SFLDataFormat)); compSize = _audioRtpRecord._audioCodec->encode (micDataEncoded, micData, nbSample * sizeof (SFLDataFormat)); _audioRtpRecord.audioCodecMutex.leave(); @@ -383,10 +375,8 @@ void AudioRtpRecordHandler::processDataDecode (unsigned char *spkrData, unsigned // test if resampling is required if (codecSampleRate != mainBufferSampleRate) { - // Do sample rate conversion - int nbSampleDown = nbSample; - nbSample = _audioRtpRecord._converter->upsampleData (spkrDataDecoded, spkrDataConverted, codecSampleRate, mainBufferSampleRate, nbSampleDown); + nbSample = _audioRtpRecord._converter->upsampleData (spkrDataDecoded, spkrDataConverted, codecSampleRate, mainBufferSampleRate, nbSample); if(Manager::instance().getEchoCancelState() == "enabled") { echoCanceller.putData(spkrDataConverted, nbSample * sizeof(SFLDataFormat)); @@ -407,22 +397,16 @@ void AudioRtpRecordHandler::processDataDecode (unsigned char *spkrData, unsigned bool AudioRtpRecordHandler::fadeIn (SFLDataFormat *audio, int size, SFLDataFormat *factor) { - // if factor reach 0, this function should no be called anymore if (*factor <= 0) return true; - // apply amplitude factor; - while (size) { - size--; - audio[size] /= *factor; - } + while (size) + audio[--size] /= *factor; - // decrease factor *factor /= FADEIN_STEP_SIZE; - return false; - + return *factor <= 0; } } diff --git a/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp index 416320eaa5b9e570ab6d1d5b536c0911d9933795..4712845ab15fa4ac335fc432e5602e7da04c5aa8 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp +++ b/sflphone-common/src/audio/audiortp/AudioRtpSession.cpp @@ -181,7 +181,6 @@ void AudioRtpSession::sendDtmfEvent (sfl::DtmfEvent *dtmf) dtmf->payload.duration++; - // next packet is going to be the last one if ( (dtmf->length - increment) < increment) dtmf->payload.ebit = true; @@ -195,26 +194,16 @@ void AudioRtpSession::sendDtmfEvent (sfl::DtmfEvent *dtmf) void AudioRtpSession::receiveSpeakerData () { - const ost::AppDataUnit* adu = NULL; - - int packetTimestamp = _queue->getFirstTimestamp(); - - adu = _queue->getData (packetTimestamp); - - if (!adu) { + const ost::AppDataUnit* adu = _queue->getData (_queue->getFirstTimestamp()); + if (!adu) return; - } - - unsigned char* spkrDataIn = NULL; - unsigned int size = 0; - spkrDataIn = (unsigned char*) adu->getData(); // data in char - size = adu->getSize(); // size in char + unsigned char* spkrDataIn = (unsigned char*) adu->getData(); // data in char + unsigned int size = adu->getSize(); // size in char // DTMF over RTP, size must be over 4 in order to process it as voice data - if (size > 4) { + if (size > 4) processDataDecode (spkrDataIn, size); - } delete adu; } @@ -324,7 +313,6 @@ void AudioRtpSession::stopRtpThread () bool AudioRtpSession::onRTPPacketRecv (ost::IncomingRTPPkt&) { receiveSpeakerData(); - return true; }