Skip to content

Commit

Permalink
Documentation - Add interface for AbrController (#4842)
Browse files Browse the repository at this point in the history
* create an interface for abr controllers

* use AbrComponentApi interface in abr-controller.ts

* update docs for custom abr controllers

* remove clearTimer from abr interface and documentation
  • Loading branch information
lpommers committed Jan 16, 2023
1 parent 0d1e4c8 commit 617d78b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,9 @@ var config = {

Customized Adaptive Bitrate Streaming Controller.

Parameter should be a class providing 2 getters, 2 setters and a `destroy()` method:
Parameter should be a class providing a getter/setter and a `destroy()` method:

- get/set `nextAutoLevel`: return next auto-quality level/force next auto-quality level that should be returned (currently used for emergency switch down)
- get/set `autoLevelCapping`: capping/max level value that could be used by ABR Controller
- `destroy()`: should clean-up all used resources

For `hls.bandwidthEstimate()` to return an estimate from your custom controller, it will also need to satisfy `abrController.bwEstimator.getEstimate()`.
Expand Down
4 changes: 2 additions & 2 deletions src/controller/abr-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import type {
ErrorData,
LevelLoadedData,
} from '../types/events';
import type { ComponentAPI } from '../types/component-api';
import type { AbrComponentAPI } from '../types/component-api';

class AbrController implements ComponentAPI {
class AbrController implements AbrComponentAPI {
protected hls: Hls;
private lastLoadedFragLevel: number = 0;
private _nextAutoLevel: number = -1;
Expand Down
7 changes: 7 additions & 0 deletions src/types/component-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import EwmaBandWidthEstimator from '../utils/ewma-bandwidth-estimator';

export interface ComponentAPI {
destroy(): void;
}

export interface AbrComponentAPI extends ComponentAPI {
nextAutoLevel: Number;
readonly bwEstimator?: EwmaBandWidthEstimator;
}

export interface NetworkComponentAPI extends ComponentAPI {
startLoad(startPosition: number): void;
stopLoad(): void;
Expand Down

0 comments on commit 617d78b

Please sign in to comment.