Commit Graph

54 Commits

Author SHA1 Message Date
Jacob Trimble b5cbc01088 Don't retry for 401/403 HTTP codes.
Closes #620

Change-Id: I1df99cca6bb6a704b6ff055399298914d6e91e8f
2017-04-05 21:35:24 +00:00
Jacob Trimble f5cabead8e Don't retry network requests on CRITICAL errors.
Issue #620

Change-Id: I6b659acdccf5d893022f3474b45020482f543550
2017-04-05 19:51:13 +00: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 0243671383 Expose data uri parsing to the HLS parser
Widevine HLS manifests have a data URI that needs to be parsed to
generate DrmInfo.  Rather than write another parser, factor the data
URI networking plugin to expose the parser to other classes.

Issue #279

Change-Id: I71f174b86cc3b0ae0e8dbc31701ea9d36cd157ee
2017-03-30 22:40:26 +00:00
Jacob Trimble 2356e5517a Clone request fields in NetworkingEngine.
Change-Id: I00275b9a857fc0c4b78b52a7c6e3c58035237127
2017-03-09 19:17:55 +00:00
Jacob Trimble 40bd34d8ac Add support for special cache header.
This allows network responses to have an X-Shaka-From-Cache header to
indicate that the response was somehow from a cache and should be
ignored for bandwidth calculations.  For example, this can be from a
service worker intercepting the request.

Change-Id: I4dfdf4211921b7205febb58f1e80967f0c4841cd
2017-03-03 19:53:17 +00:00
Chad Assareh 97cca1887b Return HTTP headers as part of the BAD_HTTP_STATUS error object.
Change-Id: I6b5a22b26fba8ace40f9cff00146e22b51c10041
2017-03-02 13:58:06 -08:00
Jacob Trimble 6f7d937d2f Add Response flag to ignore cache hits.
This adds a field to the network response that will indicate that the
response was from a cache and should be ignored for bandwidth
estimation.

Change-Id: I6b02e9d4fb3be02731bdf0a2a46bc5ce5f11e302
2017-02-16 21:17:25 +00:00
Joey Parrish fd1786b7a9 Add asynchronous filter example in the tutorials
This adds an example of using asynchronous filters for authentication.

Closes #610

Change-Id: Idf47558af4c399178ff3806f944d69909ee2fd7a
2017-02-07 16:18:27 -08:00
Joey Parrish 836bd9a177 Make filters, requests, and responses easier
By exporting StringUtils and Uint8ArrayUtils, we can simplify the
process of wrapping, unwrapping, and parsing requests and responses
in NetworkingEngine filters.

This makes it easier to write filters that deal with text-based
data, as it is no longer the job of the application developer to
deal with subtle conversions between string and ArrayBuffer.

We will also fill in requests with defaults if needed.  This allows
developers to omit fields when initiating extra requests at the
application level.

Closes #667

Change-Id: Ie6a0f23b4d46e7e458d996759eac6cd85a36b741
2017-02-08 00:09:08 +00:00
Joey Parrish 6cfd337680 Remove unnecessary triple-equals usage
Change-Id: Ibfd76f8b36926e41e9bf2fd26b5bea16d3bd8f2a
2017-02-06 22:20:09 +00:00
Theodore Abshire 8b2212c65d Enabled asynchronous response filters.
Also updated externs.

Issue #610

Change-Id: I4c9539442d6fb77781296ea1acf123b3653e3b40
2017-01-09 17:34:22 +00:00
Theodore Abshire 07c564b4a2 The http plugin now fails on 202 status codes.
Closes #645

Change-Id: Ie20d1de1e8eff30d7656886e2b85d0e39079774a
2017-01-06 21:37:59 +00:00
Theodore Abshire 07ce75273e Allowed network plugins to see the request type.
Closes #602
Change-Id: Ib86389956c4908d94184abe8775d497b09a5f90e
2017-01-06 21:23:09 +00:00
Theodore Abshire 9153f68ab3 Fixed a bug with removing pending requests.
In some cases, the networking engine could have attempted to
remove a pending request that did not exist, thus removing other
requests.

Change-Id: I08fb9c11c3dd153af7a148fcb591fe5c0c3634a1
2017-01-06 18:59:59 +00:00
Theodore Abshire abca628239 Added support for asynchronous request filters.
Closes #610
Change-Id: I10d407d6c858f6541e869b834877a2ebbc516694
2017-01-05 15:49:49 -08:00
Jacob Trimble b1711c346d Allow passing durations from scheme plugins.
This allows the networking plugins to pass the duration it took for
the request.  For example, if a plugin were pre-fetching the segment,
this allows the plugin to tell NetworkingEngine about how long it
really took to download.

Closes #621

Change-Id: Ie67e3f99389cf02d5b4a345bde06ccc418b6e91c
2016-12-20 20:17:43 +00:00
Joey Parrish d6616a0ca4 Fix quarantined NetworkingEngine tests
The test flake was caused by a leaked instance of Playhead interfering
with NetworkingEngine unit tests.  The quickest way to reproduce a
failure on the networking tests was to focus the unit tests for
Playhead and NetworkingEngine and run the suite on IE11.

Playhead tests tear down the Playhead object after each test.
However, one test created two Playheads, effectively leaking one.
That leaked Playhead would continue to poll the fake video element
after the test was complete.  Polling used setTimeout.

The NetworkingEngine unit tests would mock setTimeout and show that
the engine was calling it appropriately.  However, the leaked Playhead
would also call setTimeout during the NetworkingEngine test, which
would cause an expectation on the number of calls to fail.

The Playhead tests should clean up after themselves, but the
NetworkingEngine tests should not have to mock global setTimeout in
the first place.  This change not only fixes the Playhead tests, but
isolates NetworkingEngine's use of setTimeout to a private method
which can be mocked without affecting global state.

Change-Id: I94dd7f6c39c25f81c7e4122895ab5fae0feef2cb
2016-11-23 12:05:49 -08:00
Joey Parrish 18da8e04dc Export all plugins
This exports all plugins from the library, to make delegating and
subclassing easier for applications.

This also fixes a couple of issues with the generated documentation.

Closes #551

Change-Id: I23798f6117e1944d7ffc67bcb50ae36f3943710a
2016-11-14 23:58:09 +00:00
Joey Parrish 1d2929ab00 Add extra exports for the sake of generated externs
An upcoming compiler release will allow us to generate externs from
exports.  Because of that, we are adding some extra exports which are
otherwise not needed at runtime.

 - Export properties which implement an interface
 - Export classes which are referenced in external APIs
 - Export base classes of other exported classes

Change-Id: I78b3a4569b4b82b0a9d8993978faf268c2a791d9
2016-11-04 17:12:16 +00:00
Joey Parrish 5b6780bf39 Move filter and scheme plugin types to shakaExtern
If an external project wants to reference the filter or scheme plugin
typedefs, these should be in shakaExtern.

