Commit Graph

66 Commits

Author SHA1 Message Date
Álvaro Velad Galván 9cef117f4e feat: Remove com.widevine.alpha.experiment from probeSupport (#9687)
https://chromium-review.googlesource.com/c/chromium/src/+/7552797
2026-02-09 17:06:26 +01:00
Andy(김규회) d98169bc25 feat(EME): Add retryLicensing() and failureCallback for manual license retry (#9638)
So basically, when a license request fails (eg. network Error, server
down whatever), apps can now retry from scratch by calling
`player.retryLicensing()`. This was tricky to implement because of EME
spec limitations: `generateRequest()` can only be called once per
session. So if it fails, it would be stuck.

So I close the old session and create a brand new one with the same
`initData`

> Will Video element throw an error during this process?

we were worried that closing the session would leave the video without
keys for a brief moment, potentially triggering errors. But in practice,
the transition is fast enough( I added a 0.1s delay for CDM clean up)
and the video element handles it gracefully

> Will new encrypted event fire? If not, will it limit this feature?

The encrypted event only fires when the browser first encounters
encrypted content. When we close and recreate a session, the content is
already loaded, so no new event

Solutions: In `CreateSession()` metadata store `initData` and
`initDataType` in the session metadata when the session is first
created. So when `retryLicensing()`is called, we just grab the stored
data and pass it to `generateRequest()` on the new session. No need to
wait for an `encrypted` event at all.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2026-02-05 14:12:30 +01:00
Álvaro Velad Galván bd167c3744 feat: Add listenMulti and listenOnceMulti to shaka.util.EventManager (#9652)
Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2026-02-03 21:49:35 +01:00
Andy(김규회) eac68c7ea0 feat(EME): Add manual and automatic license renewal API (#9589)
Widevine's CDM handles renewal automatically, but FairPlay and PlayReady
require manual
`session.update()` calls to renew licenses before they expire.
Previously, developers had to access internal APIs like
`getDrmEngine().activeSessions_` which only works in debug builds - not
ideal for production use.
Based on the discussion in #9505, this PR implements both Option A and
Option C:
**Option A - Manual renewal API:**
```js
player.renewLicense(); // all sessions
player.renewLicense(sessionId); // specific session
 ``` 
  **Option C - Automatic renewal with config:**
```js
player.configure({
drm: {
renewalIntervalSec: 600
}
});
player.addEventListener('licenserenewal', (event) => {
console.log('License renewed:', event.newSessionMetadata,
event.oldSessionMetadata);
  });
```
This way, developers can choose automatic renewal, manual control, or
both depending on their use case.
Under the hood, FairPlay sends a 'renew' message via session.update(),
while PlayReady re-creates the session. Widevine just dispatches the
event since the CDM already handles everything.
2026-01-26 11:49:26 +01:00
Andy(김규회) 05b09728c7 perf: Use Map.getOrInsert/getOrInsertComputed native methods (#9546)
Added polyfills for `Map.getOrInsert()` and
`Map.getOrInsertComputed()` from the TC39 upsert proposal and refactor
the codebase to use them.
These methods replace the common "check if key exists, then set default"
pattern with a single atomic operation. This improves code readability
and eliminates redundant map lookups throughout the player.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2026-01-13 10:57:25 +01:00
Andy(김규회) 2bfb798465 feat(EME): Implement MediaKeySessionClosedReason handling (#9540)
When a MediaKeySession is closed by the CDM, the engine now utilizes the
MediaKeySessionClosedReason to determine the appropriate recovery path.
For critical reasons like hardware-context-reset, the engine
automatically recreates the session using its original initialization
data. We also addressed a race condition where keystatuseschange events
arriving for already-closed sessions would cause an engine crash.

This implementation is specific to the new EME closed promise resolution
logic and handles CDM-initiated closures. It ensures robustness on
platforms where hardware events, such as device sleep or GPU switches,
would otherwise lead to permanent playback failure.

Correctly handling these closure reasons prevents orphaned sessions and
allows playback to resume seamlessly after a hardware reset. The
additional safety check in the key status path ensures that asynchronous
notifications from the CDM do not interfere with the engine's session
management.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2026-01-05 15:04:43 +01:00
Mudit Jain 49a4d56267 feat(FairPlay): Add support for Gumlet (#9396) 2025-11-26 12:39:20 +01:00
Álvaro Velad Galván 5d59f68a84 chore: Extract PlayReady licenseServerUri from PSSH in shaka.media.SegmentUtils.BasicInfo (#9404)
Related to https://github.com/shaka-project/shaka-player/pull/9402
2025-11-19 12:14:45 +01:00
Joey Parrish 37b952db9f fix(DRM): Fix cache keys to include encryption scheme (#9392)
When caching a result from EME, it's important to consider the
encryption scheme, which can affect the success or failure of a query.
2025-11-14 15:12:43 -08:00
Joey Parrish 1aa29031d5 fix(DRM): Apply initDataTransform before deduping (#9393)
Before this, DRM engine would dedup using the old initData, then
transform it via callback, then create sessions. So if the
transformation creates duplicate initData, we get more DRM sessions than
we should have otherwise.

This changes the order from "1. dedup, 2. transform, 3. create" to "1.
transform, 2. dedup, 3. create", so that deduplication can also work on
transformed init data.
2025-11-14 15:12:30 -08:00
Wojciech Tyczyński cc73fc55da fix(Preload): Do not fetch license if delayLicenseRequestUntilPlayed is set (#9388)
DRM license is always fetched prior to play when there is no video
element. It was done like that to support offline scenario. But on
preload, we should delay license request if that was specified in
configuration.
2025-11-14 13:08:38 +01:00
Álvaro Velad Galván b1a7e7bb64 feat: Disable remote usage on TV, CONSOLE and CAST devices (#9375) 2025-11-07 16:48:16 +01:00
Julian Domingo e47c05dd6c fix: Properly assign shaka.extern.DrmInfo#mediaTypes (#9340)
Fixes https://github.com/shaka-project/shaka-player/issues/9339
2025-11-04 14:31:51 -08:00
Wojciech Tyczyński 708e520591 chore: Squash for..of loops in DRM probe support (#9295) 2025-10-27 14:32:02 +01:00
Julian Domingo 1ad34975ac feat(HLS): Add a mediaTypes field to shaka.extern.DrmInfo (#9198)
Close https://github.com/shaka-project/shaka-player/issues/9197
2025-10-14 12:53:25 -07:00
Wojciech Tyczyński 6d04f7f225 feat(net): Allow request filters to be called multiple times (#9129)
This change allows to execute request filter on every request attempt.
It can be useful i.e. to update credentials when first request fails.

New field `attempt` has been added to `shaka.extern.Request` which
informs which attempt is currently ongoing. This is needed to not do the
unnecessary work multiple times.

HTTP 401 Unauthorized and 403 Forbidden are no longer treated as
immediate critical errors, as tokens can be updated during retry
process.
2025-09-24 11:55:47 +02:00
Wojciech Tyczyński 3c0e9323dc perf: Speed up shaka.Player.probeSupport() (#9095)
Speed up execution of `shaka.Player.probeSupport()` which tends to be
super slow on Windows with HW DRM. Changes include several tweaks in DRM
probing:
- test only using `navigator.requestMediaKeySystemAccess()`, using
MediaCapabilities as well was redundant
- test HDCP only once
- drop HDCP tests once we know some version is unsupported

On Windows it speeds up execution from 20s to 0.7-1s.
2025-09-16 12:56:05 +02:00
Álvaro Velad Galván 4e1e9e66ec fix: Attach mediaKeys when the device does not force us to wait for the encrypted event (#9059)
Fixes https://github.com/shaka-project/shaka-player/issues/9032

Regression introduced in
https://github.com/shaka-project/shaka-player/pull/8497
2025-09-08 16:07:25 +02:00
Agajan J. d4e08097a0 fix: Session Update Error Handling For Youview Platform (#8918)
Fixes https://github.com/shaka-project/shaka-player/issues/8917
2025-07-28 10:44:03 +02:00
Wojciech Tyczyński 62dce4a0be fix(Offline): Fix persistent session removal (#8895)
Fixes #8882
Regression introduced in #8828
2025-07-21 17:09:53 +02:00
Wojciech Tyczyński c14e6cc060 perf(DRM): Run expiration timer only when EME is in use (#8853)
There is no need to poll expiration if content is not encrypted or EME
is not initialized yet.
2025-07-08 13:06:44 +02:00
Wojciech Tyczyński b0fde65500 chore: Move wait for encrypted event check to device API (#8833)
This info should be abstract to DRM Engine.
2025-07-03 11:51:02 +02:00
Wojciech Tyczyński fd7ee12c9d chore: Simplify DrmEngine queryMediaKeys() (#8828)
`queryMediaKeys()` was able to work both with variants and key system
configs. The latter option was needed only for `initForRemoval()`
method. By removing it we are able to make the logic more easy to
follow.
Additionally, compiled build is now 2 KB smaller.
2025-07-02 11:21:26 +02:00
Joey Parrish 7c1e31d4e6 chore: Add trailing commas to all record types (#8820)
Now that jsdoc supports this, it will make future diffs cleaner. See
#8819 and #1236.
2025-06-30 13:36:04 -07:00
Álvaro Velad Galván a61204e665 chore(EME): Remove cbcs-1-9 testing on probeSupport (#8817)
It's been removed because only the cenc and cbcs patterns are used.
cbcs-1-9 was added for FairPlay, but Safari uses cbcs for this use case.
2025-06-30 12:41:00 +02:00
Álvaro Velad Galván c00c9e4153 chore: Remove useless play listener when using delayLicenseRequestUntilPlayed as false (#8812) 2025-06-26 15:46:16 -07:00
Álvaro Velad Galván 4713909dd2 feat: Add shaka.extern.DrmSessionMetadata to LICENSE_REQUEST_FAILED error (#8788)
Related to
https://github.com/shaka-project/shaka-player/issues/1772#issuecomment-2979980293
2025-06-23 18:02:32 +02:00
Wojciech Tyczyński 796444dd8a chore: Remove session definition from SessionMetadata (#8756) 2025-06-17 16:51:54 +02:00
Wojciech Tyczyński 530c0c862f chore(DRM): DRM Engine init improvements (#8721)
- map `servers` and `advanced` config fields to maps once
- use `WeakSet` instead of `Set` to mark which objects have been
processed
2025-06-09 15:34:02 +02:00
Álvaro Velad Galván 642cecfc0e fix: Fix PlayReady support on Chromium Windows (#8683)
Related to https://github.com/shaka-project/shaka-player/pull/8682
2025-06-04 12:34:07 +02:00
Wojciech Tyczyński 970d7756ea feat: Add Device API (#8210)
The goal is to simplify and abstract feature logic detection. Currently
lots of places depend on various calls to `shaka.util.Platform` and
mainteinance of this is hard & not easy to read.

By introducing device API ideally rest of the player logic would look
into device features instead of directly checking platform. Additionally
we can more easily cache needed values, so we won't have to parse user
agent several times anymore.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-06-02 13:46:40 +02:00
Wojciech Tyczyński 03fd8f9368 chore(DRM): Remove getMediaKeySessions() (#8661) 2025-05-28 18:09:38 +02:00
Wojciech Tyczyński 784246b76f perf: Optimize DRM compatibility check across streams (#8652)
Do not create new DRM Info objects just for compatibility checks.
2025-05-28 12:57:34 +02:00
Álvaro Velad Galván 3c32f7a049 fix(DASH): Inconsistent DRM across periods when using clearkeys (#8602)
Fixes #8559
2025-05-13 13:50:08 +02:00
Álvaro Velad Galván 80972bffb6 chore: Simplify clearMediaKeySystemAccessMap (#8592) 2025-05-13 06:31:36 +02:00
Agajan J. f987f451ab fix: Sony Bravia TV Playready DRM Failure (#8577)
Fixes https://github.com/shaka-project/shaka-player/issues/8576
Browser on this Sony TV returns little-endian, which results in
false-positive unsupported key system. Looks like this is a known issue
impacting couple of other platforms as well. I need to add this TV as
well.
2025-05-09 10:05:21 +02:00
Álvaro Velad Galván f6df1f0b96 fix: Fix Firefox PlayReady support (#8497)
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1806566 and
https://bugzilla.mozilla.org/show_bug.cgi?id=1960673
This also adds mapping for other browsers on Windows, since Chromium is
working on the same functionality
(https://issues.chromium.org/issues/378869813).
2025-04-25 15:14:06 +02:00
Álvaro Velad Galván 8bab3a1762 chore: Add more PlayReady keysystems (#8495) 2025-04-22 12:23:31 +02:00
Gary Katsevman 9ba8ceb606 fix: Only expand robustness on each stream once (#8458)
Without this change, `expandRobustness` ended up running 480 times for
the stream `Angel One (multicodec, multilingual, Widevine)` with
`SW_SECURE_CRYPTO,SW_SECURE_CRYPTO,SW_SECURE_CRYPTO` set up as the
multiple robustness. With it, it only runs 44 times, which is expected
because there are 22 unique streams, and it expands `videoRobustness`
and `audioRobustness` on each.

Fixes #8408
2025-04-15 10:16:59 +02:00
Wojciech Tyczyński 25021bbda7 fix(HLS): Add key ids to Fairplay DRM parser (#8371)
Related to #8335 
This will allow us to put key id into fake encryption boxes.
2025-04-01 13:39:03 +02:00
Álvaro Velad Galván b2d62cbd3c chore: Remove some artificial limitations in probeSupport (#8330) 2025-03-24 18:31:24 +01:00
Joey Parrish 07d564ad85 test: Reject all FF+Windows DRM testing in the lab (#8271)
Firefox 136 running on Windows in our lab seems to crash when accessing
the CDM. This happens in our background Windows service, but not in the
foreground when run as a regular user. We don't really understand the
nature of it, so we have to disable this in lab tests.

This reverts commit eda85d6607 (#8173),
but then goes a bit further:

 - Add a flag to we know if we're running in the lab
- Narrow the workaround to lab test runs, not local runs or GitHub
Actions VM workflows
2025-03-13 14:35:17 -07:00
Álvaro Velad Galván c2ce68fba8 feat: Move shaka.util.FairPlayUtils to shaka.drm.FairPlay (#8217) 2025-03-06 12:43:49 +01:00
Álvaro Velad Galván 9ba31325ea chore: Move isMediaKeysPolyfilled to DrmUtils (#8216) 2025-03-05 16:03:48 +01:00
Álvaro Velad Galván eda85d6607 test: Fix crash of Firefox on Windows (#8173)
Fixes 9aea3587ef as it should only occur
with ClearKey
2025-02-26 15:53:35 +01:00
Álvaro Velad Galván 6ffc30210e fix: Remove timeout for decodingInfo in some platforms and increase the timeout (#8172) 2025-02-26 15:37:27 +01:00
Álvaro Velad Galván 2573af7bd7 fix: Avoid DRM setup for VOD that does not need it (#8154)
Now we only set up DRM in advance for live streams that might add it
later.
2025-02-25 10:43:41 +01:00
Joey Parrish 450fb5943c test: Reject all FF+Windows ClearKey testing (#8122)
My previous change, #8109, didn't go far enough. In a full test run,
some ClearKey tests still crash Firefox in the lab. By removing it from
the support dictionary used to gate DRM tests, we ensure all ClearKey
tests are skipped.
2025-02-20 08:54:10 -08:00
Joey Parrish 9aea3587ef test: Fix crash of Firefox on Windows (#8109)
Our automated test lab runs Windows browsers under a headless service.
In this environment, Firefox's ClearKey CDM seems to crash when we
create the CDM in probeSupport().

To avoid this, we check for a debug or uncompiled build running in
Firefox on Windows, and if this combination is found, we skip
createMediaKeys() in probeSupport().

Because the check uses the compile-time constant goog.DEBUG, we avoid
any penalty in a production build.
2025-02-18 21:37:16 -08:00
Wojciech Tyczyński 09b3333afe fix: Install Safari workarounds on WPE STBs (#8103)
Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-02-18 15:34:47 +01:00