Skip to content

[RFC][DRM] Recognise FairPlay key system names in the DRM property - #2148

Closed
keithah wants to merge 1 commit into
xbmc:Piersfrom
keithah:fairplay-kodi-native
Closed

keithah wants to merge 1 commit into
xbmc:Piersfrom
keithah:fairplay-kodi-native

Conversation

@keithah

@keithah keithah commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Draft, request for comments. One of three linked drafts about FairPlay Streaming on Apple platforms. The design discussion is in the Kodi one; this PR is deliberately small, and the main thing I am asking for here is your opinion on the questions at the end.

Repository Draft What it holds
xbmc/xbmc xbmc/xbmc#30942 The player, the license exchange, the routing, System.HasFairPlay
xbmc/inputstream.adaptive this PR FairPlay key system names in the drm property, a sample
script.module.inputstreamhelper emilsvennesson/script.module.inputstreamhelper#653 FairPlay as a DRM scheme add-ons can ask for

Description

  • Adds DRM::IsFairPlayKeySystem(). It is true for com.apple.fairplay (the name this add-on already uses as KS_FAIRPLAY) and for com.apple.fps with or without a version suffix (the EME name, which is what Safari based players and most service APIs use).
  • A FairPlay entry in the inputstream.adaptive.drm property is skipped with an info line that says why, instead of the error Ignored unknown key system.
  • Adds one FairPlay sample to plugin.video.isasamples.
  • Adds a unit test for the name check.

No decrypter is added and nothing changes for other key systems.

Motivation and context

Why FairPlay cannot be a decrypter here

This add-on already notes in HLSTree.cpp that FairPlay key management is unsupported. That is not a gap that can be filled from inside ISA:

  • Only Apple's media pipeline can decrypt FairPlay content.
  • Handing the system samples that an app demuxed itself, together with a key, needs a private entitlement (AVSampleBufferAttachContentKey fails with -11836 without it). I tested that.
  • The only public route is to give AVPlayer the HLS URL and answer its key requests through AVContentKeySession. The stream then never passes through an inputstream add-on or VideoPlayer.

What the Kodi draft does instead

xbmc/xbmc#30942 adds a player core for Apple platforms that plays such items itself. To keep the work for add-on authors small, it reads the same properties add-ons already set for this add-on:

li.setProperty('inputstream', 'inputstream.adaptive')
li.setProperty('inputstream.adaptive.drm', json.dumps({
    'com.apple.fps': {'license': {
        'server_url': license_url,
        'server_certificate_url': certificate_url,
        'req_headers': 'Authorization=Bearer ...',
    }}}))

Kodi routes an item with a FairPlay entry to its own player before any inputstream add-on is opened, so on Apple platforms ISA never sees it. It honours server_url, server_certificate, req_headers, req_data, wrapper, unwrapper, unwrapper_params, and the manifest_headers / stream_headers properties, with the meaning they have here.

Why this PR is still needed

  • An add-on can set a Widevine and a FairPlay configuration on the same item and let the platform decide. Today that logs an error on every non-Apple platform.
  • It puts the key system names in one place, so both projects agree on them.
  • The sample gives everyone a stream to test with.

What I would like your view on

  1. Ownership of the schema. Kodi core reading inputstream.adaptive.* properties is the cheapest thing for add-on authors, but it means core depends on a schema this add-on owns. Are you comfortable with that, or would you prefer neutral property names that both read?
  2. Shared license code. Kodi repeats part of the license request logic that lives here (request templates, wrappers, unwrappers). An alternative is that ISA performs the license request and Kodi only passes the SPC in and takes the CKC out, over a new add-on interface. I did not do that because it makes ISA a hard dependency for a path it cannot play and needs an API change, but it would give the license code one owner. Add-ons would see no difference, so it can still be done later.
  3. Key system name. com.apple.fairplay or com.apple.fps in the documentation? Kodi accepts both.
  4. FairPlay-only fields. FairPlay needs a content identifier and placeholders for the SPC ({SKD}, {SKD-ID}, {CHA-B64} and so on, described in the Kodi draft). They are additions to the license object. Do the names fit your conventions?
  5. Documentation. The wiki page for the DRM property would need a FairPlay section. I can draft it once the questions above are settled.

How has this been tested?

  • Built for macOS arm64 as a Kodi binary add-on. All 67 unit tests pass, including the new one.
  • With this build installed in Kodi from the linked draft: a FairPlay item that names inputstream.adaptive plays through Kodi's player, and a ClearKey HLS item still plays through this add-on and VideoPlayer.
  • Not tested at run time: the new log line. On Apple platforms Kodi routes FairPlay items away before this add-on is opened, so that path only runs on other platforms, which I have not built.
  • The sample entry was checked for syntax and its stream plays in Kodi from a .strm with the same configuration; it was not started from the samples plugin itself.

Screenshots (if appropriate):

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

🤖 Generated with Claude Code

FairPlay Streaming can only be decrypted by the system player of Apple
platforms, so Kodi plays such streams itself there and reads the same
"drm" property for the license configuration. An add-on that sets both
a FairPlay and a Widevine configuration got an "unknown key system"
error from here; it is now skipped with an explanation.

Both the name used in this add-on (com.apple.fairplay) and the EME one
(com.apple.fps) are accepted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@keithah

keithah commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Withdrawing this for now. It changes nothing functionally: on Apple platforms Kodi plays FairPlay items itself before this add-on is opened, so all this did was turn one log line from an error into an info message on other platforms. I would rather not add code here without a need. The question of whether you want anything changed in this add-on is asked in xbmc/xbmc#30942, and I will reopen this if you do.

@keithah keithah closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant