Skip to content

Commit

Permalink
fix(Cast): Incorrect detection of MediaCapabilities on Linux Chromeca…
Browse files Browse the repository at this point in the history
…st (#7628)

Fixes #5776
  • Loading branch information
avelad committed Nov 20, 2024
1 parent 05e54e4 commit defd2ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
13 changes: 10 additions & 3 deletions lib/polyfill/media_capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,18 @@ shaka.polyfill.MediaCapabilities = class {

let displayType = videoConfig.contentType;
if (videoConfig.width && videoConfig.height) {
displayType +=
`; width=${videoConfig.width}; height=${videoConfig.height}`;
// All Chromecast can support 720p videos
if (videoConfig.width > 1280 || videoConfig.height > 720) {
displayType +=
`; width=${videoConfig.width}; height=${videoConfig.height}`;
}
}
if (videoConfig.framerate) {
displayType += `; framerate=${videoConfig.framerate}`;
// All Chromecast can support a framerate of 24, 25 or 30.
const framerate = Math.round(videoConfig.framerate);
if (framerate < 24 || framerate > 30) {
displayType += `; framerate=${videoConfig.framerate}`;
}
}

// Don't trust Closure types here. Although transferFunction is string or
Expand Down
12 changes: 6 additions & 6 deletions test/polyfill/media_capabilities_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('MediaCapabilities', () => {
bitrate: 349265,
contentType: 'video/mp4; codecs="avc1.4D4015"',
framerate: 23.976023976023978,
height: 288,
width: 512,
height: 1080,
width: 1920,
},
};
shaka.util.DrmUtils.clearMediaKeySystemAccessMap();
Expand Down Expand Up @@ -258,14 +258,14 @@ describe('MediaCapabilities', () => {
'video/mp4; codecs="hev1.2.4.L153.B0"';
// Round to a whole number since we can't rely on number => string
// conversion precision on all devices.
mockDecodingConfig.video.framerate = 24;
mockDecodingConfig.video.framerate = 60;

const chromecastType =
'video/mp4; ' +
'codecs="hev1.2.4.L153.B0"; ' +
'width=512; ' +
'height=288; ' +
'framerate=24; ' +
'width=1920; ' +
'height=1080; ' +
'framerate=60; ' +
'eotf=smpte2084';
mockCanDisplayType.and.callFake((type) => {
expect(type).toBe(chromecastType);
Expand Down

0 comments on commit defd2ee

Please sign in to comment.