mirror of
https://github.com/video-dev/hls.js.git
synced 2026-05-17 13:30:38 +00:00
Replace ESDocs generated api-docs with api-documenter markdown (#5163)
This commit is contained in:
-18
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"source": "./src",
|
||||
"destination": "./api-docs",
|
||||
"plugins": [
|
||||
{ "name": "@itsjamie/esdoc-standard-plugin" },
|
||||
{
|
||||
"name": "@itsjamie/esdoc-typescript-plugin",
|
||||
"option": { "enable": true }
|
||||
},
|
||||
{
|
||||
"name": "@itsjamie/esdoc-ecmascript-proposal-plugin",
|
||||
"option": {
|
||||
"objectRestSpread": true,
|
||||
"optionalChaining": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,6 +8,10 @@ on:
|
||||
|
||||
permissions: {}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
config:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -99,6 +103,8 @@ jobs:
|
||||
run: |
|
||||
npm run build:ci
|
||||
npm run docs
|
||||
./scripts/check-docs-built.sh
|
||||
|
||||
# check that hls.js doesn't error if requiring in node
|
||||
# see https://github.com/video-dev/hls.js/pull/1642
|
||||
node -e 'require("./" + require("./package.json").main)'
|
||||
|
||||
@@ -21,6 +21,7 @@ coverage/
|
||||
/dist.zip
|
||||
/netlify
|
||||
/api-docs
|
||||
/api-docs-markdown
|
||||
|
||||
# eslint
|
||||
.eslintcache
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@
|
||||
"reportTempFolder": "<projectFolder>/api-extractor/report-temp"
|
||||
},
|
||||
"docModel": {
|
||||
"enabled": false
|
||||
"enabled": true,
|
||||
"apiJsonFilePath": "<projectFolder>/api-extractor/<unscopedPackageName>.api.json"
|
||||
},
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
/report-temp
|
||||
hls.js.api.json
|
||||
api-documenter
|
||||
|
||||
@@ -427,7 +427,7 @@ export interface ErrorData {
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ErrorDetails" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
// @public (undocumented)
|
||||
export enum ErrorDetails {
|
||||
// (undocumented)
|
||||
AUDIO_TRACK_LOAD_ERROR = "audioTrackLoadError",
|
||||
@@ -515,7 +515,7 @@ export enum ErrorDetails {
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ErrorTypes" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
// @public (undocumented)
|
||||
export enum ErrorTypes {
|
||||
// (undocumented)
|
||||
KEY_SYSTEM_ERROR = "keySystemError",
|
||||
@@ -531,7 +531,7 @@ export enum ErrorTypes {
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Events" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
// @public (undocumented)
|
||||
export enum Events {
|
||||
// (undocumented)
|
||||
AUDIO_TRACK_LOADED = "hlsAudioTrackLoaded",
|
||||
@@ -751,7 +751,7 @@ export interface FragLoadingData {
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Fragment" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export class Fragment extends BaseSegment {
|
||||
constructor(type: PlaylistLevelType, baseurl: string);
|
||||
// (undocumented)
|
||||
@@ -913,8 +913,6 @@ export type HdcpLevel = typeof HdcpLevels[number];
|
||||
// @public (undocumented)
|
||||
export const HdcpLevels: readonly ["NONE", "TYPE-0", "TYPE-1", "TYPE-2", null];
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Hls" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
class Hls implements HlsEventEmitter {
|
||||
constructor(userConfig?: Partial<HlsConfig>);
|
||||
@@ -931,7 +929,6 @@ class Hls implements HlsEventEmitter {
|
||||
get capLevelToPlayerSize(): boolean;
|
||||
// Warning: (ae-setter-with-docs) The doc comment for the property "capLevelToPlayerSize" must appear on the getter, not the setter.
|
||||
set capLevelToPlayerSize(shouldStartCapping: boolean);
|
||||
// (undocumented)
|
||||
readonly config: HlsConfig;
|
||||
// (undocumented)
|
||||
createController(ControllerClass: any, components: any): any;
|
||||
@@ -946,8 +943,11 @@ class Hls implements HlsEventEmitter {
|
||||
get drift(): number | null;
|
||||
// (undocumented)
|
||||
emit<E extends keyof HlsListeners>(event: E, name: E, eventObject: Parameters<HlsListeners[E]>[1]): boolean;
|
||||
// (undocumented)
|
||||
static get ErrorDetails(): typeof ErrorDetails;
|
||||
// (undocumented)
|
||||
static get ErrorTypes(): typeof ErrorTypes;
|
||||
// (undocumented)
|
||||
static get Events(): typeof Events;
|
||||
get firstLevel(): number;
|
||||
// Warning: (ae-setter-with-docs) The doc comment for the property "firstLevel" must appear on the getter, not the setter.
|
||||
@@ -955,6 +955,7 @@ class Hls implements HlsEventEmitter {
|
||||
get forceStartLoad(): boolean;
|
||||
static isSupported(): boolean;
|
||||
get latency(): number;
|
||||
// (undocumented)
|
||||
get levels(): Level[];
|
||||
// (undocumented)
|
||||
listenerCount<E extends keyof HlsListeners>(event: E): number;
|
||||
@@ -1017,7 +1018,6 @@ class Hls implements HlsEventEmitter {
|
||||
// (undocumented)
|
||||
trigger<E extends keyof HlsListeners>(event: E, eventObject: Parameters<HlsListeners[E]>[1]): boolean;
|
||||
get ttfbEstimate(): number;
|
||||
// (undocumented)
|
||||
readonly userConfig: Partial<HlsConfig>;
|
||||
static get version(): string;
|
||||
}
|
||||
@@ -1085,7 +1085,7 @@ export interface HlsEventEmitter {
|
||||
|
||||
// Warning: (ae-missing-release-tag) "HlsListeners" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export interface HlsListeners {
|
||||
// (undocumented)
|
||||
[Events.AUDIO_TRACK_LOADED]: (event: Events.AUDIO_TRACK_LOADED, data: AudioTrackLoadedData) => void;
|
||||
@@ -1429,7 +1429,7 @@ export type LevelControllerConfig = {
|
||||
|
||||
// Warning: (ae-missing-release-tag) "LevelDetails" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export class LevelDetails {
|
||||
constructor(baseUrl: any);
|
||||
// (undocumented)
|
||||
@@ -2049,7 +2049,7 @@ export interface NonNativeTextTracksData {
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Part" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export class Part extends BaseSegment {
|
||||
constructor(partAttrs: AttrList, frag: Fragment, baseurl: string, index: number, previous?: Part);
|
||||
// (undocumented)
|
||||
|
||||
+30
-24
@@ -1,5 +1,7 @@
|
||||
# HLS.js v1 API
|
||||
|
||||
See [API Reference](https://hls-js-dev.netlify.app/api-docs/) for a complete list of interfaces available in the hls.js package.
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
|
||||
@@ -19,7 +21,7 @@
|
||||
- [`Hls.DefaultConfig get/set`](#hlsdefaultconfig-getset)
|
||||
- [`capLevelToPlayerSize`](#capleveltoplayersize)
|
||||
- [`capLevelOnFPSDrop`](#caplevelonfpsdrop)
|
||||
- [`ignoreDevicePixelRatio`](#ignoreDevicePixelRatio)
|
||||
- [`ignoreDevicePixelRatio`](#ignoredevicepixelratio)
|
||||
- [`debug`](#debug)
|
||||
- [`autoStartLoad`](#autostartload)
|
||||
- [`startPosition`](#startposition)
|
||||
@@ -31,7 +33,7 @@
|
||||
- [`maxBufferHole`](#maxbufferhole)
|
||||
- [`maxStarvationDelay`](#maxstarvationdelay)
|
||||
- [`maxLoadingDelay`](#maxloadingdelay)
|
||||
- [`lowBufferWatchdogPeriod`](#lowbufferwatchdogperiod) (deprecated)
|
||||
- [`lowBufferWatchdogPeriod` (deprecated)](#lowbufferwatchdogperiod-deprecated)
|
||||
- [`highBufferWatchdogPeriod`](#highbufferwatchdogperiod)
|
||||
- [`nudgeOffset`](#nudgeoffset)
|
||||
- [`nudgeMaxRetry`](#nudgemaxretry)
|
||||
@@ -41,9 +43,9 @@
|
||||
- [`liveMaxLatencyDurationCount`](#livemaxlatencydurationcount)
|
||||
- [`liveSyncDuration`](#livesyncduration)
|
||||
- [`liveMaxLatencyDuration`](#livemaxlatencyduration)
|
||||
- [`maxLiveSyncPlaybackRate`](#maxLiveSyncPlaybackRate)
|
||||
- [`maxLiveSyncPlaybackRate`](#maxlivesyncplaybackrate)
|
||||
- [`liveDurationInfinity`](#livedurationinfinity)
|
||||
- [`liveBackBufferLength`](#livebackbufferlength) (deprecated)
|
||||
- [`liveBackBufferLength` (deprecated)](#livebackbufferlength-deprecated)
|
||||
- [`enableWorker`](#enableworker)
|
||||
- [`enableSoftwareAES`](#enablesoftwareaes)
|
||||
- [`startLevel`](#startlevel)
|
||||
@@ -52,9 +54,11 @@
|
||||
- [`fragLoadingMaxRetryTimeout` / `manifestLoadingMaxRetryTimeout` / `levelLoadingMaxRetryTimeout`](#fragloadingmaxretrytimeout--manifestloadingmaxretrytimeout--levelloadingmaxretrytimeout)
|
||||
- [`fragLoadingRetryDelay` / `manifestLoadingRetryDelay` / `levelLoadingRetryDelay`](#fragloadingretrydelay--manifestloadingretrydelay--levelloadingretrydelay)
|
||||
- [`startFragPrefetch`](#startfragprefetch)
|
||||
- [`testBandwidth`](#testBandwidth)
|
||||
- [`fpsDroppedMonitoringPeriod`](#fpsDroppedMonitoringPeriod)
|
||||
- [`fpsDroppedMonitoringThreshold`](#fpsDroppedMonitoringThreshold)
|
||||
- [`testBandwidth`](#testbandwidth)
|
||||
- [`progressive`](#progressive)
|
||||
- [`lowLatencyMode`](#lowlatencymode)
|
||||
- [`fpsDroppedMonitoringPeriod`](#fpsdroppedmonitoringperiod)
|
||||
- [`fpsDroppedMonitoringThreshold`](#fpsdroppedmonitoringthreshold)
|
||||
- [`appendErrorMaxRetry`](#appenderrormaxretry)
|
||||
- [`loader`](#loader)
|
||||
- [`fLoader`](#floader)
|
||||
@@ -62,9 +66,9 @@
|
||||
- [`xhrSetup`](#xhrsetup)
|
||||
- [`fetchSetup`](#fetchsetup)
|
||||
- [`abrController`](#abrcontroller)
|
||||
- [`bufferController`](#bufferController)
|
||||
- [`capLevelController`](#capLevelController)
|
||||
- [`fpsController`](#fpsController)
|
||||
- [`bufferController`](#buffercontroller)
|
||||
- [`capLevelController`](#caplevelcontroller)
|
||||
- [`fpsController`](#fpscontroller)
|
||||
- [`timelineController`](#timelinecontroller)
|
||||
- [`enableDateRangeMetadataCues`](#enabledaterangemetadatacues)
|
||||
- [`enableEmsgMetadataCues`](#enableemsgmetadatacues)
|
||||
@@ -76,11 +80,11 @@
|
||||
- [`captionsTextTrack1LanguageCode`](#captionstexttrack1languagecode)
|
||||
- [`captionsTextTrack2Label`](#captionstexttrack2label)
|
||||
- [`captionsTextTrack2LanguageCode`](#captionstexttrack2languagecode)
|
||||
- [`captionsTextTrack3Label`](#captionsTextTrack3Label)
|
||||
- [`captionsTextTrack3LanguageCode`](#captionsTextTrack3LanguageCode)
|
||||
- [`captionsTextTrack4Label`](#captionsTextTrack4Label)
|
||||
- [`captionsTextTrack4LanguageCode`](#captionsTextTrack4LanguageCode)
|
||||
- [`renderTextTracksNatively`](#renderTextTracksNatively)
|
||||
- [`captionsTextTrack3Label`](#captionstexttrack3label)
|
||||
- [`captionsTextTrack3LanguageCode`](#captionstexttrack3languagecode)
|
||||
- [`captionsTextTrack4Label`](#captionstexttrack4label)
|
||||
- [`captionsTextTrack4LanguageCode`](#captionstexttrack4languagecode)
|
||||
- [`renderTextTracksNatively`](#rendertexttracksnatively)
|
||||
- [`stretchShortVideoTrack`](#stretchshortvideotrack)
|
||||
- [`maxAudioFramesDrift`](#maxaudioframesdrift)
|
||||
- [`forceKeyFrameOnDiscontinuity`](#forcekeyframeondiscontinuity)
|
||||
@@ -93,13 +97,14 @@
|
||||
- [`abrBandWidthUpFactor`](#abrbandwidthupfactor)
|
||||
- [`abrMaxWithRealBitrate`](#abrmaxwithrealbitrate)
|
||||
- [`minAutoBitrate`](#minautobitrate)
|
||||
- [`emeEnabled`](#emeEnabled)
|
||||
- [`widevineLicenseUrl`](#widevineLicenseUrl) (deprecated)
|
||||
- [`licenseXhrSetup`](#licenseXhrSetup)
|
||||
- [`licenseResponseCallback`](#licenseResponseCallback)
|
||||
- [`drmSystems`](#drmSystems)
|
||||
- [`drmSystemOptions`](#drmSystemOptions)
|
||||
- [`requestMediaKeySystemAccessFunc`](#requestMediaKeySystemAccessFunc)
|
||||
- [`emeEnabled`](#emeenabled)
|
||||
- [`widevineLicenseUrl` (deprecated)](#widevinelicenseurl-deprecated)
|
||||
- [`licenseXhrSetup`](#licensexhrsetup)
|
||||
- [`licenseResponseCallback`](#licenseresponsecallback)
|
||||
- [`drmSystems`](#drmsystems)
|
||||
- [`drmSystems[KEY-SYSTEM].generateRequest](#drmsystemskey-systemgeneraterequest)
|
||||
- [`drmSystemOptions`](#drmsystemoptions)
|
||||
- [`requestMediaKeySystemAccessFunc`](#requestmediakeysystemaccessfunc)
|
||||
- [`cmcd`](#cmcd)
|
||||
- [Video Binding/Unbinding API](#video-bindingunbinding-api)
|
||||
- [`hls.attachMedia(videoElement)`](#hlsattachmediavideoelement)
|
||||
@@ -118,7 +123,7 @@
|
||||
- [`hls.maxHdcpLevel`](#hlsmaxhdcplevel)
|
||||
- [`hls.capLevelToPlayerSize`](#hlscapleveltoplayersize)
|
||||
- [`hls.bandwidthEstimate`](#hlsbandwidthestimate)
|
||||
- [`hls.removeLevel(levelIndex, urlId)`](#hlsremoveLevel)
|
||||
- [`hls.removeLevel(levelIndex, urlId)`](#hlsremovelevellevelindex-urlid)
|
||||
- [Version Control](#version-control)
|
||||
- [`Hls.version`](#hlsversion)
|
||||
- [Network Loading Control API](#network-loading-control-api)
|
||||
@@ -144,6 +149,7 @@
|
||||
- [Network Errors](#network-errors)
|
||||
- [Media Errors](#media-errors)
|
||||
- [Mux Errors](#mux-errors)
|
||||
- [EME Key System Errors](#eme-key-system-errors)
|
||||
- [Other Errors](#other-errors)
|
||||
- [Objects](#objects)
|
||||
- [Level](#level)
|
||||
@@ -633,7 +639,7 @@ Override current Media Source duration to `Infinity` for a live broadcast.
|
||||
Useful, if you are building a player which relies on native UI capabilities in modern browsers.
|
||||
If you want to have a native Live UI in environments like iOS Safari, Safari, Android Google Chrome, etc. set this value to `true`.
|
||||
|
||||
### `liveBackBufferLength`
|
||||
### `liveBackBufferLength` (deprecated)
|
||||
|
||||
`liveBackBufferLength` has been deprecated. Use `backBufferLength` instead.
|
||||
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
|
||||
**Table of Contents**
|
||||
|
||||
- [Design principle](#design-principle)
|
||||
- [Code structure](#code-structure)
|
||||
- [Error detection and Handling](#error-detection-and-handling)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## Design principle
|
||||
|
||||
design idea is pretty simple :
|
||||
|
||||
Generated
+15590
-5991
File diff suppressed because it is too large
Load Diff
+6
-7
@@ -27,7 +27,8 @@
|
||||
"build:watch": "webpack --progress --env debug --env demo --watch",
|
||||
"build:types": "tsc --build tsconfig-lib.json && api-extractor run --local",
|
||||
"dev": "webpack serve --progress --env debug --env demo --port 8000 --static .",
|
||||
"docs": "esdoc",
|
||||
"docs": "doctoc ./docs/API.md && api-documenter markdown -i api-extractor -o api-extractor/api-documenter && npm run docs-md-to-html",
|
||||
"docs-md-to-html": "generate-md --layout github --input api-extractor/api-documenter --output api-docs",
|
||||
"lint": "eslint src/ tests/ --ext .js --ext .ts",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"lint:quiet": "npm run lint -- --quiet",
|
||||
@@ -35,7 +36,7 @@
|
||||
"prettier": "prettier --write .",
|
||||
"prettier:verify": "prettier --check .",
|
||||
"pretest": "npm run lint",
|
||||
"sanity-check": "npm run lint && npm run prettier:verify && npm run type-check && npm run docs && npm run build:types && npm run build && npm run test:unit",
|
||||
"sanity-check": "npm run lint && npm run prettier:verify && npm run type-check && npm run build && npm run docs && npm run test:unit",
|
||||
"start": "npm run dev",
|
||||
"test": "npm run test:unit && npm run test:func",
|
||||
"test:unit": "karma start karma.conf.js",
|
||||
@@ -58,11 +59,7 @@
|
||||
"@babel/preset-env": "7.20.2",
|
||||
"@babel/preset-typescript": "7.18.6",
|
||||
"@babel/register": "7.18.9",
|
||||
"@itsjamie/esdoc-cli": "0.5.0",
|
||||
"@itsjamie/esdoc-core": "0.5.0",
|
||||
"@itsjamie/esdoc-ecmascript-proposal-plugin": "0.5.0",
|
||||
"@itsjamie/esdoc-standard-plugin": "0.5.0",
|
||||
"@itsjamie/esdoc-typescript-plugin": "0.5.0",
|
||||
"@microsoft/api-documenter": "7.19.28",
|
||||
"@microsoft/api-extractor": "7.33.7",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chart.js": "2.9.37",
|
||||
@@ -76,6 +73,7 @@
|
||||
"chart.js": "2.9.4",
|
||||
"chromedriver": "108.0.0",
|
||||
"coverage-istanbul-loader": "3.0.5",
|
||||
"doctoc": "2.2.1",
|
||||
"eslint": "8.31.0",
|
||||
"eslint-config-prettier": "8.6.0",
|
||||
"eslint-plugin-import": "2.27.4",
|
||||
@@ -95,6 +93,7 @@
|
||||
"karma-sourcemap-loader": "0.3.8",
|
||||
"karma-webpack": "5.0.0",
|
||||
"lint-staged": "13.1.0",
|
||||
"markdown-styles": "3.2.0",
|
||||
"micromatch": "4.0.5",
|
||||
"mocha": "10.2.0",
|
||||
"netlify-cli": "12.2.8",
|
||||
|
||||
@@ -10,6 +10,7 @@ echo "Building netlify..."
|
||||
|
||||
# redirect / to /demo
|
||||
echo "/ /demo" > "$root/_redirects"
|
||||
echo "/api-docs /api-docs/hls.js.hls.html" > "$root/_redirects"
|
||||
cp -r "./dist" "$root/dist"
|
||||
cp -r "./demo" "$root/demo"
|
||||
cp -r "./api-docs" "$root/api-docs"
|
||||
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
$(git diff --exit-code docs/API.md > /dev/null) && exit_status=$? || exit_status=$?
|
||||
if [[ $exit_status -ne 0 ]]; then
|
||||
echo "API.md is not in sync. Please run 'npm run docs' and commit that change"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Docs up to date"
|
||||
@@ -2,11 +2,10 @@ import BinarySearch from '../utils/binary-search';
|
||||
import { Fragment } from '../loader/fragment';
|
||||
|
||||
/**
|
||||
* Returns first fragment whose endPdt value exceeds the given PDT.
|
||||
* @param {Array<Fragment>} fragments - The array of candidate fragments
|
||||
* @param {number|null} [PDTValue = null] - The PDT value which must be exceeded
|
||||
* @param {number} [maxFragLookUpTolerance = 0] - The amount of time that a fragment's start/end can be within in order to be considered contiguous
|
||||
* @returns {*|null} fragment - The best matching fragment
|
||||
* Returns first fragment whose endPdt value exceeds the given PDT, or null.
|
||||
* @param fragments - The array of candidate fragments
|
||||
* @param PDTValue - The PDT value which must be exceeded
|
||||
* @param maxFragLookUpTolerance - The amount of time that a fragment's start/end can be within in order to be considered contiguous
|
||||
*/
|
||||
export function findFragmentByPDT(
|
||||
fragments: Array<Fragment>,
|
||||
@@ -48,11 +47,11 @@ export function findFragmentByPDT(
|
||||
* Finds a fragment based on the SN of the previous fragment; or based on the needs of the current buffer.
|
||||
* This method compensates for small buffer gaps by applying a tolerance to the start of any candidate fragment, thus
|
||||
* breaking any traps which would cause the same fragment to be continuously selected within a small range.
|
||||
* @param {*} fragPrevious - The last frag successfully appended
|
||||
* @param {Array} fragments - The array of candidate fragments
|
||||
* @param {number} [bufferEnd = 0] - The end of the contiguous buffered range the playhead is currently within
|
||||
* @param {number} maxFragLookUpTolerance - The amount of time that a fragment's start/end can be within in order to be considered contiguous
|
||||
* @returns {*} foundFrag - The best matching fragment
|
||||
* @param fragPrevious - The last frag successfully appended
|
||||
* @param fragments - The array of candidate fragments
|
||||
* @param bufferEnd - The end of the contiguous buffered range the playhead is currently within
|
||||
* @param maxFragLookUpTolerance - The amount of time that a fragment's start/end can be within in order to be considered contiguous
|
||||
* @returns a matching fragment or null
|
||||
*/
|
||||
export function findFragmentByPTS(
|
||||
fragPrevious: Fragment | null,
|
||||
@@ -91,10 +90,10 @@ export function findFragmentByPTS(
|
||||
|
||||
/**
|
||||
* The test function used by the findFragmentBySn's BinarySearch to look for the best match to the current buffer conditions.
|
||||
* @param {*} candidate - The fragment to test
|
||||
* @param {number} [bufferEnd = 0] - The end of the current buffered range the playhead is currently within
|
||||
* @param {number} [maxFragLookUpTolerance = 0] - The amount of time that a fragment's start can be within in order to be considered contiguous
|
||||
* @returns {number} - 0 if it matches, 1 if too low, -1 if too high
|
||||
* @param candidate - The fragment to test
|
||||
* @param bufferEnd - The end of the current buffered range the playhead is currently within
|
||||
* @param maxFragLookUpTolerance - The amount of time that a fragment's start can be within in order to be considered contiguous
|
||||
* @returns 0 if it matches, 1 if too low, -1 if too high
|
||||
*/
|
||||
export function fragmentWithinToleranceTest(
|
||||
bufferEnd = 0,
|
||||
@@ -145,10 +144,10 @@ export function fragmentWithinToleranceTest(
|
||||
/**
|
||||
* The test function used by the findFragmentByPdt's BinarySearch to look for the best match to the current buffer conditions.
|
||||
* This function tests the candidate's program date time values, as represented in Unix time
|
||||
* @param {*} candidate - The fragment to test
|
||||
* @param {number} [pdtBufferEnd = 0] - The Unix time representing the end of the current buffered range
|
||||
* @param {number} [maxFragLookUpTolerance = 0] - The amount of time that a fragment's start can be within in order to be considered contiguous
|
||||
* @returns {boolean} True if contiguous, false otherwise
|
||||
* @param candidate - The fragment to test
|
||||
* @param pdtBufferEnd - The Unix time representing the end of the current buffered range
|
||||
* @param maxFragLookUpTolerance - The amount of time that a fragment's start can be within in order to be considered contiguous
|
||||
* @returns true if contiguous, false otherwise
|
||||
*/
|
||||
export function pdtWithinToleranceTest(
|
||||
pdtBufferEnd: number,
|
||||
|
||||
@@ -41,7 +41,7 @@ export default class GapController {
|
||||
* Checks if the playhead is stuck within a gap, and if so, attempts to free it.
|
||||
* A gap is an unbuffered range between two buffered ranges (or the start and the first buffered range).
|
||||
*
|
||||
* @param {number} lastCurrentTime Previously read playhead position
|
||||
* @param lastCurrentTime - Previously read playhead position
|
||||
*/
|
||||
public poll(lastCurrentTime: number, activeFrag: Fragment | null) {
|
||||
const { config, media, stalled } = this;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module LevelHelper
|
||||
* Providing methods dealing with playlist sliding and drift
|
||||
* */
|
||||
* Provides methods dealing with playlist sliding and drift
|
||||
*/
|
||||
|
||||
import { logger } from '../utils/logger';
|
||||
import { Fragment, Part } from '../loader/fragment';
|
||||
|
||||
@@ -173,8 +173,7 @@ class ExpGolomb {
|
||||
* Read a sequence parameter set and return some interesting video
|
||||
* properties. A sequence parameter set is the H264 metadata that
|
||||
* describes the properties of upcoming video frames.
|
||||
* @param data {Uint8Array} the bytes of a sequence parameter set
|
||||
* @return {object} an object with configuration parsed from the
|
||||
* @returns an object with configuration parsed from the
|
||||
* sequence parameter set, including the dimensions of the
|
||||
* associated video frames.
|
||||
*/
|
||||
|
||||
+9
-14
@@ -6,9 +6,8 @@ export type Frame = DecodedFrame<ArrayBuffer | string>;
|
||||
|
||||
/**
|
||||
* Returns true if an ID3 header can be found at offset in data
|
||||
* @param {Uint8Array} data - The data to search in
|
||||
* @param {number} offset - The offset at which to start searching
|
||||
* @return {boolean} - True if an ID3 header is found
|
||||
* @param data - The data to search
|
||||
* @param offset - The offset at which to start searching
|
||||
*/
|
||||
export const isHeader = (data: Uint8Array, offset: number): boolean => {
|
||||
/*
|
||||
@@ -51,9 +50,8 @@ export const isHeader = (data: Uint8Array, offset: number): boolean => {
|
||||
|
||||
/**
|
||||
* Returns true if an ID3 footer can be found at offset in data
|
||||
* @param {Uint8Array} data - The data to search in
|
||||
* @param {number} offset - The offset at which to start searching
|
||||
* @return {boolean} - True if an ID3 footer is found
|
||||
* @param data - The data to search
|
||||
* @param offset - The offset at which to start searching
|
||||
*/
|
||||
export const isFooter = (data: Uint8Array, offset: number): boolean => {
|
||||
/*
|
||||
@@ -86,9 +84,9 @@ export const isFooter = (data: Uint8Array, offset: number): boolean => {
|
||||
|
||||
/**
|
||||
* Returns any adjacent ID3 tags found in data starting at offset, as one block of data
|
||||
* @param {Uint8Array} data - The data to search in
|
||||
* @param {number} offset - The offset at which to start searching
|
||||
* @return {Uint8Array | undefined} - The block of data containing any ID3 tags found
|
||||
* @param data - The data to search in
|
||||
* @param offset - The offset at which to start searching
|
||||
* @returns the block of data containing any ID3 tags found
|
||||
* or *undefined* if no header is found at the starting offset
|
||||
*/
|
||||
export const getID3Data = (
|
||||
@@ -138,8 +136,7 @@ export const canParse = (data: Uint8Array, offset: number): boolean => {
|
||||
|
||||
/**
|
||||
* Searches for the Elementary Stream timestamp found in the ID3 data chunk
|
||||
* @param {Uint8Array} data - Block of data containing one or more ID3 tags
|
||||
* @return {number | undefined} - The timestamp
|
||||
* @param data - Block of data containing one or more ID3 tags
|
||||
*/
|
||||
export const getTimeStamp = (data: Uint8Array): number | undefined => {
|
||||
const frames: Frame[] = getID3Frames(data);
|
||||
@@ -157,7 +154,6 @@ export const getTimeStamp = (data: Uint8Array): number | undefined => {
|
||||
|
||||
/**
|
||||
* Returns true if the ID3 frame is an Elementary Stream timestamp frame
|
||||
* @param {ID3 frame} frame
|
||||
*/
|
||||
export const isTimeStampFrame = (frame: Frame): boolean => {
|
||||
return (
|
||||
@@ -184,8 +180,7 @@ const getFrameData = (data: Uint8Array): RawFrame => {
|
||||
|
||||
/**
|
||||
* Returns an array of ID3 frames found in all the ID3 tags in the id3Data
|
||||
* @param {Uint8Array} id3Data - The ID3 data containing one or more ID3 tags
|
||||
* @return {ID3.Frame[]} - Array of ID3 frame objects
|
||||
* @param id3Data - The ID3 data containing one or more ID3 tags
|
||||
*/
|
||||
export const getID3Frames = (id3Data: Uint8Array): Frame[] => {
|
||||
let offset = 0;
|
||||
|
||||
@@ -114,10 +114,6 @@ class TSDemuxer implements Demuxer {
|
||||
|
||||
/**
|
||||
* Creates a track model internal to demuxer used to drive remuxing input
|
||||
*
|
||||
* @param type 'audio' | 'video' | 'id3' | 'text'
|
||||
* @param duration
|
||||
* @return TSDemuxer's internal track model
|
||||
*/
|
||||
static createTrack(
|
||||
type: 'audio' | 'video' | 'id3' | 'text',
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/**
|
||||
* @typedef {string} ErrorTypes
|
||||
*/
|
||||
export enum ErrorTypes {
|
||||
// Identifier for a network error (loading error / timeout ...)
|
||||
NETWORK_ERROR = 'networkError',
|
||||
@@ -14,9 +11,6 @@ export enum ErrorTypes {
|
||||
OTHER_ERROR = 'otherError',
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {string} ErrorDetails
|
||||
*/
|
||||
export enum ErrorDetails {
|
||||
KEY_SYSTEM_NO_KEYS = 'keySystemNoKeys',
|
||||
KEY_SYSTEM_NO_ACCESS = 'keySystemNoAccess',
|
||||
|
||||
+3
-3
@@ -49,9 +49,6 @@ import {
|
||||
BufferFlushedData,
|
||||
} from './types/events';
|
||||
|
||||
/**
|
||||
* @typedef {string} Events
|
||||
*/
|
||||
export enum Events {
|
||||
// Fired before MediaSource is attaching to media element
|
||||
MEDIA_ATTACHING = 'hlsMediaAttaching',
|
||||
@@ -167,6 +164,9 @@ export enum Events {
|
||||
BACK_BUFFER_REACHED = 'hlsBackBufferReached',
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines each Event type and payload by Event name. Used in {@link hls.js#HlsEventEmitter} to strongly type the event listener API.
|
||||
*/
|
||||
export interface HlsListeners {
|
||||
[Events.MEDIA_ATTACHING]: (
|
||||
event: Events.MEDIA_ATTACHING,
|
||||
|
||||
+26
-59
@@ -28,19 +28,24 @@ import type { Fragment } from './loader/fragment';
|
||||
import type { BufferInfo } from './utils/buffer-helper';
|
||||
|
||||
/**
|
||||
* @module Hls
|
||||
* @class
|
||||
* @constructor
|
||||
* The `Hls` class is the core of the HLS.js library used to instantiate player instances.
|
||||
* @public
|
||||
*/
|
||||
export default class Hls implements HlsEventEmitter {
|
||||
private static defaultConfig: HlsConfig | undefined;
|
||||
|
||||
/**
|
||||
* The runtime configuration used by the player. At instantiation this is combination of `hls.userConfig` merged over `Hls.DefaultConfig`.
|
||||
*/
|
||||
public readonly config: HlsConfig;
|
||||
|
||||
/**
|
||||
* The configuration object provided on player instantiation.
|
||||
*/
|
||||
public readonly userConfig: Partial<HlsConfig>;
|
||||
|
||||
private coreComponents: ComponentAPI[];
|
||||
private networkControllers: NetworkComponentAPI[];
|
||||
|
||||
private _emitter: HlsEventEmitter = new EventEmitter();
|
||||
private _autoLevelCapping: number;
|
||||
private _maxHdcpLevel: HdcpLevel = null;
|
||||
@@ -54,12 +59,11 @@ export default class Hls implements HlsEventEmitter {
|
||||
private subtitleTrackController: SubtitleTrackController;
|
||||
private emeController: EMEController;
|
||||
private cmcdController: CMCDController;
|
||||
|
||||
private _media: HTMLMediaElement | null = null;
|
||||
private url: string | null = null;
|
||||
|
||||
/**
|
||||
* Get the video-dev/hls.js npm package version.
|
||||
* Get the video-dev/hls.js package version.
|
||||
*/
|
||||
static get version(): string {
|
||||
return __VERSION__;
|
||||
@@ -72,23 +76,14 @@ export default class Hls implements HlsEventEmitter {
|
||||
return isSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Events} Returns event name enums.
|
||||
*/
|
||||
static get Events(): typeof Events {
|
||||
return Events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {ErrorTypes} Returns error type enums.
|
||||
*/
|
||||
static get ErrorTypes(): typeof ErrorTypes {
|
||||
return ErrorTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {ErrorDetails} Returns error details enums.
|
||||
*/
|
||||
static get ErrorDetails(): typeof ErrorDetails {
|
||||
return ErrorDetails;
|
||||
}
|
||||
@@ -113,6 +108,7 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Creates an instance of an HLS client that can attach to exactly one `HTMLMediaElement`.
|
||||
* @param userConfig - Configuration options applied over `Hls.DefaultConfig`
|
||||
*/
|
||||
constructor(userConfig: Partial<HlsConfig> = {}) {
|
||||
const config = (this.config = mergeConfig(Hls.DefaultConfig, userConfig));
|
||||
@@ -319,7 +315,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Attaches Hls.js to a media element
|
||||
* @param {HTMLMediaElement} media
|
||||
*/
|
||||
attachMedia(media: HTMLMediaElement) {
|
||||
logger.log('attachMedia');
|
||||
@@ -338,7 +333,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Set the source URL. Can be relative or absolute.
|
||||
* @param {string} url
|
||||
*/
|
||||
loadSource(url: string) {
|
||||
this.stopLoad();
|
||||
@@ -369,8 +363,8 @@ export default class Hls implements HlsEventEmitter {
|
||||
* Start loading data from the stream source.
|
||||
* Depending on default config, client starts loading automatically when a source is set.
|
||||
*
|
||||
* @param {number} startPosition Set the start position to stream from
|
||||
* @default -1 None (from earliest point)
|
||||
* @param startPosition - Set the start position to stream from.
|
||||
* Defaults to -1 (None: starts from earliest point)
|
||||
*/
|
||||
startLoad(startPosition: number = -1) {
|
||||
logger.log(`startLoad(${startPosition})`);
|
||||
@@ -417,7 +411,7 @@ export default class Hls implements HlsEventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of levels (variants) sorted by HDCP-LEVEL, BANDWIDTH, SCORE, and RESOLUTION (height)
|
||||
* @returns an array of levels (variants) sorted by HDCP-LEVEL, BANDWIDTH, SCORE, and RESOLUTION (height)
|
||||
*/
|
||||
get levels(): Level[] {
|
||||
const levels = this.levelController.levels;
|
||||
@@ -452,7 +446,7 @@ export default class Hls implements HlsEventEmitter {
|
||||
* Set quality level index for next loaded data.
|
||||
* This will switch the video quality asap, without interrupting playback.
|
||||
* May abort current loading of data, and flush parts of buffer (outside currently played fragment region).
|
||||
* @param {number} -1 for automatic level selection
|
||||
* @param newLevel - Pass -1 for automatic level selection
|
||||
*/
|
||||
set nextLevel(newLevel: number) {
|
||||
logger.log(`set nextLevel:${newLevel}`);
|
||||
@@ -462,7 +456,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Return the quality level of the currently or last (of none is loaded currently) segment
|
||||
* @type {number}
|
||||
*/
|
||||
get loadLevel(): number {
|
||||
return this.levelController.level;
|
||||
@@ -472,7 +465,7 @@ export default class Hls implements HlsEventEmitter {
|
||||
* Set quality level index for next loaded data in a conservative way.
|
||||
* This will switch the quality without flushing, but interrupt current loading.
|
||||
* Thus the moment when the quality switch will appear in effect will only be after the already existing buffer.
|
||||
* @type {number} newLevel -1 for automatic level selection
|
||||
* @param newLevel - Pass -1 for automatic level selection
|
||||
*/
|
||||
set loadLevel(newLevel: number) {
|
||||
logger.log(`set loadLevel:${newLevel}`);
|
||||
@@ -481,7 +474,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* get next quality level loaded
|
||||
* @type {number}
|
||||
*/
|
||||
get nextLoadLevel(): number {
|
||||
return this.levelController.nextLoadLevel;
|
||||
@@ -490,7 +482,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
/**
|
||||
* Set quality level of next loaded segment in a fully "non-destructive" way.
|
||||
* Same as `loadLevel` but will wait for next switch (until current loading is done).
|
||||
* @type {number} level
|
||||
*/
|
||||
set nextLoadLevel(level: number) {
|
||||
this.levelController.nextLoadLevel = level;
|
||||
@@ -499,7 +490,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
/**
|
||||
* Return "first level": like a default level, if not set,
|
||||
* falls back to index of first level referenced in manifest
|
||||
* @type {number}
|
||||
*/
|
||||
get firstLevel(): number {
|
||||
return Math.max(this.levelController.firstLevel, this.minAutoLevel);
|
||||
@@ -507,7 +497,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Sets "first-level", see getter.
|
||||
* @type {number}
|
||||
*/
|
||||
set firstLevel(newLevel: number) {
|
||||
logger.log(`set firstLevel:${newLevel}`);
|
||||
@@ -519,7 +508,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
* if not overrided by user, first level appearing in manifest will be used as start level
|
||||
* if -1 : automatic start level selection, playback will start from level matching download bandwidth
|
||||
* (determined from download of first segment)
|
||||
* @type {number}
|
||||
*/
|
||||
get startLevel(): number {
|
||||
return this.levelController.startLevel;
|
||||
@@ -530,7 +518,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
* if not overrided by user, first level appearing in manifest will be used as start level
|
||||
* if -1 : automatic start level selection, playback will start from level matching download bandwidth
|
||||
* (determined from download of first segment)
|
||||
* @type {number} newLevel
|
||||
*/
|
||||
set startLevel(newLevel: number) {
|
||||
logger.log(`set startLevel:${newLevel}`);
|
||||
@@ -543,18 +530,15 @@ export default class Hls implements HlsEventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current setting for capLevelToPlayerSize
|
||||
*
|
||||
* @type {boolean}
|
||||
* Whether level capping is enabled.
|
||||
* Default value is set via `config.capLevelToPlayerSize`.
|
||||
*/
|
||||
get capLevelToPlayerSize(): boolean {
|
||||
return this.config.capLevelToPlayerSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* set dynamically set capLevelToPlayerSize against (`CapLevelController`)
|
||||
*
|
||||
* @type {boolean}
|
||||
* Enables or disables level capping. If disabled after previously enabled, `nextLevelSwitch` will be immediately called.
|
||||
*/
|
||||
set capLevelToPlayerSize(shouldStartCapping: boolean) {
|
||||
const newCapLevelToPlayerSize = !!shouldStartCapping;
|
||||
@@ -574,7 +558,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Capping/max level value that should be used by automatic level selection algorithm (`ABRController`)
|
||||
* @type {number}
|
||||
*/
|
||||
get autoLevelCapping(): number {
|
||||
return this._autoLevelCapping;
|
||||
@@ -582,7 +565,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* get bandwidth estimate
|
||||
* @type {number}
|
||||
*/
|
||||
get bandwidthEstimate(): number {
|
||||
const { bwEstimator } = this.abrController;
|
||||
@@ -606,7 +588,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Capping/max level value that should be used by automatic level selection algorithm (`ABRController`)
|
||||
* @type {number}
|
||||
*/
|
||||
set autoLevelCapping(newLevel: number) {
|
||||
if (this._autoLevelCapping !== newLevel) {
|
||||
@@ -627,7 +608,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* True when automatic level selection enabled
|
||||
* @type {boolean}
|
||||
*/
|
||||
get autoLevelEnabled(): boolean {
|
||||
return this.levelController.manualLevel === -1;
|
||||
@@ -635,7 +615,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* Level set manually (if any)
|
||||
* @type {number}
|
||||
*/
|
||||
get manualLevel(): number {
|
||||
return this.levelController.manualLevel;
|
||||
@@ -643,7 +622,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* min level selectable in auto mode according to config.minAutoBitrate
|
||||
* @type {number}
|
||||
*/
|
||||
get minAutoLevel(): number {
|
||||
const {
|
||||
@@ -664,7 +642,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* max level selectable in auto mode according to autoLevelCapping
|
||||
* @type {number}
|
||||
*/
|
||||
get maxAutoLevel(): number {
|
||||
const { levels, autoLevelCapping, maxHdcpLevel } = this;
|
||||
@@ -690,7 +667,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* next automatically selected quality level
|
||||
* @type {number}
|
||||
*/
|
||||
get nextAutoLevel(): number {
|
||||
// ensure next auto level is between min and max auto level
|
||||
@@ -706,7 +682,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
* in case of load error on level N, hls.js can set nextAutoLevel to N-1 for example)
|
||||
* forced value is valid for one fragment. upon successful frag loading at forced level,
|
||||
* this value will be resetted to -1 by ABR controller.
|
||||
* @type {number}
|
||||
*/
|
||||
set nextAutoLevel(nextLevel: number) {
|
||||
this.abrController.nextAutoLevel = Math.max(this.minAutoLevel, nextLevel);
|
||||
@@ -714,7 +689,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* get the datetime value relative to media.currentTime for the active level Program Date Time if present
|
||||
* @type {Date}
|
||||
*/
|
||||
public get playingDate(): Date | null {
|
||||
return this.streamController.currentProgramDateTime;
|
||||
@@ -725,7 +699,7 @@ export default class Hls implements HlsEventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {AudioTrack[]}
|
||||
* Get the list of selectable audio tracks
|
||||
*/
|
||||
get audioTracks(): Array<MediaPlaylist> {
|
||||
const audioTrackController = this.audioTrackController;
|
||||
@@ -734,7 +708,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* index of the selected audio track (index in audio track lists)
|
||||
* @type {number}
|
||||
*/
|
||||
get audioTrack(): number {
|
||||
const audioTrackController = this.audioTrackController;
|
||||
@@ -743,7 +716,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* selects an audio track, based on its index in audio track lists
|
||||
* @type {number}
|
||||
*/
|
||||
set audioTrack(audioTrackId: number) {
|
||||
const audioTrackController = this.audioTrackController;
|
||||
@@ -754,7 +726,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* get alternate subtitle tracks list from playlist
|
||||
* @type {MediaPlaylist[]}
|
||||
*/
|
||||
get subtitleTracks(): Array<MediaPlaylist> {
|
||||
const subtitleTrackController = this.subtitleTrackController;
|
||||
@@ -765,7 +736,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* index of the selected subtitle track (index in subtitle track lists)
|
||||
* @type {number}
|
||||
*/
|
||||
get subtitleTrack(): number {
|
||||
const subtitleTrackController = this.subtitleTrackController;
|
||||
@@ -778,7 +748,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* select an subtitle track, based on its index in subtitle track lists
|
||||
* @type {number}
|
||||
*/
|
||||
set subtitleTrack(subtitleTrackId: number) {
|
||||
const subtitleTrackController = this.subtitleTrackController;
|
||||
@@ -788,7 +757,7 @@ export default class Hls implements HlsEventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* Whether subtitle display is enabled or not
|
||||
*/
|
||||
get subtitleDisplay(): boolean {
|
||||
const subtitleTrackController = this.subtitleTrackController;
|
||||
@@ -822,16 +791,16 @@ export default class Hls implements HlsEventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* position (in seconds) of live sync point (ie edge of live position minus safety delay defined by ```hls.config.liveSyncDuration```)
|
||||
* @return {(number|null)} Returns null prior to loading live Playlist
|
||||
* Position (in seconds) of live sync point (ie edge of live position minus safety delay defined by ```hls.config.liveSyncDuration```)
|
||||
* @returns null prior to loading live Playlist
|
||||
*/
|
||||
get liveSyncPosition(): number | null {
|
||||
return this.latencyController.liveSyncPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* estimated position (in seconds) of live edge (ie edge of live playlist plus time sync playlist advanced)
|
||||
* @return {number} Returns 0 before first playlist is loaded
|
||||
* Estimated position (in seconds) of live edge (ie edge of live playlist plus time sync playlist advanced)
|
||||
* @returns 0 before first playlist is loaded
|
||||
*/
|
||||
get latency(): number {
|
||||
return this.latencyController.latency;
|
||||
@@ -840,7 +809,7 @@ export default class Hls implements HlsEventEmitter {
|
||||
/**
|
||||
* maximum distance from the edge before the player seeks forward to ```hls.liveSyncPosition```
|
||||
* configured using ```liveMaxLatencyDurationCount``` (multiple of target duration) or ```liveMaxLatencyDuration```
|
||||
* @return {number} Returns 0 before first playlist is loaded
|
||||
* @returns 0 before first playlist is loaded
|
||||
*/
|
||||
get maxLatency(): number {
|
||||
return this.latencyController.maxLatency;
|
||||
@@ -848,7 +817,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* target distance from the edge as calculated by the latency controller
|
||||
* @return {number|null}
|
||||
*/
|
||||
get targetLatency(): number | null {
|
||||
return this.latencyController.targetLatency;
|
||||
@@ -856,7 +824,6 @@ export default class Hls implements HlsEventEmitter {
|
||||
|
||||
/**
|
||||
* the rate at which the edge of the current live playlist is advancing or 1 if there is none
|
||||
* @return {number|null}
|
||||
*/
|
||||
get drift(): number | null {
|
||||
return this.latencyController.drift;
|
||||
|
||||
@@ -91,6 +91,9 @@ export class BaseSegment {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Object representing parsed data from an HLS Segment. Found in {@link hls.js#LevelDetails.fragments}.
|
||||
*/
|
||||
export class Fragment extends BaseSegment {
|
||||
private _decryptdata: LevelKey | null = null;
|
||||
|
||||
@@ -259,6 +262,9 @@ export class Fragment extends BaseSegment {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Object representing parsed data from an HLS Partial Segment. Found in {@link hls.js#LevelDetails.partList}.
|
||||
*/
|
||||
export class Part extends BaseSegment {
|
||||
public readonly fragOffset: number = 0;
|
||||
public readonly duration: number = 0;
|
||||
|
||||
@@ -6,6 +6,9 @@ import type { VariableMap } from '../types/level';
|
||||
|
||||
const DEFAULT_TARGET_DURATION = 10;
|
||||
|
||||
/**
|
||||
* Object representing parsed data from an HLS Media Playlist. Found in {@link hls.js#Level.details}.
|
||||
*/
|
||||
export class LevelDetails {
|
||||
public PTSKnown: boolean = false;
|
||||
public alignedSliding: boolean = false;
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
* Once loaded, dispatches events with parsed data-models of manifest/levels/audio/subtitle tracks.
|
||||
*
|
||||
* Uses loader(s) set in config to do actual internal loading of resource tasks.
|
||||
*
|
||||
* @module
|
||||
*
|
||||
*/
|
||||
|
||||
import { Events } from '../events';
|
||||
|
||||
@@ -1026,8 +1026,7 @@ class MP4 {
|
||||
|
||||
/**
|
||||
* Generate a track box.
|
||||
* @param track {object} a track definition
|
||||
* @return {Uint8Array} the track box
|
||||
* @param track a track definition
|
||||
*/
|
||||
static trak(track) {
|
||||
track.duration = track.duration || 0xffffffff;
|
||||
|
||||
+4
-10
@@ -50,23 +50,17 @@ export default class TaskLoop {
|
||||
|
||||
protected onHandlerDestroyed() {}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public hasInterval(): boolean {
|
||||
return !!this._tickInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public hasNextTick(): boolean {
|
||||
return !!this._tickTimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} millis Interval time (ms)
|
||||
* @returns {boolean} True when interval has been scheduled, false when already scheduled (no effect)
|
||||
* @param millis - Interval time (ms)
|
||||
* @eturns True when interval has been scheduled, false when already scheduled (no effect)
|
||||
*/
|
||||
public setInterval(millis: number): boolean {
|
||||
if (!this._tickInterval) {
|
||||
@@ -77,7 +71,7 @@ export default class TaskLoop {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean} True when interval was cleared, false when none was set (no effect)
|
||||
* @returns True when interval was cleared, false when none was set (no effect)
|
||||
*/
|
||||
public clearInterval(): boolean {
|
||||
if (this._tickInterval) {
|
||||
@@ -89,7 +83,7 @@ export default class TaskLoop {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean} True when timeout was cleared, false when none was set (no effect)
|
||||
* @returns True when timeout was cleared, false when none was set (no effect)
|
||||
*/
|
||||
public clearNextTick(): boolean {
|
||||
if (this._tickTimer) {
|
||||
|
||||
@@ -6,15 +6,15 @@ const BinarySearch = {
|
||||
* This requires the condition to only match one item in the array,
|
||||
* and for the array to be ordered.
|
||||
*
|
||||
* @param {Array<T>} list The array to search.
|
||||
* @param {BinarySearchComparison<T>} comparisonFn
|
||||
* @param list The array to search.
|
||||
* @param comparisonFn
|
||||
* Called and provided a candidate item as the first argument.
|
||||
* Should return:
|
||||
* > -1 if the item should be located at a lower index than the provided item.
|
||||
* > 1 if the item should be located at a higher index than the provided item.
|
||||
* > 0 if the item is the item you're looking for.
|
||||
*
|
||||
* @return {T | null} The object if it is found or null otherwise.
|
||||
* @returns the object if found, otherwise returns null
|
||||
*/
|
||||
search: function <T>(
|
||||
list: T[],
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/**
|
||||
* @module BufferHelper
|
||||
*
|
||||
* Providing methods dealing with buffer length retrieval for example.
|
||||
* Provides methods dealing with buffer length retrieval for example.
|
||||
*
|
||||
* In general, a helper around HTML5 MediaElement TimeRanges gathered from `buffered` property.
|
||||
*
|
||||
@@ -35,9 +33,6 @@ const noopBuffered: TimeRanges = {
|
||||
export class BufferHelper {
|
||||
/**
|
||||
* Return true if `media`'s buffered include `position`
|
||||
* @param {Bufferable} media
|
||||
* @param {number} position
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static isBuffered(media: Bufferable, position: number): boolean {
|
||||
try {
|
||||
|
||||
@@ -1159,9 +1159,9 @@ class Cea608Parser {
|
||||
|
||||
/**
|
||||
* Parse Command.
|
||||
* @returns {Boolean} Tells if a command was found
|
||||
* @returns True if a command was found
|
||||
*/
|
||||
parseCmd(a: number, b: number) {
|
||||
parseCmd(a: number, b: number): boolean {
|
||||
const { cmdHistory } = this;
|
||||
const cond1 =
|
||||
(a === 0x14 || a === 0x1c || a === 0x15 || a === 0x1d) &&
|
||||
@@ -1229,9 +1229,8 @@ class Cea608Parser {
|
||||
|
||||
/**
|
||||
* Parse midrow styling command
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
parseMidrow(a: number, b: number) {
|
||||
parseMidrow(a: number, b: number): boolean {
|
||||
let chNr: number = 0;
|
||||
|
||||
if ((a === 0x11 || a === 0x19) && b >= 0x20 && b <= 0x2f) {
|
||||
@@ -1304,7 +1303,7 @@ class Cea608Parser {
|
||||
|
||||
/**
|
||||
* Interpret the second byte of the pac, and return the information.
|
||||
* @returns {Object} pacData with style parameters.
|
||||
* @returns pacData with style parameters
|
||||
*/
|
||||
interpretPAC(row: number, byte: number): PACData {
|
||||
let pacIndex;
|
||||
@@ -1391,7 +1390,7 @@ class Cea608Parser {
|
||||
|
||||
/**
|
||||
* Parse extended background attributes as well as new foreground color black.
|
||||
* @returns {Boolean} Tells if background attributes are found
|
||||
* @returns True if background attributes are found
|
||||
*/
|
||||
parseBackgroundAttributes(a: number, b: number): boolean {
|
||||
const case1 = (a === 0x10 || a === 0x18) && b >= 0x20 && b <= 0x2f;
|
||||
|
||||
@@ -188,8 +188,8 @@ export function parseSegmentIndex(sidx: Uint8Array): SidxInfo | null {
|
||||
* moov > trak > mdia > mdhd.timescale
|
||||
* moov > trak > mdia > hdlr
|
||||
* ```
|
||||
* @param initSegment {Uint8Array} the bytes of the init segment
|
||||
* @return {InitData} a hash of track type to timescale values or null if
|
||||
* @param initSegment the bytes of the init segment
|
||||
* @returns a hash of track type to timescale values or null if
|
||||
* the init segment is malformed.
|
||||
*/
|
||||
|
||||
@@ -346,9 +346,9 @@ export function parseSinf(sinf: Uint8Array): Uint8Array | null {
|
||||
* ```
|
||||
* It requires the timescale value from the mdhd to interpret.
|
||||
*
|
||||
* @param initData {InitData} a hash of track type to timescale values
|
||||
* @param fmp4 {Uint8Array} the bytes of the mp4 fragment
|
||||
* @return {number} the earliest base media decode start time for the
|
||||
* @param initData - a hash of track type to timescale values
|
||||
* @param fmp4 - the bytes of the mp4 fragment
|
||||
* @returns the earliest base media decode start time for the
|
||||
* fragment, in seconds
|
||||
*/
|
||||
export function getStartDTS(initData: InitData, fmp4: Uint8Array): number {
|
||||
|
||||
@@ -165,8 +165,7 @@ describe('FragmentTracker', function () {
|
||||
|
||||
describe('getBufferedFrag', function () {
|
||||
let hls;
|
||||
/** @type {FragmentTracker} */
|
||||
let fragmentTracker;
|
||||
let fragmentTracker: FragmentTracker;
|
||||
beforeEach(function () {
|
||||
hls = new Hls({});
|
||||
fragmentTracker = new FragmentTracker(hls);
|
||||
@@ -458,14 +457,22 @@ describe('FragmentTracker', function () {
|
||||
});
|
||||
});
|
||||
|
||||
type FragmentTrackerTestable = Omit<
|
||||
FragmentTracker,
|
||||
'hasFragment' | 'removeFragment'
|
||||
> & {
|
||||
hasFragment: (fragment: Fragment) => void;
|
||||
removeFragment: (fragment: Fragment) => void;
|
||||
};
|
||||
|
||||
describe('removeFragment', function () {
|
||||
/** @type {Hls} */
|
||||
let hls;
|
||||
/** @type {FragmentTracker} */
|
||||
let fragmentTracker;
|
||||
let hls: Hls;
|
||||
let fragmentTracker: FragmentTrackerTestable;
|
||||
beforeEach(function () {
|
||||
hls = new Hls({});
|
||||
fragmentTracker = new FragmentTracker(hls);
|
||||
fragmentTracker = new FragmentTracker(
|
||||
hls
|
||||
) as unknown as FragmentTrackerTestable;
|
||||
});
|
||||
it('should remove fragment', function () {
|
||||
const fragment = createMockFragment(
|
||||
@@ -497,13 +504,13 @@ describe('FragmentTracker', function () {
|
||||
});
|
||||
});
|
||||
describe('removeAllFragments', function () {
|
||||
/** @type {Hls} */
|
||||
let hls;
|
||||
/** @type {FragmentTracker} */
|
||||
let fragmentTracker;
|
||||
let hls: Hls;
|
||||
let fragmentTracker: FragmentTrackerTestable;
|
||||
beforeEach(function () {
|
||||
hls = new Hls({});
|
||||
fragmentTracker = new FragmentTracker(hls);
|
||||
fragmentTracker = new FragmentTracker(
|
||||
hls
|
||||
) as unknown as FragmentTrackerTestable;
|
||||
});
|
||||
it('should remove all fragments', function () {
|
||||
const fragments = [
|
||||
|
||||
@@ -43,10 +43,6 @@ describe('StreamController', function () {
|
||||
fake.restore();
|
||||
});
|
||||
|
||||
/**
|
||||
* Assert: streamController should be started
|
||||
* @param {StreamController} streamController
|
||||
*/
|
||||
const assertStreamControllerStarted = (streamController) => {
|
||||
expect(streamController.hasInterval()).to.be.true;
|
||||
expect(streamController.state).to.equal(
|
||||
@@ -55,10 +51,6 @@ describe('StreamController', function () {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Assert: streamController should be stopped
|
||||
* @param {StreamController} streamController
|
||||
*/
|
||||
const assertStreamControllerStopped = (streamController) => {
|
||||
expect(streamController.hasInterval()).to.be.false;
|
||||
expect(streamController.state).to.equal(
|
||||
|
||||
@@ -9,9 +9,6 @@ chai.use(sinonChai);
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('Fragment class tests', function () {
|
||||
/**
|
||||
* @type {Fragment}
|
||||
*/
|
||||
let frag: Fragment;
|
||||
beforeEach(function () {
|
||||
frag = new Fragment(PlaylistLevelType.MAIN, '');
|
||||
|
||||
Reference in New Issue
Block a user