Skip to content

Commit f53373f

Browse files
authored
feat: maxDevicePixelRatio limits the browser's value (#6825)
1 parent a878ad3 commit f53373f

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

api-extractor/report/hls.js.api.md

+1
Original file line numberDiff line numberDiff line change
@@ -2159,6 +2159,7 @@ export type HlsConfig = {
21592159
enableSoftwareAES: boolean;
21602160
minAutoBitrate: number;
21612161
ignoreDevicePixelRatio: boolean;
2162+
maxDevicePixelRatio: number;
21622163
preferManagedMediaSource: boolean;
21632164
timelineOffset?: number;
21642165
loader: {

docs/API.md

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ See [API Reference](https://hlsjs-dev.video-dev.org/api-docs/) for a complete li
2121
- [`capLevelToPlayerSize`](#capleveltoplayersize)
2222
- [`capLevelOnFPSDrop`](#caplevelonfpsdrop)
2323
- [`ignoreDevicePixelRatio`](#ignoredevicepixelratio)
24+
- [`maxDevicePixelRatio`](#maxdevicepixelratio)
2425
- [`debug`](#debug)
2526
- [`autoStartLoad`](#autostartload)
2627
- [`startPosition`](#startposition)
@@ -526,6 +527,12 @@ This configuration will be applied by default to all instances.
526527
- when set to true, calculations related to player size will ignore browser `devicePixelRatio`.
527528
- when set to false, calculations related to player size will respect browser `devicePixelRatio`.
528529

530+
### `maxDevicePixelRatio`
531+
532+
(default: `Number.POSITIVE_INFINITY`)
533+
534+
- when set, calculations related to player size will limit the browser's `devicePixelRatio` to this specified value.
535+
529536
### `debug`
530537

531538
(default: `false`)

src/config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ export type HlsConfig = {
272272
enableSoftwareAES: boolean;
273273
minAutoBitrate: number;
274274
ignoreDevicePixelRatio: boolean;
275+
maxDevicePixelRatio: number;
275276
preferManagedMediaSource: boolean;
276277
timelineOffset?: number;
277278
loader: { new (confg: HlsConfig): Loader<LoaderContext> };
@@ -356,6 +357,7 @@ export const hlsDefaultConfig: HlsConfig = {
356357
capLevelOnFPSDrop: false, // used by fps-controller
357358
capLevelToPlayerSize: false, // used by cap-level-controller
358359
ignoreDevicePixelRatio: false, // used by cap-level-controller
360+
maxDevicePixelRatio: Number.POSITIVE_INFINITY, // used by cap-level-controller
359361
preferManagedMediaSource: true,
360362
initialLiveManifestSize: 1, // used by stream-controller
361363
maxBufferLength: 30, // used by stream-controller

src/controller/cap-level-controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class CapLevelController implements ComponentAPI {
258258
}
259259
}
260260

261-
return pixelRatio;
261+
return Math.min(pixelRatio, this.hls.config.maxDevicePixelRatio);
262262
}
263263

264264
private isLevelAllowed(level: Level): boolean {

0 commit comments

Comments
 (0)