shaka-player
Version:
DASH/EME video player library
1,411 lines (1,352 loc) • 103 kB
JavaScript
/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @externs
*/
/**
* @typedef {{
* timestamp: number,
* id: number,
* type: string,
* fromAdaptation: boolean,
* bandwidth: ?number
* }}
*
* @property {number} timestamp
* The timestamp the choice was made, in seconds since 1970
* (i.e. <code>Date.now() / 1000</code>).
* @property {number} id
* The id of the track that was chosen.
* @property {string} type
* The type of track chosen (<code>'variant'</code> or <code>'text'</code>).
* @property {boolean} fromAdaptation
* <code>true</code> if the choice was made by AbrManager for adaptation;
* <code>false</code> if it was made by the application through
* <code>selectTrack</code>.
* @property {?number} bandwidth
* The bandwidth of the chosen track (<code>null</code> for text).
* @exportDoc
*/
shaka.extern.TrackChoice;
/**
* @typedef {{
* timestamp: number,
* state: string,
* duration: number
* }}
*
* @property {number} timestamp
* The timestamp the state was entered, in seconds since 1970
* (i.e. <code>Date.now() / 1000</code>).
* @property {string} state
* The state the player entered. This could be <code>'buffering'</code>,
* <code>'playing'</code>, <code>'paused'</code>, or <code>'ended'</code>.
* @property {number} duration
* The number of seconds the player was in this state. If this is the last
* entry in the list, the player is still in this state, so the duration will
* continue to increase.
* @exportDoc
*/
shaka.extern.StateChange;
/**
* @typedef {{
* width: number,
* height: number,
* streamBandwidth: number,
*
* decodedFrames: number,
* droppedFrames: number,
* corruptedFrames: number,
* estimatedBandwidth: number,
*
* completionPercent: number,
* loadLatency: number,
* manifestTimeSeconds: number,
* drmTimeSeconds: number,
* playTime: number,
* pauseTime: number,
* bufferingTime: number,
* licenseTime: number,
* liveLatency: number,
*
* maxSegmentDuration: number,
*
* gapsJumped: number,
* stallsDetected: number,
*
* manifestSizeBytes: number,
* bytesDownloaded: number,
*
* nonFatalErrorCount: number,
* manifestPeriodCount: number,
* manifestGapCount: number,
*
* switchHistory: !Array<shaka.extern.TrackChoice>,
* stateHistory: !Array<shaka.extern.StateChange>
* }}
*
* @description
* Contains statistics and information about the current state of the player.
* This is meant for applications that want to log quality-of-experience (QoE)
* or other stats. These values will reset when <code>load()</code> is called
* again.
*
* @property {number} width
* The width of the current video track. If nothing is loaded or the content
* is audio-only, NaN.
* @property {number} height
* The height of the current video track. If nothing is loaded or the content
* is audio-only, NaN.
* @property {number} streamBandwidth
* The bandwidth required for the current streams (total, in bit/sec).
* It takes into account the playbackrate. If nothing is loaded, NaN.
*
* @property {number} decodedFrames
* The total number of frames decoded by the Player. If not reported by the
* browser, NaN.
* @property {number} droppedFrames
* The total number of frames dropped by the Player. If not reported by the
* browser, NaN.
* @property {number} corruptedFrames
* The total number of corrupted frames dropped by the browser. If not
* reported by the browser, NaN.
* @property {number} estimatedBandwidth
* The current estimated network bandwidth (in bit/sec). If no estimate
* available, NaN.
*
* @property {number} gapsJumped
* The total number of playback gaps jumped by the GapJumpingController.
* If nothing is loaded, NaN.
* @property {number} stallsDetected
* The total number of playback stalls detected by the StallDetector.
* If nothing is loaded, NaN.
*
* @property {number} completionPercent
* This is the greatest completion percent that the user has experienced in
* playback. Also known as the "high water mark". If nothing is loaded, or
* the stream is live (and therefore indefinite), NaN.
* @property {number} loadLatency
* This is the number of seconds it took for the video element to have enough
* data to begin playback. This is measured from the time load() is called to
* the time the <code>'loadeddata'</code> event is fired by the media element.
* If nothing is loaded, NaN.
* @property {number} manifestTimeSeconds
* The amount of time it took to download and parse the manifest.
* If nothing is loaded, NaN.
* @property {number} drmTimeSeconds
* The amount of time it took to download the first drm key, and load that key
* into the drm system. If nothing is loaded or DRM is not in use, NaN.
* @property {number} playTime
* The total time spent in a playing state in seconds. If nothing is loaded,
* NaN.
* @property {number} pauseTime
* The total time spent in a paused state in seconds. If nothing is loaded,
* NaN.
* @property {number} bufferingTime
* The total time spent in a buffering state in seconds. If nothing is
* loaded, NaN.
* @property {number} licenseTime
* The time spent on license requests during this session in seconds. If DRM
* is not in use, NaN.
* @property {number} liveLatency
* The time between the capturing of a frame and the end user having it
* displayed on their screen. If nothing is loaded or the content is VOD,
* NaN.
*
* @property {number} maxSegmentDuration
* The presentation's max segment duration in seconds. If nothing is loaded,
* NaN.
*
* @property {number} manifestSizeBytes
* Size of the manifest payload. For DASH & MSS it will match the latest
* downloaded manifest. For HLS, it will match the lastly downloaded playlist.
* If nothing is loaded or in src= mode, NaN.
* @property {number} bytesDownloaded
* The bytes downloaded during the playback. If nothing is loaded, NaN.
*
* @property {number} nonFatalErrorCount
* The amount of non fatal errors that occurred. If nothing is loaded, NaN.
* @property {number} manifestPeriodCount
* The amount of periods occurred in the manifest. For DASH it represents
* number of Period elements in a manifest. For HLS & MSS it is always 1.
* In src= mode or if nothing is loaded, NaN.
* @property {number} manifestGapCount
* The amount of gaps found in a manifest. For DASH, it represents number of
* discontinuities found between periods. For HLS, it is a number of EXT-X-GAP
* and GAP=YES occurrences. For MSS, it is always set to 0.
* If in src= mode or nothing is loaded, NaN.
*
* @property {!Array<shaka.extern.TrackChoice>} switchHistory
* A history of the stream changes.
* @property {!Array<shaka.extern.StateChange>} stateHistory
* A history of the state changes.
* @exportDoc
*/
shaka.extern.Stats;
/**
* @typedef {{
* start: number,
* end: number
* }}
*
* @description
* Contains the times of a range of buffered content.
*
* @property {number} start
* The start time of the range, in seconds.
* @property {number} end
* The end time of the range, in seconds.
* @exportDoc
*/
shaka.extern.BufferedRange;
/**
* @typedef {{
* total: !Array<shaka.extern.BufferedRange>,
* audio: !Array<shaka.extern.BufferedRange>,
* video: !Array<shaka.extern.BufferedRange>,
* text: !Array<shaka.extern.BufferedRange>
* }}
*
* @description
* Contains information about the current buffered ranges.
*
* @property {!Array<shaka.extern.BufferedRange>} total
* The combined audio/video buffered ranges, reported by
* <code>video.buffered</code>.
* @property {!Array<shaka.extern.BufferedRange>} audio
* The buffered ranges for audio content.
* @property {!Array<shaka.extern.BufferedRange>} video
* The buffered ranges for video content.
* @property {!Array<shaka.extern.BufferedRange>} text
* The buffered ranges for text content.
* @exportDoc
*/
shaka.extern.BufferedInfo;
/**
* @typedef {{
* id: number,
* active: boolean,
*
* type: string,
* bandwidth: number,
*
* language: string,
* label: ?string,
* kind: ?string,
* width: ?number,
* height: ?number,
* frameRate: ?number,
* pixelAspectRatio: ?string,
* hdr: ?string,
* colorGamut: ?string,
* videoLayout: ?string,
* mimeType: ?string,
* audioMimeType: ?string,
* videoMimeType: ?string,
* codecs: ?string,
* audioCodec: ?string,
* videoCodec: ?string,
* primary: boolean,
* roles: !Array<string>,
* audioRoles: Array<string>,
* accessibilityPurpose: ?shaka.media.ManifestParser.AccessibilityPurpose,
* forced: boolean,
* videoId: ?number,
* audioId: ?number,
* audioGroupId: ?string,
* channelsCount: ?number,
* audioSamplingRate: ?number,
* tilesLayout: ?string,
* audioBandwidth: ?number,
* videoBandwidth: ?number,
* spatialAudio: boolean,
* originalVideoId: ?string,
* originalAudioId: ?string,
* originalTextId: ?string,
* originalImageId: ?string,
* originalLanguage: ?string
* }}
*
* @description
* An object describing a media track. This object should be treated as
* read-only as changing any values does not have any effect. This is the
* public view of an audio/video paring (variant type) or text track (text
* type) or image track (image type).
*
* @property {number} id
* The unique ID of the track.
* @property {boolean} active
* If true, this is the track being streamed (another track may be
* visible/audible in the buffer).
*
* @property {string} type
* The type of track, either <code>'variant'</code> or <code>'text'</code>
* or <code>'image'</code>.
* @property {number} bandwidth
* The bandwidth required to play the track, in bits/sec.
*
* @property {string} language
* The language of the track, or <code>'und'</code> if not given. This value
* is normalized as follows - language part is always lowercase and translated
* to ISO-639-1 when possible, locale part is always uppercase,
* i.e. <code>'en-US'</code>.
* @property {?string} label
* The track label, which is unique text that should describe the track.
* @property {?string} kind
* (only for text tracks) The kind of text track, either
* <code>'caption'</code> or <code>'subtitle'</code>.
* @property {?number} width
* The video width provided in the manifest, if present.
* @property {?number} height
* The video height provided in the manifest, if present.
* @property {?number} frameRate
* The video framerate provided in the manifest, if present.
* @property {?string} pixelAspectRatio
* The video pixel aspect ratio provided in the manifest, if present.
* @property {?string} hdr
* The video HDR provided in the manifest, if present.
* @property {?string} colorGamut
* The video color gamut provided in the manifest, if present.
* @property {?string} videoLayout
* The video layout provided in the manifest, if present.
* @property {?string} mimeType
* The MIME type of the content provided in the manifest.
* @property {?string} audioMimeType
* The audio MIME type of the content provided in the manifest.
* @property {?string} videoMimeType
* The video MIME type of the content provided in the manifest.
* @property {?string} codecs
* The audio/video codecs string provided in the manifest, if present.
* @property {?string} audioCodec
* The audio codecs string provided in the manifest, if present.
* @property {?string} videoCodec
* The video codecs string provided in the manifest, if present.
* @property {boolean} primary
* True indicates that this in the primary language for the content.
* This flag is based on signals from the manifest.
* This can be a useful hint about which language should be the default, and
* indicates which track Shaka will use when the user's language preference
* cannot be satisfied.
* @property {!Array<string>} roles
* The roles of the track, e.g. <code>'main'</code>, <code>'caption'</code>,
* or <code>'commentary'</code>.
* @property {Array<string>} audioRoles
* The roles of the audio in the track, e.g. <code>'main'</code> or
* <code>'commentary'</code>. Will be null for text tracks or variant tracks
* without audio.
* @property {?shaka.media.ManifestParser.AccessibilityPurpose
* } accessibilityPurpose
* The DASH accessibility descriptor, if one was provided for this track.
* For text tracks, this describes the text; otherwise, this is for the audio.
* @property {boolean} forced
* True indicates that this in the forced text language for the content.
* This flag is based on signals from the manifest.
* @property {?number} videoId
* (only for variant tracks) The video stream id.
* @property {?number} audioId
* (only for variant tracks) The audio stream id.
* @property {?string} audioGroupId
* (only for variant tracks)
* The ID of the stream's parent element. In DASH, this will be a unique
* ID that represents the representation's parent adaptation element
* @property {?number} channelsCount
* The count of the audio track channels.
* @property {?number} audioSamplingRate
* Specifies the maximum sampling rate of the content.
* @property {?string} tilesLayout
* The value is a grid-item-dimension consisting of two positive decimal
* integers in the format: column-x-row ('4x3'). It describes the arrangement
* of Images in a Grid. The minimum valid LAYOUT is '1x1'.
* @property {boolean} spatialAudio
* True indicates that the content has spatial audio.
* This flag is based on signals from the manifest.
* @property {?number} audioBandwidth
* (only for variant tracks) The audio stream's bandwidth if known.
* @property {?number} videoBandwidth
* (only for variant tracks) The video stream's bandwidth if known.
* @property {?string} originalVideoId
* (variant tracks only) The original ID of the video part of the track, if
* any, as it appeared in the original manifest.
* @property {?string} originalAudioId
* (variant tracks only) The original ID of the audio part of the track, if
* any, as it appeared in the original manifest.
* @property {?string} originalTextId
* (text tracks only) The original ID of the text track, if any, as it
* appeared in the original manifest.
* @property {?string} originalImageId
* (image tracks only) The original ID of the image track, if any, as it
* appeared in the original manifest.
* @property {?string} originalLanguage
* The original language of the track, if any, as it appeared in the original
* manifest. This is the exact value provided in the manifest; for normalized
* value use <code>language</code> property.
* @exportDoc
*/
shaka.extern.Track;
/**
* @typedef {{
* active: boolean,
* language: string,
* label: ?string,
* mimeType: ?string,
* codecs: ?string,
* primary: boolean,
* roles: !Array<string>,
* accessibilityPurpose: ?shaka.media.ManifestParser.AccessibilityPurpose,
* channelsCount: ?number,
* audioSamplingRate: ?number,
* spatialAudio: boolean,
* originalLanguage: ?string
* }}
*
* @description
* An object describing a audio track. This object should be treated as
* read-only as changing any values does not have any effect.
*
* @property {boolean} active
* If true, this is the track being streamed (another track may be
* visible/audible in the buffer).
*
* @property {string} language
* The language of the track, or <code>'und'</code> if not given. This value
* is normalized as follows - language part is always lowercase and translated
* to ISO-639-1 when possible, locale part is always uppercase,
* i.e. <code>'en-US'</code>.
* @property {?string} label
* The track label, which is unique text that should describe the track.
* @property {?string} mimeType
* The MIME type of the content provided in the manifest.
* @property {?string} codecs
* The audio codecs string provided in the manifest, if present.
* @property {boolean} primary
* True indicates that this in the primary language for the content.
* This flag is based on signals from the manifest.
* This can be a useful hint about which language should be the default, and
* indicates which track Shaka will use when the user's language preference
* cannot be satisfied.
* @property {!Array<string>} roles
* The roles of the track, e.g. <code>'main'</code>, <code>'caption'</code>,
* or <code>'commentary'</code>.
* @property {?shaka.media.ManifestParser.AccessibilityPurpose
* } accessibilityPurpose
* The DASH accessibility descriptor, if one was provided for this track.
* @property {?number} channelsCount
* The count of the audio track channels.
* @property {?number} audioSamplingRate
* Specifies the maximum sampling rate of the content.
* @property {boolean} spatialAudio
* True indicates that the content has spatial audio.
* This flag is based on signals from the manifest.
* @property {?string} originalLanguage
* The original language of the track, if any, as it appeared in the original
* manifest. This is the exact value provided in the manifest; for normalized
* value use <code>language</code> property.
* @exportDoc
*/
shaka.extern.AudioTrack;
/**
* @typedef {!Array<!shaka.extern.Track>}
*/
shaka.extern.TrackList;
/**
* @typedef {{
* minWidth: number,
* maxWidth: number,
* minHeight: number,
* maxHeight: number,
* minPixels: number,
* maxPixels: number,
*
* minFrameRate: number,
* maxFrameRate: number,
*
* minBandwidth: number,
* maxBandwidth: number,
*
* minChannelsCount: number,
* maxChannelsCount: number
* }}
*
* @description
* An object describing application restrictions on what tracks can play. All
* restrictions must be fulfilled for a track to be playable/selectable.
* The restrictions system behaves somewhat differently at the ABR level and the
* player level, so please refer to the documentation for those specific
* settings.
*
* @see shaka.extern.PlayerConfiguration
* @see shaka.extern.AbrConfiguration
*
* @property {number} minWidth
* The minimum width of a video track, in pixels.
* <br>
* Defaults to <code>0</code>.
* @property {number} maxWidth
* The maximum width of a video track, in pixels.
* <br>
* Defaults to <code>Infinity</code>.
* @property {number} minHeight
* The minimum height of a video track, in pixels.
* <br>
* Defaults to <code>0</code>.
* @property {number} maxHeight
* The maximum height of a video track, in pixels.
* <br>
* Defaults to <code>Infinity</code>.
* @property {number} minPixels
* The minimum number of total pixels in a video track (i.e.
* <code>width * height</code>).
* <br>
* Defaults to <code>0</code>.
* @property {number} maxPixels
* The maximum number of total pixels in a video track (i.e.
* <code>width * height</code>).
* <br>
* Defaults to <code>Infinity</code>.
*
* @property {number} minFrameRate
* The minimum framerate of a variant track.
* <br>
* Defaults to <code>0</code>.
* @property {number} maxFrameRate
* The maximum framerate of a variant track.
* <br>
* Defaults to <code>Infinity</code>.
*
* @property {number} minBandwidth
* The minimum bandwidth of a variant track, in bit/sec.
* <br>
* Defaults to <code>0</code>.
* @property {number} maxBandwidth
* The maximum bandwidth of a variant track, in bit/sec.
* <br>
* Defaults to <code>Infinity</code>.
*
* @property {number} minChannelsCount
* The minimum channels count of a variant track.
* <br>
* Defaults to <code>0</code>.
* @property {number} maxChannelsCount
* The maximum channels count of a variant track.
* <br>
* Defaults to <code>Infinity</code>.
* @exportDoc
*/
shaka.extern.Restrictions;
/**
* @typedef {{
* persistentState: boolean,
* encryptionSchemes: !Array<string|null>,
* videoRobustnessLevels: !Array<string>,
* audioRobustnessLevels: !Array<string>,
* minHdcpVersions: !Array<string>
* }}
*
* @property {boolean} persistentState
* Whether this key system supports persistent state.
* @property {!Array<string|null>} encryptionSchemes
* An array of encryption schemes that are reported to work, through either
* EME or MCap APIs. An empty array indicates that encryptionScheme queries
* are not supported. This should not happen if our polyfills are installed.
* @property {!Array<string>} videoRobustnessLevels
* An array of video robustness levels that are reported to work. An empty
* array indicates that none were tested. Not all key systems have a list of
* known robustness levels built into probeSupport().
* @property {!Array<string>} audioRobustnessLevels
* An array of audio robustness levels that are reported to work. An empty
* array indicates that none were tested. Not all key systems have a list of
* known robustness levels built into probeSupport().
* @property {!Array<string>} minHdcpVersions
* An array of min HDCP levels that are reported to work. An empty
* array indicates that none were tested. Not all key systems have support to
* check min HDCP levels.
* @exportDoc
*/
shaka.extern.DrmSupportType;
/**
* @typedef {{
* manifest: !Object<string, boolean>,
* media: !Object<string, boolean>,
* drm: !Object<string, ?shaka.extern.DrmSupportType>,
* hardwareResolution: shaka.extern.Resolution
* }}
*
* @description
* An object detailing browser support for various features.
*
* @property {!Object<string, boolean>} manifest
* A map of supported manifest types.
* The keys are manifest MIME types and file extensions.
* @property {!Object<string, boolean>} media
* A map of supported media types.
* The keys are media MIME types.
* @property {!Object<string, ?shaka.extern.DrmSupportType>} drm
* A map of supported key systems.
* The keys are the key system names. The value is <code>null</code> if it is
* not supported. Key systems not probed will not be in this dictionary.
* @property {shaka.extern.Resolution} hardwareResolution
* The maximum detected hardware resolution, which may have
* height==width==Infinity for devices without a maximum resolution or
* without a way to detect the maximum.
*
* @exportDoc
*/
shaka.extern.SupportType;
/**
* @typedef {{
* cueTime: ?number,
* data: !Uint8Array,
* frames: !Array<shaka.extern.MetadataFrame>,
* dts: ?number,
* pts: ?number
* }}
*
* @description
* ID3 metadata in format defined by
* https://id3.org/id3v2.3.0#Declared_ID3v2_frames
* The content of the field.
*
* @property {?number} cueTime
* @property {!Uint8Array} data
* @property {!Array<shaka.extern.MetadataFrame>} frames
* @property {?number} dts
* @property {?number} pts
*
* @exportDoc
*/
shaka.extern.ID3Metadata;
/**
* @typedef {{
* type: string,
* size: number,
* data: Uint8Array
* }}
*
* @description metadata raw frame.
* @property {string} type
* @property {number} size
* @property {Uint8Array} data
* @exportDoc
*/
shaka.extern.MetadataRawFrame;
/**
* @typedef {{
* key: string,
* data: (ArrayBuffer|string|number),
* description: string,
* mimeType: ?string,
* pictureType: ?number
* }}
*
* @description metadata frame parsed.
* @property {string} key
* @property {ArrayBuffer|string|number} data
* @property {string} description
* @property {?string} mimeType
* @property {?number} pictureType
* @exportDoc
*/
shaka.extern.MetadataFrame;
/**
* @typedef {{
* video: ?shaka.extern.PlaybackStreamInfo,
* audio: ?shaka.extern.PlaybackStreamInfo,
* text: ?shaka.extern.PlaybackStreamInfo
* }}
*
* @description Represents the state of the current variant and text.
* @property {?shaka.extern.PlaybackStreamInfo} video
* @property {?shaka.extern.PlaybackStreamInfo} audio
* @property {?shaka.extern.PlaybackStreamInfo} text
* @exportDoc
*/
shaka.extern.PlaybackInfo;
/**
* @typedef {{
* codecs: string,
* mimeType: string,
* bandwidth: number,
* width: ?number,
* height: ?number
* }}
*
* @description Represents the state of the given stream.
* @property {string} codecs
* @property {string} mimeType
* @property {number} bandwidth
* @property {?number} width
* @property {?number} height
* @exportDoc
*/
shaka.extern.PlaybackStreamInfo;
/**
* @typedef {{
* startTime: number,
* endTime: ?number,
* values: !Array<shaka.extern.MetadataFrame>
* }}
*
* @property {number} startTime
* @property {?number} endTime
* @property {!Array<shaka.extern.MetadataFrame>} values
* @exportDoc
*/
shaka.extern.HLSInterstitial;
/**
* @typedef {{
* schemeIdUri: string,
* value: string,
* startTime: number,
* endTime: number,
* id: string,
* timescale: number,
* eventElement: Element,
* eventNode: ?shaka.extern.xml.Node
* }}
*
* @description
* Contains information about a region of the timeline that will cause an event
* to be raised when the playhead enters or exits it. In DASH this is the
* EventStream element.
*
* @property {string} schemeIdUri
* Identifies the message scheme.
* @property {string} value
* Specifies the value for the region.
* @property {number} startTime
* The presentation time (in seconds) that the region should start.
* @property {number} endTime
* The presentation time (in seconds) that the region should end.
* @property {string} id
* Specifies an identifier for this instance of the region.
* @property {number} timescale
* Provides the timescale, in ticks per second.
* @property {Element} eventElement
* <b>DEPRECATED</b>: Use eventNode instead.
* The XML element that defines the Event.
* @property {?shaka.extern.xml.Node} eventNode
* The XML element that defines the Event.
* @exportDoc
*/
shaka.extern.TimelineRegionInfo;
/**
* @typedef {{
* schemeIdUri: string,
* startTime: number,
* endTime: number,
* id: string,
* emsg: shaka.extern.EmsgInfo
* }}
*
* @description
* Contains information about a region of the timeline that will cause an event
* to be raised when the playhead enters or exits it.
*
* @property {string} schemeIdUri
* Identifies the metadata type.
* @property {number} startTime
* The presentation time (in seconds) that the region should start.
* @property {number} endTime
* The presentation time (in seconds) that the region should end.
* @property {string} id
* Specifies an identifier for this instance of the region.
* @property {shaka.extern.EmsgInfo} emsg
* Specifies the EMSG info.
* @exportDoc
*/
shaka.extern.EmsgTimelineRegionInfo;
/**
* @typedef {{
* schemeIdUri: string,
* startTime: number,
* endTime: number,
* id: string,
* payload: shaka.extern.MetadataFrame
* }}
*
* @description
* Contains information about a region of the timeline that will cause an event
* to be raised when the playhead enters or exits it.
*
* @property {string} schemeIdUri
* Identifies the metadata type.
* @property {number} startTime
* The presentation time (in seconds) that the region should start.
* @property {number} endTime
* The presentation time (in seconds) that the region should end.
* @property {string} id
* Specifies an identifier for this instance of the region.
* @property {shaka.extern.MetadataFrame} payload
* Specifies the metadata frame.
* @exportDoc
*/
shaka.extern.MetadataTimelineRegionInfo;
/**
* @typedef {{
* audioSamplingRate: ?number,
* bandwidth: number,
* codecs: string,
* contentType: string,
* frameRate: ?number,
* height: ?number,
* mimeType: ?string,
* label: ?string,
* roles: ?Array<string>,
* language: ?string,
* channelsCount: ?number,
* pixelAspectRatio: ?string,
* width: ?number
* }}
*
* @description
* Contains information about the quality of an audio or video media stream.
*
* @property {?number} audioSamplingRate
* Specifies the maximum sampling rate of the content.
* @property {number} bandwidth
* The bandwidth in bits per second.
* @property {string} codecs
* The Stream's codecs, e.g., 'avc1.4d4015' or 'vp9', which must be
* compatible with the Stream's MIME type.
* @property {string} contentType
* The type of content, which may be "video" or "audio".
* @property {?number} frameRate
* The video frame rate.
* @property {?number} height
* The video height in pixels.
* @property {string} mimeType
* The MIME type.
* @property {?string} label
* The stream's label, when available.
* @property {?Array<string>} roles
* The stream's role, when available.
* @property {?string} language
* The stream's language, when available.
* @property {?number} channelsCount
* The number of audio channels, or null if unknown.
* @property {?string} pixelAspectRatio
* The pixel aspect ratio value; e.g. "1:1".
* @property {?number} width
* The video width in pixels.
* @exportDoc
*/
shaka.extern.MediaQualityInfo;
/**
* @typedef {{
* schemeIdUri: string,
* value: string,
* startTime: number,
* endTime: number,
* timescale: number,
* presentationTimeDelta: number,
* eventDuration: number,
* id: number,
* messageData: Uint8Array
* }}
*
* @description
* Contains information about an EMSG MP4 box.
*
* @property {string} schemeIdUri
* Identifies the message scheme.
* @property {string} value
* Specifies the value for the event.
* @property {number} startTime
* The time that the event starts (in presentation time).
* @property {number} endTime
* The time that the event ends (in presentation time).
* @property {number} timescale
* Provides the timescale, in ticks per second.
* @property {number} presentationTimeDelta
* The offset that the event starts, relative to the start of the segment
* this is contained in (in units of timescale).
* @property {number} eventDuration
* The duration of the event (in units of timescale).
* @property {number} id
* A field identifying this instance of the message.
* @property {Uint8Array} messageData
* Body of the message.
* @exportDoc
*/
shaka.extern.EmsgInfo;
/**
* @typedef {{
* wallClockTime: number,
* programStartDate: Date
* }}
*
* @description
* Contains information about an PRFT MP4 box.
*
* @property {number} wallClockTime
* A UTC timestamp corresponding to decoding time in milliseconds.
* @property {Date} programStartDate
* The derived start date of the program.
* @exportDoc
*/
shaka.extern.ProducerReferenceTime;
/**
* @typedef {{
* distinctiveIdentifierRequired: boolean,
* persistentStateRequired: boolean,
* videoRobustness: Array<string>,
* audioRobustness: Array<string>,
* serverCertificate: Uint8Array,
* serverCertificateUri: string,
* individualizationServer: string,
* sessionType: string,
* headers: !Object<string, string>
* }}
*
* @property {boolean} distinctiveIdentifierRequired
* True if the application requires the key system to support distinctive
* identifiers.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} persistentStateRequired
* True if the application requires the key system to support persistent
* state, e.g., for persistent license storage.
* <br>
* Defaults to <code>false</code>.
* @property {Array<string>} videoRobustness
* A key-system-specific Array of strings that specifies a required security
* level for video. For multiple robustness levels, list items in priority
* order.
* <br>
* Defaults to <code>[]</code>, i.e., no specific robustness required.
* @property {Array<string>} audioRobustness
* A key-system-specific Array of strings that specifies a required security
* level for audio. For multiple robustness levels, list items in priority
* order.
* <br>
* Defaults to <code>[]</code>, i.e., no specific robustness required.
* @property {Uint8Array} serverCertificate
* <i>An empty certificate (<code>byteLength==0</code>) will be treated as
* <code>null</code>.</i> <br>
* <i>A certificate will be requested from the license server if
* required.</i> <br>
* A key-system-specific server certificate used to encrypt license requests.
* Its use is optional and is meant as an optimization to avoid a round-trip
* to request a certificate.
* <br>
* Defaults to <code>null</code>.
* @property {string} serverCertificateUri
* If given, will make a request to the given URI to get the server
* certificate. This is ignored if <code>serverCertificate</code> is set.
* <br>
* Defaults to <code>''</code>.
* @property {string} individualizationServer
* The server that handles an <code>'individualization-request'</code>.
* If the server isn't given, it will default to the license server.
* <br>
* Defaults to <code>''</code>.
* @property {string} sessionType
* The MediaKey session type to create streaming licenses with. This doesn't
* affect offline storage.
* <br>
* Defaults to <code>'temporary'</code>.
* @property {!Object<string, string>} headers
* The headers to use in the license request.
* <br>
* Defaults to <code>{}</code>.
*
* @exportDoc
*/
shaka.extern.AdvancedDrmConfiguration;
/**
* @typedef {{
* sessionId: string,
* sessionType: string,
* initData: ?Uint8Array,
* initDataType: ?string
* }}
*
* @description
* DRM Session Metadata for an active session
*
* @property {string} sessionId
* Session id
* @property {string} sessionType
* Session type
* @property {?Uint8Array} initData
* Initialization data in the format indicated by initDataType.
* @property {string} initDataType
* A string to indicate what format initData is in.
* @exportDoc
*/
shaka.extern.DrmSessionMetadata;
/**
* @typedef {{
* sessionId: string,
* initData: ?Uint8Array,
* initDataType: ?string
* }}
*
* @description
* DRM Session Metadata for saved persistent session
*
* @property {string} sessionId
* Session id
* @property {?Uint8Array} initData
* Initialization data in the format indicated by initDataType.
* @property {?string} initDataType
* A string to indicate what format initData is in.
* @exportDoc
*/
shaka.extern.PersistentSessionMetadata;
/**
* @typedef {{
* retryParameters: shaka.extern.RetryParameters,
* servers: !Object<string, string>,
* clearKeys: !Object<string, string>,
* delayLicenseRequestUntilPlayed: boolean,
* persistentSessionOnlinePlayback: boolean,
* persistentSessionsMetadata:
* !Array<shaka.extern.PersistentSessionMetadata>,
* advanced: Object<string, shaka.extern.AdvancedDrmConfiguration>,
* initDataTransform:(shaka.extern.InitDataTransform|undefined),
* logLicenseExchange: boolean,
* updateExpirationTime: number,
* preferredKeySystems: !Array<string>,
* keySystemsMapping: !Object<string, string>,
* parseInbandPsshEnabled: boolean,
* minHdcpVersion: string,
* ignoreDuplicateInitData: boolean,
* defaultAudioRobustnessForWidevine: string,
* defaultVideoRobustnessForWidevine: string
* }}
*
* @property {shaka.extern.RetryParameters} retryParameters
* Retry parameters for license requests.
* @property {!Object<string, string>} servers
* <i>Required for all but the clear key CDM.</i> <br>
* A dictionary which maps key system IDs to their license servers.
* For example,
* <code>{'com.widevine.alpha': 'https://example.com/drm'}</code>.
* <br>
* Defaults to <code>{}</code>.
* @property {!Object<string, string>} clearKeys
* <i>Forces the use of the Clear Key CDM.</i>
* A map of key IDs (hex or base64) to keys (hex or base64).
* <br>
* Defaults to <code>{}</code>.
* @property {boolean} delayLicenseRequestUntilPlayed
* True to configure drm to delay sending a license request until a user
* actually starts playing content.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} persistentSessionOnlinePlayback
* True to configure drm to try playback with given persistent session ids
* before requesting a license. Also prevents the session removal at playback
* stop, as-to be able to re-use it later.
* <br>
* Defaults to <code>false</code>.
* @property {!Array<PersistentSessionMetadata>} persistentSessionsMetadata
* Persistent sessions metadata to load before starting playback.
* <br>
* Defaults to <code>[]</code>.
* @property {Object<string, shaka.extern.AdvancedDrmConfiguration>} advanced
* <i>Optional.</i> <br>
* A dictionary which maps key system IDs to advanced DRM configuration for
* those key systems.
* <br>
* Defaults to <code>[]</code>.
* @property {shaka.extern.InitDataTransform|undefined} initDataTransform
* <i>Optional.</i><br>
* If given, this function is called with the init data from the
* manifest/media and should return the (possibly transformed) init data to
* pass to the browser.
* @property {boolean} logLicenseExchange
* <i>Optional.</i><br>
* If set to <code>true</code>, prints logs containing the license exchange.
* This includes the init data, request, and response data, printed as base64
* strings. Don't use in production, for debugging only; has no affect in
* release builds as logging is removed.
* <br>
* Defaults to <code>false</code>.
* @property {number} updateExpirationTime
* The frequency in seconds with which to check the expiration of a session.
* <br>
* Defaults to <code>1</code>.
* @property {!Array<string>} preferredKeySystems
* Specifies the priorities of available DRM key systems.
* <br>
* Defaults <code>['com.microsoft.playready']</code> on Xbox One and
* PlayStation 4, and <code>[]</code> for all other browsers.
* @property {Object<string, string>} keySystemsMapping
* A map of key system name to key system name.
* <br>
* Defaults to <code>{}</code>.
* @property {boolean} parseInbandPsshEnabled
* When true parse DRM init data from pssh boxes in media and init segments
* and ignore 'encrypted' events.
* This is required when using in-band key rotation on Xbox One.
* <br>
* Defaults to <code>true</code> on Xbox One, and <code>false</code> for all
* other browsers.
* @property {string} minHdcpVersion
* Indicates the minimum version of HDCP to start the playback of encrypted
* streams. <b>May be ignored if not supported by the device.</b>
* <br>
* Defaults to <code>''</code>, do not check the HDCP version.
* @property {boolean} ignoreDuplicateInitData
* When true indicate that the player doesn't ignore duplicate init data.
* Note: Tizen 2015 and 2016 models will send multiple webkitneedkey events
* with the same init data. If the duplicates are suppressed, playback
* will stall without errors.
* <br>
* Defaults to <code>false</code> on Tizen 2, and <code>true</code> for all
* other browsers.
* @property {string} defaultAudioRobustnessForWidevine
* Specify the default audio security level for Widevine when audio robustness
* is not specified.
* <br>
* Defaults to <code>'SW_SECURE_CRYPTO'</code>.
* @property {string} defaultVideoRobustnessForWidevine
* Specify the default video security level for Widevine when video robustness
* is not specified.
* <br>
* Defaults to <code>'SW_SECURE_DECODE'</code>.
* @exportDoc
*/
shaka.extern.DrmConfiguration;
/**
* @typedef {function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array}
*
* @description
* A callback function to handle custom content ID signaling for FairPlay
* content.
*
* @exportDoc
*/
shaka.extern.InitDataTransform;
/**
* @typedef {{
* tagName: !string,
* attributes: !Object<string, string>,
* children: !Array<shaka.extern.xml.Node | string>,
* parent: ?shaka.extern.xml.Node
* }}
*
* @description
* Data structure for xml nodes as simple objects
*
* @property {!string} tagName
* The name of the element
* @property {!object} attributes
* The attributes of the element
* @property {!Array<shaka.extern.xml.Node | string>} children
* The child nodes or string body of the element
* @property {?shaka.extern.xml.Node} parent
* The parent of the current element
*
* @exportDoc
*/
shaka.extern.xml.Node;
/**
* @typedef {{
* clockSyncUri: string,
* disableXlinkProcessing: boolean,
* xlinkFailGracefully: boolean,
* ignoreMinBufferTime: boolean,
* autoCorrectDrift: boolean,
* initialSegmentLimit: number,
* ignoreSuggestedPresentationDelay: boolean,
* ignoreEmptyAdaptationSet: boolean,
* ignoreMaxSegmentDuration: boolean,
* keySystemsByURI: !Object<string, string>,
* manifestPreprocessor: function(!Element),
* manifestPreprocessorTXml: function(!shaka.extern.xml.Node),
* sequenceMode: boolean,
* multiTypeVariantsAllowed: boolean,
* useStreamOnceInPeriodFlattening: boolean,
* enableFastSwitching: boolean
* }}
*
* @property {string} clockSyncUri
* A default clock sync URI to be used with live streams which do not
* contain any clock sync information. The <code>Date</code> header from this
* URI will be used to determine the current time.
* <br>
* Defaults to <code>''</code>.
* @property {boolean} disableXlinkProcessing
* If true, xlink-related processing will be disabled.
* <br>
* Defaults to <code>true</code>.
* @property {boolean} xlinkFailGracefully
* If true, xlink-related errors will result in a fallback to the tag's
* existing contents. If false, xlink-related errors will be propagated
* to the application and will result in a playback failure.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} ignoreMinBufferTime
* If true will cause DASH parser to ignore <code>minBufferTime</code> from
* manifest.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} autoCorrectDrift
* If <code>true</code>, ignore the <code>availabilityStartTime</code> in the
* manifest and instead use the segments to determine the live edge. This
* allows us to play streams that have a lot of drift. If <code>false</code>,
* we can't play content where the manifest specifies segments in the future.
* <br>
* Defaults to <code>true</code>.
* @property {number} initialSegmentLimit
* The maximum number of initial segments to generate for
* <code>SegmentTemplate</code> with fixed-duration segments. This is limited
* to avoid excessive memory consumption with very large
* <code>timeShiftBufferDepth</code> values.
* <br>
* Defaults to <code>1000</code>.
* @property {boolean} ignoreSuggestedPresentationDelay
* If true will cause DASH parser to ignore
* <code>suggestedPresentationDelay</code> from manifest.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} ignoreEmptyAdaptationSet
* If true will cause DASH parser to ignore
* empty <code>AdaptationSet</code> from manifest.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} ignoreMaxSegmentDuration
* If true will cause DASH parser to ignore
* <code>maxSegmentDuration</code> from manifest.
* <br>
* Defaults to <code>false</code>.
* @property {Object<string, string>} keySystemsByURI
* A map of scheme URI to key system name. Defaults to default key systems
* mapping handled by Shaka.
* @property {function(!Element)} manifestPreprocessor
* <b>DEPRECATED</b>: Use manifestPreprocessorTXml instead.
* Called immediately after the DASH manifest has been parsed into an
* XMLDocument. Provides a way for applications to perform efficient
* preprocessing of the manifest.
* @property {function(!shaka.extern.xml.Node)} manifestPreprocessorTXml
* Called immediately after the DASH manifest has been parsed into an
* XMLDocument. Provides a way for applications to perform efficient
* preprocessing of the manifest.
* @property {boolean} sequenceMode
* If true, the media segments are appended to the SourceBuffer in
* "sequence mode" (ignoring their internal timestamps).
* <br>
* Defaults to <code>false</code>.
* @property {boolean} multiTypeVariantsAllowed
* If true, the manifest parser will create variants that have multiple
* mimeTypes or codecs for video or for audio if there is no other choice.
* Meant for content where some periods are only available in one mimeType or
* codec, and other periods are only available in a different mimeType or
* codec. For example, a stream with baked-in ads where the audio codec does
* not match the main content.
* Might result in undesirable behavior if mediaSource.codecSwitchingStrategy
* is not set to SMOOTH.
* <br>
* Defaults to true if SMOOTH codec switching is supported, RELOAD overwise.
* @property {boolean} useStreamOnceInPeriodFlattening
* If period combiner is used, this option ensures every stream is used
* only once in period flattening. It speeds up underlying algorithm
* but may raise issues if manifest does not have stream consistency
* between periods.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} enableFastSwitching
* If false, disables fast switching track recognition.
* <br>
* Defaults to <code>true</code>.
* @exportDoc
*/
shaka.extern.DashManifestConfiguration;
/**
* @typedef {{
* ignoreTextStreamFailures: boolean,
* ignoreImageStreamFailures: boolean,
* defaultAudioCodec: string,
* defaultVideoCodec: string,
* ignoreManifestProgramDateTime: boolean,
* ignoreManifestProgramDateTimeForTypes: !Array<string>,
* mediaPlaylistFullMimeType: string,
* liveSegmentsDelay: number,
* sequenceMode: boolean,
* ignoreManifestTimestampsInSegmentsMode: boolean,
* disableCodecGuessing: boolean,
* disableClosedCaptionsDetection: boolean,
* allowLowLatencyByteRangeOptimization: boolean,
* allowRangeRequestsToGuessMimeType: boolean
* }}
*
* @property {boolean} ignoreTextStreamFailures
* If <code>true</code>, ignore any errors in a text stream and filter out
* those streams.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} ignoreImageStreamFailures
* If <code>true</code>, ignore any errors in a image stream and filter out
* those streams.
* <br>
* Defaults to <code>false</code>.
* @property {string} defaultAudioCodec
* The default audio codec if it is not specified in the HLS playlist.
* <br>
* Defaults to <code>'mp4a.40.2'</code>.
* @property {string} defaultVideoCodec
* The default video codec if it is not specified in the HLS playlist.
* <br>
* Defaults to <code>'avc1.42E01E'</code>.
* @property {boolean} ignoreManifestProgramDateTime
* If <code>true</code>, the HLS parser will ignore the
* <code>EXT-X-PROGRAM-DATE-TIME</code> tags in the manifest and use media
* sequence numbers instead. It also causes EXT-X-DATERANGE tags to be
* ignored. Meant for streams where <code>EXT-X-PROGRAM-DATE-TIME</code> is
* incorrect or malformed.
* <br>
* Defaults to <code>false</code>.
* @property {!Array<string>} ignoreManifestProgramDateTimeForTypes
* An array of strings representing types for which
* <code>EXT-X-PROGRAM-DATE-TIME</code> should be ignored. Only used if the
* the main ignoreManifestProgramDateTime is set to false.
* For example, setting this to ['text', 'video'] will cause the PDT values
* text and video streams to be ignored, while still using the PDT values for
* audio.
* <br>
* Defaults to <code>[]</code>.
* @property {string} mediaPlaylistFullMimeType
* A string containing a full mime type, including both the basic mime type
* and also the codecs. Used when the HLS parser parses a media playlist
* directly, required since all of the mime type and codecs information is
* contained within the master playlist.
* You can use the <code>shaka.util.MimeUtils.getFullType()</code> utility to
* format this value.
* <br>
* Defaults to <code>'video/mp2t; codecs="avc1.42E01E, mp4a.40.2"'</code>.
* @property {number} liveSegmentsDelay
* The default presentation delay will be calculated as a number of segments.
* This is the number of segments for this calculation.
* <br>
* Defaults to <code>3</code>.
* @property {boolean} sequenceMode
* If true, the media segments are appended to the SourceBuffer in
* "sequence mode" (ignoring their internal timestamps).
* <br>
* Defaults to <code>true</code> except on WebOS 3, Tizen 2,
* Tizen 3 and PlayStation 4 whose default value is <code>false</code>.
* @property {boolean} ignoreManifestTimestampsInSegmentsMode
* If true, don't adjust the timestamp offset to account for manifest
* segment durations being out of sync with segment durations. In other
* words, assume that there are no gaps in the segments when appending
* to the SourceBuffer, even if the manifest and segment times disagree.
* Only applies when sequenceMode is <code>false</code>.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} disableCodecGuessing
* If set to true, the HLS parser won't automatically guess or assume default
* codec for playlists with no "CODECS" attribute. Instead, it will attempt to
* extract the missing information from the media segment.
* As a consequence, lazy-loading media playlists won't be possible for this
* use case, which may result in longer video startup times.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} disableClosedCaptionsDetection
* If true, disables the automatic detection of closed captions.
* Otherwise, in the absence of a EXT-X-MEDIA tag w