Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for XOne devices #7529

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
7 changes: 6 additions & 1 deletion lib/media/time_ranges_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

goog.provide('shaka.media.TimeRangesUtils');

goog.require('shaka.util.Platform');

/**
* @summary A set of utility functions for dealing with TimeRanges objects.
Expand Down Expand Up @@ -106,13 +107,17 @@ shaka.media.TimeRangesUtils = class {
return 0;
}

// NOTE: The 0.1ms fudge is needed on XOne,
// where removal up to X may leave
// a range which starts at X + 1us + some small epsilon.
const fudge = shaka.util.Platform.isXOne() ? 0.001 : 0;
// We calculate the buffered amount by ONLY accounting for the content
// buffered (i.e. we ignore the times of the gaps). We also buffer through
// all gaps.
// Therefore, we start at the end and add up all buffers until |time|.
let result = 0;
for (const {start, end} of shaka.media.TimeRangesUtils.getBufferedInfo(b)) {
if (end > time) {
if (time + fudge >= start && end > time) {
result += end - Math.max(start, time);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/polyfill/media_capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ shaka.polyfill.MediaCapabilities = class {
shaka.util.Platform.isWebOS() ||
shaka.util.Platform.isTizen() ||
shaka.util.Platform.isEOS() ||
shaka.util.Platform.isHisense()) {
shaka.util.Platform.isHisense() ||
shaka.util.Platform.isXOne()) {
canUseNativeMCap = false;
}
if (canUseNativeMCap && navigator.mediaCapabilities) {
Expand Down
12 changes: 12 additions & 0 deletions lib/polyfill/mediasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ shaka.polyfill.MediaSource = class {
// the player from trying to play opus on Tizen, we will override media
// source to always reject opus content.
shaka.polyfill.MediaSource.rejectCodec_('opus');
} else if (shaka.util.Platform.isXOne()) {
// XOne look to be like safari 8 which do not correctly
// implement abort() on SourceBuffer.
// Calling abort() before appending a segment causes that segment to be
// incomplete in the buffer.
// Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342
shaka.polyfill.MediaSource.stubAbort_();
// If you remove up to a keyframe, Webkit 601.x.x incorrectly will also
// remove that keyframe and the content up to the next.
// Offsetting the end of the removal range seems to help.
// Bug filed: https://bugs.webkit.org/show_bug.cgi?id=177884
shaka.polyfill.MediaSource.patchRemovalRange_();
} else {
shaka.log.info('Using native MSE as-is.');
}
Expand Down
17 changes: 14 additions & 3 deletions lib/util/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ shaka.util.Platform = class {
!shaka.util.Platform.isAmazonFireTV() &&
!shaka.util.Platform.isWPE() &&
!shaka.util.Platform.isZenterio() &&
!shaka.util.Platform.isSkyQ();
!shaka.util.Platform.isSkyQ() &&
!shaka.util.Platform.isXOne();
}

/**
Expand Down Expand Up @@ -354,6 +355,15 @@ shaka.util.Platform = class {
return shaka.util.Platform.userAgentContains_('Sky_STB');
}

/**
* Check if the current platform is XOne.
*/
static isXOne() {
return navigator.platform &&
navigator.platform.includes('Linux aarch64') &&
shaka.util.Platform.userAgentContains_('AppleWebKit');
joeyparrish marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Check if the current platform is Amazon Fire TV.
* https://developer.amazon.com/docs/fire-tv/identify-amazon-fire-tv-devices.html
Expand Down Expand Up @@ -537,7 +547,8 @@ shaka.util.Platform = class {
Platform.isEOS() || Platform.isAPL() ||
Platform.isVirginMedia() || Platform.isOrange() ||
Platform.isWPE() || Platform.isChromecast() ||
Platform.isHisense() || Platform.isZenterio()) {
Platform.isHisense() || Platform.isZenterio() ||
Platform.isXOne()) {
return true;
}
return false;
Expand Down Expand Up @@ -639,7 +650,7 @@ shaka.util.Platform = class {
if (Platform.isTizen2() || Platform.isTizen3() || Platform.isTizen4() ||
Platform.isTizen5() || Platform.isTizen6() || Platform.isWebOS3() ||
Platform.isWebOS4() || Platform.isWebOS5() || Platform.isPS4() ||
Platform.isPS5()) {
Platform.isPS5() || Platform.isXOne()) {
return false;
}
// Older chromecasts without GoogleTV seem to not support SMOOTH properly.
Expand Down
Loading