Change-Id: I7bf70d2efbf741c8b07a7b8502b3f52eff49dd9d
2016-11-04 17:12:16 +00:00
Lucas Gabriel Sánchez 403a141f2c Use data URI content-type for manifest type detection (#550)
* Fix when using Data URIs for the manifest
* update test/net/data_uri_plugin_unit.js to test Data URIs content-type header response
2016-10-19 09:50:07 -07:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07:00
Timothy Drews ea94157f5c Set default request retry to 2.
Issue #390

Change-Id: I1458892f4317176f5aaac9665b6bedfd672a9a12
2016-06-23 16:36:09 +00:00
Joey Parrish c29fdf401b Shaka v2 Upgrade Guide
Also fixes docs export on some of our external structures.

Change-Id: Ia31f2ad46c6f07845c289c6ca2f206a6fd6cf341
2016-04-13 21:15:40 +00:00
Joey Parrish cb64d7646d Add response text to HTTP errors
Requested in #319

Change-Id: I2f52519d7a45769a0d2db3c038c9c04cf7fb59c1
2016-04-12 21:59:03 +00:00
Joey Parrish e70461221f Fix jsdoc output of non-constructor plugins
jsdoc was getting confused and generating, for example, a file called
"shaka.media.html#VttTextParser".  Moving the @namespace annotation to
the method itself fixes it.

Change-Id: If26cac698b19d1305c270e519b7ed50ed81492fe
2016-04-06 16:52:06 +00:00
Joey Parrish 32e351d060 Add @namespace annotations to static classes
Without @namespace annotations, static classes do not show up in the
generated API docs.  Although I stumbled over one instance while
writing tutorials, the rest were discovered programmatically by:

for x in $(find lib/ -name '*.js'); do
  grep -Eq '@(constructor|interface|namespace)' $x || echo $x
done

Change-Id: I97dd2bb4bf3faad5ac8d952a28837fa1f594deb9
2016-04-01 11:37:41 -07:00
Joey Parrish bda33cc9b6 Demo app v2
Still missing custom controls for live, but otherwise functional.

UI design and CSS based on work by Sam Dutton.

Change-Id: I0ee41254fb3b145822b018dff87aa583d6bef179
2016-03-30 00:36:32 +00:00
Jacob Trimble 8b85e58f73 Add several utility functions.
Change-Id: Ifbd2582747d2cb54d4abda789b0989b7a6b77aa6
2016-03-29 20:17:44 +00:00
Jacob Trimble 19973d63f4 Changed copyright headers from 2015 to 2016.
Change-Id: I429ff27e4794c03b7ea392e38415075077f9bfb1
2016-03-15 16:32:13 -07:00
Jacob Trimble 8daf53e329 Renamed shaka.asserts to goog.asserts.
Using goog.asserts will work with the compiler.  So rather than
simply casting a nullable value when passing to a method, we can use
an assert which will correct the type and print a log if it somehow
is null.

This is not the same goog.asserts found in closure library, this
simply calls console.assert, but it is not required to do anything
for the compiler help.

Change-Id: I2548e39e772f0aa7ec41437cf9f5a2be383e0fbd
2016-03-11 15:29:20 -08:00
Jacob Trimble 846e7beb48 Unified comment spacing.
Before there were two style to indent comments after an annotation,
using 2 and 4 spaces.  Now this only uses 2 spaces.

Change-Id: Id06415d7193cc154a2768fb3932aff7a06b7ed32
2016-03-10 16:27:45 -08:00
Timothy Drews eaadb52627 Add AbrManager.
* Import and rework Shaka v1.x AbrManager.
* Import Shaka v1.x EWMA utilities.
* Integrate AbrManager into Player.
* Add DefaultAbrManager unit tests.

Change-Id: I8df9c1caddff97684ad3cdc3064b10e9bc014874
2016-03-07 17:40:06 -08:00
Joey Parrish d0701d525c DrmEngine integration tests and associated fixes
- Update MediaKeyStatusMap definitions
 - Remove MediaKeyStatusMap iterators (not present in Edge)
 - Work around MediaKeyStatusMap interop issues
 - Update MSMediaKeys definitions (stricter on Edge 12 than IE 11)
 - Add onKeyStatus callback from DrmEngine and associated unit tests
 - Unpack PlayReady license requests
 - Byte-swap Edge 13 key IDs
 - Fix nullability of types in NetworkingEngine
 - Skip all DrmEngine integration tests unless either Widevine or
   PlayReady are available.

Change-Id: I49cbcdb5f82afa9a70a127601b195cf0794e1181
2016-02-22 16:23:33 -08:00
Jacob Trimble 49b238b3c9 Fix support for UTF-8 encoded data.
Before, we simply converted each byte from an ArrayBuffer into a
character; however, this is only valid for ASCII characters.  This
changes it to fully support UTF-8 encoded network responses.

Change-Id: I9c49f29b09960501d345b98aa7af1bb711972abf
2016-02-23 00:12:43 +00:00
Joey Parrish 454662817b Remove unnecessary defaults in HttpPlugin
Change-Id: Ib146e46980dd5e10ed437be09d6360481335f149
2016-02-19 22:20:51 +00:00
Joey Parrish 3dcd6d3891 Fix data uri test failures on Edge 12
Some failure scenarios resulted in success on Edge 12.
It seems that calling reject() followed by resolve() in a Promise
constructor was resulting in a resolved Promise on Edge 12.

Change-Id: I353d37f34be59c4535a11eb6c181bfa3d320c52d
2016-02-19 22:20:25 +00:00
Joey Parrish 5c4240e358 Add debug logs for HTTP error text
This was useful when debugging license request failures.

Change-Id: Icb8f56fa02fe52f0d01c3c353fdb6ee0fa3f751d
2016-02-19 19:18:51 +00:00
Joey Parrish 493438cce5 Infer a missing URI scheme
Uses location to determine what the scheme should be if unspecified.
This is important because it allows us to use URIs that work for
either HTTP or HTTPS hosted apps without mixed content warnings.

Some special sauce was needed to make it testable, since we generally
can't mock location in tests.

Change-Id: I294ac532f1bba80977597e11addd7f585d1e9b79
2016-02-10 19:00:23 +00:00
Joey Parrish 82e5654636 No optional args in NetworkingEngine.makeRequest
The optional arguments in this convenience function really only help
in the tests.  To avoid some component in the library accidentally
making a request with default retry parameters instead of those
configured by the user, I'm making the retry parameters required.

The optional argument for method is only used once.  To avoid the
temptation to add more positional arguments for other seldom-used
fields, I'm dropping the method argument completely.

Change-Id: Ib0afb5766f68c5505f11372e3b004fc8eaca1223
2016-01-25 12:12:06 -08:00
Jacob Trimble 3cc1a43b8d Added some networking utility functions.
This adds some utility functions to NetworkingEngine for common
actions.  This also cleans up the related unit tests.

Change-Id: I1105b77b6dac3637d566c1a4e2f77004ad705e8b
2016-01-25 09:27:38 -08:00
Joey Parrish 0b886325ab All response headers should be lowercase
This makes it possible for the few parts of the code which will use
headers to do so without relying on assumptions about case.

Change-Id: I3b1ca57a3d789d18d51b4ee94f0791daf301993f
2016-01-15 15:12:21 -08:00
Joey Parrish 075af4ed4b Detect HTTP 302 redirects
When possible, use xhr.responseURL to detect 302 redirects and make
the information available in the Response object.

Use redirect URI as BaseURL for manifest parsing.

See also #225, #266

Change-Id: Ie24abeb3b8418b3e89fed6666eb525aecd74f03b
2016-01-13 17:20:51 -08:00
Donato Borrello 13e21f805d Fix typo, rename registerPlugin to registerScheme
This is a simple change to an out of date comment
2016-01-08 14:22:15 -08:00
Joey Parrish 3bb8f06b7d Require assertion messages
This will enforce messages on assertions, which should make console
logs more useful.

Change-Id: I2cff9e20f630d1d4d46192e2ee317b1942cc7188
2016-01-08 13:29:56 -08:00
Joey Parrish f2ca3a5b53 Move externally-used record types to externs
This is important to avoid renaming properties during compilation so
that applications can inject these types without compiling their code.

This also migrates record typedefs to the new documentation format.
Each record will be annotated with 'property' for each field in the
record.  This results in better output from jsdoc.

Change-Id: Ia877b1e2b333ef7020a85f16bc2469a20879bf94
2016-01-06 12:10:47 -08:00
Jacob Trimble 0b4ba1f8f8 Unified naming of variables about URIs.
Renamed variables to only use URI instead of URL.  Also made variable
names plural when referring to an array of choices.

Change-Id: I7bfd5022606d77a3153575d8f13dd1e040331901
2015-12-16 16:37:04 -08:00
Joey Parrish c934f426d8 Add new error type
This error type will be used for all internal errors, and will rely
on numeric error codes which can be easily checked by the application.

This also changes PSSH parsing to throw on errors instead of retaining
partial data.

Issue #201
b/25306826

Change-Id: I19d23d99d4ee72cb31fe5f233bac57a3a9cfc283
2015-12-04 10:26:08 -08:00
Joey Parrish fff5dd7ee7 Audit exports
This changes namespace exports to the more targetted exportDoc,
adds exports where they are needed and removes them where they are
not.  Exporting of Uint8Array and String utils should be re-evaluated
later.

Change-Id: I9298e73a0a5ef026b6f2b1854488d2c359be10c1
2015-12-01 13:56:37 -08:00