Commit Graph

114 Commits

Author SHA1 Message Date
Jacob Trimble f6d0f15fa6 Refactor handling of destroy().
This changes several classes to use the Destroyer class to handle
destroy().  This also changes the behavior to not ignore destruction
and instead throw a new error.  This is more clear for callers and
ensures we propagate errors.

Change-Id: I756c085639558509c22e5c43d69ddf4acd28d46f
2019-06-19 20:39:20 +00:00
Sandra Lokshina 3e3e940e34 Add a temporary fix to enable casting.
Issue #1948

Change-Id: Id3953cdc32f1cdd02729c1a3f08c522b2ee376f1
2019-06-03 21:05:36 +00:00
Joey Parrish 615ce93178 Fix formatting of test failures/errors
Code in karma-jasmine's adapter will malform test failures when the
expectation message contains a stack trace, losing the failure message
and mixing up the stack trace of the failure.  To avoid this, we
modify shaka.util.Error not to create a stack trace.  This trace is
not available in production, and there is never any need for it in the
tests.

One test expectation had to be updated.  The previous version of
jasmineError would use the original error by reference.  Now that it's
capturing a few fields explicitly, the severity value doesn't update
when NetworkingEngine modifies the original.

Change-Id: If7af93a1a0357df9763dbf6a4afc45db2c8317df
2019-05-31 21:29:27 +00:00
Sandra Lokshina 0e7c366e9d Convert more utils to es6.
Issue #1157.

Change-Id: I49092237b7fe7f98a22087b0ecf41f65005dbc61
2019-05-28 22:17:48 +00:00
Jacob Trimble ded2b84313 Require consistent return values.
This enables the eslint rule that requires all functions to consistently
either return a value or not return a value.

Change-Id: I98b579f3689c3b6c74968116824231bb792bd9dd
2019-05-09 20:34:47 +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 d27d8180e0 Only use configured license servers if provided
If the application developer specifies license servers, only those
should be used.  Before this, a manifest-specified license server
for a certain key system could still be used if the application didn't
provide one.

Now, if there are _any_ license servers specified by the app, _no_
license servers will be used from the manifest.  This is important
because it allows the application a clear way to indicate which DRM
systems should be used on platforms with multiple DRM systems.

The new order of preference for drmInfo:
1. Clear Key config, used for debugging, should override everything else.
   (The application can still specify a clearkey license server.)
2. Application-configured servers, if any are present, should override
   anything from the manifest.  Nuance: if key system A is in the manifest
   and key system B is in the player config, only B will be used, not A.
3. Manifest-provided license servers are only used if nothing else is
   specified.

Introduced in #1644 to solve #484
Internal issue b/131264101
Closes #1905

Change-Id: I1a36a70044dc7bcc22681e3e4246d0a43d58e413
2019-05-02 20:30:54 +00:00
Michelle Zhuo cb9decbb5f Reject AES-128 HLS content with meaningful error
Currently we check encrypt key tags after we parse the segment, so
playing an AES-128 encrypted content results in error message
'MANIFEST.HLS_COULD_NOT_PARSE_SEGMENT_START_TIME'. We should check the
encrypt key before, and give a more clear error message.
Filtering out the contents encrypted with AES-128, and if there's no
valid content left, we'll show 'CONTENT_UNSUPPORTED_BY_BROWSER'.

Closes #1838

Change-Id: I893f57a939e45f2787144dfe311b779aed26ac34
2019-04-22 18:48:18 +00:00
Jacob Trimble 76f78187b6 Add extended error code for failed license request
Issue #1689

Change-Id: I7d3b4eee487395fdb8c121a4b6acc11ec461f0e3
2018-11-28 23:27:51 +00:00
Jacob Trimble 9b885bac06 Give extra data for RESTRICTIONS_CANNOT_BE_MET.
Fixes #1368

Change-Id: I14563d309251c3ecd146fe6a467f30f637e4e6fc
2018-08-07 22:49:31 +00:00
Aaron Vaage 952c9b8341 Reject Promise In Player With Error
When reading through shaka.Player I found a promise that was being
rejected without an error. This change removes the log call and
rejects the promise with an error object.

