Commit Graph

218 Commits

Author SHA1 Message Date
Joey Parrish ead344fe1f chore: Drop MS EME polyfill (#4123)
The MS EME polyfill has been unused since v3.1 and removal of IE support, and isn't needed for Edge or Xbox One support.

Closes #4113
2022-04-12 21:15:14 -07:00
Álvaro Velad Galván 8bb70449d3 feat!: Remove support for Safari 12 and iOS 12 (#4112)
1. Remove support for Safari 12
2. Support modern EME in Safari 13
3. Remove EME Apple polyfill
4. Update documentation
2022-04-11 16:17:51 -07:00
Álvaro Velad Galván 169943f668 chore: remove mathround polyfill (used in IE) (#4114) 2022-04-11 13:15:04 -07:00
Álvaro Velad Galván 57c73241a0 fix(performance): Eliminate use of ES6 generators (#4092)
See: https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1077826210

Co-authored-by: @joeyparrish

Issue #4062
2022-04-04 10:58:16 -07:00
theodab 8a3bed710c feat(HLS): Re-add TS support to Safari (#4097)
It appears that the problems we previously had with TS content
on Safari have been fixed. We no longer need the workaround where
we transmuxed TS on that platform.
2022-04-01 20:32:12 -07:00
Álvaro Velad Galván 400575498f fix(cmcd): Fix Symbol usage in CMCD on Xbox One (#4073)
Close #4072

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-03-29 16:04:26 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Vincent Valot 6d76a135e5 feat: add modern EME support for FairPlay (#3776)
Add support for HLS com.apple.streamingkeydelivery through MSE/EME implementation.

Close #3346

## Tests
Tested on:
- Mac 11.6 Safari 15.2
- iOS 15.2 Safari 15.2
- Mac 11.6 Chrome 96 (for potential regressions on Widevine keySystem)

| Mode | DRM API | TS | CMAF (mono-key and multi-keys)
|---|---|---|---|
| file | EME |   |   |
| file | Legacy-prefixed |    |    |
| media-source | EME | **mux-js**: `encrypted` never fired<br />**real MSE**: `encrypted` event received, but with incorrect `sinf` initData (*1)  |   |
| media-source | Legacy-prefixed | **mux-js**: `webkitneedkey` never fired<br/>**real MSE**: TBD  | 🔴 fails to append media segment to SourceBuffer (init segment ok) `(video:4) – "failed fetch and append: code=3015"` |

## Support table 
| Mode | DRM API | TS | CMAF (mono-key and multi-keys)
|---|---|---|---|
| file | EME |   |   |
| file | Legacy-prefixed |    |    |
| media-source | EME | 🚫 `4040: HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED`  |   |
| media-source | Legacy-prefixed | 🚫 `4041: HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED`  |🚫 `4041: HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED` |

⚠️ Use EME APIs with multi-keys CMAF makes the video stalling with the audio continuing alone after a short time (~3 minutes in the stream, could be shorter, could be longer). Didn't find an explanation to that yet. I've observed the same behaviour with hls.js code so I don't think this is a player issue.
2022-02-07 11:17:22 -08:00
Joey Parrish 0201f2b760 fix: Fix MediaCapabilities polyfill on Safari
Fixes #3696
Fixes #3530

Change-Id: I2f2e248c9001e10013eb4b03af6b9ef49f28dc6c
2022-01-11 04:02:38 +00:00
Joey Parrish dfc44cbca6 fix: Fix usage of Shaka without polyfills
Revert "fix: Work around override of MediaCapabilities polyfill in Apple browsers (#3668)"

This reverts commit 31c0cd4b8c.

Fixes #3843 (usage of Shaka without polyfills)
Re-opens #3530 (MediaCapabilities polyfill not working on Safari)

Change-Id: Ib5aff1b38759e1a39200332f3f07d3d6bd3bd2e1
2022-01-11 04:02:38 +00:00
Casey Occhialini 1d54965bdc Update media capability polyfill to account for Playstation 5 (#3808)
Add Playstation 5 detection to the Media Capabilities Polyfill install method.

Fixes #3582

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2021-12-16 12:54:02 -08:00
Theodore Abshire dd3748d599 fix: Enforce string-format of event data keys.
Previously, many events were being defined with a data dictionary
that used variable-type keys (e.g. {key: value}). This worked fine
in uncompiled mode, but in compiled mode it lead to those properties
being obfuscated.
This changes the FakeEvent constructor to take a map rather than an
object, so the compiler will force the keys to be strings.

Closes #3710

Change-Id: I67b1a391540a5ee21f0aaf940ae054d26f4c10a4
2021-10-25 12:40:32 -07:00
david-hm-morgan 13aafcfd7e fix: Fix vp09 playback on webOS (#3566)
Skip the vp09 polyfill for isTypeSupported on this platform.
2021-10-18 13:51:54 -07:00
Álvaro Velad Galván 31c0cd4b8c fix: Work around override of MediaCapabilities polyfill in Apple browsers (#3668)
See also #3696

Closes #3530
2021-10-12 10:59:06 -07:00
Álvaro Velad Galván a72adca9fd feat: Add randomUUID polyfill (#3669)
Related to: #3662
2021-09-29 15:09:05 -07:00
vodlogic 52f18df21b chore: Add @export annotations to polyfill install methods (#3660)
This change allows polyfills to be installed individually e.g. shaka.polyfill.MediaCapabilities.install() instead of shaka.polyfill.installAll()

Related to #2625
2021-09-23 14:27:50 -07:00
Álvaro Velad Galván 4dce1e0ba5 Fix: Always polyfill MediaCapabilities for Apple browsers (#3588) 2021-08-20 17:21:35 -07:00
Álvaro Velad Galván ef506ac647 Fix: Add Support to iOS 12 in MediaCapabilities polyfill (#3573)
In iOS, there is no support for MediaSource, and we should have  'file' as the type of the MediaiDecodingConfig, to check whether the content is supported or not. We should only require MediaSource support in the polyfill when the type of MediaiDecodingConfig is 'media-source'. 
Issue: #3530 .
2021-08-16 07:16:21 -07:00
Álvaro Velad Galván c07d1a3e09 fix: Add support to file type in MediaCapabilities polyfill (#3569)
Issue: #3530
2021-08-10 10:04:24 -07:00
Joey Parrish b185b3c9ea fix: Make ARIA polyfill more robust
All the attributes listed in the polyfill already begin with "aria".
However, to add extra protection against the possibility of XSS
attacks through one of the polyfill's internal methods, this enforces
"aria-" at the beginning of the snake-case attribute name, even if
somehow "aria" were missing from the input JavaScript attribute name.

This change is based on the outcome of an internal security review.

Change-Id: Iec8a9cbd5f88fdf4b87da3e5cd058c4ffb69c3ff
2021-07-20 16:59:17 +00:00
Joey Parrish 6757d238d0 fix: Fix compilation error with strict constness
The MediaCapabilities polyfill caused compiler errors in stricter
environments, in which navigator.mediaCapabilities was marked as
const.  This suppresses constness errors from the compiler in the
install method of the polyfill.

Change-Id: Idb47a473335c886a2a7b3c77b84ce8f51fce4114
2021-07-20 00:19:31 +00:00
Joey Parrish de77787219 fix: Fix mediaCapabilities polyfill on Chromecast
Chromecast firmware now includes limited support for
mediaCapabilities, but we still need to install the polyfill for now.
The platform will let us overwrite the decodingInfo method, but not
the mediaCapabilities object itself.  This fixes the polyfill to
handle this situation.

Change-Id: Ia770457ad8465ec1caf4420ef757303adbe55ce5
2021-07-09 03:41:41 +00:00
Theodore Abshire cf2fb903cb feat(ARIA): Add polyfill for ARIAMixin.
The ARIAMixin interface mixin lets users apply ARIA attributes to
DOM elements without having to rely on setAttribute and getAttribute.
It is one of our goals to switch to using that interface.
Unfortunately, it is not implemented on Firefox, so a polyfill is
necessary for that platform, before we can start using it.

Issue #3378

Change-Id: Ia878900d75c7c2c04613360baacb4524774ac746
2021-07-01 15:43:37 -07:00
Michelle Zhuo bf0644aa4a feat(MediaCap): Patch VP9 codec
MediaCapabilities supports 'vp09...' codecs, but not 'vp9'. Translate
vp9 codec strings into 'vp09...', to allow such content to play with
mediaCapabilities enabled.

Change-Id: Iff7ddae379efb8a9f0766c89a62b85a325f81e93
2021-04-29 20:27:09 +00:00
Michelle Zhuo e592d4888e feat(MediaCap): Always polyfill MediaCap for Chromecast
Since we got some unexpected decodingInfo results from MediaCapabilities
on Chromecast, we should fall back to MediaSource.isTypeSupported() on
Chromecast.

Issue #1391

Change-Id: I4947ec78624e98c7039df64ad691e14ece2588e0
2021-04-29 18:04:06 +00:00
Michelle Zhuo 95ba28b5af refactor: Remove IE 11 support
Issue #2339

Change-Id: I80ffa7b04f7afd943aa0f881d2a494dd35def732
2021-04-29 17:47:07 +00:00
Álvaro Velad Galván 463b1b6886 Remove support for IE 11 (#3309)
Issue #2339
2021-04-16 13:59:35 -07:00
Michelle Zhuo b63a64e4ba feat(MediaCap): Use mediaKeySystemAccess from decodingInfo in DrmEngine
In DrmEngine, previously we created MediaKeySystemConfiguration for the
variants, and called navigator.requestMediaKeySystemAccess() to get the
mediaKeySystemAccess, and set up MediaKeys.

Now we can use the mediaKeySystemAccess from the decodingInfo results of
the variants directly to set up MediaKeys.

Issue #1391

Change-Id: Id93a5e2fed7f6827317ae11644967185fc0cffbd
2021-04-07 19:32:47 +00:00
Michelle Zhuo aca343bf2c feat(MediaCap): get mediaKeySystemAccess via decodingInfo
In StreamUtils, add a MediaCapabilitiesKeySystemConfiguration
for each key system for the encrypted variant passed to the
decodingInfo API, to get the mediaKeySystemAccess as a part of
the decodingInfo results.

We create a list of mediaDecodingConfigurations for each variant,
and call decodingInfo() with each mediaDecodingConfiguration to
get the mediaKeySystemAccess.

Eventually, we'll use the mediaKeySystemAccess from the
decodingInfo results to replace the call of
navigator.requestMediaKeySystemAccess() in DrmEngine. That will be
in the next CL.

Also, adding MediaCapabilties polyfill with mediaKeysSystemAccess.

Issue #1391

Change-Id: Ied4a27dd8a1ade43209bcf07f21f0c9b31c2693c
2021-03-30 20:26:46 +00:00
Michelle Zhuo f4c6063b82 feat(MediaCap): Add polyfill for MediaCapabilities
If navigator.mediaCapabilties is not supported by the browser, use
MediaSource.isTypeSupported to check if the stream is supported.

Issue #1391

Change-Id: Iee0c7e339add2a07028ed14a03df14e4d36a203e
2021-03-12 13:44:53 -08:00
Joey Parrish dd94bd3365 fix: Disable unprefixed EME on Safari
@avelad reported that PR #3021 caused a regression.  Rather than
revert the entire thing, we are disabling one part of that change to
make it easier to re-enable once the issue is fixed.  We will also
reopen issue #2999 until this is resolved.

Change-Id: I65d93da903d90668bb19e5248658eb458e8bb5c4
2021-01-25 23:15:29 +00:00
Álvaro Velad Galván 2b60f38fa5 Add navigator.storage.estimate polyfill (#3050)
Issue #2900
2021-01-20 10:32:04 -08:00
Álvaro Velad Galván 42d9ec052d Prefer unprefixed EME for Safari (#3021)
Closes: #2999
2021-01-19 15:06:10 -08:00
Joey Parrish 562a2d567b chore: Strictly require jsdoc
This enables the eslint rule requiring jsdocs on all class
declarations, function declarations, and methods.

Unfortunately, there are two problems with this:

1. We don't use class _declarations_, we use class _expressions_,
which are not covered by this rule.  So it does not enforce jsdoc at
the class level.
2. We tend to document a class at the class-level, rather than at the
constructor.  But a constructor counts as a method for eslint, so it
requires docs on the constructor.  There is no way to configure it to
make an exception for trivial constructors.

So for all trivial (no-argument) constructors, we add empty jsdocs:
  /** */
  constructor() {

This was quicker and easier than setting up some alternative plugin in
eslint to make an exception for us.

The good news is that this rule caught several undocumented parameters
and places where the jsdoc comment was malformed.  So fixing those
also improves the compiler's ability to enforce types.

Change-Id: Icbc46ed690c94e53d354648a883119524f8fca45
2021-01-09 02:00:31 +00:00
Joey Parrish 126a398c70 feat(vp9): Polyfill vp09 checks when only vp9 is recognized
Some smart TVs only recognize the older "vp9" codec string, but not
the newer "vp09...." string.  This change recognizes those platforms
and patches them so that newer, compliant content can still be
recognized as playable on those platforms.

Closes #2870

Change-Id: I6026ecea4f3176303237c7fddaf26cd150c7751d
2020-09-26 04:53:41 +00:00
michellezhuo c17f427194 build: Add require and requireType
Add missing require and requireType for compiler upgrade.

Change-Id: Ie21418d93eb70c2213815638d6fd2d784cf6ef2e
2020-09-24 22:20:14 +00:00
Joey Parrish 256f89dff7 fix(cast): Fix Shaka+Cast apps using IndexedDB
The IndexedDB polyfill was preventing Cast apps from using IndexedDB
outside of Shaka Player.  Instead of breaking IDB, we should just
directly disallow offline storage on the Cast platform.

Fixes #2850

b/168565999

Change-Id: Ie504531c412723cc0f93530b2e34000873bfaf32
2020-09-17 18:40:47 +00:00
Joey Parrish 72ecaff923 fix(cast): Do not assume HDR for HEVC1.2
Instead of assuming that hevc1.2 indicates HDR, we should get HDR
profile information from DASH manifests.  This removes the assumption
in the Cast isTypeSupported polyfill.

Issue #2813

Change-Id: Ieb40a06c78c99b6975082eaffb23d5e09a5f2464
2020-08-24 22:39:12 +00:00
Joey Parrish 4499149a8b fix(text): Fix VTTCue polyfill in uncompiled mode on Edge
The polyfill assigns a static method over window.VTTCue, which is then
called with "new".  This will not work on Edge in uncompiled mode,
since the method is not an old-style "function".

To fix this, we wrap the chosen static method into a "function".

Change-Id: I9b5687e39b3af1bd160e4db4595de06720564a1d
2020-08-11 07:52:47 -07:00
Jacob Trimble dc8b007d56 cleanup: Add missing requires.
This is a port of the internal changes: cr/321495405, cr/321592702,
and cr/321594488.

Change-Id: If6a4c4266ed10a70b01442974dbd19329bb5122e
2020-07-16 10:59:49 -07:00
Theodore Abshire 34337ca28d feat(UI): Added polyfill for screen.orientation.
There are some platforms (e.g. iPad) which can be rotated,
but do not support the screen.orientation API. This is relevant
because iPad now supports requestFullscreen, which it did not
before.

Found while investigating #2653

Change-Id: Iacc93433aa1fb50a25d968203dc9fd4f7f16b4ae
2020-06-17 12:31:24 -07:00
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00
Joey Parrish 453ab69a11 Add missing goog.require calls in polyfills
Change-Id: Ieb3724fb8e6b29a1b85e73cb249c1bd5a166f732
2020-05-21 11:46:10 -07:00
Sandra Lokshina 26d2e98959 Add a util for handling media readyState related logic.
Fixes #2555.

Change-Id: I735064952bc425bfb18d6c5681921ae1691eb348
2020-05-19 22:43:13 +00:00
michellezhuo 8ad0f48939 export shaka.polyfill
@exportInterface is used by the extern generator, but ignored by the
compiler. @export should be used for shaka.polyfill.

Closes #2549 .

Change-Id: I400db152ec8ca222a45a598ab58ddfbe44552443
2020-05-12 17:27:33 -07:00
Álvaro Velad Galván 6f9b36f755 Allow OPUS on Tizen 5 or higher. (#2564) 2020-05-11 15:07:04 -07:00
Joey Parrish 80f53221fd Correct minimum supported Safari version in README
Also add a note to the MSE polyfill about restrictions being applied
in Player as well.  We used to restrict Safari versions only in the
polyfill, and I had forgotten about the other version check.

Closes #2548

Change-Id: I4d2f319939c3a079e7f0ec7134876d91fc425bf4
2020-05-05 14:47:08 -07:00
Joey Parrish 5f62f4e779 Clean up use of "self" in arrow function
There is no need to use "self" to capture "this" with arrow functions.

Change-Id: I8d4c2251292d7e27952770b2d45f34fbdfceceb6
2020-05-05 09:13:43 -07:00
Joey Parrish 11f3347a48 Fix static method aliases
We used to alias static utility methods by assigning the method itself
to a local variable.  This is not allowed by the new Closure Compiler
release that we are adopting, and for good reason.

The old compiler did not understand the use of "this" in static
methods, but the new one does.  And it turns out that when we start
using "this" in static methods (see #2532), aliasing the method itself
can break everything.

When you refer to "this" in a static method, it refers to the class.
This is really useful in utility classes that have private static
methods they use to perform common tasks.  However, just as it ruins
the value of "this" to alias an instance method, the same is true of
an ES6 class's static method.

The fix is to always alias the class instead of the method.  The new
compiler will simply not let us get away with the old way any more, so
regressions after this are unlikely.

Issue #2528 (compiler upgrade)
Issue #2532 (static "this")

Change-Id: Id800d466e639c7cbcf4aa6fbb05114c772a2229f
2020-04-30 19:28:53 +00:00
Joey Parrish 34cde38108 Fix type info and initData types in EME polyfills
The latest Closure Compiler initially complained about "initData" not
being a known property of "Event".  Correcting the type to
MediaEncryptedEvent exposed a potential bug, which is that we were
assigning Uint8Array in some cases instead of the correct ArrayBuffer.
This fixes both the type of the event and converts the Uint8Arrays to
ArrayBuffers.

This also works around a complaint about "code" on "Error".  We use
"Error" objects as look-alikes for DOMException because there is no
exposed constructor for DOMExceptions.  To satisfy the compiler, we
use square brackets now to set the "code" field on these DOMException
look-alikes.

Finally, this removes the "method" field on certain Errors in the
WebKit EME polyfill.  These must have been leftover from some
debugging, and are not used at all.

Issue #2528

Change-Id: I32c4617b14a30c412d5bc532ec17a46fdc1fea1a
2020-04-28 22:30:19 +00:00