Axinom

Integrating USP with Axinom DRM

The following script shows how to create a single Axinom DRM compatible USP server manifest and an Axinom DRM License Token, which can then be used to playback content protected by Widevine, PlayReady or FairPlay DRM.

Demo players for testing playback with each DRM are provided further below.

The script covers the following steps:

  1. Get Content Key, Key ID, Key IV and "pssh" data from Axinom Widevine Key Server ("pssh" data is optional as USP can create it on-the-fly for instance when the source is PIFF secured, e.g. PlayReady encrypted)
  2. Create USP server manifest that supports Widevine, PlayReady and FairPlay content
  3. Generate Axinom DRM License Token (customer- and content-specific data that is sent as HTTP header to Axinom license servers to authenticate the user and configure licenses)

Overall steps to test integration:

  1. Meet the "prerequisites" mentioned in the beginning of the script
  2. Run the script
  3. Note down the License Token printed by the script
  4. Test playback using players and settings provided below

Server manifest and License Token creation script

#!/bin/bash

# Prerequisites
#
# Install Python PyJWT Library to generate Axinom DRM License Tokens (for testing playback)
#   - Install Python PIP package manager: "sudo apt-get -y install python-pip"
#   - Install the library: "sudo pip install pyjwt"
#
# Adapt the following fields in the script to suit your needs:
#   - Set "com_key" to your Axinom Communication Key
#   - Set "com_key_id" to your Axinom Communication Key ID
#   - Adjust the "mp4split ..." command line to your media

com_key=""
com_key_id=""

# Obtain KID and CEK from Axinom Key Widevine Server
key_request=`curl -v -X POST \
  -d '{"request": "eyJjb250ZW50X2lkIjoiTUVJek5UQkRNRGd0TkVKRFFpMDBRamsyTFVFNE56TXRPRU15TkVZMlJUazVNVU0xIiwiZHJtX3R5cGVzIjpbIldJREVWSU5FIiwiUExBWVJFQURZIiwiRkFJUlBMQVkiXSwidHJhY2tzIjpbeyJ0eXBlIjoiQVVESU8ifSx7InR5cGUiOiJTRCJ9LHsidHlwZSI6IkhEIn1dfQ==", "signature": "qpMpyKOhL6ShcKD4nBkLTm8MbAblxak2X8cSy2vqsLA=", "signer": "widevine_test" }' \
  'http://keyserver.axtest.net/api/getcontentkey'`

key_response=$(echo $key_request | python -c 'import json,jwt,sys,base64;obj=json.load(sys.stdin);print base64.b64decode(obj["response"])')

kid64=$(echo $key_response | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["tracks"][0]["key_id"]')
cek64=$(echo $key_response | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["tracks"][0]["key"]')
iv64=$(echo $key_response | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["tracks"][0]["iv"]')
widevine_pssh64=$(echo $key_response | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["tracks"][0]["pssh"][0]["data"]')

# Convert to base16
kid16=$(echo $kid64 | base64 -d | hexdump -e '16/1 "%02x"')
cek16=$(echo $cek64 | base64 -d | hexdump -e '16/1 "%02x"')
iv16=$(echo $iv64 | base64 -d | hexdump -e '16/1 "%02x"')

# Convert KID to UUID
kid_uuid=`echo -n $kid16 | python -c 'import base64,uuid,sys; kid=sys.stdin.readline(); print uuid.UUID(kid)'`

# Set USP server manifest options
options_widevine+=" --widevine.key=${kid16}:${cek16}"
options_widevine+=" --widevine.drm_specific_data=${widevine_pssh64}"
options_widevine+=" --widevine.license_server_url=https://drm-widevine-licensing.axtest.net/AcquireLicense"

options_playready+=" --iss.key=${kid16}:${cek16}"
options_playready+=" --iss.license_server_url=https://drm-playready-licensing.axtest.net/AcquireLicense"

options_fairplay+=" --hls.key=:${cek16}"
options_fairplay+=" --hls.key_iv=${iv16}"
options_fairplay+=" --hls.license_server_url=skd://${kid_uuid}"
options_fairplay+=" --hls.playout=sample_aes_streamingkeydelivery"

mp4split_options="${options_widevine} ${options_playready} ${options_fairplay}"

# Create USP server manifest (NB! Adjust input/output to your needs)
mp4split -o video.ism ${mp4split_options} video.ismv video.isma

# Generate Axinom DRM License Token (NB! Note down the generated token value to use it for playback)
drm_message='{"version":1,"com_key_id":"'$com_key_id'","message":{"type":"entitlement_message","keys":[{"id":"'$kid_uuid'", "iv":"'$iv64'"}]}}'
drm_message_jwt=$(echo -n $drm_message | python -c 'import sys,base64,json,jwt;obj=json.load(sys.stdin);print jwt.encode(obj, base64.b16decode("'$com_key'", True), algorithm="HS256")')

echo "Axinom DRM License Token: ${drm_message_jwt}"

Test playback

Playback of USP "on-the-fly" packaged and DRM-protected content, utilizing Axinom DRM, can be tested using web-players on Axinom Video Test-Bench page.

Playback of Widevine and PlayReady protected content

Player URL:

http://vtb.axinom.com/index.html

Fill the following fields:

  • Stream URL: <your_usp_server_manifest.ism_url>/.mpd
  • Token: <your_axinom_drm_license_server_token>
  • License server:
    1. for Widevine: https://drm-widevine-licensing.axtest.net/AcquireLicense
    2. for PlayReady: https://drm-playready-licensing.axtest.net/AcquireLicense

Playback of FairPlay protected content

Player URL:

http://vtb.axinom.com/fairplay_streaming_sample_player.html

Fill the following fields:

  • Stream URL: <your_usp_server_manifest.ism_url>/.m3u8
  • Token: <your_axinom_drm_license_server_token>
  • License server: https://drm-fairplay-licensing.axtest.net/AcquireLicense
  • FPS Certificate URL: <your_fairplay_streaming_application_certificate.cer_url>

Note

A FairPlay player also requires an URL to the customer-specific FairPlay Streaming Application Certificate, provided by Apple to content-owners to enable FairPlay DRM on their playback applications.