Skip to content

Commit

Permalink
feat: Add config to ignore hardware resolution (#7572)
Browse files Browse the repository at this point in the history
For some niche cases where content is only available at resolutions
beyond the device's native resolution, and you are confident it can be
decoded and downscaled, this flag can allow playback when it would
otherwise fail.
  • Loading branch information
joeyparrish authored Nov 12, 2024
1 parent 5eb5b39 commit 11a7b92
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,7 @@ shaka.extern.TextDisplayerConfiguration;
* cmsd: shaka.extern.CmsdConfiguration,
* lcevc: shaka.extern.LcevcConfiguration,
* offline: shaka.extern.OfflineConfiguration,
* ignoreHardwareResolution: boolean,
* preferredAudioLanguage: string,
* preferredAudioLabel: string,
* preferredTextLanguage: string,
Expand Down Expand Up @@ -2345,6 +2346,11 @@ shaka.extern.TextDisplayerConfiguration;
* (Low Complexity Enhancement Video Codec)
* @property {shaka.extern.OfflineConfiguration} offline
* Offline configuration and settings.
* @property {boolean} ignoreHardwareResolution
* Do not detect the hardware resolution. For some niche cases where content
* is only available at resolutions beyond the device's native resolution,
* and you are confident it can be decoded and downscaled, this flag can
* allow playback when it would otherwise fail.
* @property {string} preferredAudioLanguage
* The preferred language to use for audio tracks. If not given it will use
* the <code>'main'</code> track.
Expand Down
3 changes: 2 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,8 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
// Avoid having to detect the resolution again if it has already been
// detected or set
if (this.maxHwRes_.width == Infinity &&
this.maxHwRes_.height == Infinity) {
this.maxHwRes_.height == Infinity &&
!this.config_.ignoreHardwareResolution) {
const maxResolution =
await shaka.util.Platform.detectMaxHardwareResolution();
this.maxHwRes_.width = maxResolution.width;
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ shaka.util.PlayerConfiguration = class {
cmsd: cmsd,
lcevc: lcevc,
ads: ads,
ignoreHardwareResolution: false,
};

// Add this callback so that we can reference the preferred audio language
Expand Down
1 change: 1 addition & 0 deletions test/demo/demo_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('Demo', () => {
function checkConfig(checkValueNameFn) {
const configPrimitives = new Set(['number', 'string', 'boolean']);
const exceptions = new Set()
.add('ignoreHardwareResolution')
.add('playRangeStart')
.add('playRangeEnd')
.add('manifest.dash.keySystemsByURI')
Expand Down

0 comments on commit 11a7b92

Please sign in to comment.