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 many places, we check error codes on shaka.util.Error. But the
compiler doesn't know that what is caught in "catch" is that type, so
we add type assertions.
In some cases, we know that other types may also be thrown, so there
are also some runtime checks. Some of these had to be refactored to
allow the compiler to correctly infer types.
Change-Id: I053bd7e96213c689aae3889315052dd402124690
DrmEngine is adding an extra property to MediaKeySystemConfiguration
objects, knowing that EME will ignore it. The latest Closure Compiler
won't allow this.
In the future, we should refactor DrmEngine and consider tracking this
in some other way. For now, this changes the dot to square brackets.
Issue #2528
Change-Id: I544c93dfa2534e9d62ac5ea47e20a6dc3cb79e3a
For webOS TV 2020 platform, like for Tizen, key IDs should not be
transformed to big-endian UUIDs, it causes `4012
RESTRICTIONS_CANNOT_BE_MET` error.
Closes#2512
When period-flattening combines Streams, key ID arrays would get very
long with duplicates.
This changes keyIds in the manifest and offline structures from Array
to Set.
Issue #1339
Change-Id: I003d23e567efafa771ecd2ad597900181604ad18
Period-flattening will concatenate Stream objects, so this information
should be available per-Stream instead of at the Variant level.
Issue #1339
Change-Id: I96195fea48cab1e4a349b2ab0b16064a443e928a
The 'webkitkeyneeded' and 'encrypted' events send similar data, but
they were incompatible with each other and our transform handling.
This makes our polyfill produce the same format as the browser for
cases where the browser may only fire the old event. This also makes
our utilities work with the new format.
The 'webkitkeyneeded' event was a length-prefixed UTF-16 string while
the 'encrypted' event was just a UTF-8 string.
This also makes a breaking change in the transform callback to pass the
init data type. This shouldn't break anyone that only uses the first
argument; the second argument was mainly added so we could have the
default transform work without knowing anything.
This change could also break people who use custom transform functions.
The init data format is changing, which could break people who read
it directly. If they follow the tutorial and use our utilities, it
shouldn't break. This also updates the tutorial to match the new format
and be more clear about the format.
Fixes#2214
Change-Id: I006382028e828e31e20e085114fd7fd85c0e1eaa
querySelector isn't available in Shaka Player Embedded. Since we only
use it to find nodes with a specific tag name, we can usually use
getElementsByTagName.
Issue google/shaka-player-embedded#113
Change-Id: Ia225e5d1f7598b13bd05db868fe2ea566dca4493
`'webkitneedkey'` events are fired with the same `event.initData` for the video and audio tracks, and a new session is needed for each.
Closes#813 (duplicate sessions required on Tizen)
Closes#2447 (polyfills broken on Tizen)
Closes#2448 (PlayReady broken on Tizen)
That alias was confusing the closure compiler, and causing it to
produce invalid output when making release versions.
Closes#2438
Change-Id: Ic232ce4f29222543b13c2cc725ffefaedea29e3a
It is common when debugging protected content to want to see the
license request/response data. This adds a configuration to easily log
the license request/response data so we can see this without modifying
the code or adding breakpoints.
Change-Id: Ib5db3eaa1447ae8714da935ee459fc7f9ba1e937
For Video Futur platform, like for Tizen, key IDs should not be
transformed to big-endian UUIDs, it causes `4012
RESTRICTIONS_CANNOT_BE_MET` error.
Issue #2189
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
An upcoming release of the compiler gets confused about robustness
fields being potentially undefined. Adding a fallback to a blank
string satisfies the compiler.
Change-Id: I794b49002c86dde7236a09061c8ed2390ae26136
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
Most of the persistent-license bugs on Chrome have been fixed, so this
updates the comments to point to the only remaining issue. The tests
have also been updated to pass (except for the flaky failure caused by
the remaining bug). The tests are still quarantined since they are
fairly flaky, even with a large delay.
This also adds some more logging to DrmEngine, makes it use the
"session.closed" property when closing, and removes the close
workaround for Chrome since it has been fixed.
Change-Id: I2dbd0b7005e288ae2a4d9694516daae6f5e0b49a
When storing assets offline with the storage system, the DRM
engine is used if the asset is protected. However, we never attach
the DRM engine, which means it never gets an associated video.
When the delayLicenseRequestUntilPlayed config value is set, the
DRM engine checks the paused status of the video; thus, if there is no
video element, the DRM engine errors and the download fails.
It would be fairly simple to make the DRM engine attach the video, but
honestly, the delayLicenseRequestUntilPlayed parameter doesn't make
sense for offline storage anyway. So this just changes the DRM engine
to ignore delayLicenseRequestUntilPlayed if it has no video.
Fixes#2218
Change-Id: If4e8d24fdcd1eca81cc39b845e5a833a3f1ce5e6
Because src= content lacks codec information, ClearKey setup fails.
However, because there was no DrmInfo prior to the ClearKey settings
being applied, the variable hadDrmInfo was false, which led to a
suppression of the resulting DRM error.
Instead, we should count ClearKey settings toward hadDrmInfo. So now,
ClearKey settings are applied before we calculate hadDrmInfo.
Closes#2139
Change-Id: I14d5bfe63fd2ce1a461ae7ef8c2fee7f42bb1b3e
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
Now there is a generic callback to transform the init data before
passing it to the browser. This can be used by apps to use a custom
content ID in FairPlay content. This also adds some utilities to help
in writing these functions and moves the default behavior to DrmEngine.
Closes#1951
Change-Id: I78ce660c126b53a69d5f55b16775ffcdbbe4d748
This allows a request/response filter to determine which EME session
made the request. This also changes the session ID of FairPlay sessions
so they are available too.
Issue #1951
Change-Id: I1a07abae6faf4a87fad7b5d4290a00b25e83da8e
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
- Reduce times for "short delays".
- Remove backoff delay from networking tests.
- Avoid hard-coding delays in the library.
- Move Storage tests to integration tests since they use indexedDB (and
take over 200ms each to run).
This reduces the time it takes to run unit tests (with --quick) from
50 seconds to about 6 seconds. Now all but one unit test finish <100ms.
Change-Id: I88461472a87c4cf750a36d07d07422818e069a4d
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
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
This enables the eslint rule that requires all functions to consistently
either return a value or not return a value.
Change-Id: I98b579f3689c3b6c74968116824231bb792bd9dd
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
A follow-up commit will convert "function" functions to arrow functions.
This caused some errors with the compiler, which this change fixes
beforehand.
Change-Id: Iff85b1e1f56b63a38b09f8db9947ed5daf02ddf4
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
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
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 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
In our tests, it was possible for a timeout to fire after |clearTimeout|
was called. This CL makes sure that cannot happen by adding an "alive"
flag to each timeout.
To ensure that the change was as well defined as possible, this CL
changes how |shaka.util.Timer| is implemented and updates the API to
better communicate what is happening internally.
Change-Id: I57e3899046a762bff3293b9822a7e8f7ac804042
We often use the IDestroyable interface to provide us with a standardized
way to break internal references and tear-down objects, however many
objects don't need this to be async. Once using IDestroyable, everyone
must assume that you must be async.
This change introduces IReleasable, a sibling to IDestryable, which
provides the |release| method. IReleasable is the synchronous version of
IDestroyable.
This change converts EventManager from IDestroyable to IReleasable as
the first of many conversions.
Change-Id: Ic3e90e594abc1c7326eccbe2521eb71676b74a09