Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline clear key drm #3178

Closed
mhassanist opened this issue Aug 16, 2017 · 9 comments
Closed

Offline clear key drm #3178

mhassanist opened this issue Aug 16, 2017 · 9 comments

Comments

@mhassanist
Copy link

Is there a clear simple way now to implement Clear Key DRM in ExoPlayer 2 ?
I have the keyID and KeyValue and the video URL is online however the keys are stored offline. I just want to set the keys by hand instead of getting them from license server.

@ojw28
Copy link
Contributor

ojw28 commented Aug 16, 2017

Clarification around ClearKey support is tracked by #3138.

@ojw28 ojw28 closed this as completed Aug 16, 2017
@mhassanist
Copy link
Author

I'm able to get the clear key to work if I put the response on the server.
http://ec2-52-42-32-95.us-west-2.compute.amazonaws.com/shaka/shaka_final/request.php

My question is how to set those values on the player without requesting it from online server.

@ojw28
Copy link
Contributor

ojw28 commented Aug 16, 2017

You will have to implement a MediaDrmCallback that provides a local response.

@mhassanist
Copy link
Author

Thanks a lot for your replay.

Do you have or can provide any example or sample code for this ?

@mhassanist
Copy link
Author

I made this. But not sure how to return the key value from these methods.

public class MyDRMCallBack implements MediaDrmCallback {
    @Override
    public byte[] executeProvisionRequest(UUID uuid, ExoMediaDrm.ProvisionRequest request) throws Exception {
        return new byte[0];
    }

    @Override
    public byte[] executeKeyRequest(UUID uuid, ExoMediaDrm.KeyRequest request) throws Exception {
        return new byte[0];
    }
}

@ojw28
Copy link
Contributor

ojw28 commented Aug 16, 2017

I don't think provisioning is relevant. For the key request you'll need to respond with whatever the server response would be.

@mhassanist
Copy link
Author

mhassanist commented Aug 16, 2017

It worked thank yo very much for your support.
Here is the final class is some one needs it.


import com.google.android.exoplayer2.drm.ExoMediaDrm;
import com.google.android.exoplayer2.drm.MediaDrmCallback;
import java.util.UUID;

public class MyDRMCallBack implements MediaDrmCallback {

    String keyString;

    @Override
    public byte[] executeProvisionRequest(UUID uuid, ExoMediaDrm.ProvisionRequest request) throws Exception {
        return new byte[0];
    }

    public MyDRMCallBack(String keyId, String keyValue) {
        this.keyString = "{\"keys\":[{\"kty\":\"oct\",\"k\":\""+keyValue+"\",\"kid\":\""+keyId+"\"}],\"type\":\"temporary\"}";;
    }

    @Override
    public byte[] executeKeyRequest(UUID uuid, ExoMediaDrm.KeyRequest request) throws Exception {
        return keyString.getBytes();
    }
}

@ojw28
Copy link
Contributor

ojw28 commented Aug 16, 2017

Glad you got it working! You can probably throw UnsupportedOperationException from executeProvisionRequest, since you're basically not supporting it :). The ClearKey CDM should never request provisioning from the callback, as far as I'm aware.

@ojw28
Copy link
Contributor

ojw28 commented Aug 16, 2017

By the way, how would you feel about making a pull request to contribute this back to the dev-v2 branch, in the drm package, called something like LocalClearKeyMediaDrmCallback? Please feel free to send a pull request if you're able.

ojw28 added a commit that referenced this issue Aug 29, 2017
Issue: #3178

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166330215
ojw28 added a commit that referenced this issue Sep 6, 2017
Issue: #3178

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166330215
@google google locked and limited conversation to collaborators Dec 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants