Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: maxDevicePixelRatio limits the browser's value #6825

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api-extractor/report/hls.js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,7 @@ export type HlsConfig = {
enableSoftwareAES: boolean;
minAutoBitrate: number;
ignoreDevicePixelRatio: boolean;
maxDevicePixelRatio: number;
preferManagedMediaSource: boolean;
timelineOffset?: number;
loader: {
Expand Down
7 changes: 7 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ See [API Reference](https://hlsjs-dev.video-dev.org/api-docs/) for a complete li
- [`capLevelToPlayerSize`](#capleveltoplayersize)
- [`capLevelOnFPSDrop`](#caplevelonfpsdrop)
- [`ignoreDevicePixelRatio`](#ignoredevicepixelratio)
- [`maxDevicePixelRatio`](#maxdevicepixelratio)
- [`debug`](#debug)
- [`autoStartLoad`](#autostartload)
- [`startPosition`](#startposition)
Expand Down Expand Up @@ -526,6 +527,12 @@ This configuration will be applied by default to all instances.
- when set to true, calculations related to player size will ignore browser `devicePixelRatio`.
- when set to false, calculations related to player size will respect browser `devicePixelRatio`.

### `maxDevicePixelRatio`

(default: `Number.POSITIVE_INFINITY`)

- when set, calculations related to player size will limit the browser's `devicePixelRatio` to this specified value.

### `debug`

(default: `false`)
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export type HlsConfig = {
enableSoftwareAES: boolean;
minAutoBitrate: number;
ignoreDevicePixelRatio: boolean;
maxDevicePixelRatio: number;
preferManagedMediaSource: boolean;
timelineOffset?: number;
loader: { new (confg: HlsConfig): Loader<LoaderContext> };
Expand Down Expand Up @@ -356,6 +357,7 @@ export const hlsDefaultConfig: HlsConfig = {
capLevelOnFPSDrop: false, // used by fps-controller
capLevelToPlayerSize: false, // used by cap-level-controller
ignoreDevicePixelRatio: false, // used by cap-level-controller
maxDevicePixelRatio: Number.POSITIVE_INFINITY, // used by cap-level-controller
preferManagedMediaSource: true,
initialLiveManifestSize: 1, // used by stream-controller
maxBufferLength: 30, // used by stream-controller
Expand Down
2 changes: 1 addition & 1 deletion src/controller/cap-level-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class CapLevelController implements ComponentAPI {
}
}

return pixelRatio;
return Math.min(pixelRatio, this.hls.config.maxDevicePixelRatio);
}

private isLevelAllowed(level: Level): boolean {
Expand Down
Loading