Class JitterBuffer
Puts received RTP packets back in order and evens out their arrival, for a player that takes one frame every packet interval: it holds a few packets before the first one plays, and then gives the next in sequence, or null so that the decoder conceals a frame.
Inherited Members
Namespace: Uniform.Matrix.WebRtc.Rtp
Assembly: Uniform.Matrix.WebRtc.dll
Syntax
public sealed class JitterBuffer
Remarks
A packet that has not arrived when its turn comes is waited for, as it is usually late rather than lost; only when later packets pile up behind it is it skipped as lost. Waiting adds delay, which capacityPackets bounds. A packet of another stream, by its SSRC, starts over, as when the sender reconnects through an SFU and its sequence numbers begin anew.
Constructors
| Edit this page View SourceJitterBuffer(int, int)
Puts received RTP packets back in order and evens out their arrival, for a player that takes one frame every packet interval: it holds a few packets before the first one plays, and then gives the next in sequence, or null so that the decoder conceals a frame.
Declaration
public JitterBuffer(int delayPackets = 3, int capacityPackets = 50)
Parameters
| Type | Name | Description |
|---|---|---|
| int | delayPackets | How many packets to hold before playing; three of 20 ms are 60 ms of delay. |
| int | capacityPackets | How many packets to hold at most; when more come, e.g. after a stall, the oldest are dropped to catch up. |
Remarks
A packet that has not arrived when its turn comes is waited for, as it is usually late rather than lost; only when later packets pile up behind it is it skipped as lost. Waiting adds delay, which capacityPackets bounds. A packet of another stream, by its SSRC, starts over, as when the sender reconnects through an SFU and its sequence numbers begin anew.
Properties
| Edit this page View SourceCount
Packets held.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Lost
Packets skipped as lost: missing while later ones were held.
Declaration
public long Lost { get; }
Property Value
| Type | Description |
|---|---|
| long |
Underruns
Turns when the next packet had not arrived yet, and a frame was concealed while waiting for it.
Declaration
public long Underruns { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
| Edit this page View SourceAdd(RtpPacket)
Add a received packet; late ones, whose turn has passed, and duplicates are dropped.
Declaration
public void Add(RtpPacket packet)
Parameters
| Type | Name | Description |
|---|---|---|
| RtpPacket | packet |
Next(out bool)
Return the packet whose turn it is; null for a lost packet, to conceal, and also while filling, when isPlaying tells the two apart.
Declaration
public RtpPacket? Next(out bool isPlaying)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isPlaying | Whether playing: false while filling, or after the stream stopped, when nothing should play. |
Returns
| Type | Description |
|---|---|
| RtpPacket |