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