View Source ExWebRTC.RTP.JitterBuffer (ex_webrtc v0.7.0)
Buffers and reorders RTP packets based on sequence_number
, introducing controlled latency
in order to combat network jitter and improve the QoS.
Summary
Types
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.
Creates a new ExWebRTC.RTP.JitterBuffer.t/0
.
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
.
packets
- a list with packets flushed from the buffer as a result of the function call. May be empty.timer_duration_ms
- seetimer/0
.buffer
-ExWebRTC.RTP.JitterBuffer.t/0
.
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
Flushes all remaining packets and resets the JitterBuffer.
Note: After flushing, the rollover counter is reset to 0
.
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.
Creates a new ExWebRTC.RTP.JitterBuffer.t/0
.