WebRTC RTP Usage

HOME © Muaz Khan . @WebRTCWeb . Github . Latest issues . What's New?

This tutorial is out-dated (written in 2013). WebRTC implementation is heavily changed since then. So please do NOT refer or rely on this page.

Note: Chrome usually bundles & multiplexes media ports over single UDP port. Below all scenarios are for non-bundled media connections.

Simple Scenario: One-to-One audio/video sharing

In this scenario; maximum 4 RTP ports are opened for each peer:

  1. One RTP port for outgoing video
  2. One RTP port for outgoing audio
  3. One RTP port for incoming video
  4. One RTP port for incoming audio

Each RTP port is using 1 MB bandwidth. It means that 4 MB bandwidth is acquired by each peer.

Remember, you can use 'b=AS' to increase/decrease bandwidth usage for each stream; which will be divided according to number of RTP ports for each stream.

One-Way audio/video sharing Scenario

There are two kinds of users in this scenario:

  1. Broadcaster or Session-initiator
  2. Participant or Roommate

Broadcaster in One-Way Scenario

2 RTP ports are opened for broadcasting peer:

  1. One RTP port for outgoing video
  2. One RTP port for outgoing audio

There is no incoming RTP ports.

2 MB audio/video bandwidth is required and used by the broadcasting peer. Because there are two outgoing RTP ports.

Participant in One-Way Scenario

2 RTP ports are opened for participating peer:

  1. One RTP port for incoming video
  2. One RTP port for incoming audio

There is no outgoing RTP ports.

2 MB audio/video bandwidth is required and used by the participating peer. Because there are two incoming RTP ports.

Video-Conferencing i.e. Many-to-Many Scenario

In this scenario; number of RTP ports depends upon number of peer connections multiplied by 4.

10-users video-conferencing

40 RTP ports are opened for each user; i.e. 40 MB bandwidth is used by each user.

  1. 10 RTP port for outgoing video / 10 MB bandwidth usage
  2. 10 RTP port for outgoing audio / 10 MB bandwidth usage
  3. 10 RTP port for incoming video / 10 MB bandwidth usage
  4. 10 RTP port for incoming audio / 10 MB bandwidth usage

How to use b=AS?

// remove existing bandwidth lines
sdp = sdp.replace( /b=AS([^\r\n]+\r\n)/g , '');

// audio bandwidth 50 kilobits per second
sdp = sdp.replace( /a=mid:audio\r\n/g , 'a=mid:audio\r\nb=AS:50\r\n');

// video bandwidth 256 kilobits per second
sdp = sdp.replace( /a=mid:video\r\n/g , 'a=mid:video\r\nb=AS:256\r\n');

// data bandwidth 1638400 kilobits per second
sdp = sdp.replace( /a=mid:data\r\n/g , 'a=mid:data\r\nb=AS:1638400\r\n');

Above snippet is setting bandwidth for first track in each m-line. You need to set application specific bandwidth attribute for each track if you attached multiple streams.

One-to-One and Multiple Streams Scenario

Assume that you attached following streams per single peer:

  1. Audio+Video Stream
  2. Screen Sharing Stream
  3. Only Video stream coming from a second webcam

In this scenario; 8 RTP ports will be opened for each peer:

  1. 4 RTP port for outgoing/incoming audio+video streams
  2. 2 RTP port for outgoing/incoming screen sharing streams
  3. 2 RTP port for outgoing/incoming video-only streams

In such scenario; default bandwidth acquired by each peer is 8 MB.

For Your Information...

By default, 5 simultaneous calls need 20M bandwidth, as 2M each. You can also try to limit each stream by adding 'b=AS' according to your available bandwidth.

Maximum video bitrate 2 Mbps
Minimum video bitrate .05 Mbps
Starting video bitrate .3 Mbps

Reference.



Feedback

Enter your email too; if you want "direct" reply!