Skip to content

Basic ClearKey support

Created by: CSilivestru

Hello!

I was experiencing the similar issues as in https://github.com/Dash-Industry-Forum/dash.js/issues/2249

Why am I Submitting this?

After quite a bit of digging, I discovered that the ClearKey ContentProtection information in my manifest was being ignored since they did not have pssh entry. This is not the case with the Shaka player so I am submitting this as a fix. My understanding is that ClearKeys only need the key id specified and the actual key used should simply be provided to the player for use at the time of playback.

What did I do?

In the case of a ClearKey key system, I would still push that as a supported KeySystem. Since, at that time, I do not yet have the actual decryption key, I need to set initData to null so that I can properly set it later with my key. I'm not sure if this is the best way of doing it but it seems to follow the correct event handlers since ClearKey doesn't need to communicate with a CDM

I'm extremely new to everything involved in dash and DRM systems in general so please please let me know if I'm way off base here with my proposed solution.

My Testing

I tested this solution by encrypting a video file with the following very simple crypt.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<GPACDRM type="CENC AES-CTR">
  <CrypTrack IV_size="16" isEncrypted="1" saiSavedBox="senc" trackID="1">
    <key KID="0x02030507011013017019023029031037" value="0x03050701302303204201080425098033"/>
  </CrypTrack>
</GPACDRM>

The command I used was:

mp4box -segment-name oceans_encrypted_%s -profile live -dash-strict 10000 -sample-groups-traf -bs-switching no -out "manifest.mpd" audio_only_encrypted.m4a video_only_encrypted.mp4

This would produce the following manifest (after I switched the generic xmlns to the proper keyids one:

<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.7.2-DEV-revUNKNOWN-master  at 2017-11-01T20:11:12.294Z-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500S" type="static" mediaPresentationDuration="PT0H0M46.614S" maxSegmentDuration="PT0H0M13.430S" profiles="urn:mpeg:dash:profile:isoff-live:2011" xmlns:cenc="urn:mpeg:cenc:2013">
 <ProgramInformation moreInformationURL="http://gpac.io">
  <Title>manifest.mpd generated by GPAC</Title>
 </ProgramInformation>

 <Period duration="PT0H0M46.614S">
  <AdaptationSet segmentAlignment="true" lang="und">
   <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="02030507-0110-1301-7019-023029031037"/>
   <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" startWithSAP="1" bandwidth="97849">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
    <SegmentTemplate media="oceans_encrypted_audio_only_encrypted$Number$.m4s" timescale="48000" startNumber="1" duration="479232" initialization="oceans_encrypted_audio_only_encryptedinit.mp4"/>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" maxWidth="960" maxHeight="400" maxFrameRate="24000/1001" par="960:400" lang="und">
   <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="02030507-0110-1301-7019-023029031037"/>
   <Representation id="2" mimeType="video/mp4" codecs="avc1.42C01E" width="960" height="400" frameRate="24000/1001" sar="1:1" startWithSAP="1" bandwidth="3866238">
    <SegmentTemplate media="oceans_encrypted_video_only_encrypted$Number$.m4s" timescale="24000" startNumber="1" duration="269019" initialization="oceans_encrypted_video_only_encryptedinit.mp4"/>
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>

After all this, I'm currently using the related video-dash-contrib plugin and initializing it like so:

player.ready(() => {
  player.src({
    src: 'http://localhost:8080/serve/files/manifest.mpd',
    type: 'application/dash+xml',
    keySystemOptions: [
      {
        name: 'org.w3.clearkey',
        options: {
          clearkeys: {
            'AgMFBwEQEwFwGQIwKQMQNw' : 'AwUHATAjAyBCAQgEJQmAMw'
          }
        }
      }
    ]
  });
})

This all works on my current branch when loading all libraries locally. On the development branch, the video buffers forever and no DRM events are logged.

Merge request reports