UNPKG

audio_x

Version:

The audio player for the gen-x

1,445 lines (1,370 loc) 116 kB
declare interface AbrComponentAPI extends ComponentAPI { nextAutoLevel: number; readonly bwEstimator?: EwmaBandWidthEstimator; } declare class AbrController implements AbrComponentAPI { protected hls: Hls; private lastLevelLoadSec; private lastLoadedFragLevel; private _nextAutoLevel; private nextAutoLevelKey; private audioTracksByGroup; private codecTiers; private timer; private onCheck; private fragCurrent; private partCurrent; private bitrateTestDelay; bwEstimator: EwmaBandWidthEstimator; constructor(hls: Hls); resetEstimator(abrEwmaDefaultEstimate?: number): void; private initEstimator; protected registerListeners(): void; protected unregisterListeners(): void; destroy(): void; protected onManifestLoading(event: Events.MANIFEST_LOADING, data: ManifestLoadingData): void; private onLevelsUpdated; protected onFragLoading(event: Events.FRAG_LOADING, data: FragLoadingData): void; protected onLevelSwitching(event: Events.LEVEL_SWITCHING, data: LevelSwitchingData): void; protected onError(event: Events.ERROR, data: ErrorData): void; private getTimeToLoadFrag; protected onLevelLoaded(event: Events.LEVEL_LOADED, data: LevelLoadedData): void; private _abandonRulesCheck; protected onFragLoaded(event: Events.FRAG_LOADED, { frag, part }: FragLoadedData): void; protected onFragBuffered(event: Events.FRAG_BUFFERED, data: FragBufferedData): void; private ignoreFragment; clearTimer(): void; get firstAutoLevel(): number; get forcedAutoLevel(): number; get nextAutoLevel(): number; private getAutoLevelKey; private getNextABRAutoLevel; private getBwEstimate; private findBestLevel; set nextAutoLevel(nextLevel: number); } declare type ABRControllerConfig = { abrEwmaFastLive: number; abrEwmaSlowLive: number; abrEwmaFastVoD: number; abrEwmaSlowVoD: number; /** * Default bandwidth estimate in bits/s prior to collecting fragment bandwidth samples */ abrEwmaDefaultEstimate: number; abrEwmaDefaultEstimateMax: number; abrBandWidthFactor: number; abrBandWidthUpFactor: number; abrMaxWithRealBitrate: boolean; maxStarvationDelay: number; maxLoadingDelay: number; }; declare class AttrList { [key: string]: any; constructor(attrs: string | Record<string, any>); decimalInteger(attrName: string): number; hexadecimalInteger(attrName: string): Uint8Array | null; hexadecimalIntegerAsNumber(attrName: string): number; decimalFloatingPoint(attrName: string): number; optionalFloat(attrName: string, defaultValue: number): number; enumeratedString(attrName: string): string | undefined; bool(attrName: string): boolean; decimalResolution(attrName: string): { width: number; height: number; } | undefined; static parseAttrList(input: string): Record<string, any>; } declare type AudioPlaylistType = 'AUDIO'; declare class AudioStreamController extends BaseStreamController implements NetworkComponentAPI { private videoBuffer; private videoTrackCC; private waitingVideoCC; private bufferedTrack; private switchingTrack; private trackId; private waitingData; private mainDetails; private bufferFlushed; private cachedTrackLoadedData; constructor(hls: Hls, fragmentTracker: FragmentTracker, keyLoader: KeyLoader); protected onHandlerDestroying(): void; private _registerListeners; private _unregisterListeners; onInitPtsFound(event: Events.INIT_PTS_FOUND, { frag, id, initPTS, timescale }: InitPTSFoundData): void; startLoad(startPosition: number): void; doTick(): void; clearWaitingFragment(): void; protected resetLoadingState(): void; protected onTickEnd(): void; private doTickIdle; protected getMaxBufferLength(mainBufferLength?: number): number; onMediaDetaching(): void; onAudioTracksUpdated(event: Events.AUDIO_TRACKS_UPDATED, { audioTracks }: AudioTracksUpdatedData): void; onAudioTrackSwitching(event: Events.AUDIO_TRACK_SWITCHING, data: AudioTrackSwitchingData): void; onManifestLoading(): void; onLevelLoaded(event: Events.LEVEL_LOADED, data: LevelLoadedData): void; onAudioTrackLoaded(event: Events.AUDIO_TRACK_LOADED, data: TrackLoadedData): void; _handleFragmentLoadProgress(data: FragLoadedData): void; protected _handleFragmentLoadComplete(fragLoadedData: FragLoadedData): void; onBufferReset(): void; onBufferCreated(event: Events.BUFFER_CREATED, data: BufferCreatedData): void; onFragBuffered(event: Events.FRAG_BUFFERED, data: FragBufferedData): void; private onError; private onBufferFlushed; private _handleTransmuxComplete; private _bufferInitSegment; protected loadFragment(frag: Fragment, track: Level, targetBufferTime: number): void; private flushAudioIfNeeded; private completeAudioSwitch; } declare class AudioTrackController extends BasePlaylistController { private tracks; private groupId; private tracksInGroup; private trackId; private currentTrack; private selectDefaultTrack; constructor(hls: Hls); private registerListeners; private unregisterListeners; destroy(): void; protected onManifestLoading(): void; protected onManifestParsed(event: Events.MANIFEST_PARSED, data: ManifestParsedData): void; protected onAudioTrackLoaded(event: Events.AUDIO_TRACK_LOADED, data: AudioTrackLoadedData): void; protected onLevelLoading(event: Events.LEVEL_LOADING, data: LevelLoadingData): void; protected onLevelSwitching(event: Events.LEVEL_SWITCHING, data: LevelSwitchingData): void; private switchLevel; protected onError(event: Events.ERROR, data: ErrorData): void; get allAudioTracks(): MediaPlaylist[]; get audioTracks(): MediaPlaylist[]; get audioTrack(): number; set audioTrack(newId: number); private setAudioTrack; private selectInitialTrack; private findTrackId; protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void; } declare interface AudioTrackLoadedData extends TrackLoadedData { } declare interface AudioTracksUpdatedData { audioTracks: MediaPlaylist[]; } declare interface AudioTrackSwitchedData extends MediaPlaylist { } declare interface AudioTrackSwitchingData extends MediaPlaylist { } declare interface BackBufferData { bufferEnd: number; } declare class BasePlaylistController implements NetworkComponentAPI { protected hls: Hls; protected timer: number; protected requestScheduled: number; protected canLoad: boolean; protected log: (msg: any) => void; protected warn: (msg: any) => void; constructor(hls: Hls, logPrefix: string); destroy(): void; protected clearTimer(): void; startLoad(): void; stopLoad(): void; protected switchParams(playlistUri: string, previous: LevelDetails | undefined): HlsUrlParameters | undefined; protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void; protected shouldLoadPlaylist(playlist: Level | MediaPlaylist | null | undefined): boolean; protected shouldReloadPlaylist(playlist: Level | MediaPlaylist | null | undefined): boolean; protected playlistLoaded(index: number, data: LevelLoadedData | AudioTrackLoadedData | TrackLoadedData, previousDetails?: LevelDetails): void; private getDeliveryDirectives; protected checkRetry(errorEvent: ErrorData): boolean; } declare class BaseSegment { private _byteRange; private _url; readonly baseurl: string; relurl?: string; elementaryStreams: ElementaryStreams; constructor(baseurl: string); setByteRange(value: string, previous?: BaseSegment): void; get byteRange(): number[]; get byteRangeStartOffset(): number; get byteRangeEndOffset(): number; get url(): string; set url(value: string); } declare class BaseStreamController extends TaskLoop implements NetworkComponentAPI { protected hls: Hls; protected fragPrevious: Fragment | null; protected fragCurrent: Fragment | null; protected fragmentTracker: FragmentTracker; protected transmuxer: TransmuxerInterface | null; protected _state: string; protected playlistType: PlaylistLevelType; protected media: HTMLMediaElement | null; protected mediaBuffer: Bufferable | null; protected config: HlsConfig; protected bitrateTest: boolean; protected lastCurrentTime: number; protected nextLoadPosition: number; protected startPosition: number; protected startTimeOffset: number | null; protected loadedmetadata: boolean; protected retryDate: number; protected levels: Array<Level> | null; protected fragmentLoader: FragmentLoader; protected keyLoader: KeyLoader; protected levelLastLoaded: number | null; protected startFragRequested: boolean; protected decrypter: Decrypter; protected initPTS: RationalTimestamp[]; protected onvseeking: EventListener | null; protected onvended: EventListener | null; private readonly logPrefix; protected log: (msg: any) => void; protected warn: (msg: any) => void; constructor(hls: Hls, fragmentTracker: FragmentTracker, keyLoader: KeyLoader, logPrefix: string, playlistType: PlaylistLevelType); protected doTick(): void; protected onTickEnd(): void; startLoad(startPosition: number): void; stopLoad(): void; protected _streamEnded(bufferInfo: BufferInfo, levelDetails: LevelDetails): boolean; protected getLevelDetails(): LevelDetails | undefined; protected onMediaAttached(event: Events.MEDIA_ATTACHED, data: MediaAttachedData): void; protected onMediaDetaching(): void; protected onMediaSeeking(): void; protected onMediaEnded(): void; protected onManifestLoaded(event: Events.MANIFEST_LOADED, data: ManifestLoadedData): void; protected onHandlerDestroying(): void; protected onHandlerDestroyed(): void; protected loadFragment(frag: Fragment, level: Level, targetBufferTime: number): void; private _loadFragForPlayback; protected clearTrackerIfNeeded(frag: Fragment): void; protected flushMainBuffer(startOffset: number, endOffset: number, type?: SourceBufferName | null): void; protected _loadInitSegment(frag: Fragment, level: Level): void; private completeInitSegmentLoad; protected fragContextChanged(frag: Fragment | null): boolean; protected fragBufferedComplete(frag: Fragment, part: Part | null): void; protected seekToStartPos(): void; protected _handleFragmentLoadComplete(fragLoadedEndData: PartsLoadedData): void; protected _handleFragmentLoadProgress(frag: PartsLoadedData | FragLoadedData): void; protected _doFragLoad(frag: Fragment, level: Level, targetBufferTime?: number | null, progressCallback?: FragmentLoadProgressCallback): Promise<PartsLoadedData | FragLoadedData | null>; private doFragPartsLoad; private handleFragLoadError; protected _handleTransmuxerFlush(chunkMeta: ChunkMetadata): void; protected getCurrentContext(chunkMeta: ChunkMetadata): { frag: Fragment; part: Part | null; level: Level; } | null; protected bufferFragmentData(data: RemuxedTrack, frag: Fragment, part: Part | null, chunkMeta: ChunkMetadata, noBacktracking?: boolean): void; protected flushBufferGap(frag: Fragment): void; protected getFwdBufferInfo(bufferable: Bufferable | null, type: PlaylistLevelType): BufferInfo | null; protected getFwdBufferInfoAtPos(bufferable: Bufferable | null, pos: number, type: PlaylistLevelType): BufferInfo | null; protected getMaxBufferLength(levelBitrate?: number): number; protected reduceMaxBufferLength(threshold: number): boolean; protected getAppendedFrag(position: number, playlistType?: PlaylistLevelType): Fragment | null; protected getNextFragment(pos: number, levelDetails: LevelDetails): Fragment | null; protected isLoopLoading(frag: Fragment, targetBufferTime: number): boolean; protected getNextFragmentLoopLoading(frag: Fragment, levelDetails: LevelDetails, bufferInfo: BufferInfo, playlistType: PlaylistLevelType, maxBufLen: number): Fragment | null; mapToInitFragWhenRequired(frag: Fragment | null): typeof frag; getNextPart(partList: Part[], frag: Fragment, targetBufferTime: number): number; private loadedEndOfParts; protected getInitialLiveFragment(levelDetails: LevelDetails, fragments: Array<Fragment>): Fragment | null; protected getFragmentAtPosition(bufferEnd: number, end: number, levelDetails: LevelDetails): Fragment | null; protected synchronizeToLiveEdge(levelDetails: LevelDetails): void; protected alignPlaylists(details: LevelDetails, previousDetails?: LevelDetails): number; protected waitForCdnTuneIn(details: LevelDetails): boolean | 0; protected setStartPosition(details: LevelDetails, sliding: number): void; protected getLoadPosition(): number; private handleFragLoadAborted; protected resetFragmentLoading(frag: Fragment): void; protected onFragmentOrKeyLoadError(filterType: PlaylistLevelType, data: ErrorData): void; protected reduceLengthAndFlushBuffer(data: ErrorData): boolean; protected resetFragmentErrors(filterType: PlaylistLevelType): void; protected afterBufferFlushed(media: Bufferable, bufferType: SourceBufferName, playlistType: PlaylistLevelType): void; protected resetLoadingState(): void; protected resetStartWhenNotLoaded(level: number): void; protected resetWhenMissingContext(chunkMeta: ChunkMetadata): void; protected removeUnbufferedFrags(start?: number): void; private updateLevelTiming; protected resetTransmuxer(): void; protected recoverWorkerError(data: ErrorData): void; set state(nextState: string); get state(): string; } declare type Bufferable = { buffered: TimeRanges; }; declare interface BufferAppendedData { type: SourceBufferName; frag: Fragment; part: Part | null; chunkMeta: ChunkMetadata; parent: PlaylistLevelType; timeRanges: Partial<Record<SourceBufferName, TimeRanges>>; } declare interface BufferAppendingData { type: SourceBufferName; frag: Fragment; part: Part | null; chunkMeta: ChunkMetadata; parent: PlaylistLevelType; data: Uint8Array; } declare interface BufferCodecsData { video?: Track; audio?: Track; } declare class BufferController implements ComponentAPI { private details; private _objectUrl; private operationQueue; private listeners; private hls; bufferCodecEventsExpected: number; private _bufferCodecEventsTotal; media: HTMLMediaElement | null; mediaSource: MediaSource | null; private lastMpegAudioChunk; private appendSource; appendErrors: { audio: number; video: number; audiovideo: number; }; tracks: TrackSet; pendingTracks: TrackSet; sourceBuffer: SourceBuffers; protected log: (msg: any) => void; protected warn: (msg: any, obj?: any) => void; protected error: (msg: any, obj?: any) => void; constructor(hls: Hls); hasSourceTypes(): boolean; destroy(): void; protected registerListeners(): void; protected unregisterListeners(): void; private _initSourceBuffer; private onManifestLoading; protected onManifestParsed(event: Events.MANIFEST_PARSED, data: ManifestParsedData): void; protected onMediaAttaching(event: Events.MEDIA_ATTACHING, data: MediaAttachingData): void; private _onEndStreaming; private _onStartStreaming; protected onMediaDetaching(): void; protected onBufferReset(): void; private resetBuffer; protected onBufferCodecs(event: Events.BUFFER_CODECS, data: BufferCodecsData): void; protected appendChangeType(type: any, mimeType: any): void; protected onBufferAppending(event: Events.BUFFER_APPENDING, eventData: BufferAppendingData): void; protected onBufferFlushing(event: Events.BUFFER_FLUSHING, data: BufferFlushingData): void; protected onFragParsed(event: Events.FRAG_PARSED, data: FragParsedData): void; private onFragChanged; protected onBufferEos(event: Events.BUFFER_EOS, data: BufferEOSData): void; protected onLevelUpdated(event: Events.LEVEL_UPDATED, { details }: LevelUpdatedData): void; flushBackBuffer(): void; /** * Update Media Source duration to current level duration or override to Infinity if configuration parameter * 'liveDurationInfinity` is set to `true` * More details: https://github.com/video-dev/hls.js/issues/355 */ private updateMediaElementDuration; updateSeekableRange(levelDetails: any): void; protected checkPendingTracks(): void; protected createSourceBuffers(tracks: TrackSet): void; private _onMediaSourceOpen; private _onMediaSourceClose; private _onMediaSourceEnded; private _onMediaEmptied; private get mediaSrc(); private _onSBUpdateStart; private _onSBUpdateEnd; private _onSBUpdateError; private removeExecutor; private appendExecutor; private blockBuffers; private getSourceBufferTypes; private addBufferListener; private removeBufferListeners; } declare type BufferControllerConfig = { appendErrorMaxRetry: number; backBufferLength: number; liveDurationInfinity: boolean; /** * @deprecated use backBufferLength */ liveBackBufferLength: number | null; }; declare interface BufferCreatedData { tracks: TrackSet; } declare interface BufferEOSData { type?: SourceBufferName; } declare interface BufferFlushedData { type: SourceBufferName; } declare interface BufferFlushingData { startOffset: number; endOffset: number; endOffsetSubtitles?: number; type: SourceBufferName | null; } declare type BufferInfo = { len: number; start: number; end: number; nextStart?: number; }; declare class CapLevelController implements ComponentAPI { private hls; private autoLevelCapping; private firstLevel; private media; private restrictedLevels; private timer; private clientRect; private streamController?; constructor(hls: Hls); setStreamController(streamController: StreamController): void; destroy(): void; protected registerListeners(): void; protected unregisterListener(): void; protected onFpsDropLevelCapping(event: Events.FPS_DROP_LEVEL_CAPPING, data: FPSDropLevelCappingData): void; protected onMediaAttaching(event: Events.MEDIA_ATTACHING, data: MediaAttachingData): void; protected onManifestParsed(event: Events.MANIFEST_PARSED, data: ManifestParsedData): void; private onLevelsUpdated; protected onBufferCodecs(event: Events.BUFFER_CODECS, data: BufferCodecsData): void; protected onMediaDetaching(): void; detectPlayerSize(): void; getMaxLevel(capLevelIndex: number): number; startCapping(): void; stopCapping(): void; getDimensions(): { width: number; height: number; }; get mediaWidth(): number; get mediaHeight(): number; get contentScaleFactor(): number; private isLevelAllowed; static getMaxLevelByMediaSize(levels: Array<Level>, width: number, height: number): number; } declare type CapLevelControllerConfig = { capLevelToPlayerSize: boolean; }; /** * Keep a CEA-608 screen of 32x15 styled characters * @constructor */ declare class CaptionScreen { rows: Row[]; currRow: number; nrRollUpRows: number | null; lastOutputScreen: CaptionScreen | null; logger: CaptionsLogger; constructor(logger: CaptionsLogger); reset(): void; equals(other: CaptionScreen): boolean; copy(other: CaptionScreen): void; isEmpty(): boolean; backSpace(): void; clearToEndOfRow(): void; /** * Insert a character (without styling) in the current row. */ insertChar(char: number): void; setPen(styles: Partial<PenStyles>): void; moveCursor(relPos: number): void; setCursor(absPos: number): void; setPAC(pacData: PACData): void; /** * Set background/extra foreground, but first do back_space, and then insert space (backwards compatibility). */ setBkgData(bkgData: Partial<PenStyles>): void; setRollUpRows(nrRows: number | null): void; rollUp(): void; /** * Get all non-empty rows with as unicode text. */ getDisplayText(asOneRow?: boolean): string; getTextAndFormat(): Row[]; } declare class CaptionsLogger { time: number | null; verboseLevel: VerboseLevel; log(severity: VerboseLevel, msg: string | (() => string)): void; } declare class ChunkMetadata { readonly level: number; readonly sn: number; readonly part: number; readonly id: number; readonly size: number; readonly partial: boolean; readonly transmuxing: HlsChunkPerformanceTiming; readonly buffering: { [key in SourceBufferName]: HlsChunkPerformanceTiming; }; constructor(level: number, sn: number, id: number, size?: number, part?: number, partial?: boolean); } /** * CMCD */ declare interface CMCD { /** * Encoded bitrate * * The encoded bitrate of the audio or video object being requested. This may not be known precisely by the player; however, * it MAY be estimated based upon playlist/manifest declarations. If the playlist declares both peak and average bitrate values, * the peak value should be transmitted. * * Integer kbps */ br?: number; /** * Object duration * * The playback duration in milliseconds of the object being requested. If a partial segment is being requested, then this value * MUST indicate the playback duration of that part and not that of its parent segment. This value can be an approximation of the * estimated duration if the explicit value is not known. * * Integer milliseconds */ d?: number; /** * Object type * * The media type of the current object being requested: * - `m` = text file, such as a manifest or playlist * - `a` = audio only * - `v` = video only * - `av` = muxed audio and video * - `i` = init segment * - `c` = caption or subtitle * - `tt` = ISOBMFF timed text track * - `k` = cryptographic key, license or certificate. * - `o` = other * * If the object type being requested is unknown, then this key MUST NOT be used. */ ot?: CMCDObjectType; /** * Top bitrate * * The highest bitrate rendition in the manifest or playlist that the client is allowed to play, given current codec, licensing and * sizing constraints. * * Integer Kbps */ tb?: number; /** * Buffer length * * The buffer length associated with the media object being requested. This value MUST be rounded to the nearest 100 ms. This key SHOULD only be * sent with an object type of ‘a’, ‘v’ or ‘av’. * * Integer milliseconds */ bl?: number; /** * Deadline * * Deadline from the request time until the first sample of this Segment/Object needs to be available in order to not create a buffer underrun or * any other playback problems. This value MUST be rounded to the nearest 100ms. For a playback rate of 1, this may be equivalent to the player’s * remaining buffer length. * * Integer milliseconds */ dl?: number; /** * Measured mtp CMCD throughput * * The throughput between client and server, as measured by the client and MUST be rounded to the nearest 100 kbps. This value, however derived, * SHOULD be the value that the client is using to make its next Adaptive Bitrate switching decision. If the client is connected to multiple * servers concurrently, it must take care to report only the throughput measured against the receiving server. If the client has multiple concurrent * connections to the server, then the intent is that this value communicates the aggregate throughput the client sees across all those connections. * * Integer kbps */ mtp?: number; /** * Next object request * * Relative path of the next object to be requested. This can be used to trigger pre-fetching by the CDN. This MUST be a path relative to the current * request. This string MUST be URLEncoded. The client SHOULD NOT depend upon any pre-fetch action being taken - it is merely a request for such a * pre-fetch to take place. * * String */ nor?: string; /** * Next range request * * If the next request will be a partial object request, then this string denotes the byte range to be requested. If the ‘nor’ field is not set, then the * object is assumed to match the object currently being requested. The client SHOULD NOT depend upon any pre-fetch action being taken – it is merely a * request for such a pre-fetch to take place. Formatting is similar to the HTTP Range header, except that the unit MUST be ‘byte’, the ‘Range:’ prefix is * NOT required and specifying multiple ranges is NOT allowed. Valid combinations are: * * - `"\<range-start\>-"` * - `"\<range-start\>-\<range-end\>"` * - `"-\<suffix-length\>"` * * String */ nrr?: string; /** * Startup * * Key is included without a value if the object is needed urgently due to startup, seeking or recovery after a buffer-empty event. The media SHOULD not be * rendering when this request is made. This key MUST not be sent if it is FALSE. * * Boolean */ su?: boolean; /** * Content ID * * A unique string identifying the current content. Maximum length is 64 characters. This value is consistent across multiple different * sessions and devices and is defined and updated at the discretion of the service provider. * * String */ cid?: string; /** * Playback rate * * `1` if real-time, `2` if double speed, `0` if not playing. SHOULD only be sent if not equal to `1`. * * Decimal */ pr?: number; /** * Streaming format * * The streaming format that defines the current request. * * - `d` = MPEG DASH * - `h` = HTTP Live Streaming (HLS) * - `s` = Smooth Streaming * - `o` = other * * If the streaming format being requested is unknown, then this key MUST NOT be used. */ sf?: typeof CMCDStreamingFormatHLS; /** * Session ID * * A GUID identifying the current playback session. A playback session typically ties together segments belonging to a single media asset. * Maximum length is 64 characters. It is RECOMMENDED to conform to the UUID specification. * * String */ sid?: string; /** * Stream type * - `v` = all segments are available – e.g., VOD * - `l` = segments become available over time – e.g., LIVE */ st?: CMCDStreamType; /** * CMCD version * * The version of this specification used for interpreting the defined key names and values. If this key is omitted, the client and server MUST * interpret the values as being defined by version 1. Client SHOULD omit this field if the version is 1. * * Integer */ v?: number; /** * Buffer starvation * * Key is included without a value if the buffer was starved at some point between the prior request and this object request, * resulting in the player being in a rebuffering state and the video or audio playback being stalled. This key MUST NOT be * sent if the buffer was not starved since the prior request. * * If the object type `ot` key is sent along with this key, then the `bs` key refers to the buffer associated with the particular * object type. If no object type is communicated, then the buffer state applies to the current session. * * Boolean */ bs?: boolean; /** * Requested maximum throughput * * The requested maximum throughput that the client considers sufficient for delivery of the asset. Values MUST be rounded to the * nearest 100kbps. For example, a client would indicate that the current segment, encoded at 2Mbps, is to be delivered at no more * than 10Mbps, by using rtp=10000. * * Note: This can benefit clients by preventing buffer saturation through over-delivery and can also deliver a community benefit * through fair-share delivery. The concept is that each client receives the throughput necessary for great performance, but no more. * The CDN may not support the rtp feature. * * Integer kbps */ rtp?: number; } /** * Controller to deal with Common Media Client Data (CMCD) * @see https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf */ declare class CMCDController implements ComponentAPI { private hls; private config; private media?; private sid?; private cid?; private useHeaders; private initialized; private starved; private buffering; private audioBuffer?; private videoBuffer?; constructor(hls: Hls); private registerListeners; private unregisterListeners; destroy(): void; private onMediaAttached; private onMediaDetached; private onBufferCreated; private onWaiting; private onPlaying; /** * Create baseline CMCD data */ private createData; /** * Apply CMCD data to a request. */ private apply; /** * Apply CMCD data to a manifest request. */ private applyPlaylistData; /** * Apply CMCD data to a segment request */ private applyFragmentData; /** * The CMCD object type. */ private getObjectType; /** * Get the highest bitrate. */ private getTopBandwidth; /** * Get the buffer length for a media type in milliseconds */ private getBufferLength; /** * Create a playlist loader */ private createPlaylistLoader; /** * Create a playlist loader */ private createFragmentLoader; /** * Generate a random v4 UUI * * @returns {string} */ static uuid(): string; /** * Serialize a CMCD data object according to the rules defined in the * section 3.2 of * [CTA-5004](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf). */ static serialize(data: CMCD): string; /** * Convert a CMCD data object to request headers according to the rules * defined in the section 2.1 and 3.2 of * [CTA-5004](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf). */ static toHeaders(data: CMCD): Partial<CMCDHeaders>; /** * Convert a CMCD data object to query args according to the rules * defined in the section 2.2 and 3.2 of * [CTA-5004](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf). */ static toQuery(data: CMCD): string; /** * Append query args to a uri. */ static appendQueryToUri(uri: any, query: any): any; } declare type CMCDControllerConfig = { sessionId?: string; contentId?: string; useHeaders?: boolean; }; /** * CMCD Headers */ declare interface CMCDHeaders { 'CMCD-Object': string; 'CMCD-Request': string; 'CMCD-Session': string; 'CMCD-Status': string; } /** * CMCD Object Type */ declare const enum CMCDObjectType { MANIFEST = "m", AUDIO = "a", VIDEO = "v", MUXED = "av", INIT = "i", CAPTION = "c", TIMED_TEXT = "tt", KEY = "k", OTHER = "o" } /** * CMCD Streaming Format */ declare const CMCDStreamingFormatHLS = "h"; /** * CMCD Streaming Type */ declare const enum CMCDStreamType { VOD = "v", LIVE = "l" } declare interface ComponentAPI { destroy(): void; } declare class ContentSteeringController implements NetworkComponentAPI { private readonly hls; private log; private loader; private uri; private pathwayId; private pathwayPriority; private timeToLoad; private reloadTimer; private updated; private started; private enabled; private levels; private audioTracks; private subtitleTracks; private penalizedPathways; constructor(hls: Hls); private registerListeners; private unregisterListeners; startLoad(): void; stopLoad(): void; clearTimeout(): void; destroy(): void; removeLevel(levelToRemove: Level): void; private onManifestLoading; private onManifestLoaded; private onManifestParsed; private onError; filterParsedLevels(levels: Level[]): Level[]; private getLevelsForPathway; private updatePathwayPriority; private clonePathways; private loadSteeringManifest; private scheduleRefresh; } declare type ContentSteeringOptions = { uri: string; pathwayId: string; }; declare interface CuesInterface { newCue(track: TextTrack | null, startTime: number, endTime: number, captionScreen: CaptionScreen): VTTCue[]; } declare interface CuesParsedData { type: 'captions' | 'subtitles'; cues: any; track: string; } declare class DateRange { attr: AttrList; private _startDate; private _endDate?; private _badValueForSameId?; constructor(dateRangeAttr: AttrList, dateRangeWithSameId?: DateRange); get id(): string; get class(): string; get startDate(): Date; get endDate(): Date | null; get duration(): number | null; get plannedDuration(): number | null; get endOnNext(): boolean; get isValid(): boolean; } declare interface DecryptData { uri: string; method: string; keyFormat: string; keyFormatVersions: number[]; iv: Uint8Array | null; key: Uint8Array | null; keyId: Uint8Array | null; pssh: Uint8Array | null; encrypted: boolean; isCommonEncryption: boolean; } declare class Decrypter { private logEnabled; private removePKCS7Padding; private subtle; private softwareDecrypter; private key; private fastAesKey; private remainderData; private currentIV; private currentResult; private useSoftware; constructor(config: HlsConfig, { removePKCS7Padding }?: { removePKCS7Padding?: boolean | undefined; }); destroy(): void; isSync(): boolean; flush(): Uint8Array | null; reset(): void; decrypt(data: Uint8Array | ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer): Promise<ArrayBuffer>; softwareDecrypt(data: Uint8Array, key: ArrayBuffer, iv: ArrayBuffer): ArrayBuffer | null; webCryptoDecrypt(data: Uint8Array, key: ArrayBuffer, iv: ArrayBuffer): Promise<ArrayBuffer>; private onWebCryptoError; private getValidChunk; private logOnce; } declare type DRMSystemConfiguration = { licenseUrl: string; serverCertificateUrl?: string; generateRequest?: (this: Hls, initDataType: string, initData: ArrayBuffer | null, keyContext: MediaKeySessionContext) => { initDataType: string; initData: ArrayBuffer | null; } | undefined | never; }; declare type DRMSystemOptions = { audioRobustness?: string; videoRobustness?: string; audioEncryptionScheme?: string | null; videoEncryptionScheme?: string | null; persistentState?: MediaKeysRequirement; distinctiveIdentifier?: MediaKeysRequirement; sessionTypes?: string[]; sessionType?: string; }; declare type DRMSystemsConfiguration = Partial<Record<KeySystems, DRMSystemConfiguration>>; declare interface ElementaryStreamInfo { startPTS: number; endPTS: number; startDTS: number; endDTS: number; partial?: boolean; } declare type ElementaryStreams = Record<ElementaryStreamTypes, ElementaryStreamInfo | null>; declare const enum ElementaryStreamTypes { AUDIO = "audio", VIDEO = "video", AUDIOVIDEO = "audiovideo" } /** * Controller to deal with encrypted media extensions (EME) * @see https://developer.mozilla.org/en-US/docs/Web/API/Encrypted_Media_Extensions_API * * @class * @constructor */ declare class EMEController implements ComponentAPI { static CDMCleanupPromise: Promise<void> | void; private readonly hls; private readonly config; private media; private keyFormatPromise; private keySystemAccessPromises; private _requestLicenseFailureCount; private mediaKeySessions; private keyIdToKeySessionPromise; private setMediaKeysQueue; private onMediaEncrypted; private onWaitingForKey; private debug; private log; private warn; private error; constructor(hls: Hls); destroy(): void; private registerListeners; private unregisterListeners; private getLicenseServerUrl; private getServerCertificateUrl; private attemptKeySystemAccess; private requestMediaKeySystemAccess; private getMediaKeysPromise; private createMediaKeySessionContext; private renewKeySession; private getKeyIdString; private updateKeySession; selectKeySystemFormat(frag: Fragment): Promise<KeySystemFormats>; private getKeyFormatPromise; loadKey(data: KeyLoadedData): Promise<MediaKeySessionContext>; private throwIfDestroyed; private handleError; private getKeySystemForKeyPromise; private getKeySystemSelectionPromise; private _onMediaEncrypted; private _onWaitingForKey; private attemptSetMediaKeys; private generateRequestWithPreferredKeySession; private onKeyStatusChange; private fetchServerCertificate; private setMediaKeysServerCertificate; private renewLicense; private unpackPlayReadyKeyMessage; private setupLicenseXHR; private requestLicense; private onMediaAttached; private onMediaDetached; private onManifestLoading; private onManifestLoaded; private removeSession; } declare type EMEControllerConfig = { licenseXhrSetup?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext, licenseChallenge: Uint8Array) => void | Uint8Array | Promise<Uint8Array | void>; licenseResponseCallback?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext) => ArrayBuffer; emeEnabled: boolean; widevineLicenseUrl?: string; drmSystems: DRMSystemsConfiguration; drmSystemOptions: DRMSystemOptions; requestMediaKeySystemAccessFunc: MediaKeyFunc | null; }; declare const enum ErrorActionFlags { None = 0, MoveAllAlternatesMatchingHost = 1, MoveAllAlternatesMatchingHDCP = 2, SwitchToSDR = 4 } declare class ErrorController implements NetworkComponentAPI { private readonly hls; private playlistError; private penalizedRenditions; private log; private warn; private error; constructor(hls: Hls); private registerListeners; private unregisterListeners; destroy(): void; startLoad(startPosition: number): void; stopLoad(): void; private getVariantLevelIndex; private onManifestLoading; private onLevelUpdated; private onError; private keySystemError; private getPlaylistRetryOrSwitchAction; private getFragRetryOrSwitchAction; private getLevelSwitchAction; onErrorOut(event: Events.ERROR, data: ErrorData): void; private sendAlternateToPenaltyBox; private switchLevel; private redundantFailover; private penalizeRendition; } declare interface ErrorData { type: ErrorTypes; details: ErrorDetails; error: Error; fatal: boolean; errorAction?: IErrorAction; buffer?: number; bytes?: number; chunkMeta?: ChunkMetadata; context?: PlaylistLoaderContext; event?: keyof HlsListeners | 'demuxerWorker'; frag?: Fragment; part?: Part | null; level?: number | undefined; levelRetry?: boolean; loader?: Loader<LoaderContext>; networkDetails?: any; stats?: LoaderStats; mimeType?: string; reason?: string; response?: LoaderResponse; url?: string; parent?: PlaylistLevelType; sourceBufferName?: SourceBufferName; /** * @deprecated Use ErrorData.error */ err?: { message: string; }; } declare enum ErrorDetails { KEY_SYSTEM_NO_KEYS = "keySystemNoKeys", KEY_SYSTEM_NO_ACCESS = "keySystemNoAccess", KEY_SYSTEM_NO_SESSION = "keySystemNoSession", KEY_SYSTEM_NO_CONFIGURED_LICENSE = "keySystemNoConfiguredLicense", KEY_SYSTEM_LICENSE_REQUEST_FAILED = "keySystemLicenseRequestFailed", KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED = "keySystemServerCertificateRequestFailed", KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED = "keySystemServerCertificateUpdateFailed", KEY_SYSTEM_SESSION_UPDATE_FAILED = "keySystemSessionUpdateFailed", KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED = "keySystemStatusOutputRestricted", KEY_SYSTEM_STATUS_INTERNAL_ERROR = "keySystemStatusInternalError", MANIFEST_LOAD_ERROR = "manifestLoadError", MANIFEST_LOAD_TIMEOUT = "manifestLoadTimeOut", MANIFEST_PARSING_ERROR = "manifestParsingError", MANIFEST_INCOMPATIBLE_CODECS_ERROR = "manifestIncompatibleCodecsError", LEVEL_EMPTY_ERROR = "levelEmptyError", LEVEL_LOAD_ERROR = "levelLoadError", LEVEL_LOAD_TIMEOUT = "levelLoadTimeOut", LEVEL_PARSING_ERROR = "levelParsingError", LEVEL_SWITCH_ERROR = "levelSwitchError", AUDIO_TRACK_LOAD_ERROR = "audioTrackLoadError", AUDIO_TRACK_LOAD_TIMEOUT = "audioTrackLoadTimeOut", SUBTITLE_LOAD_ERROR = "subtitleTrackLoadError", SUBTITLE_TRACK_LOAD_TIMEOUT = "subtitleTrackLoadTimeOut", FRAG_LOAD_ERROR = "fragLoadError", FRAG_LOAD_TIMEOUT = "fragLoadTimeOut", FRAG_DECRYPT_ERROR = "fragDecryptError", FRAG_PARSING_ERROR = "fragParsingError", FRAG_GAP = "fragGap", REMUX_ALLOC_ERROR = "remuxAllocError", KEY_LOAD_ERROR = "keyLoadError", KEY_LOAD_TIMEOUT = "keyLoadTimeOut", BUFFER_ADD_CODEC_ERROR = "bufferAddCodecError", BUFFER_INCOMPATIBLE_CODECS_ERROR = "bufferIncompatibleCodecsError", BUFFER_APPEND_ERROR = "bufferAppendError", BUFFER_APPENDING_ERROR = "bufferAppendingError", BUFFER_STALLED_ERROR = "bufferStalledError", BUFFER_FULL_ERROR = "bufferFullError", BUFFER_SEEK_OVER_HOLE = "bufferSeekOverHole", BUFFER_NUDGE_ON_STALL = "bufferNudgeOnStall", INTERNAL_EXCEPTION = "internalException", INTERNAL_ABORTED = "aborted", UNKNOWN = "unknown" } declare enum ErrorTypes { NETWORK_ERROR = "networkError", MEDIA_ERROR = "mediaError", KEY_SYSTEM_ERROR = "keySystemError", MUX_ERROR = "muxError", OTHER_ERROR = "otherError" } declare enum Events { MEDIA_ATTACHING = "hlsMediaAttaching", MEDIA_ATTACHED = "hlsMediaAttached", MEDIA_DETACHING = "hlsMediaDetaching", MEDIA_DETACHED = "hlsMediaDetached", BUFFER_RESET = "hlsBufferReset", BUFFER_CODECS = "hlsBufferCodecs", BUFFER_CREATED = "hlsBufferCreated", BUFFER_APPENDING = "hlsBufferAppending", BUFFER_APPENDED = "hlsBufferAppended", BUFFER_EOS = "hlsBufferEos", BUFFER_FLUSHING = "hlsBufferFlushing", BUFFER_FLUSHED = "hlsBufferFlushed", MANIFEST_LOADING = "hlsManifestLoading", MANIFEST_LOADED = "hlsManifestLoaded", MANIFEST_PARSED = "hlsManifestParsed", LEVEL_SWITCHING = "hlsLevelSwitching", LEVEL_SWITCHED = "hlsLevelSwitched", LEVEL_LOADING = "hlsLevelLoading", LEVEL_LOADED = "hlsLevelLoaded", LEVEL_UPDATED = "hlsLevelUpdated", LEVEL_PTS_UPDATED = "hlsLevelPtsUpdated", LEVELS_UPDATED = "hlsLevelsUpdated", AUDIO_TRACKS_UPDATED = "hlsAudioTracksUpdated", AUDIO_TRACK_SWITCHING = "hlsAudioTrackSwitching", AUDIO_TRACK_SWITCHED = "hlsAudioTrackSwitched", AUDIO_TRACK_LOADING = "hlsAudioTrackLoading", AUDIO_TRACK_LOADED = "hlsAudioTrackLoaded", SUBTITLE_TRACKS_UPDATED = "hlsSubtitleTracksUpdated", SUBTITLE_TRACKS_CLEARED = "hlsSubtitleTracksCleared", SUBTITLE_TRACK_SWITCH = "hlsSubtitleTrackSwitch", SUBTITLE_TRACK_LOADING = "hlsSubtitleTrackLoading", SUBTITLE_TRACK_LOADED = "hlsSubtitleTrackLoaded", SUBTITLE_FRAG_PROCESSED = "hlsSubtitleFragProcessed", CUES_PARSED = "hlsCuesParsed", NON_NATIVE_TEXT_TRACKS_FOUND = "hlsNonNativeTextTracksFound", INIT_PTS_FOUND = "hlsInitPtsFound", FRAG_LOADING = "hlsFragLoading", FRAG_LOAD_EMERGENCY_ABORTED = "hlsFragLoadEmergencyAborted", FRAG_LOADED = "hlsFragLoaded", FRAG_DECRYPTED = "hlsFragDecrypted", FRAG_PARSING_INIT_SEGMENT = "hlsFragParsingInitSegment", FRAG_PARSING_USERDATA = "hlsFragParsingUserdata", FRAG_PARSING_METADATA = "hlsFragParsingMetadata", FRAG_PARSED = "hlsFragParsed", FRAG_BUFFERED = "hlsFragBuffered", FRAG_CHANGED = "hlsFragChanged", FPS_DROP = "hlsFpsDrop", FPS_DROP_LEVEL_CAPPING = "hlsFpsDropLevelCapping", ERROR = "hlsError", DESTROYING = "hlsDestroying", KEY_LOADING = "hlsKeyLoading", KEY_LOADED = "hlsKeyLoaded", LIVE_BACK_BUFFER_REACHED = "hlsLiveBackBufferReached", BACK_BUFFER_REACHED = "hlsBackBufferReached", STEERING_MANIFEST_LOADED = "hlsSteeringManifestLoaded" } declare class EwmaBandWidthEstimator { private defaultEstimate_; private minWeight_; private minDelayMs_; private slow_; private fast_; private defaultTTFB_; private ttfb_; constructor(slow: number, fast: number, defaultEstimate: number, defaultTTFB?: number); update(slow: number, fast: number): void; sample(durationMs: number, numBytes: number): void; sampleTTFB(ttfb: number): void; canEstimate(): boolean; getEstimate(): number; getEstimateTTFB(): number; destroy(): void; } declare type ExtendedSourceBuffer = SourceBuffer & { ended?: boolean; ending?: boolean; changeType?: (type: string) => void; }; declare class FPSController implements ComponentAPI { private hls; private isVideoPlaybackQualityAvailable; private timer?; private media; private lastTime; private lastDroppedFrames; private lastDecodedFrames; private streamController; constructor(hls: Hls); setStreamController(streamController: StreamController): void; protected registerListeners(): void; protected unregisterListeners(): void; destroy(): void; protected onMediaAttaching(event: Events.MEDIA_ATTACHING, data: MediaAttachingData): void; checkFPS(video: HTMLVideoElement, decodedFrames: number, droppedFrames: number): void; checkFPSInterval(): void; } declare type FPSControllerConfig = { capLevelOnFPSDrop: boolean; fpsDroppedMonitoringPeriod: number; fpsDroppedMonitoringThreshold: number; }; declare interface FPSDropData { currentDropped: number; currentDecoded: number; totalDroppedFrames: number; } declare interface FPSDropLevelCappingData { droppedLevel: number; level: number; } declare interface FragBufferedData { stats: LoadStats; frag: Fragment; part: Part | null; id: string; } declare interface FragChangedData { frag: Fragment; } declare interface FragDecryptedData { frag: Fragment; payload: ArrayBuffer; stats: { tstart: number; tdecrypt: number; }; } declare interface FragLoadedData { frag: Fragment; part: Part | null; payload: ArrayBuffer; networkDetails: unknown; } declare interface FragLoadEmergencyAbortedData { frag: Fragment; part: Part | null; stats: LoaderStats; } declare interface FragLoadFailResult extends ErrorData { frag: Fragment; part?: Part; response?: { data: any; code: number; text: string; url: string; }; networkDetails: any; } declare interface FragLoadingData { frag: Fragment; part?: Part; targetBufferTime: number | null; } /** * Object representing parsed data from an HLS Segment. Found in {@link hls.js#LevelDetails.fragments}. */ declare class Fragment extends BaseSegment { private _decryptdata; rawProgramDateTime: string | null; programDateTime: number | null; tagList: Array<string[]>; duration: number; sn: number | 'initSegment'; levelkeys?: { [key: string]: LevelKey; }; readonly type: PlaylistLevelType; loader: Loader<FragmentLoaderContext> | null; keyLoader: Loader<KeyLoaderContext> | null; level: number; cc: number; startPTS?: number; endPTS?: number; startDTS: number; endDTS: number; start: number; deltaPTS?: number; maxStartPTS?: number; minEndPTS?: number; stats: LoadStats; urlId: number; data?: Uint8Array; bitrateTest: boolean; title: string | null; initSegment: Fragment | null; endList?: boolean; gap?: boolean; constructor(type: PlaylistLevelType, baseurl: string); get decryptdata(): LevelKey | null; get end(): number; get endProgramDateTime(): number | null; get encrypted(): boolean; setKeyFormat(keyFormat: KeySystemFormats): void; abortRequests(): void; setElementaryStreamInfo(type: ElementaryStreamTypes, startPTS: number, endPTS: number, startDTS: number, endDTS: number, partial?: boolean): void; clearElementaryStreamInfo(): void; } declare class FragmentLoader { private readonly config; private loader; private partLoadTimeout; constructor(config: HlsConfig); destroy(): void; abort(): void; load(frag: Fragment, onProgress?: FragmentLoadProgressCallback): Promise<FragLoadedData>; loadPart(frag: Fragment, part: Part, onProgress: FragmentLoadProgressCallback): Promise<FragLoadedData>; private updateStatsFromPart; private resetLoader; } /** * @deprecated use fragLoadPolicy.default */ declare type FragmentLoaderConfig = { fragLoadingTimeOut: number; fragLoadingMaxRetry: number; fragLoadingRetryDela