Multiparty sound in WebRTC on iOS / Android is distorted

I’m trying to figure out which is the best way to do the following: having peer-to-peer communication between parties A and B, I want to add a third-party C, but the difficulty is that I do not want a complete mesh, B should only communicate with C through A (setting MCU, where A is the MCU).

B <-> A <-> C 

What I tried so far is this: when peerConnectionAC is created and the didAddStream callback is called, I add peerConnectionAB.remoteStream as a local stream to peerConnectionAC, for example:

 peerConnectionAC.addStream(remoteStreamAB) 

Then I do it the other way around:

 peerConnectionAB.addStream(remoteStreamAC) 

At this point, WebRTC starts the re-registration callback, so a new offer is generated and sent to the relevant parties.

Audio now flows between B and C through A, but it is terribly distorted, almost incomprehensible. The sound flowing from the microphone to B and C remains clear.

Both peers use the same codec (OPUS, but also with iLBC) and with the same sampling rate.

The only link I found for this is a question more than six months ago , but without a clear answer.

It seems to be easy to do in the browser settings , but I need it to work on iOS / Android as a standalone application.

Can someone give me an idea or a pointer on how to fix a distorted sound?

+5
source share

Source: https://habr.com/ru/post/1269165/


All Articles