Skip to content

Commit

Permalink
feat: maxDevicePixelRatio limits the browser's value (#6825)
Browse files Browse the repository at this point in the history
  • Loading branch information
signalwerk authored Nov 14, 2024
1 parent a878ad3 commit f53373f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
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 @@ -2159,6 +2159,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

0 comments on commit f53373f

Please sign in to comment.