Search code examples
network-programmingtcpudpstreamingwebrtc

How is the choice of UDP or TCP protocol specified in WebRTC


I understand that WebRTC supports TCP and UDP protocols. However, I don't see where in the API it can be specified which protocol to favor. Where does an app typically specify the choice of protocol to use?


Solution

  • When two RTC/P clients connect, they exchange a list of parameters by means of a session description, among them connection options as discovered by the ICE protocol. These have a priority attached and can be either UDP or TCP. Which options to offer and how to prioritize them, is up to the client implementation, i.e. the browser.

    Since it is up to a signalling layer controlled by the JavaScript application to transmit these ice candidates*, these priorities could be changed by the website developer. For example, one could filter TCP or UDP candidates received in onicecandidate, or use RegExp to modify the priority.

    * This answer applies to webRTC's trickle ICE. For interoperability with other RTC systems, one would need to offer all ice candidates in the SDP and as such modify the session description instead.