Adaptive bitrate streaming and jitter buffer.
Monitors network conditions and dynamically adjusts:
- Video resolution and bitrate
- Buffer size
- Frame dropping strategy
Borrowed from WebRTC / RTP / QUIC approaches.
States
:stable → network is good, use highest quality
:degrading → packet loss detected, reduce quality
:recovering → network improving, slowly ramp up
:buffered → buffer full, can increase qualityExample
{:ok, adapter} = Dala.Media.Adaptive.start_link(%{
min_bitrate: 200_000,
max_bitrate: 4_000_000,
target_buffer_ms: 2000
})
# Report network stats (called by stream decoder)
Dala.Media.Adaptive.report_stats(adapter, %{
bytes_received: 50000,
packets_lost: 2,
jitter_ms: 15,
rtt_ms: 80
})
Summary
Functions
Returns a specification to start this module under a supervisor.
Get full diagnostic info.
Get current adapter state.
Get the current recommended bitrate.
Get the current recommended resolution.
Report network statistics from the stream decoder.
Start the adaptive bitrate adapter.
Types
@type adapter_ref() :: pid()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec diagnostic(adapter_ref()) :: map()
Get full diagnostic info.
@spec get_state(adapter_ref()) :: atom()
Get current adapter state.
@spec recommended_bitrate(adapter_ref()) :: non_neg_integer()
Get the current recommended bitrate.
@spec recommended_resolution(adapter_ref()) :: {non_neg_integer(), non_neg_integer()}
Get the current recommended resolution.
@spec report_stats(adapter_ref(), map()) :: :ok
Report network statistics from the stream decoder.
@spec start_link(keyword()) :: GenServer.on_start()
Start the adaptive bitrate adapter.