pjsip / pjproject

PJSIP project
http://www.pjsip.org
GNU General Public License v2.0
2k stars 767 forks source link

macOS rustle in audio #4032

Open ednt opened 1 month ago

ednt commented 1 month ago

Describe the bug

The RTP stream is clear without rustle (checked with wireshark) But there is loud rustle to hear.

To check that it is not our application, I checked the app opensource 'Telephone' which uses also PJSIP. Same loud rustle.

But the only thing we do is to tell PJSIP which audio devices should be used.

From where comes the rustle?

Steps to reproduce

Install 'Telephone' on your macOS and try different incomming calls.

PJSIP version

We use 2.14.1

Context

It happens on MacOS.

Log, call stack, etc

The logs are ok, since the call itself is Ok.
nanangizz commented 1 month ago

To reproduce audio quality issue, could you describe more, e.g: which codec you are using, whether it works fine with default/built-in audio device (if applicable), audio device settings (some audio device may have issues when opened using non-native clock rates, native is usually 48.1k or 44.1kHz & stereo).

ednt commented 4 weeks ago

The customer PBX uses only PCMA. But as written, the wireshark capture has a clear output, without rustle. In the meantime I told the customer to test 'Telefon' a freeware in the app store which uses also PJSIP. I hoped it is a bug from us, but the customer has the same rustle with 'Telefon'.

But if the customer uses linphone the sound is clear.

We also have volume problems. everything is very quiet. I think the rustle comes from a very high amplification of the sound.

The customer tested it with the inbuild microphone and loudspeaker and also with a headset.

nanangizz commented 4 weeks ago

Ok, generally here are the audio processing steps in receiving direction:

  1. packet reordering, latency monitor & control (by jitter buffer)
  2. audio payload decoding (by codec)
  3. audio playback (by sound device) Now let's try to pinpoint the issue. For simplicity, I will use pjsua sample app.

First, try to record the audio before played back to speaker, this can be done by connecting stream port to a WAV file recorder port (beside to sound-device/speaker port) in the conference bridge. Using pjsua sample app, you can use param --rec-file=[file-path] then connect ports using cc command or just add --auto-rec to automatically record audio calls. To enable only PCMA codec, you can use pjsua param --dis-codec * --add-codec pcma. Note that here the media uses sound device clock, so if the recorded audio is not clear, perhaps the clock is too skewed (so frame-generation/PLC or frame discard frequently occurs), try with null sound device by adding param --null-audio.

If audio is okay, the issue should not be introduced by processing step 1 & 2 above, so let's check whether the issue happens in the sound device. Let's try to disable AEC using pjsua param --ec-tail=0, note that some AEC also applies some additional audio processings such as AGC and denoiser. If the audio is still not clear, try using native sound device clock rate (you need to find out the sound device native clock rate by yourselves), for example, to use clock rate 48000Hz, add pjsua param --snd-clock-rate=48000. You may also try with --stereo to allow stereo mode (as mentioned before, some sound device may work better in its native mode which may involve stereo). You may also try add pjsua param --quality=4 to avoid using large resampling filter which uses a significantly higher CPU load (IMO small resampling filter quality is still very acceptable).