Change-Id: I7072e2bb1ec367750ebb2dce31edff4e9c9e857b
2018-07-24 17:31:31 +00:00
Jacob Trimble 061aea1828 Add another entry for RESTRICTIONS_CANNOT_BE_MET.
Change-Id: I8bccecaa88c81581db524a6351c34a7a4750bfbe
2018-07-23 11:55:21 -07: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
Sandra Lokshina 8163dd84b9 Work around (what we think is) a bug in mux.js which
prevents them from letting us know they're finished
transmuxing.

Issue #1449

Change-Id: Icfd4e16a29064783b57ef605228bfda4ca9bb169
2018-06-01 21:24:19 +00:00
Aaron Vaage 2a847e97f4 Removed Unused Error Code
Removed the error code for unsupported upgrade as we no longer support
upgrading offline content.

Change-Id: Ic4a6852acd7e7e18ce3038a771cc32d2d7806559
2018-05-10 16:20:45 -07:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Aaron Vaage ef5c92c720 Added GetCell to StorageMuxer
Added a method to get a cell from storage muxer. Unlike resolve path
this will return a rejected promise if the cell can not be found.

Issue #1248

Change-Id: Ia594b7741351d515e564e574321e49ad51073005
2018-04-11 21:09:25 +00:00
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Theodore Abshire f32767578a Handle segment tags before playlist tags in HLS
Normally, we expect that only media playlists contain segment tags
(EXT-X-KEY, EXTINF, etc).  We determine if a playlist is a media
playlist by the presence of an appropriate playlist tag (EXT-X-MAP,
EXT-X-PLAYLIST-TYPE, etc).
However, we were checking tags one-by-one, on a single while loop.
This meant that we would reject manifests where a segment tag appears
before a playlist tag, as we did not yet know that the playlist was a
media playlist.

This changes the manifest text parser so that it checks for playlist
type first.

Issue #1382

Change-Id: I1b9f674a58c60ab291d6d004462b0c0cae49631d
2018-03-30 16:30:16 -07: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 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
Aaron Vaage 85bdf8ca23 Fix Errors in IndexedDB Code
Fixed an issue where an update call the IndexedDB was not replacing
the correct value because the key was getting changed to a string.

IndexedDB will count a missing key as a success, so check that the
value is undefined.

Issue: #1248
Change-Id: Icdd6ae263374c655170c6470df85c656b8bd3ba2
2018-03-14 00:06:04 +00:00
Joey Parrish 69ddb9537d Fix CONTENT_UNSUPPORTED_BY_BROWSER error code & docs
Issue #1349

Change-Id: Iea423c3192186d52acfe9990da2137fb0518a3fc
2018-03-09 09:36:45 -08:00
Joey Parrish b27ea82e7f Allow Player to attach/detach from video
This adds attach/detach methods to replace the media element in the
Player constructor.  Now applications can take back control of the
media element or provide a reference later in the Player's life cycle.

This also allows applications to decide whether or not to set up
MediaSource in advance, through an optional argument on attach and
unload.  The default will be to set up MediaSource in advance, which
maintains current behavior.  This advanced setup of MediaSource can
improve load latency later.

This change also introduces async/await for the first time in the
project, which required changes to eslint config, Closure build
arguments, Babel & Babel-polyfill setup, and the esprima parser used
by our extern generator.

The use of async/await will improve readability in many places, and
these infrastructure changes to enable async/await should also unblock
issues #1336 and #1337.

Closes #1087

Change-Id: I0d6b4e0e2af27a6520a3d070fa92b7139b2cb8b0
2018-03-06 22:19:53 +00:00
Aaron Vaage b92d8f31e7 IndexedDB Storage Cell for IDB Version 2 and 3
Since the database schemes for idb versions 2 and 3 used the same
data types (shaka offline version 2) this storage cell can be used
for both. The only difference is that idb version 2 has a fixed
key space.

Issue: #1248

