Skip to content

Commit 86fa9f1

Browse files
aveladjoeyparrish
authored andcommitted
fix(Cast): Incorrect detection of MediaCapabilities on Linux Chromecast (#7628)
Fixes #5776
1 parent b1df345 commit 86fa9f1

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

lib/polyfill/media_capabilities.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,18 @@ shaka.polyfill.MediaCapabilities = class {
320320

321321
let displayType = videoConfig.contentType;
322322
if (videoConfig.width && videoConfig.height) {
323-
displayType +=
324-
`; width=${videoConfig.width}; height=${videoConfig.height}`;
323+
// All Chromecast can support 720p videos
324+
if (videoConfig.width > 1280 || videoConfig.height > 720) {
325+
displayType +=
326+
`; width=${videoConfig.width}; height=${videoConfig.height}`;
327+
}
325328
}
326329
if (videoConfig.framerate) {
327-
displayType += `; framerate=${videoConfig.framerate}`;
330+
// All Chromecast can support a framerate of 24, 25 or 30.
331+
const framerate = Math.round(videoConfig.framerate);
332+
if (framerate < 24 || framerate > 30) {
333+
displayType += `; framerate=${videoConfig.framerate}`;
334+
}
328335
}
329336

330337
// Don't trust Closure types here. Although transferFunction is string or

test/polyfill/media_capabilities_unit.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ describe('MediaCapabilities', () => {
6464
bitrate: 349265,
6565
contentType: 'video/mp4; codecs="avc1.4D4015"',
6666
framerate: 23.976023976023978,
67-
height: 288,
68-
width: 512,
67+
height: 1080,
68+
width: 1920,
6969
},
7070
};
7171
shaka.media.DrmEngine.clearMediaKeySystemAccessMap();
@@ -258,14 +258,14 @@ describe('MediaCapabilities', () => {
258258
'video/mp4; codecs="hev1.2.4.L153.B0"';
259259
// Round to a whole number since we can't rely on number => string
260260
// conversion precision on all devices.
261-
mockDecodingConfig.video.framerate = 24;
261+
mockDecodingConfig.video.framerate = 60;
262262

263263
const chromecastType =
264264
'video/mp4; ' +
265265
'codecs="hev1.2.4.L153.B0"; ' +
266-
'width=512; ' +
267-
'height=288; ' +
268-
'framerate=24; ' +
266+
'width=1920; ' +
267+
'height=1080; ' +
268+
'framerate=60; ' +
269269
'eotf=smpte2084';
270270
mockCanDisplayType.and.callFake((type) => {
271271
expect(type).toBe(chromecastType);

0 commit comments

Comments
 (0)