Skip to content
Snippets Groups Projects
Commit 09bc72d7 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3691] Resync buffer during a conference

parent ac6cad2e
Branches
Tags
No related merge requests found
......@@ -405,6 +405,8 @@ int MainBuffer::getData (void *buffer, int toCopy, unsigned short volume, CallID
while (iter_id != callid_set->end()) {
memset(mixBuffer, 0, toCopy);
size = getDataByID(mixBuffer, toCopy, volume, (CallID) (*iter_id), call_id);
if (size > 0) {
......@@ -462,6 +464,8 @@ int MainBuffer::availForGet (CallID call_id)
int nb_bytes;
CallIDSet::iterator iter_id = callid_set->begin();
syncBuffers(call_id);
for (iter_id = callid_set->begin(); iter_id != callid_set->end(); iter_id++) {
nb_bytes = availForGetByID (*iter_id, call_id);
......@@ -522,7 +526,6 @@ int MainBuffer::discard (int toDiscard, CallID call_id)
return toDiscard;
}
}
......@@ -599,6 +602,45 @@ void MainBuffer::flushAllBuffers()
}
}
void MainBuffer:: syncBuffers(CallID call_id)
{
CallIDSet* callid_set = getCallIDSet(call_id);
if (callid_set == NULL)
return;
if (callid_set->empty()) {
_debug ("MainBuffer: CallIDSet with ID: \"%s\" is empty!", call_id.c_str());
return;
}
if (callid_set->size() == 1) {
// no need to resync, only one session
return;
}
int nbBuffers = 0;
float mean_nbBytes = 0.0;
CallIDSet::iterator iter_id = callid_set->begin();
// compute mean nb byte in buffers
for (iter_id = callid_set->begin(); iter_id != callid_set->end(); iter_id++) {
nbBuffers++;
mean_nbBytes += availForGetByID (*iter_id, call_id);
}
mean_nbBytes = mean_nbBytes / (float) nbBuffers;
// resync buffers in this conference according to the computed mean
for (iter_id = callid_set->begin(); iter_id != callid_set->end(); iter_id++) {
if(availForGetByID (*iter_id, call_id) > (mean_nbBytes + 640))
discardByID (640, *iter_id, call_id);
}
}
void MainBuffer::stateInfo()
{
......@@ -665,7 +707,4 @@ void MainBuffer::stateInfo()
iter_buffer++;
}
}
......@@ -115,6 +115,8 @@ class MainBuffer {
void flushDefault();
void syncBuffers(CallID call_id);
void stateInfo();
private:
......
......@@ -260,6 +260,8 @@ PulseLayer::PulseLayer (ManagerImpl* manager)
AudioLayer::_echocancelstate = true;
AudioLayer::_noisesuppressstate = true;
byteCounter = 0;
/*
captureFile = new ofstream("captureFile", ofstream::binary);
captureRsmplFile = new ofstream("captureRsmplFile", ofstream::binary);
......@@ -902,8 +904,9 @@ void PulseLayer::writeToSpeaker (void)
}
// Copy far-end signal in echo canceller to adapt filter coefficient
AudioLayer::_echoCanceller->putData(out, byteToGet);
// AudioLayer::_echoCanceller->putData(out, byteToGet);
pa_xfree (out);
......@@ -971,11 +974,12 @@ void PulseLayer::readFromMic (void)
// captureFilterFile->write ((const char *)rsmpl_out, nbSample*sizeof(SFLDataFormat));
// echo cancellation processing
int sampleready = _echoCanceller->processAudio(rsmpl_out, echoCancelledMic, nbSample*sizeof(SFLDataFormat));
// int sampleready = _echoCanceller->processAudio(rsmpl_out, echoCancelledMic, nbSample*sizeof(SFLDataFormat));
// getMainBuffer()->putData ( (void*) rsmpl_out, nbSample*sizeof (SFLDataFormat), 100);
if(sampleready)
getMainBuffer()->putData ( echoCancelledMic, sampleready*sizeof (SFLDataFormat), 100);
// if(sampleready)
// getMainBuffer()->putData ( echoCancelledMic, sampleready*sizeof (SFLDataFormat), 100);
getMainBuffer()->putData ( rsmpl_out, nbSample*sizeof (SFLDataFormat), 100);
pa_xfree (rsmpl_out);
......@@ -987,10 +991,11 @@ void PulseLayer::readFromMic (void)
_audiofilter->processAudio((SFLDataFormat *)data, filter_out, r);
// echo cancellation processing
int sampleready = _echoCanceller->processAudio((SFLDataFormat *)filter_out, echoCancelledMic, r);
// int sampleready = _echoCanceller->processAudio((SFLDataFormat *)filter_out, echoCancelledMic, r);
// no resampling required
getMainBuffer()->putData (echoCancelledMic, sampleready*sizeof (SFLDataFormat), 100);
// getMainBuffer()->putData (echoCancelledMic, sampleready*sizeof (SFLDataFormat), 100);
getMainBuffer()->putData (filter_out, r, 100);
pa_xfree(filter_out);
}
......
......@@ -287,6 +287,8 @@ class PulseLayer : public AudioLayer {
// private:
int byteCounter;
public:
friend class AudioLayerTest;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment