Commit Graph

178 Commits

Author SHA1 Message Date
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Joey Parrish 9108431359 Simplify Webkit PiP polyfill
By listening to events on document in the capturing phase, we can
avoid complex event shims on HTMLVideoElement.  By monitoring
global PiP state on the document, we can get rid of the getter and
setter for the document's PiP element, as well.

Follow-up on PR #1902

Change-Id: Ib5f5d0c7c735124a438901c5bb15e034ab10b996
2019-05-07 18:39:24 +00:00
Sandra Lokshina 65768a3d41 Hide fullscreen button on platforms that don't support it.
Safari on iOS does not support HTML5 fullscreen API. There
seems to be a (separate) way for a video element to enter
fullscreen mode. I will see if we can adopt it in a different CL.
For now, just hide the button if fullscreen API is not supported.

Issue #1909
Issue b/131923216
Change-Id: Ia30660c7a68fd626051fdf5abce59dbe993b2de2
2019-05-06 22:25:41 +00:00
Joey Parrish e3b49573a2 Rename PiP polyfill to PiPWebkit
Follow-up to #1902

Change-Id: I760d0006c4cbd7c3aad2ce96801259b578269195
2019-05-03 21:30:17 +00:00
Álvaro Velad Galván caa34ca90d Add PiP pollyfill for Safari (#1902) 2019-05-03 10:50:37 -07:00
Joey Parrish 9a4b73df7c Fix runtime errors in the new demo on IE 11
- Polyfill navigator.languages, which is missing on IE
 - Add missing handler for uncaught exceptions (doesn't work on IE,
   but is a good idea to have for debugging the demo app)
 - Avoid offline setup if it's not supported (as on IE)
 - Fix bad reference to uncompiled link (wrong ID)
 - Log any caught errors to the console
 - Wrap the init functions to catch and log any errors during init

Fixes b/131863587
Fixes #1911 (similar storage error on iOS)

Change-Id: Ib2a53392d5632c71825af17dd3e955cd54279e98
2019-05-03 17:26:44 +00:00
Joey Parrish 1d4efe6f35 Prefer prefixed EME on Apple devices
The unprefixed EME launched with macOS 10.14 (Mojave) rejects requests
for the key system IDs we know how to use.  So until the bug we filed
against Apple is resolved, prefer the prefixed API.

Issue #382

Change-Id: I71313be2102af2da66a6389a9e9afdebd8ae033d
2019-04-30 21:15:11 +00:00
Joey Parrish a121733a11 Add FairPlay EME polyfill and DrmEngine support
This adds a polyfill for Apple's prefixed EME implementation.  This
will be used on all macOS versions prior to 10.14 (Mojave) and on
Safari versions prior to 12.1.

This also adds support for FairPlay license protocol eccentricities
in DrmEngine, so that the proper formatting is used for requests and
responses.

Issue #382

Change-Id: If1274d2f018a475f56c09df97645694f13acbde9
2019-04-30 21:15:11 +00:00
Joey Parrish 133f161b93 Support all types of single-file playback
Instead of triggering src= based on 'video/mp4' MIME types, ask the
browser what it can support using video.canPlayType().

Querying canPlayType() also allows us to detect src= support for
native HLS in Safari.

The original version of this change also added a complete fallback
system to detect MIME types based on common file extensions and
fetch MIME types via HEAD request when necessary, but the load graph
system does not yet allow us to make async decisions about destination
node.  So this async MIME detection is commented out for now.

Closes #816 (src= single file playback)
Issue #997 (native HLS in Safari)

Change-Id: If1930ca4fd5710481a925d63fb312d9a5b15fec8
2019-04-16 22:59:18 +00:00
Aaron Vaage 040ecf6978 Create src= node
This CL creates the "loaded with src=" node and its initial
implementation. Adding this node required some changed to the routing
logic as a new destination was created.

We will use src= when given mp4 content or media source is unavailable.
We detect mp4 content via the mimeType in |load| and/or the file
extension. When media source is not available on a platform, we fall
back to using src=. To do this, we check if media source is available
whenever |load| is called, and will route to the src= branch if media
source is not found.

To avoid pre-initializing media source (when it is not available) we
modify the |initializeMediaSource| flag in |attach| and |unload| when
media source is not available.

Doing this showed that we had inconsistent behaviour between |attach|
and |unload|. |attach| would default to initializing media source
whereas |unload| would not. This has been fixed.

Issue #816
Issue #997

Change-Id: I00599832b49c9079e273e65a4b827fee736479cc
2019-04-01 22:56:39 +00:00
Bart Teeuwisse 7660edc995 Dolby Vision fixes for Chromecast (#1844)
- Fix the link to Dolby's Dolby Vision Profiles and levels PDF
  - Was pointing to a document version that no longer exists
- Update Dolby Vision regex to match all DV codecs
  - Dolby Vision is available in 4 different (base) codecs: dvhe, dvh1, dvav, dva1
  - dvh* represents HEVC-based Dolby Vision
  - dva* represents AVC-based Dolby Vision.
- Do not remove Dolby Vision codecs on Chromecast

No need to remove Dolby Vision codecs on Chromecast. Chromecast's canDisplayType will reject them when the cast receiver or the attached display can't play Dolby Vision.

On Dolby Vision capable cast receivers attached to a TV in Dolby Vision mode, canDisplayType does not reject Dolby Vision streams. One such device is the Chromecast Ultra. With this change, Shaka Player plays Dolby Vision on qualifying setups.
2019-03-18 15:43:37 +05:30
Aaron Vaage 71fb7a03ec Use Timer/DelayedTick instead of setTimeout
This CL limits the use of |setTimeout| by wrapping it in our own timer
class. The timer class makes it easier to track and cancel time-based
events.

To ensure that|setTimeout| is not used outside of our timer classes, the
conformance rules have been updated to only allow |setTimeout| to be
used by our timer classes.

Since |setTimeout| is very similar to |setInterval|, the conformance
rules for |setInternal| rules were updates to reflect more of the logic
behind why we don't want to use |setTimeout| and |setInterval| directly.

Change-Id: Iff5da32a61b515dd2016837fa74a34c04b6c5fd2
2019-03-12 18:52:32 +00:00
Aaron Vaage 1506182de9 Reject opus content on Tizen
Tizen Smart TVs do not play opus content well when using MSE. To prevent
Shaka Player from trying to play opus content on Tizen, we override
media source's isTypeSupported to reject opus content.

Since most content will have AAC as a fallback, this should not limit
playback on Tizen.

Issue #1751

Change-Id: Ia61a1d26f547082fa68a9f38e4af16951191dd4f
2019-02-12 20:54:57 +00:00
Joey Parrish 2872f31e01 Add polyfills for Safari 12
Now that we have Safari 12 in the lab, we have found that it requires
the same MediaSource polyfills as Safari 11.

Fixes b/120434307

Change-Id: I45f8be79d0aca7987ffcba1ce13b8589a2287712
2018-12-12 10:47:39 -08:00
Aaron Vaage 4167b1658b Isolate Platform Checks
To make it easier to know where we are check what platform something is
(normally a sign of a work-around), this change isolates the logic to
make the check into functions.

Now looking for uses of |shaka.util.Platform| should show when we are
using platform-specific logic.

Change-Id: Ief49837c503e951f7138ec08a83355fe1c46db88
2018-12-11 05:43:52 +00:00
Jacob Trimble 3db435e87d Fix some issues with IE11 EME polyfill.
- We can get a 'msneedkey' event with no init data.
- Use the correct message type name.

Issue #1689

Change-Id: Ic0e54fe8331d4700971d78095b77831de2d9580b
2018-11-30 22:43:00 +00:00
Aaron Vaage f8b707aaeb Use Sets For Uniqueness
Update all our code to use |Set| to handle storing and testing
unique values.

Change-Id: Id809d4d84e4779ae19be58eca96983750c3f3a81
2018-09-14 22:03:04 +00:00
Joey Parrish 7091275cbf Replace indexOf with includes, startsWith
This replaces almost every instance of indexOf on both String and
Array.  There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.

Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
2018-09-14 19:10:56 +00:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Jacob Trimble 759eef9685 Change goo.gl links to bit.ly.
https://goo.gl is being turned-down, so we can't use it for new URLS.
So we have consistent short links, this converts them to be
https://bit.ly.

Change-Id: I07a86cba807b67157664893341f648023918d0de
2018-06-22 20:20:00 +00:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Theodore Abshire 7c5186332b Typo fixes and rewording in comments, part 7
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I225f5c7e54adf4cca8512cddae082ba50ed82e4e
2018-03-21 19:45:15 +00:00
Theodore Abshire d46e8fdf92 Typo fixes and rewording in comments, part 6
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I2bfa4d531a8fcdcf9578e9c181c4534ad7443b7a
2018-03-21 17:59:42 +00:00
Theodore Abshire f58afd21da Typo fixes and rewording in comments, part 5
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: Ibcaf21382bd78b91e589122983dd14e001bfdad5
2018-03-21 17:25:13 +00:00
Jacob Trimble bfb42c69c4 Make EME polyfills independent.
Now each EME polyfill can be removed independently; this allows
someone to remove just the IE11 polyfill while still keeping the
others.

This adds a priority ordering to the polyfills so the nop polyfill
will be run last as a fallback if there are no other polyfills.

Issue #1261

Change-Id: I865e1c0d6a73a079dd91505e96572e215e6f6c6a
2018-03-06 21:34:25 +00:00
Jacob Trimble b512db87dd Convert 'var' to 'let'/'const' (8 of 9).
This is part of a change to convert all usages of 'var' with either
'let' or 'const'.  This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.

Change-Id: I6a329d28e13a81c9f7136737518c6bb8fa18402e
2018-02-20 11:29:30 -08:00
Joey Parrish 82357486a6 Replace buggy Promise polyfill
A bug in our Promise polyfill caused issues with the recently-added
AbortableOperation class on IE11.  Since external polyfills for this
are smaller, it is easier to remove ours in favor of a third-party
polyfill.  Applications that wish to support IE11 must now load this
additional polyfill.

We are using the "es6-promise-polyfill" module from npm, but any
compliant polyfill should suffice.

One feature our own polyfill offered was the ability to flush all
Promises, which allowed us to write synchronous unit tests that
simulated async processes.  To get this ability back, we are now
using the "promise-mock" module in our tests.

Getting "promise-mock" to load correctly involved switching from
"requirejs" to "cajon", which builds on requirejs and supports
AMD modules more directly.

Closes #1260

Change-Id: I5de48e88a910736ae5c1897a7a509bc5641acb70
2018-01-30 23:10:04 +00:00
Joey Parrish a63352c8f3 [ES6] Enable stricter checks in eslint
This digests and organizes many of the automatic settings in eslint,
and changes several of them to be more strict.  This also fixes the
following errors:
  - array-callback-return
  - no-catch-shadow
  - no-multi-spaces
  - no-new
  - no-throw-literal
  - no-useless-call
  - no-useless-concat
  - no-useless-return

Several checks have been organized into a group of checks we should
use, but need more time to implement and fix.  Some other checks have
been delegated to the Closure compiler, which can more precisely
whitelist exceptions.

Issue #1157

Change-Id: I8fe4966959e08050f8159e6a1fee161e7d71177e
2018-01-17 21:56:41 +00:00
Joey Parrish 4067c20a7c [ES6] Replace gjslint with compiler linter & eslint
The eslint configuration is derived from analyzing the style of our
sources as they are now, plus a few tweaks.

In particular, we have disabled checks for undefined variables and use
of console, both of which the compiler handle with greater precision.
The compiler already knows what is defined in the environment through
our externs, and has specific exceptions for the use of console (demo,
tests).

We have also disabled a few checks that we should use, but will
require many changes to the code: no-unused-vars, no-redeclare,
and comma-dangle.

This commit also fixes several types of eslint errors that were easy:
  - no-useless-escape (unneccessary escape characters in Regexp)
  - no-constant-condition (using true/false/0/1/etc in if/while)
  - no-fallthrough (caught an actual bug in one EME polyfill)
  - no-irregular-whitespace (we had a UTF-8 nbsp in externs)
  - no-cond-assign (using an assignment inside a conditional)

To satisfy stricter provide/require checks in the Closure Compiler
Linter, we will no longer use provide/require at all in tests.  We
will still use provide in test utilities (test/test/util/) since it
sets up the namespace for us.  But we will not use require there
because there is no deps management for test code.

Issue #1157

Change-Id: Icc44f51feeb568ea7d3980e693e92e560d897afd
2018-01-16 17:25:05 +00:00
Joey Parrish 1a2c88745e Upgrade the Closure compiler to v20171203
Change-Id: Id0dd4619db0c3a141d60e9e38757739e0697e6f0
2018-01-03 15:07:02 -08:00
Joey Parrish e2aef50912 Disallow unknown "this"
This change enables an additional conformance check in the compiler
which prevents us from committing code where the compiler fails to
infer what "this" means.

None of these changes constituted actual bugs, just inference failures
in the compiler.

Issue #1130

Change-Id: If9b18203768e197258042a9b4339530f371ed831
2017-11-15 11:35:56 -08:00
Theodore Abshire c6ddf593e5 Polyfill Safari 11 MSE bug in SourceBuffer.remove
SourceBuffer.remove, when told to remove exactly up to a keyframe,
will also remove that keyframe and all of the content till the next
keyframe. This results in far too much content being deleted, and is
breaking our tests on Safari 11.

Patching this by offseting the end of the removal range by 1ms seems
to be a viable workaround.

Closes #1048

Change-Id: I062b2dc2617f1372f885f4ccbc906d77c65412d7
2017-10-05 13:15:25 -07:00
Joey Parrish 859d7d1a8f Reject TS content in Safari
Because Safari's support for TS via MSE is broken, reject all TS
content in Safari.  Transmuxing (#887) will compensate.

https://bugs.webkit.org/show_bug.cgi?id=165342

Closes #743

Change-Id: Iff8a6a7c159e48a4f388d99396915752e649c6ac
2017-10-03 15:31:10 -07:00
Joey Parrish 87b723473b Apply MSE patches to Safari 11
One of the Safari 10 bugs we work around is still present in Safari 11.

Issue #1048

Change-Id: I54e146bcce9770f980a0dabd477a86b482a6c901
2017-10-03 15:31:09 -07:00
Joey Parrish b7b890b908 Add a polyfill for Chromecast isTypeSupported
There are several issues with isTypeSupported on Chromecast that
require workarounds in JavaScript:
  - Dolby Vision strings must be removed from the codecs parameter,
    even though the content is supported by the platform
  - HDR must be guessed at from the codecs parameter and an additional
    parameter must be added to query HDR support
  - Queries must be made through a non-standard interface

Change-Id: I4c8c70e70cf9c26283913783f5f62f7d6470c2f1
2017-08-17 17:35:00 +00:00
Jacob Trimble b974a1d12d Fix field renaming in Safari polyfill.
Closes #974

Change-Id: I407f7d0437383e05c42c0762bad42337bd558f8c
2017-08-15 17:21:38 -07:00
Joey Parrish d1df5dade6 Make it safe to install polyfills twice
Closes #941

Change-Id: I706aadd1bfc2c477d0ac8a0dff13defad74b3bda
2017-07-24 12:25:46 -07:00
Joey Parrish 84a8d1ca18 Polyfill the HTML5 'input' event
The HTML5 'input' event does not work correctly on all input elements
in IE 11.  There are equivalent events that the UI can use on IE.

Instead of remembering this and checking for IE every time the 'input'
event is needed, let the polyfill translate the event type.

Change-Id: I23258a5c6a0bd37e946214380ad07949f3ee7f88
2017-07-12 12:29:14 -07:00
Joey Parrish c69a009960 Do not assume persistent storage support
Two EME polyfills currently assume persistent storage support: one
for old Tizen TVs and other older embedded Chromium devices, and one
for IE11.

This backfires when an application is trying to detect support for
encrypted offline content.

By removing this assumption, we do not convey support for EME features
that are not known to be available on these devices.

Change-Id: If427eeda1cde60341a2b57f76744c2adfdb34beb
2017-07-12 18:46:08 +00:00
Jacob Trimble adb8da4764 Disallow unknown properties (1/5).
This is part of adding a new conformance rule to add additional type
safety.  This will disallow using properties of unknown types or using
unknown properties.

The first parts will be fixing errors caused by the new rule.  These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.

Change-Id: Iefde089b2f62ddfdf43944cda5badab438577561
2017-06-27 19:43:00 +00:00
Joey Parrish 53220b5acb Polyfill video.play to silence confusing errors
Closes #836

Change-Id: Ie5b42bc707ce7443641e86c04ec116fd732bbbae
2017-06-05 12:34:31 -07:00
iKinnrot f145dffc9e Fix math round when number > 2^52 on IE11 (#832)
Don't use math round on ie11 if number > 2^52.
2017-06-02 14:51:25 -07:00
Joey Parrish 2f5e2dbc5b Fix declaration of unprefixed v0.1b APIs
Change-Id: I0334b08d5e67320f19f6df78fb1271278b9d3078
2017-05-17 16:28:23 +00:00
Joey Parrish afb3a634b6 Update EME polyfills setServerCertificate to spec
The method should return a Promise resolved with false if unsupported.

Change-Id: I304f2566fc2cf6521eb35f963d7c862e3eca1f48
2017-05-08 23:37:08 +00:00
Ross-cz 3831664a22 Fix fullscreen polyfill for MSIE 11 (#777) 2017-05-05 15:35:27 -07:00
Jacob Trimble 67c874c2ca Fix some test contaminations.
There were two instances of tests not cleaning up correctly.  The
Dash Live tests didn't uninstall the Promise polyfill, which breaks
Promise.resolve for tests that don't expect it.  Also, in the
CastReceiver tests, it defines a property on window.  It needs to be
configurable, otherwise it cannot be set twice.  Somehow the resulting
exception is not being caught by jasmine.

Change-Id: I0691a7bcddf14fd455f034d63e12fc8046044750
2017-03-28 12:16:08 -07:00
Theodore Abshire 8ab9188bdb Expanded the fullscreen polyfill.
Now it includes fullscreenEnabled.

Closes #669

Change-Id: I7df3c422ecc72215a48ba72ac57aae2bc9b600d5
2017-02-10 22:05:31 +00:00
Aaron Vaage f0286ae7f8 Fixing DBEngine Failures on Chromecast
The Chromecast reports supporting IndexedDB but whenever an insert
command was performed, the operation would hang indefinitely.

This change introduces a pollyfill for the Chromecast that will
remove the indexed db reference which will have DBEngine's
"is supported" behavior to report no support.

Alone this change would not stop the tests from running, so the
DBEngine tests had to be updated to first check that the DEngine
is supported on the active platform.

Bug: 34927282
Change-Id: I8d4797f0981b014fb42db1c237c85704888bea7f
2017-02-08 00:04:23 +00:00
Jozef Chutka ca299b2822 VTTCue polyfill (#643)
This adds a VTTCue polyfill for IE/Edge (3-arg TextTrackCue) and
Toshiba dTV (6-arg TextTrackCue).

Closes #635
2017-01-17 10:42:54 -08:00