Dala.Media.Adaptive (dala v0.6.0)

Copy Markdown View Source

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 quality

Example

{: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

adapter_ref()

@type adapter_ref() :: pid()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

diagnostic(pid)

@spec diagnostic(adapter_ref()) :: map()

Get full diagnostic info.

get_state(pid)

@spec get_state(adapter_ref()) :: atom()

Get current adapter state.

report_stats(pid, stats)

@spec report_stats(adapter_ref(), map()) :: :ok

Report network statistics from the stream decoder.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Start the adaptive bitrate adapter.