Search in sources :

Example 1 with KeyRequest

use of com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest in project ExoPlayer by google.

the class DefaultDrmSessionManager method postKeyRequest.

private void postKeyRequest(byte[] scope, int keyType) {
    try {
        KeyRequest keyRequest = mediaDrm.getKeyRequest(scope, schemeInitData, schemeMimeType, keyType, optionalKeyRequestParameters);
        postRequestHandler.obtainMessage(MSG_KEYS, keyRequest).sendToTarget();
    } catch (Exception e) {
        onKeysError(e);
    }
}
Also used : KeyRequest(com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest) NotProvisionedException(android.media.NotProvisionedException) DeniedByServerException(android.media.DeniedByServerException)

Example 2 with KeyRequest

use of com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest in project ExoPlayer by google.

the class OfflineLicenseHelperTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(mediaDrm.openSession()).thenReturn(new byte[] { 1, 2, 3 });
    when(mediaDrm.getKeyRequest(any(), any(), anyInt(), any())).thenReturn(new KeyRequest(/* data= */
    new byte[0], /* licenseServerUrl= */
    "", KeyRequest.REQUEST_TYPE_INITIAL));
    offlineLicenseHelper = new OfflineLicenseHelper(new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(C.WIDEVINE_UUID, new ExoMediaDrm.AppManagedProvider(mediaDrm)).build(mediaDrmCallback), new DrmSessionEventListener.EventDispatcher());
}
Also used : KeyRequest(com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest) Before(org.junit.Before)

Example 3 with KeyRequest

use of com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest in project ExoPlayer by google.

the class FrameworkMediaDrm method getKeyRequest.

// Return values of MediaDrm.KeyRequest.getRequestType are equal to KeyRequest.RequestType.
@SuppressLint("WrongConstant")
@Override
public KeyRequest getKeyRequest(byte[] scope, @Nullable List<DrmInitData.SchemeData> schemeDatas, int keyType, @Nullable HashMap<String, String> optionalParameters) throws NotProvisionedException {
    SchemeData schemeData = null;
    byte[] initData = null;
    String mimeType = null;
    if (schemeDatas != null) {
        schemeData = getSchemeData(uuid, schemeDatas);
        initData = adjustRequestInitData(uuid, Assertions.checkNotNull(schemeData.data));
        mimeType = adjustRequestMimeType(uuid, schemeData.mimeType);
    }
    MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, initData, mimeType, keyType, optionalParameters);
    byte[] requestData = adjustRequestData(uuid, request.getData());
    String licenseServerUrl = request.getDefaultUrl();
    if (MOCK_LA_URL_VALUE.equals(licenseServerUrl)) {
        licenseServerUrl = "";
    }
    if (TextUtils.isEmpty(licenseServerUrl) && schemeData != null && !TextUtils.isEmpty(schemeData.licenseServerUrl)) {
        licenseServerUrl = schemeData.licenseServerUrl;
    }
    @KeyRequest.RequestType int requestType = Util.SDK_INT >= 23 ? request.getRequestType() : KeyRequest.REQUEST_TYPE_UNKNOWN;
    return new KeyRequest(requestData, licenseServerUrl, requestType);
}
Also used : MediaDrm(android.media.MediaDrm) SchemeData(com.google.android.exoplayer2.drm.DrmInitData.SchemeData) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Aggregations

KeyRequest (com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest)2 SuppressLint (android.annotation.SuppressLint)1 DeniedByServerException (android.media.DeniedByServerException)1 MediaDrm (android.media.MediaDrm)1 NotProvisionedException (android.media.NotProvisionedException)1 SchemeData (com.google.android.exoplayer2.drm.DrmInitData.SchemeData)1 Before (org.junit.Before)1