Class: shaka.mkv.MatroskaIndexParser

Constructor

new MatroskaIndexParser()

Source:

Methods

getElementLength(data, expectedId) → {number}

Reads the total length of a top-level element (header included) from its first bytes. The caller can use this to fetch precisely the element with one more range request.
Parameters:
Name Type Description
data BufferSource
expectedId shaka.mkv.ElementId
Source:
Returns:
Type
number

getInitEndOffset(header, tracknon-null) → {number}

Gets the last byte of the initialization segment of a track. That is the beginning of the file, up to the end of the TrackEntry of the track (and of the Info, which holds the timecode scale, should it come later). Nothing that follows is needed to tell what the track is. Besides being small, this makes the initialization segment of each track a different byte range, which is how the StreamingEngine knows it has to append it again when the track changes.
Parameters:
Name Type Description
header shaka.mkv.MatroskaIndexParser.Header
track shaka.mkv.MatroskaIndexParser.Track
Source:
Returns:
The offset of the last byte, inclusive.
Type
number

invalid_() → {shaka.util.Error}

Source:
Returns:
@private
Type
shaka.util.Error

parseAudioSettings_(audionon-null, tracknon-null)

Parameters:
Name Type Description
audio shaka.util.EbmlElement
track shaka.mkv.MatroskaIndexParser.Track
Source:

parseBlockAdditionMapping_(mappingnon-null, tracknon-null)

Reads a BlockAdditionMapping, which says what the additional data of the blocks, or the extra data of the track, is. The one that is looked for is the Dolby Vision configuration.
Parameters:
Name Type Description
mapping shaka.util.EbmlElement
track shaka.mkv.MatroskaIndexParser.Track
Source:

parseChapterAtom_(atomnon-null, resultnon-null)

Parameters:
Name Type Description
atom shaka.util.EbmlElement
result Array<shaka.mkv.MatroskaIndexParser.Chapter>
Source:

parseChapters(data) → {Array<shaka.mkv.MatroskaIndexParser.Chapter>}

Parses a complete Chapters element fetched with a byte range request. Only the first edition is read: Shaka's chapter API has no notion of edition selection.
Parameters:
Name Type Description
data BufferSource
Source:
Returns:
Type
Array<shaka.mkv.MatroskaIndexParser.Chapter>

parseContentEncodings_(encodingsnon-null, tracknon-null)

Reads the ContentEncodings of a track. The only encoding that can be undone without a decompressor or a key is header stripping, in which the muxer removed a common prefix from every frame.
Parameters:
Name Type Description
encodings shaka.util.EbmlElement
track shaka.mkv.MatroskaIndexParser.Track
Source:

parseCues(data, segmentOffset, timecodeScale) → {Array<shaka.mkv.MatroskaIndexParser.CuePoint>}

Parses a complete Cues element fetched with a byte range request.
Parameters:
Name Type Description
data BufferSource
segmentOffset number
timecodeScale number
Source:
Returns:
Type
Array<shaka.mkv.MatroskaIndexParser.CuePoint>

parseHeader(data) → {shaka.mkv.MatroskaIndexParser.Header}

Parses the beginning of a file. The data does not need to contain the whole header: everything up to the first Cluster (or up to the first element the data cuts short) is read, and if that element is the list of tracks, the complete tracks that precede the cut.
Parameters:
Name Type Description
data BufferSource Bytes beginning at offset zero in the file.
Source:
Returns:
Type
shaka.mkv.MatroskaIndexParser.Header

parseInfo_(infonon-null) → {{timecodeScale: number, unscaledDuration: ?number}}

Parameters:
Name Type Description
info shaka.util.EbmlElement
Source:
Returns:
Type
{timecodeScale: number, unscaledDuration: ?number}

parseSeekHead_(seekHeadnon-null, segmentOffset, header, seekPositionsnon-null)

Parameters:
Name Type Description
seekHead shaka.util.EbmlElement
segmentOffset number
header shaka.mkv.MatroskaIndexParser.Header
seekPositions Array<number> Receives the absolute position of every element the SeekHead lists.
Source:

