Direct.Caps (direct v0.1.0)

Copy Markdown View Source

What a browser decodes, as it reported on connecting: a map with :hevc, :av1, :vp9 (and whatever else you carry, such as :uhd for 4K). The page can learn these with MediaSource.isTypeSupported / canPlayType and send them as connect params:

{hevc: v.canPlayType('video/mp4; codecs="hvc1.1.6.L120.B0"') !== "",
 av1: MediaSource.isTypeSupported('video/mp4; codecs="av01.0.08M.08"'),
 vp9: MediaSource.isTypeSupported('video/mp4; codecs="vp09.00.10.08"')}

Summary

Functions

Whether a codec, as a release name or ffprobe says it ("hevc", "x265", "av1", …), is one the browser with caps decodes itself. H.264 is, everywhere.

The browser's abilities from string-keyed params (%{"hevc" => true}) as a map of atoms; anything missing is "no". :keys adds names beyond hevc av1 vp9 uhd local.

Functions

decodable?(codec, caps)

@spec decodable?(String.t() | nil, map()) :: boolean()

Whether a codec, as a release name or ffprobe says it ("hevc", "x265", "av1", …), is one the browser with caps decodes itself. H.264 is, everywhere.

from_params(params, opts \\ [])

@spec from_params(map(), keyword()) :: map()

The browser's abilities from string-keyed params (%{"hevc" => true}) as a map of atoms; anything missing is "no". :keys adds names beyond hevc av1 vp9 uhd local.