feat(hls): license a FairPlay-only SAMPLE-AES playlist through a PlayReady or Widevine CDM

This commit is contained in:
imSp4rky
2026-11-30 19:36:01 -07:00
parent c41d8ec3cf
commit b826eccb86
9 changed files with 449 additions and 98 deletions
+22 -3
View File
@@ -474,7 +474,25 @@ that needs a process on the server also works for a remote client.
A media playlist can name only a key system that unshackle does not read, such as an `skd://` key
over cbcs media, while the licence server of the platform also issues the same content key over
PlayReady or Widevine. To license such a track through one of those systems:
PlayReady or Widevine. `HLS.download_track` licenses such a track with no service code when all of
these conditions are true:
- The track has no DRM object.
- Every `EXT-X-KEY` of its media playlist is `SAMPLE-AES` or `SAMPLE-AES-CTR` for a DRM system
unshackle cannot license.
- The configured CDM is a PlayReady or Widevine CDM.
- The init segment (`EXT-X-MAP`) of the track names a key ID in its `tenc` box. When the `tenc` key ID is all
zeros, its `pssh` boxes must name exactly one key ID, and the encrypted segments must have one init
segment and the playlist one key URI. MPEG-TS media has no init segment.
- The init segment does not change without an `EXT-X-DISCONTINUITY`.
The download reads the key ID from the init segment, builds a DRM object for the DRM system of the
CDM with `drm_stub`, and sends the challenge to the licence callback of the service. Over `--remote`
the server reads the same key ID at the licence step, so it accepts the DRM object of the client. A
licence that gives no content key stops the track before it downloads a segment.
A service that must choose the DRM system itself, or one that knows the key ID, puts the DRM object
on the track:
1. Read the key ID from the init segment of the track. `HLS.get_track_kid_from_init` returns it.
2. Put a DRM object that names the key ID on the track: `drm_stub` from `unshackle.core.drm.cenc`
@@ -488,8 +506,9 @@ content key of one package of a title and refuse another. When a track carries a
object and every `EXT-X-KEY` of its playlist is `SAMPLE-AES` or `SAMPLE-AES-CTR` for a key system
unshackle cannot license, `HLS.drop_unsupported_keys` removes the tags from the parsed playlist.
The download then licenses and decrypts the track with the DRM object of the track. This works for
one content key per track: the key changes of the playlist go with the tags. A track with no such
DRM object stops with `None of the key systems are supported` before it downloads a segment.
one content key per track: the key changes of the playlist go with the tags. This limit also
applies to a DRM object that the download builds. Any other track stops with
`None of the key systems are supported` before it downloads a segment.
### How unshackle chooses a CDM and finds keys