Commit d4822091 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

AudioRtpRecordHandler / AudioRtpSession : simplify

parent 43b3961c
......@@ -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;
}
}
......
......@@ -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;
}
......
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