Skip to content

[HLS] Support FairPlay-signaled CMAF with ClearKey - #2105

Merged
CastagnaIT merged 1 commit into
xbmc:Piersfrom
ldzhjn:hls-fairplay-clearkey-cmaf
Aug 30, 2026
Merged

[HLS] Support FairPlay-signaled CMAF with ClearKey#2105
CastagnaIT merged 1 commit into
xbmc:Piersfrom
ldzhjn:hls-fairplay-clearkey-cmaf

Conversation

@ldzhjn

@ldzhjn ldzhjn commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Description

Preserve a 128-bit hexadecimal KID from a FairPlay skd:// URI and expose the
track encryption KID as Common Encryption information when an encrypted CMAF
initialization segment contains no usable PSSH box.

This allows a user-configured ClearKey decrypter to open SAMPLE-AES fMP4
streams that use FairPlay HLS signaling. It does not implement FairPlay key
management or license acquisition.

Motivation and context

Some CMAF HLS streams signal KEYFORMAT="com.apple.streamingkeydelivery" and
use cbcs, while carrying the default KID only in the skd:// URI and/or the
track's tenc box. Without a PSSH box, the initialization segment previously
returned no DRM information, so the ClearKey session could not be matched to
the configured KID.

The parser now accepts only skd:// values that normalize to exactly 16 bytes
of hexadecimal data. Other FairPlay asset identifiers remain unchanged.

How has this been tested?

  • All 62 native unit tests pass on macOS.
  • Added an HLS regression test for a hyphenated, uppercase skd:// KID and
    SAMPLE-AES/CBC mode.
  • Built successfully for tvOS arm64 against Kodi 22 Addon API 2.0.3.
  • Verified playback of a 3840x2160 50 fps HEVC 10-bit CBCS CMAF HLS stream on
    Apple TV using a configured ClearKey, including video and audio decryption.

Screenshots (if appropriate):

Not applicable.

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • I have read the Contributing document
  • My code follows the Code Guidelines of this project
  • My change requires a change to the Wiki documentation
  • I have updated the documentation accordingly

@CastagnaIT CastagnaIT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not bad idea but needs a bit of more cleanups

Comment thread src/samplereader/FragmentedSampleReader.cpp Outdated
Comment thread src/parser/HLSTree.cpp Outdated
Comment thread src/parser/HLSTree.cpp Outdated
Comment thread src/parser/HLSTree.cpp Outdated
Comment thread src/parser/HLSTree.cpp Outdated
Comment thread src/parser/HLSTree.cpp Outdated
Comment thread src/parser/HLSTree.cpp Outdated
Comment thread src/parser/HLSTree.cpp Outdated
@ldzhjn
ldzhjn force-pushed the hls-fairplay-clearkey-cmaf branch from 5093ede to 32b5c77 Compare August 30, 2026 12:19
@ldzhjn

ldzhjn commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

@CastagnaIT PTAL

Comment thread src/parser/HLSTree.cpp
@ldzhjn
ldzhjn force-pushed the hls-fairplay-clearkey-cmaf branch from 32b5c77 to 354be35 Compare August 30, 2026 12:52
Preserve a hexadecimal KID from FairPlay skd URIs and expose the tenc KID as Common Encryption information when an encrypted CMAF initialization segment has no usable PSSH. This allows a configured ClearKey decrypter to open SAMPLE-AES fMP4 streams without adding FairPlay key management.
@ldzhjn
ldzhjn force-pushed the hls-fairplay-clearkey-cmaf branch from 354be35 to 3ad066b Compare August 30, 2026 12:53
@ldzhjn
ldzhjn requested a review from CastagnaIT August 30, 2026 12:55
@CastagnaIT CastagnaIT added Type: Improvement non-breaking change which improves existing functionality Component: HLS v22 Piers DRM: ClearKey labels Aug 30, 2026

@CastagnaIT CastagnaIT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some tests i think its ok
thank you

@CastagnaIT
CastagnaIT merged commit 50c4ef3 into xbmc:Piers Aug 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: HLS DRM: ClearKey Type: Improvement non-breaking change which improves existing functionality v22 Piers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants