Constructor
new MatroskaParser()
- Implements:
- Source:
Members
ELEMENT_HEADER_READ_SIZE_ :number
The size of an element header: an ID (at most 4 bytes) and a size (at most
8 bytes), rounded up.
Type:
- number
- Source:
INITIAL_HEADER_READ_SIZE_ :number
How much of the file is read first. The EBML header, the SeekHead, the Info
and the Tracks add up to a few kilobytes, so this is enough for almost any
file in one request.
Type:
- number
- Source:
MAX_ELEMENT_SIZE_ :number
The most an element that is downloaded whole (Cues, Chapters) may be. Cues
take about 20 bytes per keyframe, so this holds those of days of video; it
keeps a corrupt size from asking for the whole file.
Type:
- number
- Source:
MAX_HEADER_READ_SIZE_ :number
The most that is read to find the first Cluster. Files that put large
elements (cover art, big Void areas) before their media need more than the
first read, but there is a limit to what can be a header.
Type:
- number
- Source:
MIME_TYPES_ :Array<string>
The MIME types of Matroska: the ones IANA registered and the ones that are
really sent.
Type:
- Array<string>
- Source:
VP9_PROBE_SIZE_ :number
How many bytes of the first Cluster are read to look for a VP9 key frame.
Frames of the track come early in the Cluster, and a key frame of a VP9 track
at 4K is a few hundred kilobytes.
Type:
- number
- Source:
Methods
estimateDuration_(cuesnon-null, trackNumber) → {number}
Guesses the duration of a file that does not write it: the time of the
last keyframe, and one more interval like the last one.
Parameters:
| Name | Type | Description |
|---|---|---|
cues |
Array<shaka.mkv.MatroskaIndexParser.CuePoint> | |
trackNumber |
number |
- Source:
Returns:
- Type
- number
getTotalSize_(responsenon-null) → {number}
Parameters:
| Name | Type | Description |
|---|---|---|
response |
shaka.extern.Response |
- Source:
Returns:
The size of the whole file, from a Content-Range header.
- Type
- number
makeChapterStreams_(chaptersnon-null, duration, firstId) → {Array<!shaka.extern.Stream>}
Parameters:
| Name | Type | Description |
|---|---|---|
chapters |
Array<shaka.mkv.MatroskaIndexParser.Chapter> | |
duration |
number | |
firstId |
number |
- Source:
Returns:
- Type
- Array<!shaka.extern.Stream>
makeReferences_(cuesnon-null, header, trackNumber, duration, uri, initSegmentReference, timestampOffsetopt) → {Array<!shaka.media.SegmentReference>}
Makes references to consecutive cluster ranges. A range may contain more
than one cluster when not every cluster has a CuePoint. Each reference
therefore starts on a random access point indicated by Cues.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
cues |
Array<shaka.mkv.MatroskaIndexParser.CuePoint> | |||
header |
shaka.mkv.MatroskaIndexParser.Header | |||
trackNumber |
number | The track whose CuePoints define the ranges. Cues of other tracks (e.g. subtitles) do not fall on keyframes. | ||
duration |
number | |||
uri |
string | |||
initSegmentReference |
shaka.media.InitSegmentReference | |||
timestampOffset |
number |
<optional> |
0 |
- Source:
Returns:
- Type
- Array<!shaka.media.SegmentReference>
makeVariants_(videoStreamsnon-null, audioStreamsnon-null, bandwidth) → {Array<!shaka.extern.Variant>}
Combines every video with every audio: they are all in the same file, so
any pair can be played.
Parameters:
| Name | Type | Description |
|---|---|---|
videoStreams |
Array<!shaka.extern.Stream> | |
audioStreams |
Array<!shaka.extern.Stream> | |
bandwidth |
number |
- Source:
Returns:
- Type
- Array<!shaka.extern.Variant>
addUri_(error, uri) → {*}
Adds the URI to the errors of the file, which are created without it.
Parameters:
| Name | Type | Description |
|---|---|---|
error |
* | |
uri |
string |
- Source:
Returns:
- Type
- *
banLocation(uri)
Tells the parser that a location should be banned. This is called on
retry.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string |
- Implements:
- Source:
configure(config, isPreloadFnopt)
Called by the Player to provide an updated configuration any time the
configuration changes. Will be called at least once before start().
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
config |
shaka.extern.ManifestConfiguration | ||
isPreloadFn |
function |
<optional> |
- Implements:
- Source:
createStream_(candidatenon-null, referencesnon-null, bandwidth) → {shaka.extern.Stream}
Parameters:
| Name | Type | Description |
|---|---|---|
candidate |
shaka.mkv.MatroskaParser.Candidate | |
references |
Array<!shaka.media.SegmentReference> | |
bandwidth |
number |
- Source:
Returns:
- Type
- shaka.extern.Stream
getCandidates_(header) → {Array<shaka.mkv.MatroskaParser.Candidate>}
Lists the tracks that become streams, with what is known of them.
Parameters:
| Name | Type | Description |
|---|---|---|
header |
shaka.mkv.MatroskaIndexParser.Header |
- Source:
Returns:
- Type
- Array<shaka.mkv.MatroskaParser.Candidate>
load_(uri) → {Promise<shaka.extern.Manifest>}
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string |
- Source:
Returns:
- Type
- Promise<shaka.extern.Manifest>
onExpirationUpdated(sessionId, expiration)
Tells the parser that the expiration time of an EME session has changed.
Implementing this is optional.
Parameters:
| Name | Type | Description |
|---|---|---|
sessionId |
string | |
expiration |
number |
- Implements:
- Source:
onInitialVariantChosen(variant)
Tells the parser that the initial variant has been chosen.
Parameters:
| Name | Type | Description |
|---|---|---|
variant |
shaka.extern.Variant |
- Implements:
- Source:
probeVp9_(uri, header, cuesnon-null, indexTracknon-null, candidatesnon-null) → {Promise}
A VP9 track normally has no CodecPrivate, so the profile and the bit depth
that the codec string needs are only in the first key frame. Reads it.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | |
header |
shaka.mkv.MatroskaIndexParser.Header | |
cues |
Array<shaka.mkv.MatroskaIndexParser.CuePoint> | |
indexTrack |
shaka.mkv.MatroskaIndexParser.Track | |
candidates |
Array<shaka.mkv.MatroskaParser.Candidate> |
- Source:
Returns:
- Type
- Promise
readChapters_(uri, header) → {Promise<!Array<shaka.mkv.MatroskaIndexParser.Chapter>>}
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | |
header |
shaka.mkv.MatroskaIndexParser.Header |
- Source:
Returns:
- Type
- Promise<!Array<shaka.mkv.MatroskaIndexParser.Chapter>>
readCues_(uri, header) → {Promise<!Array<shaka.mkv.MatroskaIndexParser.CuePoint>>}
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | |
header |
shaka.mkv.MatroskaIndexParser.Header |
- Source:
Returns:
- Type
- Promise<!Array<shaka.mkv.MatroskaIndexParser.CuePoint>>
readHeader_(uri) → {Promise<{header: shaka.mkv.MatroskaIndexParser.Header, totalSize: ?number}>}
Reads the header of the file: everything before the first Cluster. Its
size is not known beforehand, so the range that is requested grows until
the first Cluster is in it.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string |
- Source:
Returns:
- Type
- Promise<{header: shaka.mkv.MatroskaIndexParser.Header, totalSize: ?number}>
requestElement_(uri, offset, id) → {Promise<BufferSource>}
Downloads a top-level element whose size is not known: its header first,
then exactly the element.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | |
offset |
number | |
id |
shaka.mkv.ElementId |
- Source:
Returns:
- Type
- Promise<BufferSource>
requestRange_(uri, start, end) → {Promise<shaka.extern.Response>}
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | |
start |
number | |
end |
number |
- Source:
Returns:
- Type
- Promise<shaka.extern.Response>
setMediaElement(mediaElement)
Set media element.
Parameters:
| Name | Type | Description |
|---|---|---|
mediaElement |
HTMLMediaElement |
- Implements:
- Source:
start(uri, playerInterface) → {Promise<shaka.extern.Manifest>}
Initialize and start the parser. When |start| resolves, it should return
the initial version of the manifest. |start| will only be called once. If
|stop| is called while |start| is pending, |start| should reject.
Parameters:
| Name | Type | Description |
|---|---|---|
uri |
string | The URI of the manifest. |
playerInterface |
shaka.extern.ManifestParser.PlayerInterface | The player interface contains the callbacks and members that the parser can use to communicate with the player and outside world. |
- Implements:
- Source:
Returns:
- Type
- Promise<shaka.extern.Manifest>
stop() → {Promise}
Tell the parser that it must stop and free all internal resources as soon
as possible. Only once all internal resources are stopped and freed will
the promise resolve. Once stopped a parser will not be started again.
The parser should support having |stop| called multiple times and the
promise should always resolve.
- Implements:
- Source:
Returns:
- Type
- Promise
update()
Tells the parser to do a manual manifest update. Implementing this is
optional. This is only called when 'emsg' boxes are present.
- Implements:
- Source:
Type Definitions
Candidate
Type:
- {track: !shaka.mkv.MatroskaIndexParser.Track, contentType: string, codecs: string, supplementalCodecs: string, streamId: number, isAlternate: boolean}
Properties:
| Name | Type | Description |
|---|---|---|
track |
shaka.mkv.MatroskaIndexParser.Track | |
contentType |
string | |
codecs |
string | |
supplementalCodecs |
string | The codecs of the Dolby Vision version of the track, if it has one. |
streamId |
number | |
isAlternate |
boolean | True for the second stream of a track: the one with the supplemental codecs. |
- Source: