Search code examples
androidwebrtcvoipopus

webrtc android video call sound has screeching sound and echos


I am trying to implement VideoCall feature using this repo as base. I got everything working but now the issue is the audio is very poor and it has screeching sound and echo. Audio is barely audible. I am using proper constraints when creating audio source in both callee/caller. Here is how I create audio source-

    MediaConstraints audioConstraints = new MediaConstraints();
    audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googNoiseSuppression", "true"));
    audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googEchoCancellation", "true"));
    audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("echoCancellation", "true"));
    audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("noiseSuppression", "true"));
    AudioSource audioSource = peerConnectionFactory.createAudioSource(audioConstraints);
    localAudioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);

Please help me get this working.


Solution

  • The problem was when enabling remote audio track I had these lines set

    AudioTrack audioTrack = mediaStream.audioTracks.get(0);
    audioTrack.setEnabled(true);
    audioTrack.setVolume(100); // culprit
    

    The last line where I set volume to 100 was the issue. Removing it did the trick.