Change-Id: Iac5cb1d57f93fdb81729b59d67d6736e29c9968c
2018-03-06 21:47:37 +00:00
Chris Fillmore 3494c2e137 Update docs for 6014 EXPIRED (#1324)
Closes #1319
2018-02-27 13:48:35 -08:00
Jacob Trimble 624acc66b8 Add curly braces to all blocks.
Google style guide requires adding curly braces to all block statements
even if it is only has one line.  This fixes it by using eslint's
--fix flag followed by running clang-format to reformat the change.

Change-Id: Idc086c2aa8c02df5ef8b2140a11bfb9128eeb4bd
2018-02-21 11:23:34 -08:00
Jacob Trimble f70436540c Convert 'var' to 'let'/'const' (3 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: I10f5c38a8b06b5797c6eec7492829084114514c9
2018-02-14 00:47:03 +00:00
Chris Fillmore 4ac1a40578 Provide RequestType in error data from HttpPlugin. (#1254)
Closes #1253
2018-02-12 10:01:58 -08:00
Theodore Abshire 35d8838ed3 Change null body to undefined in Fetch
Fetch requests with a method of GET or HEADER cannot have a body, or
else the request will fail. Normally we had no problems with this, but
it turns out that Edge counts a body of 'null' as being defined.
This changes the Fetch scheme plugin so that it will replace null with
undefined for the body in the init data.

This also makes it so that HTTP_ERROR errors emitted by the http
plugin will include the original error, to aid in debugging future
issues.

Change-Id: I0531656dada25f97ef610d4285c225d57d7ef262
2018-02-09 22:21:27 +00:00
Joey Parrish d4b1eb0ca6 Handle UNSUPPORTED_UPGRADE_REQUEST in the demo app
Issue #1230
Issue #1248

Change-Id: Ia3942d8f6fc1b6c5e0166f86aa6620625f75d0db
2018-02-01 08:36:05 -08:00
Joey Parrish ed54199260 Upgrade and unfork jsdoc
This updates jsdoc to the latest version from npm and forks a copy of
the default jsdoc template.

In subsequent commits, we will reapply our customizations to the
template and to a jsdoc plugin.

This also fixes several bad annotations that the new jsdoc failed to
parse.

Issue #1259

Change-Id: I00a47270ea4754e1c96c43ca900d5cf889ab72e6
2018-01-31 22:04:48 +00:00
Joey Parrish 2f55d2a3bd Use AbortableOperation in networking
This uses AbortableOperation in all networking, from the scheme
plugins all the way to the request interface.

This also updates all default scheme plugins, docs, and sample code.

Backward compatibility is provided for scheme plugins and the
request API in NetworkingEngine.  This compatibility will be
removed in v2.5.

Two cancelation-related tests have been disabled in
player_integration until the new abort interface has been adopted
in the manifest parsers.

Issue #829

Change-Id: I91c8e6efe97798d111e8ddca5655cddc1f6bcbf3
2018-01-29 19:23:47 +00:00
Joey Parrish e5afb35169 AbortableOperation interface
This adds a general interface for abortable operations, and a specific
implementation of that interface for use internally.  This should
simplify the transition to abortable network requests and others.

Issue #829

Change-Id: Icf54e23028f7454640f5ec76ca97d8a8ed5915ed
2018-01-29 19:23:47 +00:00
Aaron Vaage 14e6b3a230 Create Upgrade Pattern
Create the pattern for how to handle database upgrades. As of this
change the only upgrade supported is from version 0 (no database).

Issue #1047

Change-Id: I9f889a9e39a190e926cf06f0720a5371bc3c59af
2017-12-14 14:53:48 -08:00
Joey Parrish 2e5b856f79 Do not require EXT-X-MEDIA-SEQUENCE in HLS live
Closes #1189

Change-Id: Iae6f4f4524bb9895f8b211491793cf7626661a5d
2017-12-13 18:49:03 +00:00
Joey Parrish a18dc01874 Remove broken HLS time offset code
We misinterpretted the EXT-X-START tag before.  Now, we ignore this
tag and parse segment times from the segments themselves.  This is
more robust for both VOD and live HLS content.

We avoid segment parsing when updating normal, well-behaved live
streams.  For poorly-behaved live streams, we will fall back to
segment parsing and recover.

This also addresses the issue of VOD content which does not start at
zero.  Instead of using configuration to make this playable, we will
now offset VOD content back to 0 automatically.

Issue #740
Closes #1011

Change-Id: Ib3a59f87e3a050244cd39854409d8e3542c50b0a
2017-10-30 18:51:29 +00:00
Sandra Lokshina 113d9744a7 Add support for HLS playlists with type LIVE
Issue #740

Change-Id: Ia3dcdd29d8b85f5f1b266455d70a6cafbdc94757
2017-10-24 23:58:37 +00:00
Jacob Trimble 1224464535 Use goog.DEBUG over COMPILED.
This allows including the extra assertions and logging in the debug
compiled library.

Change-Id: Ie8575a31b428e1985077939169bfae9254e395d5
2017-09-27 11:24:32 -07:00
Tim Plummer 775d755259 Remove deprecated @expose annotations.
Added externs for error.js and removed the @expose declarations from the
actual error.js file. Updated the jscompiler flags and docs.

Change-Id: I2aa95ef1c82fc7bd349c637cca3141d5a003b646
2017-09-26 13:51:36 -07:00
Joey Parrish 2af0de2adb Move streaming retry logic into callback
Closes #960

Change-Id: Ieeacbf2e25f53a5af25a1de1935085e43457a092
2017-08-10 20:27:53 +00:00
Sandra Lokshina 5f0a830c36 Reject HLS live content until we have support for it.
Change-Id: I57842758cf62ec05df0c552886b8a80d2c15b38e
2017-08-07 22:06:57 +00:00
Michelle Zhuo d67764b5ff New Error Code for Content unsupported by Browser
Previously "UNPLAYABLE_PERIOD" exception is thrown when a browser
doesn't support the container or codecs in a piece of content, which is
confusing to developers and customers.
Changing it to "CONTENT_NOT_SUPPORTED_BY_BROWSER" exception.

Test manifest:
https://media-ci.foxford.ru/dist/hls-issue/issue.master.m3u8

Closes #868.

Change-Id: Ied135b687190919abbeb1561c2bff36a7203136e
2017-08-04 11:07:07 -07:00
Joey Parrish 651b32a4ea Add detail to video errors in Chrome
This makes use of a new field added to Chrome 59.

Change-Id: I1b68e803967cfd7cfb64cea26458d0f3ef8a27c1
2017-06-20 16:49:59 -07:00
Joey Parrish 8fdd2921dc Fix offline storage offline in compiled mode
We were giving Storage a Player proxy from CastProxy instead of a
local Player instance.  This fixes the mistake and adds a new error
code to make it clear when this mistake is made by other apps.

Change-Id: I4f2d49adc45ef5ca3a942a72192a09f001f5100c
2017-06-05 18:03:32 +00:00
Theodore Abshire 723e6ad1bc Added basic xlink support.
This adds a utility to mpd_utils.js that filters a manifest and
automatically downloads and substitutes in the contents of any xlink
link.

This only supports xlink:actuate="onLoad"; "onRequest" would require
significant changes to our manifest processing pipeline.
It also adds a new field to INVALID_XML errors to indicate which
xml was invalid, to make the error more informative when called on
xml loaded by xlink links.

Also added a demo asset.
This is just a simple modification of heliocentrism to break it into
multiple files.

Closes #587

Change-Id: If87b1e78e65261dcc4e043b0c2e6cf69c1b12e08
2017-05-08 14:00:56 -07:00
Theodore Abshire a99ec6e378 Added a comment to warn about a Firefox bug.
Change-Id: I4a2a6f56c37d8223e5ba28ffaa04ae33334df7c1
2017-04-10 13:37:55 -07:00
Jacob Trimble 575f2ad109 Add an indicator for critical errors.
This adds a severity field to Error objects.  This can be used to
detect whether an error is recoverable.  All the same errors are still
reported so the field can be ignored.

There are two possible values:
* RECOVERABLE means that the Player will try to recover from the error
* CRITICAL means the Player will be unable to continue and must call
  load() again

Closes #564

Change-Id: Ie2c5468340c13e7a288b99690ab65b7ecc0a6b29
2017-04-04 23:57:59 +00:00
Joey Parrish db909b0f2e Add support for Widevine-encrypted HLS content
This abstracts the creation of DrmInfo to parse the EXT-X-KEY tag
differently per KEYFORMAT.

Issue #279

Change-Id: I2e187dcfc01f7306183c9090c54de58e81872bc4
2017-03-31 12:34:10 -07:00