'WebRTC lowest possible latency

I have a simple UDP streaming protocol that takes RAW H264 video frames and sends them instantly from server side to the client side.

Using this protocol I can get near network RTT latency (no packet resending and I don't care about packet loss), so if I have 20 ms latency from server to the client I can make a video frame to be ready from encoder output to the client side (ready to be decoded) in... let's say 30 ms.

My question is:

Is WebRTC (over UDP) capable of going down to this kind of latencies? Not taking into account encoding and decoding times, what is the lowest latency possible I can get with WebRTC for the protocol layer?

I don't know if this kind of latencies will require my own protocol to be more deeply developed or I may go to something more generic like WebRTC for my video server development in order to instantly be supported by every web browser.



Solution 1:[1]

WebRTC can have the same low latency as regular SIP/RTP stacks. WebRTC stack vendors does their best to reduce delay.

For recording and sending out there is no any delay. The stack will send the packets immediately once received from the recorder device and compressed with the selected codec. Some codec's (and some codec settings) might introduce some delay here to enable some features such as FEC.

Regarding the receiver side: In optimal circumstances the stack should not delay the playback of the packets, so they can be display as soon as they arrive. However in sub-optimal circumstances (with network delays or packet loss) the stack will introduce a jitter buffer. The lower is the network quality, the higher will be the jitter buffer length.

So, to achieve the lowest delay, you might have to do the followings:

  • choose a codec with the smallest processing time
  • remove FEC and disable any other settings which might cause additional delays
  • remove the jitter buffer (most WebRTC stacks doesn't have a setting for this so you might have to modify the code yourself, but it is an easy modification, because you just need to deactivate a part of the code)

Solution 2:[2]

WebRTC uses RTP as the underlying media transport which has only a small additional header at the beginning of the payload compared to plain UDP. This means it should be on par with what you achieve with plain UDP. RTP is heavily used in latency critical environments like real time audio and video (its the media transport in SIP, H.323, XMPP) and thus you can expect the latency to be sufficient for this purpose.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Istvan
Solution 2 Steffen Ullrich