Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix increasing audio delay for WebRTC calls #30

Closed
hrosa opened this issue Aug 27, 2015 · 5 comments
Closed

Fix increasing audio delay for WebRTC calls #30

hrosa opened this issue Aug 27, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@hrosa
Copy link
Contributor

hrosa commented Aug 27, 2015

The latency level keeps increasing for WebRTC calls.

https://groups.google.com/forum/#!msg/mozilla.dev.media/tkxeLEnBK9M/_4TMgrCShtMJ

@hrosa hrosa added the bug label Aug 27, 2015
@hrosa hrosa self-assigned this Aug 27, 2015
@hrosa hrosa added this to the 3.0.3 milestone Aug 27, 2015
@ivelin
Copy link
Contributor

ivelin commented Aug 29, 2015

@hrosa Any useful findings from the webrtc diagnostics tools we discussed?

@hrosa
Copy link
Contributor Author

hrosa commented Sep 2, 2015

@ivelin https://github.com/webrtc/testrtc is our best candidate. I opened an issue to wire integrate it in Olympus so we can have a proper tool to measure call quality.

@hrosa
Copy link
Contributor Author

hrosa commented Sep 2, 2015

After disabling RTCP from Mobicents MS I noticed that the RTT kept increasing on Chrome.
This ruled out malformed RTCP from list of possible causes, so I turned my attention to STUN.

Looking at the Wireshark trace, I noticed how Mobicents MS takes increasingly more time to reply to the STUN requests. This matches the information on Chrome's log where the RTT is measured accordingly to the STUN pings.

@hrosa
Copy link
Contributor Author

hrosa commented Sep 3, 2015

I believe I know what is the problem with the audio delay in WebRTC calls.

So, Chrome sends two streams of packets over the same port at different rates: RTP each 20ms and STUN each 400ms.

The Media Server's Scheduler was designed on top of RTP 20ms golden rule, so from the logs I noticed that the UDP Manager invokes the receive() method each 20ms (this means we receive one packet each 20ms, either RTP or STUN).

Now let’s assume this example, representing a sample of the stream coming from chrome:
packet 1 - time=2.310, RTP
packet 2 - time=2.330, RTP
packet 3 - time=2.350, RTP
packet 4 - time=2.370, RTP
packet 5 - time=2.382, STUN
packet 6 - time=2.390, RTP

Notice how the interval between packets 4 and 5 is 12ms, and how interval between packets 5 and 6 is 8ms. This breaks the 20ms rule and that's how the congestion starts pilling up on the MS side.

Based in the last 3 packets we can make the following analysis: "in the interval of 40ms, Chrome sends 3 packets (2 RTP, 1 STUN). In the same interval, Mobicents MS only receives 2 (1 RTP, 1 STUN). So, we add 20ms latency because the 3rd packet will only be received after 20 ms."

...and so on until we end up with latency in the order of n seconds.

@hrosa
Copy link
Contributor Author

hrosa commented Sep 3, 2015

I will have to untie the UdpManager from the Scheduler, so that the UDP manager reads from the sockets continuously and not at a 20ms rate.

hrosa added a commit that referenced this issue Sep 3, 2015
…eduler to manage IO threads.

Optimized code of the MultiplexedChannel and ProtocolHandlerPipeline.

Performance tests show considerable number of failed calls and exceptions on Jitter Buffer. Next step is to make the JitterBuffer thread safe.
hrosa added a commit that referenced this issue Sep 3, 2015
…e condition between scheduler thread and the UDP manager thread.
hrosa added a commit that referenced this issue Sep 8, 2015
@hrosa hrosa closed this as completed Oct 5, 2015
hrosa pushed a commit that referenced this issue Feb 9, 2018
…ixes (pull request #30)

Fix for combined SPEECH+DTMF mode

Approved-by: Henrique Rosa <henrique.rosa@telestax.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants