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
+8
View File
@@ -77,6 +77,12 @@ To download a Widevine-protected title you need a `.wvd` device. For PlayReady y
need a `.prd` device. You can hold both, and unshackle automatically selects the
appropriate one for each track.
!!! note "HLS tracks with only a FairPlay key tag"
unshackle has no FairPlay CDM. When each `EXT-X-KEY` of an fMP4 playlist is sample encryption
for a DRM system that unshackle cannot license, such as FairPlay, unshackle reads the key ID from
the init segment and asks for the licence with your PlayReady or Widevine device. This works
only when the licence server of the platform also issues that content key for that DRM system. MPEG-TS SAMPLE-AES stops with an error.
!!! info "Obtaining device files"
A `.wvd` or `.prd` encodes the private keys of a real client device. unshackle
does **not** ship with one and cannot make the underlying secret material for
@@ -568,6 +574,8 @@ unshackle dl --skip-dl --all-drm --export EXAMPLE 81234567
system does not license, so the title fails unless you use `--best-available`.
- An HLS playlist that changes its `EXT-X-KEY` entries part-way: only the first set
licenses with the second system.
- An HLS playlist with only FairPlay key tags: the DRM system of the configured CDM
licenses it.
- A remote session that the server CDM licenses, and `unshackle import`. unshackle
shows a warning and ignores the flag.
- A remote CDM that stores content keys can answer without a challenge to the service.