Last active
February 4, 2018 11:07
-
-
Save niklaskorz/67d1a4931d503f6f40bcfc69a1dfa4c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare namespace shaka { | |
namespace media { | |
/** | |
* Creates an InitSegmentReference, which provides the location to an initialization segment. | |
*/ | |
class InitSegmentReference { | |
/** | |
* Creates an InitSegmentReference, which provides the location to an initialization segment. | |
* @param uris A function that creates the URIs of the resource containing the segment. | |
* @param startByte The offset from the start of the resource to the start of the segment. | |
* @param endByte The offset from the start of the resource to the end of the segment, inclusive. null indicates that the segment extends to the end of the resource. | |
*/ | |
constructor(uris: (() => string[]), startByte: number, endByte: number | null); | |
/** | |
* Creates the URIs of the resource containing the segment. | |
*/ | |
createUris(): string[]; | |
/** | |
* Returns the offset from the start of the resource to the start of the segment. | |
*/ | |
getStartByte(): number; | |
/** | |
* Returns the offset from the start of the resource to the end of the segment, inclusive. null indicates that the segment extends to the end of the resource. | |
*/ | |
getEndByte(): number | null; | |
} | |
/** | |
* Creates a SegmentReference, which provides the start time, end time, and location to a media segment. | |
*/ | |
class SegmentReference { | |
/** | |
* Creates a SegmentReference, which provides the start time, end time, and location to a media segment. | |
* @param position The segment's position within a particular Period. The following should hold true between any two SegmentReferences from the same Period, r1 and r2: IF r2.position > r1.position THEN [ (r2.startTime > r1.startTime) OR (r2.startTime == r1.startTime AND r2.endTime >= r1.endTime) ] | |
* @param startTime The segment's start time in seconds, relative to the start of a particular Period. | |
* @param endTime The segment's end time in seconds, relative to the start of a particular Period. The segment ends the instant before this time, so |endTime| must be strictly greater than |startTime|. | |
* @param uris A function that creates the URIs of the resource containing the segment. | |
* @param startByte The offset from the start of the resource to the start of the segment. | |
* @param endByte The offset from the start of the resource to the end of the segment, inclusive. null indicates that the segment extends to the end of the resource. | |
*/ | |
constructor(position: number, startTime: number, endTime: number, uris: (() => string[]), startByte: number, endByte: number | null); | |
/** | |
* Returns the segment's position within a particular Period. | |
* @returnType The segment's position. | |
*/ | |
getPosition(): number; | |
/** | |
* Returns the segment's start time in seconds, relative to the start of a particular Period. | |
*/ | |
getStartTime(): number; | |
/** | |
* Returns the segment's end time in seconds, relative to the start of a particular Period. | |
*/ | |
getEndTime(): number; | |
/** | |
* Creates the URIs of the resource containing the segment. | |
*/ | |
createUris(): string[]; | |
/** | |
* Returns the offset from the start of the resource to the start of the segment. | |
*/ | |
getStartByte(): number; | |
/** | |
* Returns the offset from the start of the resource to the end of the segment, inclusive. null indicates that the segment extends to the end of the resource. | |
*/ | |
getEndByte(): number | null; | |
} | |
namespace ManifestParser { | |
/** | |
* Registers a manifest parser by file extension. | |
* @param extension The file extension of the manifest. | |
* @param parserFactory The factory used to create parser instances. | |
*/ | |
function registerParserByExtension(extension: string, parserFactory: shakaExtern.ManifestParser.Factory): void; | |
/** | |
* Registers a manifest parser by MIME type. | |
* @param mimeType The MIME type of the manifest. | |
* @param parserFactory The factory used to create parser instances. | |
*/ | |
function registerParserByMime(mimeType: string, parserFactory: shakaExtern.ManifestParser.Factory): void; | |
} | |
/** | |
* Creates a SegmentIndex. | |
*/ | |
class SegmentIndex implements shaka.util.IDestroyable { | |
/** | |
* Creates a SegmentIndex. | |
* @param references The list of SegmentReferences, which must be sorted first by their start times (ascending) and second by their end times (ascending), and have continuous, increasing positions. | |
*/ | |
constructor(references: shaka.media.SegmentReference[]); | |
destroy(): Promise<void>; | |
/** | |
* Finds the position of the segment for the given time, in seconds, relative to the start of a particular Period. Returns the position of the segment with the largest end time if more than one segment is known for the given time. | |
* @returnType The position of the segment, or null if the position of the segment could not be determined. | |
*/ | |
find(time: number): number | null; | |
/** | |
* Gets the SegmentReference for the segment at the given position. | |
* @param position The position of the segment. | |
* @returnType The SegmentReference, or null if no such SegmentReference exists. | |
*/ | |
get(position: number): shaka.media.SegmentReference | null; | |
/** | |
* Offset all segment references by a fixed amount. | |
* @param offset The amount to add to each segment's start and end times. | |
*/ | |
offset(offset: number): void; | |
/** | |
* Merges the given SegmentReferences. Supports extending the original references only. Will not replace old references or interleave new ones. | |
* @param references The list of SegmentReferences, which must be sorted first by their start times (ascending) and second by their end times (ascending), and have continuous, increasing positions. | |
*/ | |
merge(references: shaka.media.SegmentReference[]): void; | |
/** | |
* Removes all SegmentReferences that end before the given time. | |
* @param time The time in seconds. | |
*/ | |
evict(time: number): void; | |
} | |
/** | |
* Creates a PresentationTimeline. | |
*/ | |
class PresentationTimeline { | |
/** | |
* Creates a PresentationTimeline. | |
* @param presentationStartTime The wall-clock time, in seconds, when the presentation started or will start. Only required for live. | |
* @param presentationDelay The delay to give the presentation, in seconds. Only required for live. | |
*/ | |
constructor(presentationStartTime: number | null, presentationDelay: number); | |
/** | |
* @returnType The presentation's duration in seconds. Infinity indicates that the presentation continues indefinitely. | |
*/ | |
getDuration(): number; | |
/** | |
* Sets the presentation's duration. | |
* @param duration The presentation's duration in seconds. Infinity indicates that the presentation continues indefinitely. | |
*/ | |
setDuration(duration: number): void; | |
/** | |
* @returnType The presentation's start time in seconds. | |
*/ | |
getPresentationStartTime(): number | null; | |
/** | |
* Sets the clock offset, which is the the difference between the client's clock and the server's clock, in milliseconds (i.e., serverTime = Date.now() + clockOffset). | |
* @param offset The clock offset, in ms. | |
*/ | |
setClockOffset(offset: number): void; | |
/** | |
* Sets the presentation's static flag. | |
* @param isStatic If true, the presentation is static, meaning all segments are available at once. | |
*/ | |
setStatic(isStatic: boolean): void; | |
/** | |
* Gets the presentation's segment availability duration, which is the amount of time, in seconds, that the start of a segment remains available after the live-edge moves past the end of that segment. Infinity indicates that segments remain available indefinitely. For example, if your live presentation has a 5 minute DVR window and your segments are 10 seconds long then the segment availability duration should be 4 minutes and 50 seconds. | |
* @returnType The presentation's segment availability duration. | |
*/ | |
getSegmentAvailabilityDuration(): number; | |
/** | |
* Sets the presentation's segment availability duration. The segment availability duration should only be set for live. | |
* @param segmentAvailabilityDuration The presentation's new segment availability duration in seconds. | |
*/ | |
setSegmentAvailabilityDuration(segmentAvailabilityDuration: number): void; | |
/** | |
* Sets the presentation delay. | |
*/ | |
setDelay(delay: number): void; | |
/** | |
* Gives PresentationTimeline a Stream's segments so it can size and position the segment availability window, and account for missing segment information. This function should be called once for each Stream (no more, no less). | |
*/ | |
notifySegments(periodStartTime: number, references: shaka.media.SegmentReference[]): void; | |
/** | |
* Gives PresentationTimeline a Stream's maximum segment duration so it can size and position the segment availability window. This function should be called once for each Stream (no more, no less), but does not have to be called if notifySegments() is called instead for a particular stream. | |
* @param maxSegmentDuration The maximum segment duration for a particular stream. | |
*/ | |
notifyMaxSegmentDuration(maxSegmentDuration: number): void; | |
/** | |
* @returnType True if the presentation is live; otherwise, return false. | |
*/ | |
isLive(): boolean; | |
/** | |
* @returnType True if the presentation is in progress (meaning not live, but also not completely available); otherwise, return false. | |
*/ | |
isInProgress(): boolean; | |
/** | |
* Gets the presentation's current segment availability start time. Segments ending at or before this time should be assumed to be unavailable. | |
* @returnType The current segment availability start time, in seconds, relative to the start of the presentation. | |
*/ | |
getSegmentAvailabilityStart(): number; | |
/** | |
* Gets the presentation's current segment availability start time, offset by the given amount. This is used to ensure that we don't "fall" back out of the availability window while we are buffering. | |
* @param offset The offset to add to the start time. | |
* @returnType The current segment availability start time, in seconds, relative to the start of the presentation. | |
*/ | |
getSafeAvailabilityStart(offset: number): number; | |
/** | |
* Sets the presentation's current segment availability start time. | |
*/ | |
setAvailabilityStart(time: number): void; | |
/** | |
* Gets the presentation's current segment availability end time. Segments starting after this time should be assumed to be unavailable. | |
* @returnType The current segment availability end time, in seconds, relative to the start of the presentation. Always returns the presentation's duration for video-on-demand. | |
*/ | |
getSegmentAvailabilityEnd(): number; | |
/** | |
* Gets the seek range end. | |
*/ | |
getSeekRangeEnd(): number; | |
} | |
} | |
namespace util { | |
/** | |
* Creates a new Error. | |
*/ | |
class Error extends Error implements shakaExtern.Error { | |
severity: shaka.util.Error.Severity | null; | |
readonly category: shaka.util.Error.Category | null; | |
readonly code: shaka.util.Error.Code | null; | |
readonly data: any[]; | |
handled: boolean; | |
/** | |
* Creates a new Error. | |
*/ | |
constructor(severity: shaka.util.Error.Severity | null, category: shaka.util.Error.Category | null, code: shaka.util.Error.Code | null, ...var_args: any[]); | |
} | |
namespace Error { | |
enum Severity { | |
RECOVERABLE, | |
CRITICAL, | |
} | |
enum Category { | |
NETWORK, | |
TEXT, | |
MEDIA, | |
MANIFEST, | |
STREAMING, | |
DRM, | |
PLAYER, | |
CAST, | |
STORAGE, | |
} | |
enum Code { | |
UNSUPPORTED_SCHEME, | |
BAD_HTTP_STATUS, | |
HTTP_ERROR, | |
TIMEOUT, | |
MALFORMED_DATA_URI, | |
UNKNOWN_DATA_URI_ENCODING, | |
REQUEST_FILTER_ERROR, | |
RESPONSE_FILTER_ERROR, | |
MALFORMED_TEST_URI, | |
UNEXPECTED_TEST_REQUEST, | |
INVALID_TEXT_HEADER, | |
INVALID_TEXT_CUE, | |
UNABLE_TO_DETECT_ENCODING, | |
BAD_ENCODING, | |
INVALID_XML, | |
INVALID_MP4_TTML, | |
INVALID_MP4_VTT, | |
UNABLE_TO_EXTRACT_CUE_START_TIME, | |
BUFFER_READ_OUT_OF_BOUNDS, | |
JS_INTEGER_OVERFLOW, | |
EBML_OVERFLOW, | |
EBML_BAD_FLOATING_POINT_SIZE, | |
MP4_SIDX_WRONG_BOX_TYPE, | |
MP4_SIDX_INVALID_TIMESCALE, | |
MP4_SIDX_TYPE_NOT_SUPPORTED, | |
WEBM_CUES_ELEMENT_MISSING, | |
WEBM_EBML_HEADER_ELEMENT_MISSING, | |
WEBM_SEGMENT_ELEMENT_MISSING, | |
WEBM_INFO_ELEMENT_MISSING, | |
WEBM_DURATION_ELEMENT_MISSING, | |
WEBM_CUE_TRACK_POSITIONS_ELEMENT_MISSING, | |
WEBM_CUE_TIME_ELEMENT_MISSING, | |
MEDIA_SOURCE_OPERATION_FAILED, | |
MEDIA_SOURCE_OPERATION_THREW, | |
VIDEO_ERROR, | |
QUOTA_EXCEEDED_ERROR, | |
UNABLE_TO_GUESS_MANIFEST_TYPE, | |
DASH_INVALID_XML, | |
DASH_NO_SEGMENT_INFO, | |
DASH_EMPTY_ADAPTATION_SET, | |
DASH_EMPTY_PERIOD, | |
DASH_WEBM_MISSING_INIT, | |
DASH_UNSUPPORTED_CONTAINER, | |
DASH_PSSH_BAD_ENCODING, | |
DASH_NO_COMMON_KEY_SYSTEM, | |
DASH_MULTIPLE_KEY_IDS_NOT_SUPPORTED, | |
DASH_CONFLICTING_KEY_IDS, | |
UNPLAYABLE_PERIOD, | |
RESTRICTIONS_CANNOT_BE_MET, | |
NO_PERIODS, | |
HLS_PLAYLIST_HEADER_MISSING, | |
INVALID_HLS_TAG, | |
HLS_INVALID_PLAYLIST_HIERARCHY, | |
DASH_DUPLICATE_REPRESENTATION_ID, | |
HLS_MULTIPLE_MEDIA_INIT_SECTIONS_FOUND, | |
HLS_COULD_NOT_GUESS_MIME_TYPE, | |
HLS_MASTER_PLAYLIST_NOT_PROVIDED, | |
HLS_REQUIRED_ATTRIBUTE_MISSING, | |
HLS_REQUIRED_TAG_MISSING, | |
HLS_COULD_NOT_GUESS_CODECS, | |
HLS_KEYFORMATS_NOT_SUPPORTED, | |
DASH_UNSUPPORTED_XLINK_ACTUATE, | |
DASH_XLINK_DEPTH_LIMIT, | |
HLS_COULD_NOT_PARSE_SEGMENT_START_TIME, | |
INVALID_STREAMS_CHOSEN, | |
NO_RECOGNIZED_KEY_SYSTEMS, | |
REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE, | |
FAILED_TO_CREATE_CDM, | |
FAILED_TO_ATTACH_TO_VIDEO, | |
INVALID_SERVER_CERTIFICATE, | |
FAILED_TO_CREATE_SESSION, | |
FAILED_TO_GENERATE_LICENSE_REQUEST, | |
LICENSE_REQUEST_FAILED, | |
LICENSE_RESPONSE_REJECTED, | |
ENCRYPTED_CONTENT_WITHOUT_DRM_INFO, | |
NO_LICENSE_SERVER_GIVEN, | |
OFFLINE_SESSION_REMOVED, | |
EXPIRED, | |
LOAD_INTERRUPTED, | |
OPERATION_ABORTED, | |
CAST_API_UNAVAILABLE, | |
NO_CAST_RECEIVERS, | |
ALREADY_CASTING, | |
UNEXPECTED_CAST_ERROR, | |
CAST_CANCELED_BY_USER, | |
CAST_CONNECTION_TIMED_OUT, | |
CAST_RECEIVER_APP_UNAVAILABLE, | |
STORAGE_NOT_SUPPORTED, | |
INDEXED_DB_ERROR, | |
DEPRECATED_OPERATION_ABORTED, | |
REQUESTED_ITEM_NOT_FOUND, | |
MALFORMED_OFFLINE_URI, | |
CANNOT_STORE_LIVE_OFFLINE, | |
STORE_ALREADY_IN_PROGRESS, | |
NO_INIT_DATA_FOR_OFFLINE, | |
LOCAL_PLAYER_INSTANCE_REQUIRED, | |
CONTENT_UNSUPPORTED_BY_BROWSER, | |
UNSUPPORTED_UPGRADE_REQUEST, | |
} | |
} | |
namespace StringUtils { | |
/** | |
* Creates a string from the given buffer as UTF-8 encoding. | |
*/ | |
function fromUTF8(data: BufferSource | null): string; | |
/** | |
* Creates a string from the given buffer as UTF-16 encoding. | |
* @param littleEndian true to read little endian, false to read big. | |
* @param opt_noThrow true to avoid throwing in cases where we may expect invalid input. If noThrow is true and the data has an odd length, it will be truncated. | |
*/ | |
function fromUTF16(data: BufferSource | null, littleEndian: boolean, opt_noThrow?: boolean): string; | |
/** | |
* Creates a string from the given buffer, auto-detecting the encoding that is being used. If it cannot detect the encoding, it will throw an exception. | |
*/ | |
function fromBytesAutoDetect(data: BufferSource | null): string; | |
/** | |
* Creates a ArrayBuffer from the given string, converting to UTF-8 encoding. | |
*/ | |
function toUTF8(str: string): ArrayBuffer; | |
} | |
/** | |
* Creates a DataViewReader, which abstracts a DataView object. | |
*/ | |
class DataViewReader { | |
/** | |
* Creates a DataViewReader, which abstracts a DataView object. | |
* @param dataView The DataView. | |
* @param endianness The endianness. | |
*/ | |
constructor(dataView: DataView, endianness: shaka.util.DataViewReader.Endianness | null); | |
/** | |
* @returnType True if the reader has more data, false otherwise. | |
*/ | |
hasMoreData(): boolean; | |
/** | |
* Gets the current byte position. | |
*/ | |
getPosition(): number; | |
/** | |
* Gets the byte length of the DataView. | |
*/ | |
getLength(): number; | |
/** | |
* Reads an unsigned 8 bit integer, and advances the reader. | |
* @returnType The integer. | |
*/ | |
readUint8(): number; | |
/** | |
* Reads an unsigned 16 bit integer, and advances the reader. | |
* @returnType The integer. | |
*/ | |
readUint16(): number; | |
/** | |
* Reads an unsigned 32 bit integer, and advances the reader. | |
* @returnType The integer. | |
*/ | |
readUint32(): number; | |
/** | |
* Reads a signed 32 bit integer, and advances the reader. | |
* @returnType The integer. | |
*/ | |
readInt32(): number; | |
/** | |
* Reads an unsigned 64 bit integer, and advances the reader. | |
* @returnType The integer. | |
*/ | |
readUint64(): number; | |
/** | |
* Reads the specified number of raw bytes. | |
* @param bytes The number of bytes to read. | |
*/ | |
readBytes(bytes: number): Uint8Array; | |
/** | |
* Skips the specified number of bytes. | |
* @param bytes The number of bytes to skip. | |
*/ | |
skip(bytes: number): void; | |
/** | |
* Rewinds the specified number of bytes. | |
* @param bytes The number of bytes to rewind. | |
*/ | |
rewind(bytes: number): void; | |
/** | |
* Seeks to a specified position. | |
* @param position The desired byte position within the DataView. | |
*/ | |
seek(position: number): void; | |
/** | |
* Keeps reading until it reaches a byte that equals to zero. The text is assumed to be UTF-8. | |
*/ | |
readTerminatedString(): string; | |
} | |
namespace DataViewReader { | |
/** | |
* Endianness. | |
*/ | |
enum Endianness { | |
BIG_ENDIAN, | |
LITTLE_ENDIAN, | |
} | |
} | |
/** | |
* Create a new MP4 Parser | |
*/ | |
class Mp4Parser { | |
/** | |
* A callback that tells the Mp4 parser to treat the body of a box as a series of boxes. The number of boxes is limited by the size of the parent box. | |
*/ | |
static children(box: shaka.util.Mp4Parser.ParsedBox): void; | |
/** | |
* A callback that tells the Mp4 parser to treat the body of a box as a sample description. A sample description box has a fixed number of children. The number of children is represented by a 4 byte unsigned integer. Each child is a box. | |
*/ | |
static sampleDescription(box: shaka.util.Mp4Parser.ParsedBox): void; | |
/** | |
* Create a callback that tells the Mp4 parser to treat the body of a box as a binary blob and how to handle it. | |
*/ | |
static allData(callback: ((p0: Uint8Array) => void)): shaka.util.Mp4Parser.CallbackType; | |
/** | |
* Create a new MP4 Parser | |
*/ | |
constructor(); | |
/** | |
* Delcare a box type as a Box. | |
*/ | |
box(type: string, definition: shaka.util.Mp4Parser.CallbackType): shaka.util.Mp4Parser; | |
/** | |
* Declare a box type as a Full Box. | |
*/ | |
fullBox(type: string, definition: shaka.util.Mp4Parser.CallbackType): shaka.util.Mp4Parser; | |
/** | |
* Stop parsing. Useful for extracting information from partial segments and avoiding an out-of-bounds error once you find what you are looking for. | |
*/ | |
stop(): void; | |
/** | |
* Parse the given data using the added callbacks. | |
* @param opt_partialOkay If true, allow partial payload for some boxes. If the goal is a child box, we can sometimes find it without enough data to find all child boxes. | |
*/ | |
parse(data: BufferSource, opt_partialOkay?: boolean): void; | |
/** | |
* Parse the next box on the current level. | |
* @param absStart The absolute start position in the original byte array. | |
* @param opt_partialOkay If true, allow partial payload for some boxes. If the goal is a child box, we can sometimes find it without enough data to find all child boxes. | |
*/ | |
parseNext(absStart: number, reader: shaka.util.DataViewReader, opt_partialOkay?: boolean): void; | |
} | |
namespace Mp4Parser { | |
interface ParsedBox { | |
/** | |
* The parser that parsed this box. The parser can be used to parse child boxes where the configuration of the current parser is needed to parsed other boxes. | |
*/ | |
parser: shaka.util.Mp4Parser; | |
/** | |
* If true, allow partial payload for some boxes. If the goal is a child box, we can sometimes find it without enough data to find all child boxes. This property allows the opt_partialOkay flag from parse() to be propagated through methods like children(). | |
*/ | |
partialOkay: boolean; | |
/** | |
* The start of this box (before the header) in the original buffer. This start position is the absolute position. | |
*/ | |
start: number; | |
/** | |
* The size of this box (including the header). | |
*/ | |
size: number; | |
/** | |
* The version for a full box, null for basic boxes. | |
*/ | |
version: number | null; | |
/** | |
* The flags for a full box, null for basic boxes. | |
*/ | |
flags: number | null; | |
/** | |
* The reader for this box is only for this box. Reading or not reading to the end will have no affect on the parser reading other sibling boxes. | |
*/ | |
reader: shaka.util.DataViewReader; | |
} | |
type CallbackType = ((p0: shaka.util.Mp4Parser.ParsedBox) => void); | |
} | |
/** | |
* An interface to standardize how objects are destroyed. | |
*/ | |
interface IDestroyable { | |
/** | |
* Destroys the object, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected. | |
*/ | |
destroy(): Promise<void>; | |
} | |
/** | |
* A work-alike for EventTarget. Only DOM elements may be true EventTargets, but this can be used as a base class to provide event dispatch to non-DOM classes. Only FakeEvents should be dispatched. | |
*/ | |
class FakeEventTarget implements EventTarget { | |
/** | |
* A work-alike for EventTarget. Only DOM elements may be true EventTargets, but this can be used as a base class to provide event dispatch to non-DOM classes. Only FakeEvents should be dispatched. | |
*/ | |
constructor(); | |
/** | |
* Add an event listener to this object. | |
* @param type The event type to listen for. | |
* @param listener The callback or listener object to invoke. | |
* @param opt_options Ignored. | |
*/ | |
addEventListener(type: string, listener: shaka.util.FakeEventTarget.ListenerType | null, opt_options?: AddEventListenerOptions | boolean): void; | |
/** | |
* Remove an event listener from this object. | |
* @param type The event type for which you wish to remove a listener. | |
* @param listener The callback or listener object to remove. | |
* @param opt_options Ignored. | |
*/ | |
removeEventListener(type: string, listener: shaka.util.FakeEventTarget.ListenerType | null, opt_options?: EventListenerOptions | boolean | null): void; | |
/** | |
* Dispatch an event from this object. | |
* @param event The event to be dispatched from this object. | |
* @returnType True if the default action was prevented. | |
*/ | |
dispatchEvent(event: Event): boolean; | |
} | |
namespace FakeEventTarget { | |
/** | |
* These are the listener types defined in the closure extern for EventTarget. | |
*/ | |
type ListenerType = EventListener | ((p0: Event) => boolean | undefined); | |
} | |
namespace Uint8ArrayUtils { | |
/** | |
* Convert a Uint8Array to a base64 string. The output will always use the alternate encoding/alphabet also known as "base64url". | |
* @param opt_padding If true, pad the output with equals signs. Defaults to true. | |
*/ | |
function toBase64(arr: Uint8Array, opt_padding?: boolean): string; | |
/** | |
* Convert a base64 string to a Uint8Array. Accepts either the standard alphabet or the alternate "base64url" alphabet. | |
*/ | |
function fromBase64(str: string): Uint8Array; | |
/** | |
* Convert a hex string to a Uint8Array. | |
*/ | |
function fromHex(str: string): Uint8Array; | |
/** | |
* Convert a Uint8Array to a hex string. | |
*/ | |
function toHex(arr: Uint8Array): string; | |
/** | |
* Compare two Uint8Arrays for equality. | |
*/ | |
function equal(arr1: Uint8Array | null, arr2: Uint8Array | null): boolean; | |
/** | |
* Concatenate Uint8Arrays. | |
*/ | |
function concat(...var_args: Uint8Array[]): Uint8Array | null; | |
} | |
} | |
namespace polyfill { | |
/** | |
* Install all polyfills. | |
*/ | |
function installAll(): void; | |
/** | |
* Registers a new polyfill to be installed. | |
*/ | |
function register(polyfill: (() => void)): void; | |
} | |
namespace cast { | |
/** | |
* A proxy to switch between local and remote playback for Chromecast in a way that is transparent to the app's controls. | |
*/ | |
class CastProxy extends shaka.util.FakeEventTarget implements shaka.util.IDestroyable { | |
/** | |
* A proxy to switch between local and remote playback for Chromecast in a way that is transparent to the app's controls. | |
* @param video The local video element associated with the local Player instance. | |
* @param player A local Player instance. | |
* @param receiverAppId The ID of the cast receiver application. | |
*/ | |
constructor(video: HTMLMediaElement, player: shaka.Player, receiverAppId: string); | |
/** | |
* Destroys the proxy and the underlying local Player. | |
* @param opt_forceDisconnect If true, force the receiver app to shut down by disconnecting. Does nothing if not connected. | |
*/ | |
destroy(opt_forceDisconnect?: boolean): Promise<void>; | |
/** | |
* Get a proxy for the video element that delegates to local and remote video elements as appropriate. | |
*/ | |
getVideo(): HTMLMediaElement | null; | |
/** | |
* Get a proxy for the Player that delegates to local and remote Player objects as appropriate. | |
*/ | |
getPlayer(): shaka.Player | null; | |
/** | |
* @returnType True if the cast API is available and there are receivers. | |
*/ | |
canCast(): boolean; | |
/** | |
* @returnType True if we are currently casting. | |
*/ | |
isCasting(): boolean; | |
/** | |
* @returnType The name of the Cast receiver device, if isCasting(). | |
*/ | |
receiverName(): string; | |
/** | |
* @returnType Resolved when connected to a receiver. Rejected if the connection fails or is canceled by the user. | |
*/ | |
cast(): Promise<void>; | |
/** | |
* Set application-specific data. | |
* @param appData Application-specific data to relay to the receiver. | |
*/ | |
setAppData(appData: object | null): void; | |
/** | |
* Show a dialog where user can choose to disconnect from the cast connection. | |
*/ | |
suggestDisconnect(): void; | |
/** | |
* Force the receiver app to shut down by disconnecting. | |
*/ | |
forceDisconnect(): void; | |
} | |
/** | |
* A receiver to communicate between the Chromecast-hosted player and the sender application. | |
*/ | |
class CastReceiver extends shaka.util.FakeEventTarget implements shaka.util.IDestroyable { | |
/** | |
* A receiver to communicate between the Chromecast-hosted player and the sender application. | |
* @param video The local video element associated with the local Player instance. | |
* @param player A local Player instance. | |
* @param opt_appDataCallback A callback to handle application-specific data passed from the sender. | |
* @param opt_contentIdCallback A callback to retrieve manifest URI from the provided content id. | |
*/ | |
constructor(video: HTMLMediaElement, player: shaka.Player, opt_appDataCallback?: ((p0: object | null) => void), opt_contentIdCallback?: ((p0: string) => string)); | |
/** | |
* @returnType True if the cast API is available and there are receivers. | |
*/ | |
isConnected(): boolean; | |
/** | |
* @returnType True if the receiver is not currently doing loading or playing anything. | |
*/ | |
isIdle(): boolean; | |
/** | |
* Destroys the underlying Player, then terminates the cast receiver app. | |
*/ | |
destroy(): Promise<void>; | |
} | |
} | |
namespace text { | |
namespace TextEngine { | |
function registerParser(mimeType: string, plugin: shakaExtern.TextParserPlugin): void; | |
function unregisterParser(mimeType: string): void; | |
namespace prototype { | |
function setDisplayer(displayer: shakaExtern.TextDisplayer | null): void; | |
} | |
} | |
/** | |
* Creates a Cue object. | |
*/ | |
class Cue implements shakaExtern.Cue { | |
startTime: number; | |
endTime: number; | |
payload: string; | |
region: shakaExtern.CueRegion; | |
position: number | null; | |
positionAlign: shaka.text.Cue.positionAlign | null; | |
size: number; | |
textAlign: shaka.text.Cue.textAlign | null; | |
writingDirection: shaka.text.Cue.writingDirection | null; | |
lineInterpretation: shaka.text.Cue.lineInterpretation | null; | |
line: number | null; | |
lineHeight: string; | |
lineAlign: shaka.text.Cue.lineAlign | null; | |
displayAlign: shaka.text.Cue.displayAlign | null; | |
color: string; | |
backgroundColor: string; | |
fontSize: string; | |
fontWeight: shaka.text.Cue.fontWeight | null; | |
fontStyle: shaka.text.Cue.fontStyle | null; | |
fontFamily: string; | |
textDecoration: shaka.text.Cue.textDecoration[]; | |
wrapLine: boolean; | |
id: string; | |
/** | |
* Creates a Cue object. | |
*/ | |
constructor(startTime: number, endTime: number, payload: string); | |
} | |
namespace Cue { | |
enum positionAlign { | |
LEFT, | |
RIGHT, | |
CENTER, | |
AUTO, | |
} | |
enum textAlign { | |
LEFT, | |
RIGHT, | |
CENTER, | |
START, | |
END, | |
} | |
enum displayAlign { | |
BEFORE, | |
CENTER, | |
AFTER, | |
} | |
enum writingDirection { | |
HORIZONTAL_LEFT_TO_RIGHT, | |
HORIZONTAL_RIGHT_TO_LEFT, | |
VERTICAL_LEFT_TO_RIGHT, | |
VERTICAL_RIGHT_TO_LEFT, | |
} | |
enum lineInterpretation { | |
LINE_NUMBER, | |
PERCENTAGE, | |
} | |
enum lineAlign { | |
CENTER, | |
START, | |
END, | |
} | |
/** | |
* In CSS font weight can be a number, where 400 is normal and 700 is bold. Use these values for the enum for consistency. | |
*/ | |
enum fontWeight { | |
NORMAL, | |
BOLD, | |
} | |
enum fontStyle { | |
NORMAL, | |
ITALIC, | |
OBLIQUE, | |
} | |
enum textDecoration { | |
UNDERLINE, | |
LINE_THROUGH, | |
OVERLINE, | |
} | |
} | |
/** | |
* <p> This defines the default text displayer plugin. An instance of this class is used when no custom displayer is given. </p> <p> This class simply converts shaka.text.Cue objects to TextTrackCues and feeds them to the browser. </p> | |
*/ | |
class SimpleTextDisplayer implements shakaExtern.TextDisplayer { | |
/** | |
* <p> This defines the default text displayer plugin. An instance of this class is used when no custom displayer is given. </p> <p> This class simply converts shaka.text.Cue objects to TextTrackCues and feeds them to the browser. </p> | |
*/ | |
constructor(video: HTMLMediaElement | null); | |
remove(start: number, end: number): boolean; | |
append(cues: shaka.text.Cue[]): void; | |
destroy(): void; | |
isTextVisible(): boolean; | |
setTextVisibility(on: boolean): void; | |
} | |
} | |
namespace net { | |
/** | |
* NetworkingEngine wraps all networking operations. This accepts plugins that handle the actual request. A plugin is registered using registerScheme. Each scheme has at most one plugin to handle the request. | |
*/ | |
class NetworkingEngine implements shaka.util.IDestroyable { | |
/** | |
* Registers a scheme plugin. This plugin will handle all requests with the given scheme. If a plugin with the same scheme already exists, it is replaced, unless the existing plugin is of higher priority. If no priority is provided, this defaults to the highest priority of APPLICATION. | |
*/ | |
static registerScheme(scheme: string, plugin: shakaExtern.SchemePlugin, opt_priority?: number): void; | |
/** | |
* Removes a scheme plugin. | |
*/ | |
static unregisterScheme(scheme: string): void; | |
/** | |
* NetworkingEngine wraps all networking operations. This accepts plugins that handle the actual request. A plugin is registered using registerScheme. Each scheme has at most one plugin to handle the request. | |
* @param opt_onSegmentDownloaded Called when a segment is downloaded. Passed the duration, in milliseconds, that the request took; and the total number of bytes transferred. | |
*/ | |
constructor(opt_onSegmentDownloaded?: ((p0: number, p1: number) => void)); | |
/** | |
* Registers a new request filter. All filters are applied in the order they are registered. | |
*/ | |
registerRequestFilter(filter: shakaExtern.RequestFilter): void; | |
/** | |
* Removes a request filter. | |
*/ | |
unregisterRequestFilter(filter: shakaExtern.RequestFilter): void; | |
/** | |
* Clear all request filters. | |
*/ | |
clearAllRequestFilters(): void; | |
/** | |
* Registers a new response filter. All filters are applied in the order they are registered. | |
*/ | |
registerResponseFilter(filter: shakaExtern.ResponseFilter): void; | |
/** | |
* Removes a response filter. | |
*/ | |
unregisterResponseFilter(filter: shakaExtern.ResponseFilter): void; | |
/** | |
* Clear all response filters. | |
*/ | |
clearAllResponseFilters(): void; | |
destroy(): Promise<void>; | |
/** | |
* Makes a network request and returns the resulting data. | |
*/ | |
request(type: shaka.net.NetworkingEngine.RequestType | null, request: shakaExtern.Request): shakaExtern.IAbortableOperation<shakaExtern.Response>; | |
} | |
namespace NetworkingEngine { | |
/** | |
* Request types. Allows a filter to decide which requests to read/alter. | |
*/ | |
enum RequestType { | |
MANIFEST, | |
SEGMENT, | |
LICENSE, | |
APP, | |
} | |
/** | |
* Priority level for network scheme plugins. If multiple plugins are provided for the same scheme, only the highest-priority one is used. | |
*/ | |
enum PluginPriority { | |
FALLBACK, | |
PREFERRED, | |
APPLICATION, | |
} | |
} | |
/** | |
* A networking plugin to handle data URIs. | |
*/ | |
function DataUriPlugin(uri: string, request: shakaExtern.Request): shakaExtern.IAbortableOperation<shakaExtern.Response>; | |
/** | |
* A networking plugin to handle http and https URIs via XHR. | |
*/ | |
function HttpPlugin(uri: string, request: shakaExtern.Request): shakaExtern.IAbortableOperation<shakaExtern.Response>; | |
} | |
namespace abr { | |
/** | |
* <p> This defines the default ABR manager for the Player. An instance of this class is used when no ABR manager is given. </p> <p> The behavior of this class is to take throughput samples using segmentDownloaded to estimate the current network bandwidth. Then it will use that to choose the streams that best fit the current bandwidth. It will always pick the highest bandwidth variant it thinks can be played. </p> <p> After initial choices are made, this class will call switchCallback() when there is a better choice. switchCallback() will not be called more than once per ({@link shaka.abr.SimpleAbrManager.SWITCH_INTERVAL_MS}). </p> | |
*/ | |
class SimpleAbrManager implements shakaExtern.AbrManager { | |
/** | |
* <p> This defines the default ABR manager for the Player. An instance of this class is used when no ABR manager is given. </p> <p> The behavior of this class is to take throughput samples using segmentDownloaded to estimate the current network bandwidth. Then it will use that to choose the streams that best fit the current bandwidth. It will always pick the highest bandwidth variant it thinks can be played. </p> <p> After initial choices are made, this class will call switchCallback() when there is a better choice. switchCallback() will not be called more than once per ({@link shaka.abr.SimpleAbrManager.SWITCH_INTERVAL_MS}). </p> | |
*/ | |
constructor(); | |
stop(): void; | |
init(switchCallback: shakaExtern.AbrManager.SwitchCallback): void; | |
chooseVariant(): shakaExtern.Variant; | |
enable(): void; | |
disable(): void; | |
segmentDownloaded(deltaTimeMs: number, numBytes: number): void; | |
getBandwidthEstimate(): number; | |
setVariants(variants: shakaExtern.Variant[]): void; | |
configure(config: shakaExtern.AbrConfiguration): void; | |
} | |
} | |
/** | |
* Construct a Player. | |
*/ | |
class Player extends shaka.util.FakeEventTarget implements shaka.util.IDestroyable { | |
static readonly version: string; | |
/** | |
* Registers a plugin callback that will be called with support(). The callback will return the value that will be stored in the return value from support(). | |
*/ | |
static registerSupportPlugin(name: string, callback: (() => any)): void; | |
/** | |
* Return whether the browser provides basic support. If this returns false, Shaka Player cannot be used at all. In this case, do not construct a Player instance and do not use the library. | |
*/ | |
static isBrowserSupported(): boolean; | |
/** | |
* Probes the browser to determine what features are supported. This makes a number of requests to EME/MSE/etc which may result in user prompts. This should only be used for diagnostics. NOTE: This may show a request to the user for permission. | |
*/ | |
static probeSupport(): Promise<shakaExtern.SupportType>; | |
/** | |
* Construct a Player. | |
* @param video Any existing TextTracks attached to this element that were not created by Shaka will be disabled. A new TextTrack may be created to display captions or subtitles. | |
* @param opt_dependencyInjector Optional callback which is called to inject mocks into the Player. Used for testing. | |
*/ | |
constructor(video: HTMLMediaElement, opt_dependencyInjector?: ((p0: shaka.Player | null) => void)); | |
/** | |
* After destruction, a Player object cannot be used again. | |
*/ | |
destroy(): Promise<void>; | |
/** | |
* Load a manifest. | |
* @param opt_startTime Optional start time, in seconds, to begin playback. Defaults to 0 for VOD and to the live edge for live. | |
* @param opt_manifestParserFactory Optional manifest parser factory to override auto-detection or use an unregistered parser. | |
* @returnType Resolved when the manifest has been loaded and playback has begun; rejected when an error occurs or the call was interrupted by destroy(), unload() or another call to load(). | |
*/ | |
load(manifestUri: string, opt_startTime?: number, opt_manifestParserFactory?: shakaExtern.ManifestParser.Factory): Promise<void>; | |
/** | |
* Configure the Player instance. The config object passed in need not be complete. It will be merged with the existing Player configuration. Config keys and types will be checked. If any problems with the config object are found, errors will be reported through logs. | |
* @param config This should follow the form of {@link shakaExtern.PlayerConfiguration}, but you may omit any field you do not wish to change. | |
*/ | |
configure(config: object): void; | |
/** | |
* Return a copy of the current configuration. Modifications of the returned value will not affect the Player's active configuration. You must call player.configure() to make changes. | |
*/ | |
getConfiguration(): shakaExtern.PlayerConfiguration; | |
/** | |
* Reset configuration to default. | |
*/ | |
resetConfiguration(): void; | |
/** | |
* @returnType A reference to the HTML Media Element passed in during initialization. | |
*/ | |
getMediaElement(): HTMLMediaElement | null; | |
/** | |
* @returnType A reference to the Player's networking engine. Applications may use this to make requests through Shaka's networking plugins. | |
*/ | |
getNetworkingEngine(): shaka.net.NetworkingEngine | null; | |
/** | |
* @returnType If a manifest is loaded, returns the manifest URI given in the last call to load(). Otherwise, returns null. | |
*/ | |
getManifestUri(): string | null; | |
/** | |
* @returnType True if the current stream is live. False otherwise. | |
*/ | |
isLive(): boolean; | |
/** | |
* @returnType True if the current stream is in-progress VOD. False otherwise. | |
*/ | |
isInProgress(): boolean; | |
/** | |
* @returnType True for audio-only content. False otherwise. | |
*/ | |
isAudioOnly(): boolean; | |
/** | |
* Get the seekable range for the current stream. | |
*/ | |
seekRange(): {start: number, end: number}; | |
/** | |
* Get the key system currently being used by EME. This returns the empty string if not using EME. | |
*/ | |
keySystem(): string; | |
/** | |
* Get the DrmInfo used to initialize EME. This returns null when not using EME. | |
*/ | |
drmInfo(): shakaExtern.DrmInfo | null; | |
/** | |
* The next known expiration time for any EME session. If the sessions never expire, or there are no EME sessions, this returns Infinity. | |
*/ | |
getExpiration(): number; | |
/** | |
* @returnType True if the Player is in a buffering state. | |
*/ | |
isBuffering(): boolean; | |
/** | |
* Unload the current manifest and make the Player available for re-use. | |
* @returnType Resolved when streaming has stopped and the previous content, if any, has been unloaded. | |
*/ | |
unload(): Promise<void>; | |
/** | |
* Gets the current effective playback rate. If using trick play, it will return the current trick play rate; otherwise, it will return the video playback rate. | |
*/ | |
getPlaybackRate(): number; | |
/** | |
* Skip through the content without playing. Simulated using repeated seeks. Trick play will be canceled automatically if the playhead hits the beginning or end of the seekable range for the content. | |
* @param rate The playback rate to simulate. For example, a rate of 2.5 would result in 2.5 seconds of content being skipped every second. To trick-play backward, use a negative rate. | |
*/ | |
trickPlay(rate: number): void; | |
/** | |
* Cancel trick-play. | |
*/ | |
cancelTrickPlay(): void; | |
/** | |
* Return a list of variant tracks available for the current Period. If there are multiple Periods, then you must seek to the Period before being able to switch. | |
*/ | |
getVariantTracks(): shakaExtern.Track[]; | |
/** | |
* Return a list of text tracks available for the current Period. If there are multiple Periods, then you must seek to the Period before being able to switch. | |
*/ | |
getTextTracks(): shakaExtern.Track[]; | |
/** | |
* Select a specific text track. Note that AdaptationEvents are not fired for manual track selections. | |
*/ | |
selectTextTrack(track: shakaExtern.Track): void; | |
/** | |
* Select a specific track. Note that AdaptationEvents are not fired for manual track selections. | |
*/ | |
selectVariantTrack(track: shakaExtern.Track, opt_clearBuffer?: boolean): void; | |
/** | |
* Return a list of audio language-role combinations available for the current Period. | |
*/ | |
getAudioLanguagesAndRoles(): shakaExtern.LanguageRole[]; | |
/** | |
* Return a list of text language-role combinations available for the current Period. | |
*/ | |
getTextLanguagesAndRoles(): shakaExtern.LanguageRole[]; | |
/** | |
* Return a list of audio languages available for the current Period. | |
*/ | |
getAudioLanguages(): string[]; | |
/** | |
* Return a list of text languages available for the current Period. | |
*/ | |
getTextLanguages(): string[]; | |
/** | |
* Sets currentAudioLanguage and currentVariantRole to the selected language and role, and chooses new variant if need be. | |
*/ | |
selectAudioLanguage(language: string, opt_role?: string): void; | |
/** | |
* Sets currentTextLanguage and currentTextRole to the selected language and role, and chooses new text stream if need be. | |
*/ | |
selectTextLanguage(language: string, opt_role?: string): void; | |
/** | |
* @returnType True if the current text track is visible. | |
*/ | |
isTextTrackVisible(): boolean; | |
/** | |
* Set the visibility of the current text track, if any. | |
*/ | |
setTextTrackVisibility(on: boolean): void; | |
/** | |
* Returns current playhead time as a Date. | |
*/ | |
getPlayheadTimeAsDate(): Date | null; | |
/** | |
* Returns the presentation start time as a Date. | |
*/ | |
getPresentationStartTimeAsDate(): Date | null; | |
/** | |
* Return the information about the current buffered ranges. | |
*/ | |
getBufferedInfo(): shakaExtern.BufferedInfo; | |
/** | |
* Return playback and adaptation stats. | |
*/ | |
getStats(): shakaExtern.Stats; | |
/** | |
* Adds the given text track to the current Period. Load() must resolve before calling. The current Period or the presentation must have a duration. This returns a Promise that will resolve when the track can be switched to and will resolve with the track that was created. | |
*/ | |
addTextTrack(uri: string, language: string, kind: string, mime: string, opt_codec?: string, opt_label?: string): Promise<shakaExtern.Track>; | |
/** | |
* Set the maximum resolution that the platform's hardware can handle. This will be called automatically by shaka.cast.CastReceiver to enforce limitations of the Chromecast hardware. | |
*/ | |
setMaxHardwareResolution(width: number, height: number): void; | |
/** | |
* Retry streaming after a failure. Does nothing if not in a failure state. | |
* @returnType False if unable to retry. | |
*/ | |
retryStreaming(): boolean; | |
/** | |
* Return the manifest information if it's loaded. Otherwise, return null. | |
*/ | |
getManifest(): shakaExtern.Manifest | null; | |
} | |
namespace offline { | |
/** | |
* A plugin that handles requests for offline content. | |
*/ | |
function OfflineScheme(uri: string, request: shakaExtern.Request): shakaExtern.IAbortableOperation<shakaExtern.Response>; | |
/** | |
* This manages persistent offline data including storage, listing, and deleting stored manifests. Playback of offline manifests are done using Player using the special URI (see shaka.offline.OfflineUri). First, check support() to see if offline is supported by the platform. Second, configure() the storage object with callbacks to your application. Third, call store(), remove(), or list() as needed. When done, call destroy(). | |
*/ | |
class Storage implements shaka.util.IDestroyable { | |
/** | |
* Gets whether offline storage is supported. Returns true if offline storage is supported for clear content. Support for offline storage of encrypted content will not be determined until storage is attempted. | |
*/ | |
static support(): boolean; | |
/** | |
* Delete the on-disk storage and all content it contains. This should not be done regularly, only when storage is rendered unusable. | |
*/ | |
static deleteAll(): Promise<void>; | |
/** | |
* This manages persistent offline data including storage, listing, and deleting stored manifests. Playback of offline manifests are done using Player using the special URI (see shaka.offline.OfflineUri). First, check support() to see if offline is supported by the platform. Second, configure() the storage object with callbacks to your application. Third, call store(), remove(), or list() as needed. When done, call destroy(). | |
* @param player The player instance to pull configuration data from. | |
*/ | |
constructor(player: shaka.Player | null); | |
destroy(): Promise<void>; | |
/** | |
* Sets configuration values for Storage. This is not associated with Player.configure and will not change Player. There are two important callbacks configured here: one for download progress, and one to decide which tracks to store. The default track selection callback will store the largest SD video track. Provide your own callback to choose the tracks you want to store. | |
* @param config This should follow the form of {@link shakaExtern.OfflineConfiguration}, but you may omit any field you do not wish to change. | |
*/ | |
configure(config: object): void; | |
/** | |
* Stores the given manifest. If the content is encrypted, and encrypted content cannot be stored on this platform, the Promise will be rejected with error code 6001, REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE. | |
* @param manifestUri The URI of the manifest to store. | |
* @param opt_appMetadata An arbitrary object from the application that will be stored along-side the offline content. Use this for any application-specific metadata you need associated with the stored content. For details on the data types that can be stored here, please refer to {@link https://goo.gl/h62coS} | |
* @returnType A Promise to a structure representing what was stored. The "offlineUri" member is the URI that should be given to Player.load() to play this piece of content offline. The "appMetadata" member is the appMetadata argument you passed to store(). | |
*/ | |
store(manifestUri: string, opt_appMetadata?: object, opt_manifestParserFactory?: shakaExtern.ManifestParser.Factory): Promise<shakaExtern.StoredContent>; | |
/** | |
* Removes the given stored content. | |
*/ | |
remove(contentUri: string): Promise<void>; | |
/** | |
* Lists all the stored content available. | |
* @returnType A Promise to an array of structures representing all stored content. The "offlineUri" member of the structure is the URI that should be given to Player.load() to play this piece of content offline. The "appMetadata" member is the appMetadata argument you passed to store(). | |
*/ | |
list(): Promise<shakaExtern.StoredContent[]>; | |
} | |
} | |
namespace hls { | |
/** | |
* Creates a new HLS parser. | |
*/ | |
class HlsParser implements shakaExtern.ManifestParser { | |
/** | |
* Creates a new HLS parser. | |
*/ | |
constructor(); | |
configure(config: shakaExtern.ManifestConfiguration): void; | |
start(uri: string, playerInterface: shakaExtern.ManifestParser.PlayerInterface): Promise<shakaExtern.Manifest>; | |
stop(): Promise<void>; | |
update(): void; | |
onExpirationUpdated(sessionId: string, expiration: number): void; | |
} | |
} | |
namespace dash { | |
/** | |
* Creates a new DASH parser. | |
*/ | |
class DashParser implements shakaExtern.ManifestParser { | |
/** | |
* Creates a new DASH parser. | |
*/ | |
constructor(); | |
configure(config: shakaExtern.ManifestConfiguration): void; | |
start(uri: string, playerInterface: shakaExtern.ManifestParser.PlayerInterface): Promise<shakaExtern.Manifest>; | |
stop(): Promise<void>; | |
update(): void; | |
onExpirationUpdated(sessionId: string, expiration: number): void; | |
} | |
} | |
} | |
declare namespace shakaExtern { | |
/** | |
* A representation of an abortable operation. Note that these are not cancelable. Cancelation implies undoing what has been done so far, whereas aborting only means that futher work is stopped. | |
*/ | |
interface IAbortableOperation<T> { | |
readonly promise: Promise<T>; | |
/** | |
* Can be called by anyone holding this object to abort the underlying operation. This is not cancelation, and will not necessarily result in any work being undone. abort() should return a Promise which is resolved when the underlying operation has been aborted. The returned Promise should never be rejected. | |
*/ | |
abort(): Promise<void>; | |
/** | |
* @param onFinal A callback to be invoked after the operation succeeds or fails. The boolean argument is true if the operation succeeded and false if it failed. | |
* @returnType Returns this. | |
*/ | |
finally(onFinal: ((p0: boolean) => void)): shakaExtern.IAbortableOperation<T>; | |
} | |
/** | |
* An object which selects Streams from a set of possible choices. This also watches for system changes to automatically adapt for the current streaming requirements. For example, when the network slows down, this class is in charge of telling the Player which streams to switch to in order to reduce the required bandwidth. This class is given a set of streams to choose from when the Player starts up. This class should store these and use them to make future decisions about ABR. It is up to this class how those decisions are made. All the Player will do is tell this class what streams to choose from. | |
*/ | |
interface AbrManager { | |
/** | |
* Initializes the AbrManager. | |
*/ | |
init(switchCallback: shakaExtern.AbrManager.SwitchCallback): void; | |
/** | |
* Stops any background timers and frees any objects held by this instance. This will only be called after a call to init. | |
*/ | |
stop(): void; | |
/** | |
* Updates manager's variants collection. | |
*/ | |
setVariants(variants: shakaExtern.Variant[]): void; | |
/** | |
* Chooses one variant to switch to. Called by the Player. | |
*/ | |
chooseVariant(): shakaExtern.Variant; | |
/** | |
* Enables automatic Variant choices from the last ones passed to setVariants. After this, the AbrManager may call switchCallback() at any time. | |
*/ | |
enable(): void; | |
/** | |
* Disables automatic Stream suggestions. After this, the AbrManager may not call switchCallback(). | |
*/ | |
disable(): void; | |
/** | |
* Notifies the AbrManager that a segment has been downloaded (includes MP4 SIDX data, WebM Cues data, initialization segments, and media segments). | |
* @param deltaTimeMs The duration, in milliseconds, that the request took to complete. | |
* @param numBytes The total number of bytes transferred. | |
*/ | |
segmentDownloaded(deltaTimeMs: number, numBytes: number): void; | |
/** | |
* Gets an estimate of the current bandwidth in bit/sec. This is used by the Player to generate stats. | |
*/ | |
getBandwidthEstimate(): number; | |
/** | |
* Sets the abr configurations. | |
*/ | |
configure(config: shakaExtern.AbrConfiguration): void; | |
} | |
namespace AbrManager { | |
/** | |
* A callback into the Player that should be called when the AbrManager decides it's time to change to a different variant. The first argument is a variant to switch to. The second argument is an optional boolean. If true, all data will be from the buffer, which will result in a buffering event. | |
*/ | |
type SwitchCallback = ((p0: shakaExtern.Variant, p1: boolean) => void); | |
/** | |
* A factory for creating the abr manager. This will be called with 'new'. | |
*/ | |
interface Factory { | |
new(): shakaExtern.AbrManager | null; | |
} | |
} | |
interface Error { | |
severity: shaka.util.Error.Severity | null; | |
readonly category: shaka.util.Error.Category | null; | |
readonly code: shaka.util.Error.Code | null; | |
readonly data: any[]; | |
handled: boolean; | |
} | |
/** | |
* <p> A Manifest object describes a collection of streams (segmented audio, video, or text data) that share a common timeline. We call the collection of streams "the presentation" and their timeline "the presentation timeline". A Manifest describes one of two types of presentations: live and video-on-demand. </p> <p> A live presentation begins at some point in time and either continues indefinitely or ends when the presentation stops broadcasting. For a live presentation, wall-clock time maps onto the presentation timeline, and the current wall-clock time maps to the live-edge (AKA "the current presentation time"). In contrast, a video-on-demand presentation exists entirely independent of wall-clock time. </p> <p> The presentation timeline is divided into one or more Periods, and each of these Periods contains its own collection of Variants and text streams. Variant is a combination of an audio and a video streams that can be played together. </p> <p> A stream has the same logical content as another stream if the only difference between the two is their quality. For example, an SD video stream and an HD video stream that depict the same scene have the same logical content; whereas an English audio stream and a French audio stream have different logical content. The player can automatically switch between streams which have the same logical content to adapt to network conditions. </p> | |
*/ | |
interface Manifest { | |
/** | |
* <i>Required.</i> <br> The presentation timeline. | |
*/ | |
presentationTimeline: shaka.media.PresentationTimeline; | |
/** | |
* <i>Required.</i> <br> The presentation's Periods. There must be at least one Period. | |
*/ | |
periods: shakaExtern.Period[]; | |
/** | |
* <i>Defaults to [].</i> <br> An array of EME sessions to load for offline playback. | |
*/ | |
offlineSessionIds: string[]; | |
/** | |
* <i>Defaults to 0.</i> <br> The minimum number of seconds of content that must be buffered before playback can begin. Can be overridden by a higher value from the Player configuration. | |
*/ | |
minBufferTime: number; | |
} | |
/** | |
* A Period object contains the Streams for part of the presentation. | |
*/ | |
interface Period { | |
/** | |
* <i>Required.</i> <br> The Period's start time, in seconds, relative to the start of the presentation. The first Period must begin at the start of the presentation. The Period ends immediately before the next Period's start time or exactly at the end of the presentation timeline. Periods which begin after the end of the presentation timeline are ignored. | |
*/ | |
startTime: number; | |
/** | |
* <i>Required.</i> <br> The Period's Variants. There must be at least one Variant. | |
*/ | |
variants: shakaExtern.Variant[]; | |
/** | |
* <i>Required.</i> <br> The Period's text streams. | |
*/ | |
textStreams: shakaExtern.Stream[]; | |
} | |
/** | |
* Explicit initialization data, which override any initialization data in the content. The initDataType values and the formats that they correspond to are specified {@link https://goo.gl/TNjYwn here}. | |
*/ | |
interface InitDataOverride { | |
/** | |
* Initialization data in the format indicated by initDataType. | |
*/ | |
initData: Uint8Array; | |
/** | |
* A string to indicate what format initData is in. | |
*/ | |
initDataType: string; | |
/** | |
* The key Id that corresponds to this initData. | |
*/ | |
keyId: string | null; | |
} | |
/** | |
* DRM configuration for a single key system. | |
*/ | |
interface DrmInfo { | |
/** | |
* <i>Required.</i> <br> The key system, e.g., "com.widevine.alpha". | |
*/ | |
keySystem: string; | |
/** | |
* <i>Filled in by DRM config if missing.</i> <br> The license server URI. | |
*/ | |
licenseServerUri: string; | |
/** | |
* <i>Defaults to false. Can be filled in by advanced DRM config.</i> <br> True if the application requires the key system to support distinctive identifiers. | |
*/ | |
distinctiveIdentifierRequired: boolean; | |
/** | |
* <i>Defaults to false. Can be filled in by advanced DRM config.</i> <br> True if the application requires the key system to support persistent state, e.g., for persistent license storage. | |
*/ | |
persistentStateRequired: boolean; | |
/** | |
* <i>Defaults to '', e.g., no specific robustness required. Can be filled in by advanced DRM config.</i> <br> A key-system-specific string that specifies a required security level. | |
*/ | |
audioRobustness: string; | |
/** | |
* <i>Defaults to '', e.g., no specific robustness required. Can be filled in by advanced DRM config.</i> <br> A key-system-specific string that specifies a required security level. | |
*/ | |
videoRobustness: string; | |
/** | |
* <i>Defaults to null, e.g., certificate will be requested from the license server if required. Can be filled in by advanced DRM config.</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. | |
*/ | |
serverCertificate: Uint8Array | null; | |
/** | |
* <i>Defaults to [], e.g., no override.</i> <br> A list of initialization data which override any initialization data found in the content. See also shakaExtern.InitDataOverride. | |
*/ | |
initData: shakaExtern.InitDataOverride[] | null; | |
/** | |
* <i>Defaults to []</i> <br> If not empty, contains the default key IDs for this key system, as lowercase hex strings. | |
*/ | |
keyIds: string[] | null; | |
} | |
/** | |
* A Variant describes a combination of an audio and video streams which could be played together. It's possible to have a video/audio only variant. | |
*/ | |
interface Variant { | |
/** | |
* <i>Required.</i> <br> A unique ID among all Variant objects within the same Manifest. | |
*/ | |
id: number; | |
/** | |
* <i>Defaults to '' (i.e., unknown).</i> <br> The Variant's language, specified as a language code. <br> See {@link https://tools.ietf.org/html/rfc5646} <br> See {@link http://www.iso.org/iso/home/standards/language_codes.htm} | |
*/ | |
language: string; | |
/** | |
* <i>Defaults to false.</i> <br> True indicates that the player should use this Variant over others of the in the same Period. However, the player may use another Variant to meet application preferences. | |
*/ | |
primary: boolean; | |
/** | |
* The audio stream of the variant. | |
*/ | |
audio: shakaExtern.Stream | null; | |
/** | |
* The video stream of the variant. | |
*/ | |
video: shakaExtern.Stream | null; | |
/** | |
* The variant's required bandwidth in bits per second. | |
*/ | |
bandwidth: number; | |
/** | |
* <i>Defaults to [] (i.e., no DRM).</i> <br> An array of DrmInfo objects which describe DRM schemes are compatible with the content. | |
*/ | |
drmInfos: shakaExtern.DrmInfo[]; | |
/** | |
* <i>Defaults to true.</i><br> Set by the Player to indicate whether the variant is allowed to be played by the application. | |
*/ | |
allowedByApplication: boolean; | |
/** | |
* <i>Defaults to true.</i><br> Set by the Player to indicate whether the variant is allowed to be played by the key system. | |
*/ | |
allowedByKeySystem: boolean; | |
} | |
/** | |
* Creates a SegmentIndex; returns a Promise that resolves after the SegmentIndex has been created. | |
*/ | |
type CreateSegmentIndexFunction = (() => Promise<void>); | |
/** | |
* Finds the position of the segment for the given time, in seconds, relative to the start of a particular Period; returns null if the position of the segment could not be determined. Note: the position of a segment is unique only among segments within the same Period. | |
*/ | |
type FindSegmentPositionFunction = ((p0: number) => number | null); | |
/** | |
* Gets the SegmentReference for the segment at the given position; returns null if no such SegmentReference exists. Note: the position of a segment is unique only among segments within the same Period. | |
*/ | |
type GetSegmentReferenceFunction = ((p0: number) => shaka.media.SegmentReference | null); | |
/** | |
* A Stream object describes a single stream (segmented media data). | |
*/ | |
interface Stream { | |
/** | |
* <i>Required.</i> <br> A unique ID among all Stream objects within the same Manifest. | |
*/ | |
id: number; | |
/** | |
* <i>Required.</i> <br> Creates the Stream's SegmentIndex (asynchronously). | |
*/ | |
createSegmentIndex: shakaExtern.CreateSegmentIndexFunction; | |
/** | |
* <i>Required.</i> <br> Finds the position of the segment for the given time. The caller must call createSegmentIndex() and wait until the returned Promise resolves before calling this function. | |
*/ | |
findSegmentPosition: shakaExtern.FindSegmentPositionFunction; | |
/** | |
* <i>Required.</i> <br> Gets the SegmentReference for the segment at the given position. The caller must call createSegmentIndex() and wait until the returned Promise resolves before calling this function. | |
*/ | |
getSegmentReference: shakaExtern.GetSegmentReferenceFunction; | |
/** | |
* The Stream's initialization segment metadata, or null if the segments are self-initializing. | |
*/ | |
initSegmentReference: shaka.media.InitSegmentReference | null; | |
/** | |
* <i>Defaults to 0.</i> <br> The amount of time, in seconds, that the stream's presentation timestamps are offset from the start of the Stream's Period, i.e., this value should equal the first presentation timestamp of the first frame/sample in the period. <br> <br> For example, for MP4 based streams, this value should equal the first segment's tfdt box's 'baseMediaDecodeTime' field (after it has been converted to seconds). | |
*/ | |
presentationTimeOffset: number | undefined; | |
/** | |
* <i>Required.</i> <br> The Stream's MIME type, e.g., 'audio/mp4', 'video/webm', or 'text/vtt'. | |
*/ | |
mimeType: string; | |
/** | |
* <i>Defaults to '' (i.e., unknown / not needed).</i> <br> The Stream's codecs, e.g., 'avc1.4d4015' or 'vp9', which must be compatible with the Stream's MIME type. <br> See {@link https://tools.ietf.org/html/rfc6381} | |
*/ | |
codecs: string; | |
/** | |
* <i>Video streams only.</i> <br> The Stream's framerate in frames per second | |
*/ | |
frameRate: number | undefined; | |
/** | |
* <i>Audio and video streams only.</i> <br> The stream's required bandwidth in bits per second. | |
*/ | |
bandwidth: number | undefined; | |
/** | |
* <i>Video streams only.</i> <br> The stream's width in pixels. | |
*/ | |
width: number | undefined; | |
/** | |
* <i>Video streams only.</i> <br> The stream's height in pixels. | |
*/ | |
height: number | undefined; | |
/** | |
* <i>Text streams only.</i> <br> The kind of text stream. For example, 'caption' or 'subtitle'. | |
*/ | |
kind: string | undefined; | |
/** | |
* <i>Defaults to false.</i><br> True if the stream is encrypted. | |
*/ | |
encrypted: boolean; | |
/** | |
* <i>Defaults to null (i.e., unencrypted or key ID unknown).</i> <br> The stream's key ID as a lowercase hex string. This key ID identifies the encryption key that the browser (key system) can use to decrypt the stream. | |
*/ | |
keyId: string | null; | |
/** | |
* The Stream's language, specified as a language code. <br> Audio stream's language must be identical to the language of the containing Variant. | |
*/ | |
language: string; | |
/** | |
* The Stream's label, unique text that should describe the audio/text track. | |
*/ | |
label: string | null; | |
/** | |
* <i>Required.</i> <br> Content type (e.g. 'video', 'audio' or 'text') | |
*/ | |
type: string; | |
/** | |
* <i>Defaults to false.</i> <br> True indicates that the player should prefer this Stream over others in the same Period. However, the player may use another Stream to meet application preferences. | |
*/ | |
primary: boolean; | |
/** | |
* <i>Video streams only.</i> <br> An alternate video stream to use for trick mode playback. | |
*/ | |
trickModeVideo: shakaExtern.Stream | null; | |
/** | |
* <i>Defaults to false.</i><br> Whether the stream contains embedded 'emsg' boxes that should result in Player events. | |
*/ | |
containsEmsgBoxes: boolean; | |
/** | |
* The roles of the stream as they appear on the manifest, e.g. 'main', 'caption', or 'commentary'. | |
*/ | |
roles: string[]; | |
/** | |
* The channel count information for the audio stream. | |
*/ | |
channelsCount: number | null; | |
} | |
/** | |
* Parses media manifests and handles manifest updates. Given a URI where the initial manifest is found, a parser will request the manifest, parse it, and return the resulting Manifest object. If the manifest requires updates (e.g. for live media), the parser will use background timers to update the same Manifest object. | |
*/ | |
interface ManifestParser { | |
/** | |
* Called by the Player to provide an updated configuration any time the configuration changes. Will be called at least once before start(). | |
*/ | |
configure(config: shakaExtern.ManifestConfiguration): void; | |
/** | |
* Parses the given manifest data into a Manifest object and starts any background timers that are needed. This will only be called once. | |
* @param uri The URI of the manifest. | |
* @param playerInterface Contains the interface to the Player. | |
*/ | |
start(uri: string, playerInterface: shakaExtern.ManifestParser.PlayerInterface): Promise<shakaExtern.Manifest>; | |
/** | |
* Stops any background timers and frees any objects held by this instance. This will only be called after a successful call to start. This will only be called once. | |
*/ | |
stop(): Promise<void>; | |
/** | |
* Tells the parser to do a manual manifest update. Implementing this is optional and is only called when 'emsg' boxes are present. | |
*/ | |
update(): void; | |
/** | |
* Tells the parser that the expiration time of an EME session has changed. Implementing this is optional. | |
*/ | |
onExpirationUpdated(sessionId: string, expiration: number): void; | |
} | |
namespace ManifestParser { | |
/** | |
* Defines the interface of the Player to the manifest parser. This defines fields and callback methods that the parser will use to interact with the Player. The callback methods do not to be called as member functions (i.e. they can be called as "free" functions). | |
*/ | |
interface PlayerInterface { | |
/** | |
* The networking engine to use for network requests. | |
*/ | |
networkingEngine: shaka.net.NetworkingEngine; | |
/** | |
* Should be called on a new Period so that it can be filtered. | |
*/ | |
filterNewPeriod: ((p0: shakaExtern.Period) => void); | |
/** | |
* Should be called on all Periods so that they can be filtered. | |
*/ | |
filterAllPeriods: ((p0: shakaExtern.Period[]) => void); | |
/** | |
* Should be called when a new timeline region is added. | |
*/ | |
onTimelineRegionAdded: ((p0: shakaExtern.TimelineRegionInfo) => void); | |
/** | |
* Should be called to raise events. | |
*/ | |
onEvent: ((p0: Event) => void); | |
/** | |
* Should be called when an error occurs. | |
*/ | |
onError: ((p0: shaka.util.Error) => void); | |
} | |
/** | |
* A factory for creating the manifest parser. This will be called with 'new'. This function is registered with shaka.media.ManifestParser to create parser instances. | |
*/ | |
interface Factory { | |
new(): shakaExtern.ManifestParser | null; | |
} | |
} | |
/** | |
* Parameters for retrying requests. | |
*/ | |
interface RetryParameters { | |
/** | |
* The maximum number of times the request should be attempted. | |
*/ | |
maxAttempts: number; | |
/** | |
* The delay before the first retry, in milliseconds. | |
*/ | |
baseDelay: number; | |
/** | |
* The multiplier for successive retry delays. | |
*/ | |
backoffFactor: number; | |
/** | |
* The maximum amount of fuzz to apply to each retry delay. For example, 0.5 means "between 50% below and 50% above the retry delay." | |
*/ | |
fuzzFactor: number; | |
/** | |
* The request timeout, in milliseconds. Zero means "unlimited". | |
*/ | |
timeout: number; | |
} | |
/** | |
* Defines a network request. This is passed to one or more request filters that may alter the request, then it is passed to a scheme plugin which performs the actual operation. | |
*/ | |
interface Request { | |
/** | |
* An array of URIs to attempt. They will be tried in the order they are given. | |
*/ | |
uris: string[]; | |
/** | |
* The HTTP method to use for the request. | |
*/ | |
method: string; | |
/** | |
* The body of the request. | |
*/ | |
body: ArrayBuffer | null; | |
/** | |
* A mapping of headers for the request. e.g.: {'HEADER': 'VALUE'} | |
*/ | |
headers: { [key: string]: string }; | |
/** | |
* Make requests with credentials. This will allow cookies in cross-site requests. See <a href="http://goo.gl/YBRKPe">http://goo.gl/YBRKPe</a>. | |
*/ | |
allowCrossSiteCredentials: boolean; | |
/** | |
* An object used to define how often to make retries. | |
*/ | |
retryParameters: shakaExtern.RetryParameters; | |
} | |
/** | |
* Defines a response object. This includes the response data and header info. This is given back from the scheme plugin. This is passed to a response filter before being returned from the request call. | |
*/ | |
interface Response { | |
/** | |
* The URI which was loaded. Request filters and server redirects can cause this to be different from the original request URIs. | |
*/ | |
uri: string; | |
/** | |
* The body of the response. | |
*/ | |
data: ArrayBuffer | null; | |
/** | |
* A map of response headers, if supported by the underlying protocol. All keys should be lowercased. For HTTP/HTTPS, may not be available cross-origin. | |
*/ | |
headers: { [key: string]: string }; | |
/** | |
* Optional. The time it took to get the response, in miliseconds. If not given, NetworkingEngine will calculate it using Date.now. | |
*/ | |
timeMs: number | undefined; | |
/** | |
* Optional. If true, this response was from a cache and should be ignored for bandwidth estimation. | |
*/ | |
fromCache: boolean | undefined; | |
} | |
/** | |
* Defines a plugin that handles a specific scheme. | |
*/ | |
type SchemePlugin = ((p0: string, p1: shakaExtern.Request, p2: shaka.net.NetworkingEngine.RequestType | null) => shakaExtern.IAbortableOperation<shakaExtern.Response>); | |
/** | |
* Defines a filter for requests. This filter takes the request and modifies it before it is sent to the scheme plugin. A request filter can run asynchronously by returning a promise; in this case, the request will not be sent until the promise is resolved. | |
*/ | |
type RequestFilter = ((p0: shaka.net.NetworkingEngine.RequestType | null, p1: shakaExtern.Request) => Promise<void> | undefined | null); | |
/** | |
* Defines a filter for responses. This filter takes the response and modifies it before it is returned. A response filter can run asynchronously by returning a promise. | |
*/ | |
type ResponseFilter = ((p0: shaka.net.NetworkingEngine.RequestType | null, p1: shakaExtern.Response) => Promise<void> | undefined | null); | |
interface OfflineSupport { | |
/** | |
* True if offline is usable at all. | |
*/ | |
basic: boolean; | |
/** | |
* A map of key system name to whether it supports offline playback. | |
*/ | |
encrypted: { [key: string]: boolean }; | |
} | |
interface OfflineConfiguration { | |
/** | |
* Called inside store() to determine which tracks to save from a manifest. It is passed an array of Tracks from the manifest and it should return an array of the tracks to store. This is called for each Period in the manifest (in order). | |
*/ | |
trackSelectionCallback: ((p0: shakaExtern.Track[]) => shakaExtern.Track[]); | |
/** | |
* Called inside store() to give progress info back to the app. It is given the current manifest being stored and the progress of it being stored. | |
*/ | |
progressCallback: ((p0: shakaExtern.StoredContent, p1: number) => void); | |
/** | |
* If true, store protected content with a persistent license so that no network is required to view. If false, store protected content without a persistent license. A network will be required to retrieve a temporary license to view. Defaults to true. | |
*/ | |
usePersistentLicense: boolean; | |
} | |
interface StoredContent { | |
/** | |
* An offline URI to access the content. This can be passed directly to Player. If the uri is null, it means that the content has not finished downloading and is not ready to play. | |
*/ | |
offlineUri: string | null; | |
/** | |
* The original manifest URI of the content stored. | |
*/ | |
originalManifestUri: string; | |
/** | |
* The duration of the content, in seconds. | |
*/ | |
duration: number; | |
/** | |
* The size of the content, in bytes. | |
*/ | |
size: number; | |
/** | |
* The time that the encrypted license expires, in milliseconds. If the media is clear or the license never expires, this will equal Infinity. | |
*/ | |
expiration: number; | |
/** | |
* The tracks that are stored. This only lists those found in the first Period. | |
*/ | |
tracks: shakaExtern.Track[]; | |
/** | |
* The metadata passed to store(). | |
*/ | |
appMetadata: object | null; | |
} | |
interface ManifestDB { | |
/** | |
* The URI that the manifest was originally loaded from. | |
*/ | |
originalManifestUri: string; | |
/** | |
* The total duration of the media, in seconds. | |
*/ | |
duration: number; | |
/** | |
* The total size of all stored segments, in bytes. | |
*/ | |
size: number; | |
/** | |
* The license expiration, in milliseconds; or Infinity if not applicable. | |
*/ | |
expiration: number; | |
/** | |
* The Periods that are stored. | |
*/ | |
periods: shakaExtern.PeriodDB[]; | |
/** | |
* The DRM offline session IDs for the media. | |
*/ | |
sessionIds: string[]; | |
/** | |
* The DRM info used to initialize EME. | |
*/ | |
drmInfo: shakaExtern.DrmInfo | null; | |
/** | |
* A metadata object passed from the application. | |
*/ | |
appMetadata: object | null; | |
} | |
interface PeriodDB { | |
/** | |
* The start time of the period, in seconds. | |
*/ | |
startTime: number; | |
/** | |
* The streams that define the Period. | |
*/ | |
streams: shakaExtern.StreamDB[]; | |
} | |
interface StreamDB { | |
/** | |
* The unique id of the stream. | |
*/ | |
id: number; | |
/** | |
* Whether the stream set was primary. | |
*/ | |
primary: boolean; | |
/** | |
* The presentation time offset of the stream, in seconds. | |
*/ | |
presentationTimeOffset: number; | |
/** | |
* The type of the stream, 'audio', 'text', or 'video'. | |
*/ | |
contentType: string; | |
/** | |
* The MIME type of the stream. | |
*/ | |
mimeType: string; | |
/** | |
* The codecs of the stream. | |
*/ | |
codecs: string; | |
/** | |
* The Stream's framerate in frames per second | |
*/ | |
frameRate: number | undefined; | |
/** | |
* The kind of text stream; undefined for audio/video. | |
*/ | |
kind: string | undefined; | |
/** | |
* The language of the stream; '' for video. | |
*/ | |
language: string; | |
/** | |
* The label of the stream; '' for video. | |
*/ | |
label: string | null; | |
/** | |
* The width of the stream; null for audio/text. | |
*/ | |
width: number | null; | |
/** | |
* The height of the stream; null for audio/text. | |
*/ | |
height: number | null; | |
/** | |
* The storage key where the init segment is found; null if no init segment. | |
*/ | |
initSegmentKey: number | null; | |
/** | |
* Whether this stream is encrypted. | |
*/ | |
encrypted: boolean; | |
/** | |
* The key ID this stream is encrypted with. | |
*/ | |
keyId: string | null; | |
/** | |
* An array of segments that make up the stream | |
*/ | |
segments: shakaExtern.SegmentDB[]; | |
/** | |
* An array of ids of variants the stream is a part of. | |
*/ | |
variantIds: number[]; | |
} | |
interface SegmentDB { | |
/** | |
* The start time of the segment, in seconds from the start of the Period. | |
*/ | |
startTime: number; | |
/** | |
* The end time of the segment, in seconds from the start of the Period. | |
*/ | |
endTime: number; | |
/** | |
* The key to the data in storage. | |
*/ | |
dataKey: number; | |
} | |
interface SegmentDataDB { | |
/** | |
* The data contents of the segment. | |
*/ | |
data: ArrayBuffer; | |
} | |
interface TrackChoice { | |
/** | |
* The timestamp the choice was made, in seconds since 1970 (i.e. Date.now() / 1000). | |
*/ | |
timestamp: number; | |
/** | |
* The id of the track that was chosen. | |
*/ | |
id: number; | |
/** | |
* The type of track chosen ('variant' or 'text') | |
*/ | |
type: string; | |
/** | |
* True if the choice was made by AbrManager for adaptation; false if it was made by the application through selectTrack. | |
*/ | |
fromAdaptation: boolean; | |
/** | |
* The bandwidth of the chosen track (null for text). | |
*/ | |
bandwidth: number | null; | |
} | |
interface StateChange { | |
/** | |
* The timestamp the state was entered, in seconds since 1970 (i.e. Date.now() / 1000). | |
*/ | |
timestamp: number; | |
/** | |
* The state the player entered. This could be 'buffering', 'playing', 'paused', or 'ended'. | |
*/ | |
state: string; | |
/** | |
* 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. | |
*/ | |
duration: number; | |
} | |
/** | |
* 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 load() is called again. | |
*/ | |
interface Stats { | |
/** | |
* The width of the current video track. | |
*/ | |
width: number; | |
/** | |
* The height of the current video track. | |
*/ | |
height: number; | |
/** | |
* The bandwidth required for the current streams (total, in bit/sec). | |
*/ | |
streamBandwidth: number; | |
/** | |
* The total number of frames decoded by the Player. This may be NaN if this is not supported by the browser. | |
*/ | |
decodedFrames: number; | |
/** | |
* The total number of frames dropped by the Player. This may be NaN if this is not supported by the browser. | |
*/ | |
droppedFrames: number; | |
/** | |
* The current estimated network bandwidth (in bit/sec). | |
*/ | |
estimatedBandwidth: number; | |
/** | |
* 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 'loadeddata' event is fired by the media element. | |
*/ | |
loadLatency: number; | |
/** | |
* The total time spent in a playing state in seconds. | |
*/ | |
playTime: number; | |
/** | |
* The total time spent in a buffering state in seconds. | |
*/ | |
bufferingTime: number; | |
/** | |
* A history of the stream changes. | |
*/ | |
switchHistory: shakaExtern.TrackChoice[]; | |
/** | |
* A history of the state changes. | |
*/ | |
stateHistory: shakaExtern.StateChange[]; | |
} | |
/** | |
* Contains the times of a range of buffered content. | |
*/ | |
interface BufferedRange { | |
/** | |
* The start time of the range, in seconds. | |
*/ | |
start: number; | |
/** | |
* The end time of the range, in seconds. | |
*/ | |
end: number; | |
} | |
/** | |
* Contains information about the current buffered ranges. | |
*/ | |
interface BufferedInfo { | |
/** | |
* The combined audio/video buffered ranges, reported by |video.buffered|. | |
*/ | |
total: shakaExtern.BufferedRange[]; | |
/** | |
* The buffered ranges for audio content. | |
*/ | |
audio: shakaExtern.BufferedRange[]; | |
/** | |
* The buffered ranges for video content. | |
*/ | |
video: shakaExtern.BufferedRange[]; | |
/** | |
* The buffered ranges for text content. | |
*/ | |
text: shakaExtern.BufferedRange[]; | |
} | |
/** | |
* 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). | |
*/ | |
interface Track { | |
/** | |
* The unique ID of the track. | |
*/ | |
id: number; | |
/** | |
* If true, this is the track is being streamed (another track may be visible/audible in the buffer). | |
*/ | |
active: boolean; | |
/** | |
* The type of track, either 'variant' or 'text'. | |
*/ | |
type: string; | |
/** | |
* The bandwidth required to play the track, in bits/sec. | |
*/ | |
bandwidth: number; | |
/** | |
* The language of the track, or 'und' if not given. This is the exact value provided in the manifest; it may need to be normalized. | |
*/ | |
language: string; | |
/** | |
* The track label, unique text that should describe the track. | |
*/ | |
label: string | null; | |
/** | |
* (only for text tracks) The kind of text track, either 'caption' or 'subtitle'. | |
*/ | |
kind: string | null; | |
/** | |
* The video width provided in the manifest, if present. | |
*/ | |
width: number | null; | |
/** | |
* The video height provided in the manifest, if present. | |
*/ | |
height: number | null; | |
/** | |
* The video framerate provided in the manifest, if present. | |
*/ | |
frameRate: number | null; | |
/** | |
* The MIME type of the content provided in the manifest. | |
*/ | |
mimeType: string | null; | |
/** | |
* The audio/video codecs string provided in the manifest, if present. | |
*/ | |
codecs: string | null; | |
/** | |
* The audio codecs string provided in the manifest, if present. | |
*/ | |
audioCodec: string | null; | |
/** | |
* The video codecs string provided in the manifest, if present. | |
*/ | |
videoCodec: string | null; | |
/** | |
* 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. | |
*/ | |
primary: boolean; | |
/** | |
* The roles of the track, e.g. 'main', 'caption', or 'commentary'. | |
*/ | |
roles: string[]; | |
/** | |
* (only for variant tracks) The video stream id. | |
*/ | |
videoId: number | null; | |
/** | |
* (only for variant tracks) The audio stream id. | |
*/ | |
audioId: number | null; | |
/** | |
* The count of the audio track channels. | |
*/ | |
channelsCount: number | null; | |
/** | |
* (only for variant tracks) The audio stream's bandwidth if known. | |
*/ | |
audioBandwidth: number | null; | |
/** | |
* (only for variant tracks) The video stream's bandwidth if known. | |
*/ | |
videoBandwidth: number | null; | |
} | |
/** | |
* An object describing application restrictions on what tracks can play. All restrictions must be fulfilled for a track to be playable. If a track does not meet the restrictions, it will not appear in the track list and it will not be played. | |
*/ | |
interface Restrictions { | |
/** | |
* The minimum width of a video track, in pixels. | |
*/ | |
minWidth: number; | |
/** | |
* The maximum width of a video track, in pixels. | |
*/ | |
maxWidth: number; | |
/** | |
* The minimum height of a video track, in pixels. | |
*/ | |
minHeight: number; | |
/** | |
* The maximum height of a video track, in pixels. | |
*/ | |
maxHeight: number; | |
/** | |
* The minimum number of total pixels in a video track (i.e. width * height). | |
*/ | |
minPixels: number; | |
/** | |
* The maximum number of total pixels in a video track (i.e. width * height). | |
*/ | |
maxPixels: number; | |
/** | |
* The minimum bandwidth of a variant track, in bit/sec. | |
*/ | |
minBandwidth: number; | |
/** | |
* The maximum bandwidth of a variant track, in bit/sec. | |
*/ | |
maxBandwidth: number; | |
} | |
interface DrmSupportType { | |
/** | |
* Whether this key system supports persistent state. | |
*/ | |
persistentState: boolean; | |
} | |
/** | |
* An object detailing browser support for various features. | |
*/ | |
interface SupportType { | |
/** | |
* A map of supported manifest types. The keys are manifest MIME types and file extensions. | |
*/ | |
manifest: { [key: string]: boolean }; | |
/** | |
* A map of supported media types. The keys are media MIME types. | |
*/ | |
media: { [key: string]: boolean }; | |
/** | |
* A map of supported key systems. The keys are the key system names. The value is null if it is not supported. Key systems not probed will not be in this dictionary. | |
*/ | |
drm: { [key: string]: shakaExtern.DrmSupportType | null }; | |
} | |
/** | |
* 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. | |
*/ | |
interface TimelineRegionInfo { | |
/** | |
* Identifies the message scheme. | |
*/ | |
schemeIdUri: string; | |
/** | |
* Specifies the value for the region. | |
*/ | |
value: string; | |
/** | |
* The presentation time (in seconds) that the region should start. | |
*/ | |
startTime: number; | |
/** | |
* The presentation time (in seconds) that the region should end. | |
*/ | |
endTime: number; | |
/** | |
* Specifies an identifier for this instance of the region. | |
*/ | |
id: string; | |
/** | |
* The XML element that defines the Event. | |
*/ | |
eventElement: Element | null; | |
} | |
/** | |
* Contains information about an EMSG MP4 box. | |
*/ | |
interface EmsgInfo { | |
/** | |
* Identifies the message scheme. | |
*/ | |
schemeIdUri: string; | |
/** | |
* Specifies the value for the event. | |
*/ | |
value: string; | |
/** | |
* The time that the event starts (in presentation time). | |
*/ | |
startTime: number; | |
/** | |
* The time that the event ends (in presentation time). | |
*/ | |
endTime: number; | |
/** | |
* Provides the timescale, in ticks per second. | |
*/ | |
timescale: number; | |
/** | |
* The offset that the event starts, relative to the start of the segment this is contained in (in units of timescale). | |
*/ | |
presentationTimeDelta: number; | |
/** | |
* The duration of the event (in units of timescale). | |
*/ | |
eventDuration: number; | |
/** | |
* A field identifying this instance of the message. | |
*/ | |
id: number; | |
/** | |
* Body of the message. | |
*/ | |
messageData: Uint8Array | null; | |
} | |
type DashContentProtectionCallback = ((p0: Element) => shakaExtern.DrmInfo[] | null); | |
interface AdvancedDrmConfiguration { | |
/** | |
* <i>Defaults to false.</i> <br> True if the application requires the key system to support distinctive identifiers. | |
*/ | |
distinctiveIdentifierRequired: boolean; | |
/** | |
* <i>Defaults to false.</i> <br> True if the application requires the key system to support persistent state, e.g., for persistent license storage. | |
*/ | |
persistentStateRequired: boolean; | |
/** | |
* A key-system-specific string that specifies a required security level for video. <i>Defaults to '', i.e., no specific robustness required.</i> <br> | |
*/ | |
videoRobustness: string; | |
/** | |
* A key-system-specific string that specifies a required security level for audio. <i>Defaults to '', i.e., no specific robustness required.</i> <br> | |
*/ | |
audioRobustness: string; | |
/** | |
* <i>Defaults to null.</i> <br> <i>An empty certificate (byteLength 0) will be treated as null.</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. | |
*/ | |
serverCertificate: Uint8Array | null; | |
} | |
interface DrmConfiguration { | |
/** | |
* Retry parameters for license requests. | |
*/ | |
retryParameters: shakaExtern.RetryParameters; | |
/** | |
* <i>Required for all but the clear key CDM.</i> <br> A dictionary which maps key system IDs to their license servers. For example, {'com.widevine.alpha': 'http://example.com/drm'}. | |
*/ | |
servers: { [key: string]: string }; | |
/** | |
* <i>Forces the use of the Clear Key CDM.</i> A map of key IDs (hex) to keys (hex). | |
*/ | |
clearKeys: { [key: string]: string }; | |
/** | |
* <i>Defaults to false.</i> <br> True to configure drm to delay sending a license request until a user actually starts playing content. | |
*/ | |
delayLicenseRequestUntilPlayed: boolean; | |
/** | |
* <i>Optional.</i> <br> A dictionary which maps key system IDs to advanced DRM configuration for those key systems. | |
*/ | |
advanced: { [key: string]: shakaExtern.AdvancedDrmConfiguration } | null; | |
} | |
interface DashManifestConfiguration { | |
/** | |
* If given, invoked by a DASH manifest parser to interpret custom or non-standard DRM schemes found in the manifest. The argument is a ContentProtection node. Return null if not recognized. | |
*/ | |
customScheme: shakaExtern.DashContentProtectionCallback; | |
/** | |
* A default clock sync URI to be used with live streams which do not contain any clock sync information. The "Date" header from this URI will be used to determine the current time. | |
*/ | |
clockSyncUri: string; | |
/** | |
* If true will cause DASH parser to ignore DRM information specified by the manifest and treat it as if it signaled no particular key system and contained no init data. Defaults to false if not provided. | |
*/ | |
ignoreDrmInfo: boolean; | |
/** | |
* 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. Defaults to false if not provided. | |
*/ | |
xlinkFailGracefully: boolean; | |
/** | |
* A default presentationDelay if suggestedPresentationDelay is missing in the MPEG DASH manifest, has to be bigger than minBufferTime * 1.5. | |
*/ | |
defaultPresentationDelay: number; | |
} | |
interface ManifestConfiguration { | |
/** | |
* Retry parameters for manifest requests. | |
*/ | |
retryParameters: shakaExtern.RetryParameters; | |
/** | |
* Advanced parameters used by the DASH manifest parser. | |
*/ | |
dash: shakaExtern.DashManifestConfiguration; | |
} | |
/** | |
* The StreamingEngine's configuration options. | |
*/ | |
interface StreamingConfiguration { | |
/** | |
* Retry parameters for segment requests. | |
*/ | |
retryParameters: shakaExtern.RetryParameters; | |
/** | |
* A callback to decide what to do on a streaming failure. Default behavior is to retry on live streams and not on VOD. | |
*/ | |
failureCallback: ((p0: shaka.util.Error) => void); | |
/** | |
* The minimum number of seconds of content that the StreamingEngine must buffer before it can begin playback or can continue playback after it has entered into a buffering state (i.e., after it has depleted one more more of its buffers). | |
*/ | |
rebufferingGoal: number; | |
/** | |
* The number of seconds of content that the StreamingEngine will attempt to buffer ahead of the playhead. This value must be greater than or equal to the rebuffering goal. | |
*/ | |
bufferingGoal: number; | |
/** | |
* The maximum number of seconds of content that the StreamingEngine will keep in buffer behind the playhead when it appends a new media segment. The StreamingEngine will evict content to meet this limit. | |
*/ | |
bufferBehind: number; | |
/** | |
* If true, the player will ignore text stream failures and proceed to play other streams. | |
*/ | |
ignoreTextStreamFailures: boolean; | |
/** | |
* If true, adjust the start time backwards so it is at the start of a segment. This affects both explicit start times and calculated start time for live streams. This can put us further from the live edge. Defaults to false. | |
*/ | |
startAtSegmentBoundary: boolean; | |
/** | |
* The limit (in seconds) for a gap in the media to be considered "small". Small gaps are jumped automatically without events. Large gaps result in a Player event and can be jumped. | |
*/ | |
smallGapLimit: number; | |
/** | |
* If true, jump large gaps in addition to small gaps. The event will be raised first. Then, if the app doesn't call preventDefault() on the event, the Player will jump the gap. If false, then the event will be raised, but the gap will not be jumped. | |
*/ | |
jumpLargeGaps: boolean; | |
/** | |
* By default, we will not allow seeking to exactly the duration of a presentation. This field is the number of seconds before duration we will seek to when the user tries to seek to or start playback at the duration. To disable this behavior, the config can be set to 0. We recommend using the default value unless you have a good reason not to. | |
*/ | |
durationBackoff: number; | |
} | |
interface AbrConfiguration { | |
/** | |
* If true, enable adaptation by the current AbrManager. Defaults to true. | |
*/ | |
enabled: boolean; | |
/** | |
* The default bandwidth estimate to use if there is not enough data, in bit/sec. | |
*/ | |
defaultBandwidthEstimate: number; | |
/** | |
* The restrictions to apply to ABR decisions. The AbrManager will not choose any streams that do not meet these restrictions. (Note that they can still be chosen by the application) | |
*/ | |
restrictions: shakaExtern.Restrictions; | |
/** | |
* The minimum amount of time that must pass between switches, in seconds. This keeps us from changing too often and annoying the user. | |
*/ | |
switchInterval: number; | |
/** | |
* The fraction of the estimated bandwidth which we should try to use when upgrading. | |
*/ | |
bandwidthUpgradeTarget: number; | |
/** | |
* The largest fraction of the estimated bandwidth we should use. We should downgrade to avoid this. | |
*/ | |
bandwidthDowngradeTarget: number; | |
} | |
interface PlayerConfiguration { | |
/** | |
* DRM configuration and settings. | |
*/ | |
drm: shakaExtern.DrmConfiguration; | |
/** | |
* Manifest configuration and settings. | |
*/ | |
manifest: shakaExtern.ManifestConfiguration; | |
/** | |
* Streaming configuration and settings. | |
*/ | |
streaming: shakaExtern.StreamingConfiguration; | |
/** | |
* A factory to construct an abr manager. | |
*/ | |
abrFactory: shakaExtern.AbrManager.Factory; | |
/** | |
* ABR configuration and settings. | |
*/ | |
abr: shakaExtern.AbrConfiguration; | |
/** | |
* The preferred language to use for audio tracks. If not given it will use the 'main' track. Changing this during playback will not affect the current playback. | |
*/ | |
preferredAudioLanguage: string; | |
/** | |
* The preferred language to use for text tracks. If a matching text track is found, and the selected audio and text tracks have different languages, the text track will be shown. Changing this during playback will not affect the current playback. | |
*/ | |
preferredTextLanguage: string; | |
/** | |
* The application restrictions to apply to the tracks. The track must meet all the restrictions to be playable. | |
*/ | |
restrictions: shakaExtern.Restrictions; | |
/** | |
* Optional playback and seek start time in seconds. Defaults to 0 if not provided. | |
*/ | |
playRangeStart: number; | |
/** | |
* Optional playback and seek end time in seconds. Defaults to the end of the presentation if not provided. | |
*/ | |
playRangeEnd: number; | |
/** | |
* A factory to construct text displayer. | |
*/ | |
textDisplayFactory: shakaExtern.TextDisplayer.Factory; | |
} | |
interface LanguageRole { | |
/** | |
* The language code for the stream. | |
*/ | |
language: string; | |
/** | |
* The role name for the stream. If the stream has no role, |role| will be ''. | |
*/ | |
role: string; | |
} | |
/** | |
* The region of the video to render the cues into. | |
*/ | |
interface CueRegion { | |
/** | |
* The X offset to start the rendering area. This is a percentage (0-100) of the video width. | |
*/ | |
x: number; | |
/** | |
* The Y offset to start the rendering area. This is a percentage (0-100) of the video height. | |
*/ | |
y: number; | |
/** | |
* The width of the rendering area. This is a percentage (0-100) of the video width. | |
*/ | |
width: number; | |
/** | |
* The height of the rendering area. This is a percentage (0-100) of the video height. | |
*/ | |
height: number; | |
} | |
interface Cue { | |
startTime: number; | |
endTime: number; | |
payload: string; | |
region: shakaExtern.CueRegion; | |
position: number | null; | |
positionAlign: shaka.text.Cue.positionAlign | null; | |
size: number; | |
textAlign: shaka.text.Cue.textAlign | null; | |
writingDirection: shaka.text.Cue.writingDirection | null; | |
lineInterpretation: shaka.text.Cue.lineInterpretation | null; | |
line: number | null; | |
lineHeight: string; | |
lineAlign: shaka.text.Cue.lineAlign | null; | |
displayAlign: shaka.text.Cue.displayAlign | null; | |
color: string; | |
backgroundColor: string; | |
fontSize: string; | |
fontWeight: shaka.text.Cue.fontWeight | null; | |
fontStyle: shaka.text.Cue.fontStyle | null; | |
fontFamily: string; | |
textDecoration: shaka.text.Cue.textDecoration[]; | |
wrapLine: boolean; | |
id: string; | |
} | |
/** | |
* An interface for plugins that parse text tracks. | |
*/ | |
interface TextParser { | |
/** | |
* Parse an initialization segment. Some formats do not have init segments so this won't always be called. | |
* @param data The data that makes up the init segment. | |
*/ | |
parseInit(data: Uint8Array): void; | |
/** | |
* Parse a media segment and return the cues that make up the segment. | |
* @param data The next section of buffer. | |
* @param timeContext The time information that should be used to adjust the times values for each cue. | |
*/ | |
parseMedia(data: Uint8Array, timeContext: shakaExtern.TextParser.TimeContext): shakaExtern.Cue[]; | |
} | |
namespace TextParser { | |
/** | |
* A collection of time offsets used to adjust text cue times. | |
*/ | |
interface TimeContext { | |
/** | |
* The absolute start time of the period in seconds. | |
*/ | |
periodStart: number; | |
/** | |
* The absolute start time of the segment in seconds. Null if the manifest does not provide this information, such as in HLS. | |
*/ | |
segmentStart: number | null; | |
/** | |
* The absolute end time of the segment in seconds. | |
*/ | |
segmentEnd: number; | |
} | |
} | |
interface TextParserPlugin { | |
new(): shakaExtern.TextParser | null; | |
} | |
/** | |
* An interface for plugins that display text. | |
*/ | |
interface TextDisplayer extends shaka.util.IDestroyable { | |
destroy(): Promise<void>; | |
/** | |
* Append given text cues to the list of cues to be displayed. | |
* @param cues Text cues to be appended. | |
*/ | |
append(cues: shaka.text.Cue[]): void; | |
/** | |
* Remove cues in a given time range. | |
*/ | |
remove(start: number, end: number): boolean; | |
/** | |
* Returns true if text is currently visible. | |
*/ | |
isTextVisible(): boolean; | |
/** | |
* Set text visibility. | |
*/ | |
setTextVisibility(on: boolean): void; | |
} | |
namespace TextDisplayer { | |
/** | |
* A factory for creating a TextDisplayer. | |
*/ | |
interface Factory { | |
new(): shakaExtern.TextDisplayer | null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment