Skip to content

Commit

Permalink
fix: Do not assume 1080p Cast devices, some are 720p (#6562)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed May 9, 2024
1 parent 9c1e621 commit 4498dcd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/util/platform.js
Expand Up @@ -611,27 +611,32 @@ shaka.util.Platform = class {

if (Platform.isChromecast()) {
// In our tests, the original Chromecast seems to have trouble decoding
// above 1080p. It would be a waste to select a higher res anyway, given
// above 1080p. It would be a waste to select a higher res anyway, given
// that the device only outputs 1080p to begin with.
// Chromecast has an extension to query the device/display's resolution.
const hasCanDisplayType = window.cast && cast.__platform__ &&
cast.__platform__.canDisplayType;

// Most Chromecasts can do 1080p.
maxResolution.width = 1920;
maxResolution.height = 1080;
// Some hub devices can only do 720p. Default to that.
maxResolution.width = 1280;
maxResolution.height = 720;

try {
if (hasCanDisplayType && await cast.__platform__.canDisplayType(
'video/mp4; codecs="avc1.640028"; width=3840; height=2160')) {
// The device and display can both do 4k. Assume a 4k limit.
// The device and display can both do 4k. Assume a 4k limit.
maxResolution.width = 3840;
maxResolution.height = 2160;
} else if (hasCanDisplayType && await cast.__platform__.canDisplayType(
'video/mp4; codecs="avc1.640028"; width=1920; height=1080')) {
// Most Chromecasts can do 1080p.
maxResolution.width = 1920;
maxResolution.height = 1080;
}
} catch (error) {
// This shouldn't generally happen. Log the error.
// This shouldn't generally happen. Log the error.
shaka.log.alwaysError('Failed to check canDisplayType:', error);
// Now ignore the error and let the 1080p default stand.
// Now ignore the error and let the 720p default stand.
}
} else if (Platform.isTizen()) {
maxResolution.width = 1920;
Expand Down

0 comments on commit 4498dcd

Please sign in to comment.