lib/wire-codecs
Variables
WIRE_CODECS
const WIRE_CODECS: object;Defined in: lib/wire-codecs.js:23
Codec names by wire id.
Type Declaration
1
1: string = 'h264';2
2: string = 'vp8';3
3: string = 'vp9';4
4: string = 'av1';5
5: string = 'h265';ENCODER_CODECS
const ENCODER_CODECS: object;Defined in: lib/wire-codecs.js:26
Encoder wire values and the codec each streams.
Type Declaration
jpeg
jpeg: string = 'jpeg';h264enc
h264enc: string = 'h264';h264enc-striped
"h264enc-striped": string = 'h264';h265enc
h265enc: string = 'h265';vp8enc
vp8enc: string = 'vp8';vp9enc
vp9enc: string = 'vp9';av1enc
av1enc: string = 'av1';H264_ANNEXB_SAMPLE
const H264_ANNEXB_SAMPLE: "AAAAAWdCwArd7ARAAAADAEAAAA8DxIngAAAAAWjOD8gAAAABZYiEOiYoDg==" = 'AAAAAWdCwArd7ARAAAADAEAAAA8DxIngAAAAAWjOD8gAAAABZYiEOiYoDg==';Defined in: lib/wire-codecs.js:449
A 16x16 Baseline key frame in Annex B form, for asking a decoder whether it
takes H.264 without an avcC description.
PROBE_CODEC_STRINGS
const PROBE_CODEC_STRINGS: object;Defined in: lib/wire-codecs.js:512
Type Declaration
h264
h264: string = 'avc1.42E01E';h265
h265: string = 'hev1.1.6.L93.B0';vp8
vp8: string = 'vp8';vp9
vp9: string = 'vp09.00.31.08';av1
av1: string = 'av01.0.05M.08';TEN_BIT_SAMPLES
const TEN_BIT_SAMPLES: object;Defined in: lib/wire-codecs.js:527
One 10-bit key frame of each format, 320x240 of flat gray, for asking a
decoder for a picture rather than for its word: a codec name is its 4:2:0,
the name with 444 after it its 4:4:4. An engine can accept a 10-bit
configuration and then fail the frame, which only decoding one shows.
PROBE_FULLCOLOR_STRINGS
const PROBE_FULLCOLOR_STRINGS: object;Defined in: lib/wire-codecs.js:538
The 4:4:4 configurations, at the profiles the encoders emit (VP9 profile 1).
Type Declaration
h264
h264: string = 'avc1.F4001E';h265
h265: string = 'hev1.4.10.L93.9E.8';vp9
vp9: string = 'vp09.01.10.08.03';Functions
wireCodecName()
function wireCodecName(typeByte): string;Defined in: lib/wire-codecs.js:40
Parameters
| Parameter | Type | Description |
|---|---|---|
typeByte | number | The second byte of a video frame's wire header. |
Returns
string
The codec name; an id no codec has reads as H.264.
wireFrameIsKey()
function wireFrameIsKey(typeByte): boolean;Defined in: lib/wire-codecs.js:46
Parameters
| Parameter | Type | Description |
|---|---|---|
typeByte | number | The second byte of a video frame's wire header. |
Returns
boolean
Whether the frame is a decode entry point.
codecOfEncoder()
function codecOfEncoder(encoder): string;Defined in: lib/wire-codecs.js:52
Parameters
| Parameter | Type | Description |
|---|---|---|
encoder | string | An encoder wire value. |
Returns
string
The codec it streams; an unknown encoder reads as H.264.
codecCarriesFullColor()
function codecCarriesFullColor(codec): boolean;Defined in: lib/wire-codecs.js:58
Parameters
| Parameter | Type | Description |
|---|---|---|
codec | string | A codec name. |
Returns
boolean
Whether the codec can carry 4:4:4 chroma.
codecCarriesTenBit()
function codecCarriesTenBit(codec): boolean;Defined in: lib/wire-codecs.js:67
Whether a codec has a 10-bit profile the server's encoders emit (H.264 High 10 and High 4:4:4 Predictive, H.265 Main 10 and Main 4:4:4 10, VP9 profiles 2 and 3, AV1).
Parameters
| Parameter | Type | Description |
|---|---|---|
codec | string | The codec name. |
Returns
boolean
annexbNals()
function annexbNals(bytes): Uint8Array<ArrayBufferLike>[];Defined in: lib/wire-codecs.js:74
The NAL units of an Annex-B buffer, each without its start code.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
Uint8Array<ArrayBufferLike>[]
rbspReader()
function rbspReader(
bytes,
offset,
limit,
raw?
): object;Defined in: lib/wire-codecs.js:103
A bit reader over an RBSP: bytes from offset with emulation prevention
bytes removed, limit bytes at most; raw reads them as they stand, for
AV1, which has none.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | undefined | - |
offset | number | undefined | - |
limit | number | undefined | - |
raw? | boolean | false | - |
Returns
object
u
u: (n) => number;Parameters
| Parameter | Type |
|---|---|
n | number |
Returns
number
skip
skip: (n) => void;Parameters
| Parameter | Type |
|---|---|
n | number |
Returns
void
parseAvcCodecFromAnnexB()
function parseAvcCodecFromAnnexB(bytes): string;Defined in: lib/wire-codecs.js:131
avc1.PPCCLL from the first SPS of an H.264 Annex-B key frame.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
string
null when no SPS is found.
parseHevcCodecFromAnnexB()
function parseHevcCodecFromAnnexB(bytes): string;Defined in: lib/wire-codecs.js:153
hev1.P.C.TL.CC from the first SPS of an H.265 Annex-B key frame: the
general profile, its compatibility flags as the reversed-bit hexadecimal the
codecs registration specifies, the tier and level, and the constraint bytes
with trailing zero bytes dropped.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
string
null when no SPS is found.
parseAv1CodecFromObus()
function parseAv1CodecFromObus(bytes): string;Defined in: lib/wire-codecs.js:184
av01.P.LLT.DD from the sequence header of an AV1 temporal unit: the profile,
the first operating point's level and tier, and the bit depth its color
configuration declares. Every operating point is read past, and the header
as it stands, since AV1 has no emulation prevention.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
string
null when no sequence header is found.
parseVp9Profile()
function parseVp9Profile(bytes): number;Defined in: lib/wire-codecs.js:274
The VP9 profile a frame's uncompressed header declares.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
number
parseVp9BitDepth()
function parseVp9BitDepth(bytes): number;Defined in: lib/wire-codecs.js:286
The bit depth a VP9 key frame's uncompressed header declares: 8 for profiles 0 and 1, 10 or 12 by the flag that follows the sync code for profiles 2 and 3.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
number
vp9Level()
function vp9Level(
width,
height,
fps
): string;Defined in: lib/wire-codecs.js:305
The lowest VP9 level whose luma sample rate and picture size admit a stream, as the two digits of the codec string.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | - |
height | number | - |
fps | number | - |
Returns
string
av1LevelIdx()
function av1LevelIdx(
width,
height,
fps
): number;Defined in: lib/wire-codecs.js:331
The lowest AV1 level admitting a stream, as seq_level_idx; used only when a
key frame's sequence header is unreadable. MaxPicSize is its own Annex A limit,
far below the product of the axis maxima, since no level admits a picture that
is both its widest and its tallest.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | - |
height | number | - |
fps | number | - |
Returns
number
h264LevelIdc()
function h264LevelIdc(
width,
height,
fps
): string;Defined in: lib/wire-codecs.js:368
The level_idc, as a two-hex-digit string, an H.264 stream of this geometry declares, floored
across the common frame rates like the encoder's own ladder so a rate change moves nothing.
Mirrors h264_level in pixelflux codec.rs.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | - |
height | number | - |
fps | number | - |
Returns
string
guessAvcCodec()
function guessAvcCodec(
width,
height,
is444,
fps,
chromium
): string;Defined in: lib/wire-codecs.js:381
Parameters
| Parameter | Type |
|---|---|
width | any |
height | any |
is444 | any |
fps | any |
chromium | any |
Returns
string
codecStringFor()
function codecStringFor(
codec,
keyframe,
width,
height,
fps,
is444,
chromium
): string;Defined in: lib/wire-codecs.js:402
The WebCodecs codec string of a stream, from its key frame where the codec declares it and from the geometry otherwise.
Parameters
| Parameter | Type | Description |
|---|---|---|
codec | string | The wire codec name. |
keyframe | Uint8Array<ArrayBufferLike> | The key frame's payload, or null for a delta. |
width | number | - |
height | number | - |
fps | number | - |
is444 | boolean | - |
chromium | boolean | - |
Returns
string
decoderColorSpace()
function decoderColorSpace(codec, fullRange?): VideoColorSpaceInit;Defined in: lib/wire-codecs.js:434
The color space a decoder is told to assume, which is every session's: no
engine reads it out of an H.264 bitstream. Chromium and Firefox both report
bt709 at limited range for a stream whose VUI says otherwise, so a full
range session rendered without this hint is wrong by up to eight levels a
channel, and both honor the hint exactly. VP8 is held to BT.601 whatever the
session converted with, the one value its bitstream can name, because Firefox
reads that bit and ignores this; VP9 is told BT.709 because Chromium's
decoder does not read the matrix from the frame header.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
codec | string | undefined | The wire codec name or WebCodecs codec string. |
fullRange? | boolean | false | Whether the session converted at full range. |
Returns
VideoColorSpaceInit
avcDescription()
function avcDescription(bytes): Uint8Array<ArrayBufferLike>;Defined in: lib/wire-codecs.js:457
The avcC record of an Annex B key frame's SPS and PPS, for a decoder that
takes H.264 only with a description; null when either is missing.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
Uint8Array<ArrayBufferLike>
annexbToAvcc()
function annexbToAvcc(bytes): Uint8Array<ArrayBufferLike>;Defined in: lib/wire-codecs.js:480
An Annex B access unit as length-prefixed NAL units, the framing an avcC
description implies, without its parameter sets and delimiters.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | - |
Returns
Uint8Array<ArrayBufferLike>
sameBytes()
function sameBytes(a, b): boolean;Defined in: lib/wire-codecs.js:505
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Uint8Array<ArrayBufferLike> | - |
b | Uint8Array<ArrayBufferLike> | - |
Returns
boolean
Whether both are absent or byte-for-byte equal.