Commit Graph

41 Commits

Author SHA1 Message Date
Wojciech Tyczyński d36ff6553c feat(net): Add minimum bytes for progress events (#7117)
By limiting progress events to only ones with minimal chunk size, we might end up with feeding better default ABR implementation, which should result in more accurate adaptation in case of network throttle.
2024-07-31 05:34:13 -07:00
Álvaro Velad Galván 8bb2d6e11a fix: Exclude fetch polyfill from fetch plugin (#6838)
This fix excludes the use of
https://www.npmjs.com/package/fetch-polyfill because it does not support
a signal to cancel requests in progress.
2024-06-17 11:35:45 +02:00
Álvaro Velad Galván 812163a986 fix: Fix numBytesRemaining when the request is done (#6653) 2024-05-23 04:16:50 +02:00
theodab 51554934be fix(net): Fix HEAD requests in new Chromium (#5180)
This makes it so that we no longer try to download the body of a head
response, in the http fetch plugin. This is necessary due to an upcoming
change to Chromium, where the body object of such responses is null.

Fixes #5164
2023-04-25 15:56:37 -07:00
Álvaro Velad Galván 36bcc3775a fix: Fix fetch plugin with old implementations (#5091)
Fixes https://github.com/shaka-project/shaka-player/issues/5088
2023-03-14 19:12:56 +01:00
Álvaro Velad Galván 6a032078e9 Feat: Add blob-url support (#3583)
Issue #1481
2021-08-19 06:04:55 -07:00
Theodore Abshire 7893b7733b Feat(player): Added events for download lifecycle.
This adds two new player events, 'downloadheadersreceived' and
'downloadfailed', to allow users to measure network performance
in greater detail.

Issue #3533

Change-Id: I33a3bd411d815e926d4bea2184e8d3ea69e2bb49
2021-07-29 18:47:24 +00:00
Percy Tse f09616fb41 fix(LL-DASH): Append segment chunk strictly in order (#3405)
An async process handles the appending of partial segments for LL-DASH.  This fixes the caller to wait on the results, so that partial segments are always appended in order.

Fixes #3404
2021-05-17 10:00:28 -07: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 863e3455b6 feat: Network stall detection (#3227)
Closes: #1582
2021-03-30 13:35:41 -07:00
Michelle Zhuo 40d0359732 feat(LL-Dash): Parse and append ReadableStream by MP4 boxes
To enable low latency streaming, we need to append chunked data of
ReadableStream by complete MP4 boxes.
Everytime we get chunked data of the ReadableStream, we find the
last complete Mdat box. Append the completed boxes of data, and save
the data of the incomplete box until next time we get the chunked
data.

Issue #1525

Change-Id: I722ff992f397ee2f62bca45db33a0834ef57a270
2020-09-16 13:18:03 -07:00
Michelle Zhuo f67367a81b feat(LL-Dash): Fetch and append ReadableStream
With the low latency streaming mode, we fetch a segment, and get the
response data through a ReadableStream.
For each segment request, we may get multiple chunked data. We handle
and append the chunked data of the ReadableStream via a callback
function in the StreamingEngine.
Once the whole segment gets handled and appended, we move on to the
next segment.

Issue #1525

Change-Id: I7949c87f4e491c928919c2e9dc4dafbebac22c9b
2020-09-16 20:17:02 +00: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
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 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Joey Parrish 79e2e68853 Fix export of fetch plugin
Without this, custom scheme plugins can't delegate to this standard
one.

Issue #2205
Issue #2213

Change-Id: I13e9762e75ba9afe9fd7f804404ffb1d2e684435
2019-10-23 20:23:26 +00:00
Joey Parrish 393b0ecea7 Fix HTTP test failures
This makes progress callbacks into a required parameter on all network
scheme plugins.  This does not mean that every plugin must make use of
the callback, but every caller must supply the callback.

In production, NetworkingEngine already supplies this callback
universally, so our HTTP plugins make use of it whenever progress data
is available.

Our tests, however, did not always supply this callback, leading to
test failures.  These failures were more likely to show up in Jasmine
3 than Jasmine 2 for some reason, which caused us to downgrade back to
Jasmine 2 recently.

By making the callback required, we can clean up this inconsistency
between test and production and give the HTTP plugins what they expect
in all cases.

Issue #1949

Change-Id: I8a6e1904e73cf7ca6ae8f3964261c339f404854d
2019-05-22 15:42:06 +00:00
Jacob Trimble 74918b90ec Convert networking files to ES6.
Issue #1157

Change-Id: Iae83b88881b351c97e8ec020625167f5f700f97e
2019-05-20 17:10:06 +00:00
Jacob Trimble f130dffcef Enable eslint indentation rule.
This is a fully automated change.  The linter will fail because the
extra indentation caused line-length errors.  These won't be fixed
automatically.  They are fixed in a follow-up to make this one fully
automated.

Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
2019-05-13 22:31:09 +00:00
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
Jacob Trimble cc838ff23f Fix uncaught Promise rejection errors when aborting.
We get an error from ReadableStream when we abort a request.  This
causes uncaught rejection error logs in Chrome.  This ignores the
error and stops the logs.

Change-Id: I0f339e73564ac42b28ea8b7d0bf12ffb8c2ec9cc
2019-05-03 23:02:42 +00:00
Michelle Zhuo 40f9113bb2 Abort requests when network downgrading
When the network becomes slow, we check if stopping the current request
and download the content with lower resolution is faster. If so, abort
the current request and start a new one.

Issue #1051

Change-Id: I588e524469432e362361d1cfbde6cd45c2009959
2019-05-01 20:18:16 +00:00
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
Theodore Abshire 6d57cdb83c Make Fetch plugin require USABLE ReadableStream
On Edge, window.ReadableStream exists, but attempting to call it
results in an error.
This changes the support check for Fetch to try actually creating a
ReadableStream before it OKs using Fetch.

Change-Id: Iab6ea2c459fe536ac51796808cb56c4c54dd4312
2018-09-26 15:43:29 -07:00
Theodore Abshire 809d86d2ee Make Http Fetch plugin require ReadableStream
In a recent CL, the Http Fetch plugin was modified to make use of
ReadableStream. However, ReadableStream isn't available on every
platform. This change modifies the Fetch plugin to not be used if
ReadableStream isn't defined.
This also adds a basic mock ReadableStream for tests.

Change-Id: I7554298779040ce0cef1b8ad55c3ee113f932954
2018-09-26 10:40:59 -07:00
Theodore Abshire cef4ae98b9 Added progress events for Fetch plugin.
Also adds support for the relevant methods to the fetch mocks.

Closes #1504

Change-Id: I1a94148810262ecab675aea7dca7e1a3aaf8800a
2018-09-25 18:28:16 +00:00
Aaron Vaage 8e90b840f7 Remove Use of MapUtils.forEach in shaka.net
Removed the only use of MapUtils.forEach in shaka.net as part of
using Maps over Objects.

Change-Id: Ia3fe98757bb7bfe4a46564db11fa31aeee7cff6a
2018-09-14 21:42:35 +00:00
Michelle Zhuo d6720cc7a6 Add Progress Event Handler for XHR plugin
This is part 1 of conditionally aborting requests when network
downgrading.
1. Add progress event handler for Http XHR Plugin, to get more frequent
updates for network bandwidth estimate and suggest streams based on
that.
2. When the plugin doesn't support progress event, call
onProgressUpdated function after every segment is downloaded.
3. Replace onSegmentDownloaded with onProgressUpdated function in
player.js and network_engine.js.
4. Since XHR Plugin supports progress event while Fetch doesn't, change
the config to prefer XHR over Fetch API.

Issue #1051.

Change-Id: Icf6775dd3520fb2e359b13d29e3b39d3792fe865
2018-09-07 16:10:41 -07:00
Joey Parrish e100553fa0 Add missing @private annotations
Issue #1553

Change-Id: I36cb50cbec9ee816a82274ebc83dfae2ba095214
2018-08-21 10:19:24 -07:00
Chris Fillmore 07fa82436f Refactor HttpFetchPlugin to clarify error outcomes (#1532)
Previously, HttpFetchPlugin would treat any non-Shaka error as
HTTP_ERROR when there were potentially other circumstances which
could have produced a non-Shaka error.

This change catches errors from fetch sooner, so that there is no
need to do a fuzzy check for error.severity. It also clears the
request timeout regardless of whether fetch throws or not.

Closes #1519
2018-08-14 11:46:55 -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 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +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 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 0154dbc4d4 Convert 'var' to 'let'/'const' (6 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: I475eba0a477d13cd9201c88ad44899d521ad8991
2018-02-20 11:28:02 -08:00
Chris Fillmore 4ac1a40578 Provide RequestType in error data from HttpPlugin. (#1254)
Closes #1253
2018-02-12 10:01:58 -08:00
Chris Fillmore 5ed7b5b212 Move Fetch API support detection into public method. (#1296)
The motivation for this change is to allow the client app to
share Shaka's support detection.

This should enable #1075.
2018-02-12 10:00:54 -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
theodab b4ca4bf51c Adds an HTTP/s scheme plugin using Fetch
This plugin is preferred over the XHR plugin, if available.
This plugin requires AbortController, which is only present on
Firefox 57 and Edge 16, so this will not be active on every platform.

This also adds a simple mock for the Fetch API for use with Jasmine.

Closes #829

Change-Id: Ifb79d29334fbfcfd175afe0706da5a3d5e452e2f
2018-02-08 23:11:53 +00:00