ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Persistent DRM license

Open haitech opened this issue 11 years ago • 10 comments

We are currently experimenting with ExoPlayer on our app for streaming, the currently setup is DASH+Widevine and it works perfectly. Now we want our users to be able to watch the content offline as well. This means we have to support persistent license and mpeg4+DRM. We are currently using Widevine for the license server. So our question is, does the exoplayer support persistent license? If yes, how can we acquire the persistent license? If no, is there any plan to support this?

haitech avatar Jul 18 '15 00:07 haitech

Android does support offline with Widevine via the MediaDrm interface. You'd need to implement your own DrmSessionManager that will be somewhat similar to StreamingDrmSessionManager, but will handle storage/retrieval of offline licenses. You'd also need to implement a downloader for obtaining the licenses and actually downloading the media, and you'd probably need a database to keep track of what's downloaded.

We don't provide out-of-the-box support for offline because the best approach generally requires tight integration with the rest of an application (e.g. using existing tables in an existing application database, using existing transfer logic to implement the media downloading and so on).

ojw28 avatar Jul 20 '15 09:07 ojw28

@ojw28 thanks for quick reply. We already implemented the downloading part for the media, but not the license retrieval. Good to know that Android support the offline license, we will take a look into DrmSessionManager and implement our own

haitech avatar Jul 20 '15 09:07 haitech

One caveat is the supported API levels. Google Play Movies has only adopted this approach from Lollypop onward due to issues found in earlier releases. You should probably try and build a minimal example and see how it works for you. If you have a contact at Widevine, it's worth asking them for guidance on what API levels are properly supported also.

ojw28 avatar Jul 20 '15 10:07 ojw28

Aha, good to know. We will take a look into that and see what we decide to do. Hopefully one of our partners should have a contact at Widevine that can help us further with that, thanks you.

haitech avatar Jul 20 '15 11:07 haitech

Hi @haitech, has you managed the offline license acquisition somehow? I am trying to implement custom DrmSessionManager and based on StreamingSessionManager, I came up with this method to get KeyRequest:

public MediaDrm.KeyRequest getKeyRequest(byte[] drmInitData) {
    open();
    try {
        return mediaDrm.getKeyRequest(sessionId, drmInitData, "video/mp4", MediaDrm.KEY_TYPE_OFFLINE, null);
    } catch (NotProvisionedException e) {
        onError(e);
    }
    return null; 
}

But I don't know where should I get drmInitData. Do you have a clue?

traninho avatar Apr 22 '16 10:04 traninho

@traninho If you are building it based on the StreamingSessionManager you should find a variable named schemeInitData.data this is the value that you should be using and not passing the drmInitData as a parameter.

hakemcpu avatar May 18 '16 10:05 hakemcpu

@ojw28 @hakemcpu

For licenses to be persisted, should playback happen at least once for a particular content/asset?

From what I understand, widevine licenses are device specific, so there is no way to have a generic license that is compatible across many devices for the same content/asset.

So, there's no way to make licenses entirely offline without any playback?

nitin02 avatar Sep 22 '16 11:09 nitin02

There is no requirement to play anything. You need to perform a MediaDrm key request/response, but there's nothing that ties this to occurring as part of a playback.

ojw28 avatar Sep 22 '16 11:09 ojw28

The content is encrypted with CENC and hence a license response is needed for playback. So, is there a widevine license response that is generic enough to be playable irrespective of the device (for a particular content).

nitin02 avatar Sep 22 '16 12:09 nitin02

If you could create a single response that could be used to play the content on any device, then what would the addition of DRM actually achieve? The response could be easily captured and then used to play the content arbitrarily on any device, which seems like it would defeat the purpose.

So to answer your question: Yes, to play a piece of content offline the device needs to have made a license request and received the response. A response is tied to the device that generated the request. There is no requirement to actually play media to perform a license request. In a typical scenario an application will have to download the media for offline playback, and would make the license request as part of the process of downloading the media (probably as a first step).

ojw28 avatar Sep 22 '16 22:09 ojw28