View Source ExWebRTC.RTP.JitterBuffer (ex_webrtc v0.6.2)

Buffers and reorders RTP packets based on sequence_number, introducing controlled latency in order to combat network jitter and improve the QoS.

Summary

Types

Options that can be passed to new/1.

The 3-element tuple returned by all functions other than new/1.

t()

Time (in milliseconds) after which handle_timeout/1 should be called. Can be nil, in which case no timer needs to be set.

Functions

Flushes all remaining packets and resets the JitterBuffer.

Handles the end of a previously set timer.

Places a packet in the JitterBuffer.

Types

@type options() :: [{:latency, non_neg_integer()}]

Options that can be passed to new/1.

  • latency - latency introduced by the buffer, in milliseconds. 200 by default.
@type result() ::
  {packets :: [ExRTP.Packet.t()], timer_duration_ms :: timer(), buffer :: t()}

The 3-element tuple returned by all functions other than new/1.

Generally speaking, all results of this type can be handled in the same way.

@opaque t()
@type timer() :: non_neg_integer() | nil

Time (in milliseconds) after which handle_timeout/1 should be called. Can be nil, in which case no timer needs to be set.

Functions

@spec flush(t()) :: result()

Flushes all remaining packets and resets the JitterBuffer.

Note: After flushing, the rollover counter is reset to 0.

@spec handle_timeout(t()) :: result()

Handles the end of a previously set timer.

@spec insert(t(), ExRTP.Packet.t()) :: result()

Places a packet in the JitterBuffer.

Note: The initial latency timer will be set after the first packet is inserted into the buffer. If you want to start it at your own discretion, schedule a handle_timeout/1 call prior to that.

@spec new(options()) :: t()

Creates a new ExWebRTC.RTP.JitterBuffer.t/0.