Selkies
Developer ReferenceWeb client coreLib

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

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

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';

PROBE_FULLCOLOR_STRINGS

const PROBE_FULLCOLOR_STRINGS: object;

Defined in: lib/wire-codecs.js:468

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

ParameterTypeDescription
typeBytenumberThe 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

ParameterTypeDescription
typeBytenumberThe 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

ParameterTypeDescription
encoderstringAn 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

ParameterTypeDescription
codecstringA codec name.

Returns

boolean

Whether the codec can carry 4:4:4 chroma.


annexbNals()

function annexbNals(bytes): Uint8Array<ArrayBufferLike>[];

Defined in: lib/wire-codecs.js:65

The NAL units of an Annex-B buffer, each without its start code.

Parameters

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-

Returns

Uint8Array<ArrayBufferLike>[]


rbspReader()

function rbspReader(
   bytes, 
   offset, 
   limit
): object;

Defined in: lib/wire-codecs.js:92

A bit reader over an RBSP: bytes from offset with emulation prevention bytes removed, limit bytes at most.

Parameters

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-
offsetnumber-
limitnumber-

Returns

object

u
u: (n) => number;
Parameters
ParameterType
nnumber
Returns

number

skip
skip: (n) => void;
Parameters
ParameterType
nnumber
Returns

void


parseAvcCodecFromAnnexB()

function parseAvcCodecFromAnnexB(bytes): string;

Defined in: lib/wire-codecs.js:120

avc1.PPCCLL from the first SPS of an H.264 Annex-B key frame.

Parameters

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-

Returns

string

null when no SPS is found.


parseHevcCodecFromAnnexB()

function parseHevcCodecFromAnnexB(bytes): string;

Defined in: lib/wire-codecs.js:142

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

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-

Returns

string

null when no SPS is found.


parseAv1CodecFromObus()

function parseAv1CodecFromObus(bytes): string;

Defined in: lib/wire-codecs.js:172

av01.P.LLT.08 from the sequence header of an AV1 temporal unit: the profile, the first operating point's level and tier. The encoders here emit 8-bit 4:2:0, which the fixed bit-depth field states.

Parameters

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-

Returns

string

null when no sequence header is found.


parseVp9Profile()

function parseVp9Profile(bytes): number;

Defined in: lib/wire-codecs.js:239

The VP9 profile a frame's uncompressed header declares.

Parameters

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-

Returns

number


vp9Level()

function vp9Level(
   width, 
   height, 
   fps
): string;

Defined in: lib/wire-codecs.js:253

The lowest VP9 level whose luma sample rate and picture size admit a stream, as the two digits of the codec string.

Parameters

ParameterTypeDescription
widthnumber-
heightnumber-
fpsnumber-

Returns

string


av1LevelIdx()

function av1LevelIdx(
   width, 
   height, 
   fps
): number;

Defined in: lib/wire-codecs.js:279

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

ParameterTypeDescription
widthnumber-
heightnumber-
fpsnumber-

Returns

number


h264LevelIdc()

function h264LevelIdc(
   width, 
   height, 
   fps
): string;

Defined in: lib/wire-codecs.js:316

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

ParameterTypeDescription
widthnumber-
heightnumber-
fpsnumber-

Returns

string


guessAvcCodec()

function guessAvcCodec(
   width, 
   height, 
   is444, 
   fps, 
   chromium
): string;

Defined in: lib/wire-codecs.js:329

Parameters

ParameterType
widthany
heightany
is444any
fpsany
chromiumany

Returns

string


codecStringFor()

function codecStringFor(
   codec, 
   keyframe, 
   width, 
   height, 
   fps, 
   is444, 
   chromium
): string;

Defined in: lib/wire-codecs.js:350

The WebCodecs codec string of a stream, from its key frame where the codec declares it and from the geometry otherwise.

Parameters

ParameterTypeDescription
codecstringThe wire codec name.
keyframeUint8Array<ArrayBufferLike>The key frame's payload, or null for a delta.
widthnumber-
heightnumber-
fpsnumber-
is444boolean-
chromiumboolean-

Returns

string


decoderColorSpace()

function decoderColorSpace(codec, fullRange?): VideoColorSpaceInit;

Defined in: lib/wire-codecs.js:381

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

ParameterTypeDefault valueDescription
codecstringundefinedThe wire codec name or WebCodecs codec string.
fullRange?booleanfalseWhether the session converted at full range.

Returns

VideoColorSpaceInit


avcDescription()

function avcDescription(bytes): Uint8Array<ArrayBufferLike>;

Defined in: lib/wire-codecs.js:404

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

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-

Returns

Uint8Array<ArrayBufferLike>


annexbToAvcc()

function annexbToAvcc(bytes): Uint8Array<ArrayBufferLike>;

Defined in: lib/wire-codecs.js:427

An Annex B access unit as length-prefixed NAL units, the framing an avcC description implies, without its parameter sets and delimiters.

Parameters

ParameterTypeDescription
bytesUint8Array<ArrayBufferLike>-

Returns

Uint8Array<ArrayBufferLike>


sameBytes()

function sameBytes(a, b): boolean;

Defined in: lib/wire-codecs.js:452

Parameters

ParameterTypeDescription
aUint8Array<ArrayBufferLike>-
bUint8Array<ArrayBufferLike>-

Returns

boolean

Whether both are absent or byte-for-byte equal.

On this page

Edit on GitHub