parseTopLevelElement_(parsernon-null, expectedId) → {shaka.util.EbmlElement}

Parses the element at the parser's position and checks its ID.
Parameters:
Name Type Description
parser shaka.util.EbmlParser
expectedId shaka.mkv.ElementId
Source:
Returns:
Type
shaka.util.EbmlElement

parseTrackEntry_(entrynon-null, offset) → {shaka.mkv.MatroskaIndexParser.Track}

Parameters:
Name Type Description
entry shaka.util.EbmlElement
offset number Absolute offset of the TrackEntry element.
Source:
Returns:
Type
shaka.mkv.MatroskaIndexParser.Track

parseTracks_(tracksnon-null, dataOffset) → {Array<!shaka.mkv.MatroskaIndexParser.Track>}

Parameters:
Name Type Description
tracks shaka.util.EbmlElement
dataOffset number Absolute offset of the first byte of |tracks|'s data.
Source:
Returns:
Type
Array<!shaka.mkv.MatroskaIndexParser.Track>

parseVideoSettings_(videonon-null, tracknon-null)

Parameters:
Name Type Description
video shaka.util.EbmlElement
track shaka.mkv.MatroskaIndexParser.Track
Source:

Type Definitions

Chapter

Type:
  • {start: number, end: ?number, title: string, language: string}
Source:

CuePoint

Type:
  • {time: number, track: number, offset: number}
Properties:
Name Type Description
time number CueTime in seconds.
track number CueTrack.
offset number Absolute file offset of the Cluster the CuePoint refers to.
Source:

Header

Type:
  • {segmentOffset: number, cuesOffset: ?number, chaptersOffset: ?number, infoEndOffset: ?number, mediaEndOffset: ?number, duration: ?number, timecodeScale: number, tracks: !Array<!shaka.mkv.MatroskaIndexParser.Track>, firstClusterOffset: ?number}
Properties:
Name Type Attributes Description
segmentOffset number Absolute file offset of the first byte of the Segment's data.
cuesOffset number <nullable>
Absolute file offset of the Cues element.
chaptersOffset number <nullable>
Absolute file offset of the Chapters element.
infoEndOffset number <nullable>
Absolute file offset of the byte after the Info element.
mediaEndOffset number <nullable>
Absolute file offset where the Clusters end, if known.
duration number <nullable>
Duration in seconds.
timecodeScale number Nanoseconds per timecode tick.
firstClusterOffset number <nullable>
Absolute file offset of the first Cluster; null while it has not been reached in the data.
Source:

Track

Type:
  • {offset: number, size: number, number: number, type: number, codecId: string, codecPrivate: ?Uint8Array, codecDelay: ?number, language: string, name: string, enabled: boolean, isDefault: boolean, forced: boolean, hearingImpaired: boolean, visualImpaired: boolean, original: boolean, commentary: boolean, width: ?number, height: ?number, displayWidth: ?number, displayHeight: ?number, transferCharacteristics: ?number, channels: ?number, sampleRate: ?number, outputSampleRate: ?number, defaultDuration: ?number, strippedHeader: ?Uint8Array, unsupportedEncoding: boolean, dolbyVisionConfig: ?Uint8Array}
Properties:
Name Type Attributes Description
offset number Absolute file offset of the TrackEntry element.
size number Size in bytes of the whole TrackEntry element, header included.
number number TrackNumber: what the blocks of the track refer to.
type number TrackType; see shaka.mkv.TrackType.
codecDelay number <nullable>
CodecDelay in seconds.
defaultDuration number <nullable>
DefaultDuration (the frame duration) in seconds.
transferCharacteristics number <nullable>
Video Colour transfer characteristics (H.273 values).
strippedHeader Uint8Array <nullable>
The prefix to put back in front of every frame, when the track uses header stripping.
unsupportedEncoding boolean True when the track is compressed or encrypted in a way that cannot be undone.
dolbyVisionConfig Uint8Array <nullable>
The Dolby Vision configuration record (the payload of dvcC or dvvC).
Source: