Skip to content
Snippets Groups Projects
Commit b4390a3f authored by asavard's avatar asavard
Browse files

[#4367] Refactor mic data encoding in rtp session

parent 00fc6a21
Branches
Tags
No related merge requests found
......@@ -405,26 +405,19 @@ int AudioRtpRecordHandler::processDataEncode(void)
float fixedCodecFramesize = computeCodecFrameSize(getCodecFrameSize(), getCodecSampleRate());
// compute nb of byte to get coresponding to 20 ms at audio layer frame size (44.1 khz)
int maxBytesToGet = computeNbByteAudioLayer(fixedCodecFramesize);
int bytesToGet = computeNbByteAudioLayer(fixedCodecFramesize);
_debug(" byte to get %d", bytesToGet);
// available bytes inside ringbuffer
int availBytesFromMic = audioLayer->getMainBuffer()->availForGet(_ca->getCallId());
_debug(" avail byte from mic %d", availBytesFromMic);
if(!(availBytesFromMic > 320))
if(availBytesFromMic < bytesToGet)
return 0;
// set available byte to maxByteToGet
int bytesAvail = (availBytesFromMic < maxBytesToGet) ? availBytesFromMic : maxBytesToGet;
if(bytesAvail == 0){
memset(micDataEncoded, 0, sizeof (SFLDataFormat));
return getCodecFrameSize();
}
// Get bytes from micRingBuffer to data_from_mic
// int nbSample = audioLayer->getMainBuffer()->getData(micData, bytesAvail, 100, _ca->getCallId()) / sizeof (SFLDataFormat);
int nbSample = audioLayer->getMainBuffer()->getData(micData, 320, 100, _ca->getCallId()) / sizeof (SFLDataFormat);
int nbSample = audioLayer->getMainBuffer()->getData(micData, bytesToGet, 100, _ca->getCallId()) / sizeof (SFLDataFormat);
// process mic fade in
if(!_audioRtpRecord.getMicFadeInComplete())
......@@ -453,6 +446,7 @@ int AudioRtpRecordHandler::processDataEncode(void)
// no resampling required
compSize = audioCodec->codecEncode(micDataEncoded, micData, nbSample * sizeof (SFLDataFormat));
}
return compSize;
}
......
......@@ -235,7 +235,7 @@ bool AudioRtpSession::onRTPPacketRecv (ost::IncomingRTPPkt&)
void AudioRtpSession::sendMicData()
{
// _debug("============== sendMicData ===============");
_debug("============== sendMicData ===============");
int compSize = processDataEncode();
......@@ -246,8 +246,8 @@ void AudioRtpSession::sendMicData()
// Increment timestamp for outgoing packet
_timestamp += _timestampIncrement;
// _debug(" compSize: %d", compSize);
// _debug(" timestamp: %d", _timestamp);
_debug(" compSize: %d", compSize);
_debug(" timestamp: %d", _timestamp);
// putData put the data on RTP queue, sendImmediate bypass this queue
putData (_timestamp, getMicDataEncoded(), compSize);
......@@ -357,10 +357,7 @@ void AudioRtpSession::run ()
sendMicData ();
}
// Recv session
// TODO should not be called here anymore
// receiveSpeakerData ();
// This also should be moved
notifyIncomingCall();
_manager->getAudioLayerMutex()->leave();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment