Skip to content

Apple FairPlay DRM

Getting Started

SpatialGen has direct integration of Apple’s FairPlay DRM to secure your video content. Reach out to the team at contact@spatialgen.com and they can help you add FairPlay to your account.

Fairplay Streaming Workflow

During playback, your App will need to request the decryption keys for your videos. SpatialGen DRM is hosted at drm.spatialgen.com, and all requests in the FairPlay workflow will be made to this url.

The FairPlay workflow requires two pieces of information from your App. When the HLS Stream is first requested, the playlist (.m3u8) file will contain an AssetId to identify the stream. Next, when playback of a FairPlay video begins, the devices’ Operating System (e.g. VisionOS or iOS), will generate a Server Playback Context (SPC) based on the AssetId.

Both the AssetId and SPC will be sent to the SpatialGen DRM server where the decryption key will be generated and returned as a Content Key Context (CKC) which your App will use to play the encrypted video. Learn more about the FairPlay Streaming workflow at developer.apple.com.

Requsting CKCs

POST /fairplay/spc

Send a POST request to the SpatialGen DRM server with the SPC and AssetId to receive the CKC. The body of the post request should contain the SPC and AssetId in JSON format. The SPC should be sent as a base64 encoded string.

A successful request will return a JSON object containing the CKC as a base64 encoded string. Your app will be responsible for decoding the CKC into a raw Buffer to use as the decryption key.

Example Request

fetchFairplayCKC.js
// Example data to send
const data = {
asset_id: "<asset_id>",
spc: "<base64 encoded SPC>"
};
// Fetch call
fetch('https://drm.spatialgen.com/fairplay/spc', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-SPATIALGEN-APPKEY': apiKey
},
body: JSON.stringify(data)
})

Example Response

response
{
ckc: "<base64 encoded CKC>"
}