Class: shaka.metadata.Id3Utils

A set of Id3Utils utility functions.

Constructor

new Id3Utils()

A set of Id3Utils utility functions.

Implements:
Source:

Members

EXTENDED_HEADER_FLAG_ :number

Tag header flag: the body starts with an extended header.
Type:
  • number
Source:

FOOTER_FLAG_ :number

Tag header flag: the tag ends with a footer (ID3v2.4 only).
Type:
  • number
Source:

LATIN1_encoding_ :number

ISO-8859-1 / Latin-1 encoding byte.
Type:
  • number
Source:

UNSYNCHRONIZATION_FLAG_ :number

Tag header flag: every frame is unsynchronized.
Type:
  • number
Source:

UTF8_encoding_ :number

UTF-8 encoding byte.
Type:
  • number
Source:

UTF16BE_encoding_ :number

UTF-16BE without BOM encoding byte.
Type:
  • number
Source:

UTF16BOM_encoding_ :number

UTF-16 with BOM encoding byte.
Type:
  • number
Source:

Methods

decodeFrame_(frame) → {shaka.extern.MetadataFrame}

Parameters:
Name Type Description
frame shaka.extern.MetadataRawFrame
Source:
Returns:
Type
shaka.extern.MetadataFrame

decodeString_(datanon-null, encoding) → {string}

Decodes a string from raw bytes using the given ID3 encoding indicator. ID3v2 encoding values: 0x00 = ISO-8859-1 (Latin-1) 0x01 = UTF-16 with BOM (FF FE = LE, FE FF = BE) 0x02 = UTF-16BE without BOM 0x03 = UTF-8
Parameters:
Name Type Description
data Uint8Array
encoding number
Source:
Returns:
Type
string

findNull_(data, encoding, offsetopt) → {number}

Finds the byte index of the null terminator in `data` starting from `offset`, respecting the terminator width for the given encoding. For UTF-16 encodings the search steps in two-byte increments so it never straddles a surrogate pair or misidentifies a code-unit as a terminator.
Parameters:
Name Type Attributes Default Description
data Uint8Array
encoding number
offset number <optional>
0
Source:
Returns:
Byte index of the null terminator, or -1 if not found.
Type
number

getID3Data(id3Data, offsetopt) → {Uint8Array}

Returns any adjacent ID3 tags found in data starting at offset, as one block of data
Parameters:
Name Type Attributes Default Description
id3Data Uint8Array The ID3 data containing one or more ID3 tags
offset number <optional>
0 The offset at which to start searching
Source:
Returns:
Type
Uint8Array

getID3Frames(id3Data) → {Array<shaka.extern.MetadataFrame>}

Returns an array of ID3 frames found in all the ID3 tags in the id3Data
Parameters:
Name Type Description
id3Data Uint8Array The ID3 data containing one or more ID3 tags
Source:
Returns:
Type
Array<shaka.extern.MetadataFrame>

getTagLength_(data, offset) → {number}

Returns the total length of the ID3 tag starting at `offset`: its header, its body (which includes any extended header and padding) and, in ID3v2.4, its footer.
Parameters:
Name Type Description
data Uint8Array
offset number
Source:
Returns:
Type
number

isHeader_(data, offset) → {boolean}

Parameters:
Name Type Description
data Uint8Array
offset number
Source:
Returns:
Type
boolean

nullTermSize_(encoding) → {number}

Returns the byte width of the null terminator for a given encoding. UTF-16 encodings use a two-byte null; all others use a single byte.
Parameters:
Name Type Description
encoding number
Source:
Returns:
Type
number

readFrame_(datanon-null, version, unsynchronized) → {{frame: ?shaka.extern.MetadataRawFrame, length: number}}

Reads the frame at the start of `data`, stripping the extra information its format flags add before the frame content.
Parameters:
Name Type Description
data Uint8Array
version number ID3v2 major version (3 = v2.3, 4 = v2.4)
unsynchronized boolean Whether the tag says every frame is unsynchronized (ID3v2.4 only; in ID3v2.3 it applies to the whole tag, which is undone before reading the frames).
Source:
Returns:
The frame, or null if it cannot be decoded (compressed or encrypted), and the number of bytes it takes, header included.
Type
{frame: ?shaka.extern.MetadataRawFrame, length: number}

readSize_(data, offset) → {number}

Parameters:
Name Type Description
data Uint8Array
offset number
Source:
Returns:
Type
number

readSizeBE_(data, offset) → {number}

Reads a 32-bit big-endian integer from `data` at `offset`. Used for ID3v2.3 frame sizes, which are plain big-endian (not syncsafe).
Parameters:
Name Type Description
data Uint8Array
offset number
Source:
Returns:
Type
number

removeUnsynchronization_(datanon-null) → {Uint8Array}

Undoes the unsynchronization scheme, which inserts a 0x00 after every 0xFF that could be mistaken for an MPEG sync word.
Parameters:
Name Type Description
data Uint8Array
Source:
Returns:
Type
Uint8Array

parse(datanon-null) → {Array<!shaka.extern.MetadataFrame>}

Parses {@code data} and returns every metadata frame found in it. Implementations MUST:
  • Return an empty array (never {@code null}) when no frames are found or the data is not recognised.
  • Not throw; all errors should be swallowed and result in an empty or partial return value.
  • Use ID3v2.4 four-character frame IDs as {@code key} values wherever a mapping exists (see class-level documentation).
Parameters:
Name Type Description
data Uint8Array Raw bytes of the media segment or file.
Implements:
Source:
Returns:
Type
Array<!shaka.extern.MetadataFrame>