From e1318857a7a55fd28f5e4b4cebd66ae680a65b17 Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 15:50:22 +0100 Subject: [PATCH 01/13] Add XOne check --- lib/util/platform.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/util/platform.js b/lib/util/platform.js index 2bdb8daee9..976057b3be 100644 --- a/lib/util/platform.js +++ b/lib/util/platform.js @@ -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(); } /** @@ -354,6 +355,15 @@ shaka.util.Platform = class { return shaka.util.Platform.userAgentContains_('Sky_STB'); } + /** + * Check if the current platform is SkyQ STB. + */ + static isXOne() { + return navigator.platform && + navigator.platform.includes('Linux aarch64') && + shaka.util.Platform.userAgentContains_('AppleWebKit'); + } + /** * Check if the current platform is Amazon Fire TV. * https://developer.amazon.com/docs/fire-tv/identify-amazon-fire-tv-devices.html @@ -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; @@ -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. From ea9c93ea97527212a86bba35ee7d3875e7268c5e Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 15:50:51 +0100 Subject: [PATCH 02/13] Remove native Cap for XOne --- lib/polyfill/media_capabilities.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/polyfill/media_capabilities.js b/lib/polyfill/media_capabilities.js index d5702f9a95..6c3667d5ac 100644 --- a/lib/polyfill/media_capabilities.js +++ b/lib/polyfill/media_capabilities.js @@ -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) { From f6e854fe8116717a8db5f4ef5583b56dd4461103 Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 15:51:11 +0100 Subject: [PATCH 03/13] Correct name --- lib/util/platform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/platform.js b/lib/util/platform.js index 976057b3be..6cdfb37c97 100644 --- a/lib/util/platform.js +++ b/lib/util/platform.js @@ -356,7 +356,7 @@ shaka.util.Platform = class { } /** - * Check if the current platform is SkyQ STB. + * Check if the current platform is XOne. */ static isXOne() { return navigator.platform && From cff58e0edbd73381cfa26bf96bdd6cfc48281149 Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 15:55:52 +0100 Subject: [PATCH 04/13] Addin XOne exception for Mediasource and Buffer --- lib/polyfill/mediasource.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/polyfill/mediasource.js b/lib/polyfill/mediasource.js index d459a260e2..1130bcc873 100644 --- a/lib/polyfill/mediasource.js +++ b/lib/polyfill/mediasource.js @@ -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.'); } From d4d566a0d7b00e97930130636a6bb11545bfde2e Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 16:07:49 +0100 Subject: [PATCH 05/13] Re add the fix for safari 8 --- lib/media/time_ranges_utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/media/time_ranges_utils.js b/lib/media/time_ranges_utils.js index cfcfb43bb2..9e02363a5d 100644 --- a/lib/media/time_ranges_utils.js +++ b/lib/media/time_ranges_utils.js @@ -106,13 +106,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); } } From 9dd380c2db8e4925f51caa0380067428f623e82b Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 16:17:45 +0100 Subject: [PATCH 06/13] Adding the require --- lib/media/time_ranges_utils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/media/time_ranges_utils.js b/lib/media/time_ranges_utils.js index 9e02363a5d..458cb2a6e9 100644 --- a/lib/media/time_ranges_utils.js +++ b/lib/media/time_ranges_utils.js @@ -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. From e77bee1a43b0fe9e568dff39072f611753af8d1a Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 18:30:44 +0100 Subject: [PATCH 07/13] Correct the playhead value --- lib/media/time_ranges_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/media/time_ranges_utils.js b/lib/media/time_ranges_utils.js index 458cb2a6e9..2d9d3ed37c 100644 --- a/lib/media/time_ranges_utils.js +++ b/lib/media/time_ranges_utils.js @@ -117,7 +117,7 @@ shaka.media.TimeRangesUtils = class { // 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 (time + fudge >= start && end > time) { + if ((time + fudge) >= start || end > time) { result += end - Math.max(start, time); } } From 1bb33ca1d762d7a71b6bb6094cfdac19741400b8 Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 18:38:59 +0100 Subject: [PATCH 08/13] Correct test --- lib/media/time_ranges_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/media/time_ranges_utils.js b/lib/media/time_ranges_utils.js index 2d9d3ed37c..33fdfb6810 100644 --- a/lib/media/time_ranges_utils.js +++ b/lib/media/time_ranges_utils.js @@ -117,7 +117,7 @@ shaka.media.TimeRangesUtils = class { // 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 ((time + fudge) >= start || end > time) { + if (((time + fudge) >= start && time < end ) || end > time) { result += end - Math.max(start, time); } } From bf4c4401c9e208a6714ceb5604e16617bc322242 Mon Sep 17 00:00:00 2001 From: Iragne Date: Thu, 31 Oct 2024 18:53:05 +0100 Subject: [PATCH 09/13] =?UTF-8?q?I=E2=80=99m=20stupid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/media/time_ranges_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/media/time_ranges_utils.js b/lib/media/time_ranges_utils.js index 33fdfb6810..fdc7d29d80 100644 --- a/lib/media/time_ranges_utils.js +++ b/lib/media/time_ranges_utils.js @@ -117,7 +117,7 @@ shaka.media.TimeRangesUtils = class { // 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 (((time + fudge) >= start && time < end ) || end > time) { + if (((time + fudge) > start || time < start) && time < end) { result += end - Math.max(start, time); } } From 4541c2d48dc57091e6484697e3fb4c5719c7aca6 Mon Sep 17 00:00:00 2001 From: Iragne Date: Fri, 1 Nov 2024 10:02:42 +0100 Subject: [PATCH 10/13] Improve the XOne check by checking the RDK interface too --- lib/util/platform.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/util/platform.js b/lib/util/platform.js index 6cdfb37c97..c696c8ec2f 100644 --- a/lib/util/platform.js +++ b/lib/util/platform.js @@ -359,9 +359,10 @@ shaka.util.Platform = class { * Check if the current platform is XOne. */ static isXOne() { - return navigator.platform && - navigator.platform.includes('Linux aarch64') && - shaka.util.Platform.userAgentContains_('AppleWebKit'); + return ServiceManager && ServiceManager.getServiceForJavaScript && + navigator.platform && navigator.platform.includes('Linux aarch64') && + shaka.util.Platform.userAgentContains_('AppleWebKit') && + shaka.util.Platform.userAgentContains_('Version/8.0'); } /** From d89590c78dc9eaa8ca39222a1acf9649d2137e3e Mon Sep 17 00:00:00 2001 From: Iragne Date: Fri, 1 Nov 2024 10:45:24 +0100 Subject: [PATCH 11/13] Correct check for RDK --- lib/util/platform.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/util/platform.js b/lib/util/platform.js index c696c8ec2f..8e13be3eff 100644 --- a/lib/util/platform.js +++ b/lib/util/platform.js @@ -359,8 +359,15 @@ shaka.util.Platform = class { * Check if the current platform is XOne. */ static isXOne() { - return ServiceManager && ServiceManager.getServiceForJavaScript && - navigator.platform && navigator.platform.includes('Linux aarch64') && + let rdk = false; + if (window && Object.keys(window).includes('ServiceManager')) { + const subRDK = window['ServiceManager']; + if (Object.keys(subRDK).includes('getServiceForJavaScript')) { + rdk = true; + } + } + return rdk && navigator.platform && + navigator.platform.includes('Linux aarch64') && shaka.util.Platform.userAgentContains_('AppleWebKit') && shaka.util.Platform.userAgentContains_('Version/8.0'); } From 9f4287a59847c82de497a0afd2b8c78d26a696b2 Mon Sep 17 00:00:00 2001 From: Iragne Date: Fri, 1 Nov 2024 11:32:51 +0100 Subject: [PATCH 12/13] No need to do that --- lib/media/time_ranges_utils.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/media/time_ranges_utils.js b/lib/media/time_ranges_utils.js index fdc7d29d80..cfcfb43bb2 100644 --- a/lib/media/time_ranges_utils.js +++ b/lib/media/time_ranges_utils.js @@ -6,7 +6,6 @@ goog.provide('shaka.media.TimeRangesUtils'); -goog.require('shaka.util.Platform'); /** * @summary A set of utility functions for dealing with TimeRanges objects. @@ -107,17 +106,13 @@ 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 (((time + fudge) > start || time < start) && time < end) { + if (end > time) { result += end - Math.max(start, time); } } From b8b17b20283c5f480246ea9f5d09ab9a9caded6a Mon Sep 17 00:00:00 2001 From: Iragne Date: Fri, 1 Nov 2024 15:39:55 +0100 Subject: [PATCH 13/13] Look like not needed --- lib/util/platform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/platform.js b/lib/util/platform.js index 8e13be3eff..ca8d5957ed 100644 --- a/lib/util/platform.js +++ b/lib/util/platform.js @@ -658,7 +658,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.isXOne()) { + Platform.isPS5()) { return false; } // Older chromecasts without GoogleTV seem to not support SMOOTH properly.