Previously, to decode UTF8 content, we used the browser's
decodeUriComponent method. This worked in most situations, but it
would stop and error the moment it found an invalid UTF8 character.
This meant that a single poorly-encoded character inside a text stream
would cause the entire closed captions to fail to display.
In this CL, we switch to using the newer TextDecoder API, which
will instead replace invalid characters with an "unknown character"
code point, and continue parsing. This should make our text parsers
more robust when faced with bad encoding.
Closes#2816
Change-Id: Ibf2887e143d24d15a127bbcf2961539669580eea
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
In the code for supportsChunkSize, we test to see if a given chunk
size is supported by array to string conversion by trying to perform an
operation on a Uint8Array of that size without throwing an error.
However, the result of that operation was only ever referenced inside an
assert. Because asserts are compiled out in release builds, the
result of that operation was not being used... and thus, the entire
call was being compiled out.
This changes the return value of the function to use the result of the
operation, thus preventing it from being compiled out.
This also adds a unit test that will detect this problem in the future.
Closes#2433
Change-Id: If3048531afc460beb16de0dda7f7fcbd5499fdaf
Using the spread operator in StringUtils causes issues on Xbox One.
It has something to do with the compiler's polyfill for it. But
there's no reason we have to use the spread operator instead of
Function.apply in this instance.
Closes#2186
Change-Id: If8b3ff436f852ccae1f1a8c3ee5b7d8c142e15cf
This changes the eslint rule to enforce a strict pattern for the
argument comments. The comment must appear before the argument and
must be /* foo= */. This still ignores line comments.
Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
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
These are intermittently used and cannot be verified. Most of our
methods can throw a shaka.util.Error, so having it doesn't really add
anything. Plus, if we change a function to throw, we'd need to update
all their callers to ensure they have an accurate description of what
they throw; otherwise we can't trust the directive.
Change-Id: I520bd0fc4c33443e967bf5b103ca5aa9e3274884
Using "new Uint8Array" with a TypedArray creates a copy of the buffer;
this is unnecessarily expensive for large buffers. This adds a rule
to disallow using it in favor of a new utility that correctly creates
a new "view" on the same buffer.
Note it is fine to pass an ArrayBuffer to "new Uint8Array" and it won't
copy; but there there are many cases where the type is BufferSource,
so it could be a TypedArray. Unfortunately, there are many other cases
where we explicitly pass an ArrayBuffer; but the compiler rules don't
allow us to whitelist this case (since ArrayBuffer is part of
BufferSource).
Change-Id: I58696a85a9cbcc188c0b16919c9eeb63e56edca1
This changes the network API to use BufferSource instead of ArrayBuffer,
which allows plugins to return a "view" on a buffer instead of the
whole buffer. This also adds some utilities for changing between
views and buffers.
Lastly this forbids the use of the "buffer" property of TypedArrays
since it doesn't work with partial "views". This audits and fixes the
usages of the "buffer" property to ensure correct usage.
It should be noted that both MSE and EME accept a BufferSource as input,
so we don't need to convert a "view" into an ArrayBuffer before passing
to it.
Change-Id: Iaa417773f8ce5304424e43c7372ce10ebf540d2a
This is a helper to aid in iterating over items. This returns a list
of objects that contain:
- "item": The current value.
- "prev": The previous value in the list.
- "next": The next value in the list.
- "i": The zero-based index in the list.
Issue #1518
Change-Id: Id18ab977e3ae45dfbfd2b4137a1bffb6e53c6bce
Instead of using a hard-coded chunk size when creating large strings,
this now uses a browser check to detect it. This allows us to use
large chunk sizes on browsers that support it but still support low-end
devices.
Closes#1985Closes#1994
Change-Id: Ibe45902b659516ae66bd7da33007fd15e7f64207
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.
Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
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
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
This makes it easy to dump and restore databases from IndexedDB. This,
in turn, makes it easy for us to test that all database versions can
be read. Before we close the backward compatibility issue that has
plagued v2.3, we will add tests that use this utility to load DB
snapshots from various older schemas and prove that they can still be
read.
This also adds dumps of all database versions to the assets folder,
including a snapshot of a what our broken upgrade in v2.3.0 did to the
v2 database schema.
Issue #1248
Change-Id: If7e8995f50abbdee67e3fa93e79f07a49582c5e8
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
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
We broke PlayReady on IE and Edge in #815 when we fixed PlayReady for
Tizen. This should work for both, but will still need to be tested on
Tizen after merging.
Closes#837
Change-Id: Iff41845ae6a4b369e8f21a80623ebb2cb5475fd6
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
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
In many places we tried to guess the encoding of a piece of text.
This guess fails for Chinese UTF-8 text, and probably text in many
other languages.
However, DASH manifests, TTML files, WebVTT files, and VTTC box
payloads are all specified to be in UTF-8. Rather than guess and
possibly fail, treat all text in these contexts as UTF-8.
Change-Id: I00c652a9f1dd20855e94abfac84275e41dd9e266
Because we were using Function.apply to create strings, large arrays
were causing problems with browser argument count limits. This
now splits the arrays up before calling.
Closes#335
Change-Id: Ic94a950997e2f17563ecba8fb628f62c0ed18fc2
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
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
* Updates all Copyright years to 2015.
* Adds licenses annotations to all JS.
* Makes all licenses identical to avoid repeated appearance in the
compiled output.
* Drops fileoverview annotations, which do not affect docs output.
* The linter still requires fileoverview on externs.
This patch required a newer closure compiler, since the previous
version we used had a bug regarding license annotations that caused
the license comment block to appear in the output once per file
regardless of uniqueness.
Change-Id: I2e9272db680cba7ecc4613d97f1d3a94ac2244cc
This reverts commit 8cb24652cb, due to
the fact that the new annotations caused our binary size to jump
by 52%.
The compiler preserves all 'unique' licenses, which causes trouble
since the comment blocks with the license annotations are not unique
and contain file overview comments as well.
We can re-examine this once we have restructured the license headers.
Change-Id: I418e407a0e0253630633697f30cf496a7fc2ddfc
Use 'keystatuseschange' events from EME together with cenc:default_KID
from the MPD so StreamVideoSource can determine if the key system
can/will decrypt a stream before it attempts to play it. This enables
the Player to safely (and automatically) switch between streams that
are encrypted with different keys.
Support AdaptationSet @group, which is the preferred approach to safely
use multiple encryption keys over multiple Representations.
* Squash AdaptationSets from the same group into one StreamSetInfo.
This enables support for @group without introducing special case code
into StreamVideoSource and EmeManager.
* Fire 'trackchanged' events when tracks becomes available/unavailable
either from application restrictions or key status changes.
* Pull key IDs out of DrmInfo and put them into StreamInfo so key status
changes can drive per stream availability instead of per StreamSet
(AdaptationSet) availability.
Closes#67
Issue #160
Change-Id: Ife0814deb65715923a572b45880137a99b378035
Most of these StringUtils were either operating on Uint8Arrays directly
or using strings to move around Uint8Array data anyhow.
Change-Id: I71efe6ede34210ca721d46acd53452344efff5bb