Skip to content

Commit defd2ee

Browse files
committed
fix(Cast): Incorrect detection of MediaCapabilities on Linux Chromecast (#7628)
Fixes #5776
1 parent 05e54e4 commit defd2ee

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
@@ -327,11 +327,18 @@ shaka.polyfill.MediaCapabilities = class {
327327

328328
let displayType = videoConfig.contentType;
329329
if (videoConfig.width && videoConfig.height) {
330-
displayType +=
331-
`; width=${videoConfig.width}; height=${videoConfig.height}`;
330+
// All Chromecast can support 720p videos
331+
if (videoConfig.width > 1280 || videoConfig.height > 720) {
332+
displayType +=
333+
`; width=${videoConfig.width}; height=${videoConfig.height}`;
334+
}
332335
}
333336
if (videoConfig.framerate) {
334-
displayType += `; framerate=${videoConfig.framerate}`;
337+
// All Chromecast can support a framerate of 24, 25 or 30.
338+
const framerate = Math.round(videoConfig.framerate);
339+
if (framerate < 24 || framerate > 30) {
340+
displayType += `; framerate=${videoConfig.framerate}`;
341+
}
335342
}
336343

337344
// 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.util.DrmUtils.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)