com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest Java Examples

The following examples show how to use com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultDrmSession.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void handleMessage(Message msg) {
  Object request = msg.obj;
  Object response;
  try {
    switch (msg.what) {
      case MSG_PROVISION:
        response = callback.executeProvisionRequest(uuid, (ProvisionRequest) request);
        break;
      case MSG_KEYS:
        response = callback.executeKeyRequest(uuid, (KeyRequest) request);
        break;
      default:
        throw new RuntimeException();
    }
  } catch (Exception e) {
    if (maybeRetryRequest(msg)) {
      return;
    }
    response = e;
  }
  postResponseHandler.obtainMessage(msg.what, Pair.create(request, response)).sendToTarget();
}
 
Example #2
Source File: HttpMediaDrmCallback.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  String url = request.getLicenseServerUrl();
  if (forceDefaultLicenseUrl || TextUtils.isEmpty(url)) {
    url = defaultLicenseUrl;
  }
  Map<String, String> requestProperties = new HashMap<>();
  // Add standard request properties for supported schemes.
  String contentType = C.PLAYREADY_UUID.equals(uuid) ? "text/xml"
      : (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream");
  requestProperties.put("Content-Type", contentType);
  if (C.PLAYREADY_UUID.equals(uuid)) {
    requestProperties.put("SOAPAction",
        "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
  }
  // Add additional request properties.
  synchronized (keyRequestProperties) {
    requestProperties.putAll(keyRequestProperties);
  }
  return executePost(dataSourceFactory, url, request.getData(), requestProperties);
}
 
Example #3
Source File: DefaultDrmSession.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
  RequestTask requestTask = (RequestTask) msg.obj;
  Object response;
  try {
    switch (msg.what) {
      case MSG_PROVISION:
        response =
            callback.executeProvisionRequest(uuid, (ProvisionRequest) requestTask.request);
        break;
      case MSG_KEYS:
        response = callback.executeKeyRequest(uuid, (KeyRequest) requestTask.request);
        break;
      default:
        throw new RuntimeException();
    }
  } catch (Exception e) {
    if (maybeRetryRequest(msg, e)) {
      return;
    }
    response = e;
  }
  responseHandler
      .obtainMessage(msg.what, Pair.create(requestTask.request, response))
      .sendToTarget();
}
 
Example #4
Source File: HttpMediaDrmCallback.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] executeKeyRequest(
    UUID uuid, KeyRequest request, @Nullable String mediaProvidedLicenseServerUrl)
    throws Exception {
  String url = request.getDefaultUrl();
  if (TextUtils.isEmpty(url)) {
    url = mediaProvidedLicenseServerUrl;
  }
  if (forceDefaultLicenseUrl || TextUtils.isEmpty(url)) {
    url = defaultLicenseUrl;
  }
  Map<String, String> requestProperties = new HashMap<>();
  // Add standard request properties for supported schemes.
  String contentType = C.PLAYREADY_UUID.equals(uuid) ? "text/xml"
      : (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream");
  requestProperties.put("Content-Type", contentType);
  if (C.PLAYREADY_UUID.equals(uuid)) {
    requestProperties.put("SOAPAction",
        "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
  }
  // Add additional request properties.
  synchronized (keyRequestProperties) {
    requestProperties.putAll(keyRequestProperties);
  }
  return executePost(dataSourceFactory, url, request.getData(), requestProperties);
}
 
Example #5
Source File: DefaultDrmSession.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void handleMessage(Message msg) {
  Object request = msg.obj;
  Object response;
  try {
    switch (msg.what) {
      case MSG_PROVISION:
        response = callback.executeProvisionRequest(uuid, (ProvisionRequest) request);
        break;
      case MSG_KEYS:
        response = callback.executeKeyRequest(uuid, (KeyRequest) request);
        break;
      default:
        throw new RuntimeException();
    }
  } catch (Exception e) {
    if (maybeRetryRequest(msg)) {
      return;
    }
    response = e;
  }
  postResponseHandler.obtainMessage(msg.what, Pair.create(request, response)).sendToTarget();
}
 
Example #6
Source File: HttpMediaDrmCallback.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  String url = request.getLicenseServerUrl();
  if (forceDefaultLicenseUrl || TextUtils.isEmpty(url)) {
    url = defaultLicenseUrl;
  }
  Map<String, String> requestProperties = new HashMap<>();
  // Add standard request properties for supported schemes.
  String contentType = C.PLAYREADY_UUID.equals(uuid) ? "text/xml"
      : (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream");
  requestProperties.put("Content-Type", contentType);
  if (C.PLAYREADY_UUID.equals(uuid)) {
    requestProperties.put("SOAPAction",
        "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
  }
  // Add additional request properties.
  synchronized (keyRequestProperties) {
    requestProperties.putAll(keyRequestProperties);
  }
  return executePost(dataSourceFactory, url, request.getData(), requestProperties);
}
 
Example #7
Source File: DefaultDrmSession.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void postKeyRequest(int type, boolean allowRetry) {
  byte[] scope = type == ExoMediaDrm.KEY_TYPE_RELEASE ? offlineLicenseKeySetId : sessionId;
  byte[] initData = null;
  String mimeType = null;
  String licenseServerUrl = null;
  if (schemeData != null) {
    initData = schemeData.data;
    mimeType = schemeData.mimeType;
    licenseServerUrl = schemeData.licenseServerUrl;
  }
  try {
    KeyRequest mediaDrmKeyRequest =
        mediaDrm.getKeyRequest(scope, initData, mimeType, type, optionalKeyRequestParameters);
    currentKeyRequest = Pair.create(mediaDrmKeyRequest, licenseServerUrl);
    postRequestHandler.post(MSG_KEYS, currentKeyRequest, allowRetry);
  } catch (Exception e) {
    onKeysError(e);
  }
}
 
Example #8
Source File: DefaultDrmSessionManager.java    From K-Sonic with MIT License 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
  Object response;
  try {
    switch (msg.what) {
      case MSG_PROVISION:
        response = callback.executeProvisionRequest(uuid, (ProvisionRequest) msg.obj);
        break;
      case MSG_KEYS:
        response = callback.executeKeyRequest(uuid, (KeyRequest) msg.obj);
        break;
      default:
        throw new RuntimeException();
    }
  } catch (Exception e) {
    response = e;
  }
  postResponseHandler.obtainMessage(msg.what, response).sendToTarget();
}
 
Example #9
Source File: HttpMediaDrmCallback.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] executeKeyRequest(
    UUID uuid, KeyRequest request, @Nullable String mediaProvidedLicenseServerUrl)
    throws Exception {
  String url = request.getDefaultUrl();
  if (TextUtils.isEmpty(url)) {
    url = mediaProvidedLicenseServerUrl;
  }
  if (forceDefaultLicenseUrl || TextUtils.isEmpty(url)) {
    url = defaultLicenseUrl;
  }
  Map<String, String> requestProperties = new HashMap<>();
  // Add standard request properties for supported schemes.
  String contentType = C.PLAYREADY_UUID.equals(uuid) ? "text/xml"
      : (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream");
  requestProperties.put("Content-Type", contentType);
  if (C.PLAYREADY_UUID.equals(uuid)) {
    requestProperties.put("SOAPAction",
        "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
  }
  // Add additional request properties.
  synchronized (keyRequestProperties) {
    requestProperties.putAll(keyRequestProperties);
  }
  return executePost(dataSourceFactory, url, request.getData(), requestProperties);
}
 
Example #10
Source File: HttpMediaDrmCallback.java    From K-Sonic with MIT License 6 votes vote down vote up
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  String url = request.getDefaultUrl();
  if (TextUtils.isEmpty(url)) {
    url = defaultUrl;
  }
  Map<String, String> requestProperties = new HashMap<>();
  requestProperties.put("Content-Type", "application/octet-stream");
  if (C.PLAYREADY_UUID.equals(uuid)) {
    requestProperties.putAll(PLAYREADY_KEY_REQUEST_PROPERTIES);
  }
  synchronized (keyRequestProperties) {
    requestProperties.putAll(keyRequestProperties);
  }
  return executePost(dataSourceFactory, url, request.getData(), requestProperties);
}
 
Example #11
Source File: DefaultDrmSession.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void postKeyRequest(int type, boolean allowRetry) {
  byte[] scope = type == ExoMediaDrm.KEY_TYPE_RELEASE ? offlineLicenseKeySetId : sessionId;
  byte[] initData = null;
  String mimeType = null;
  String licenseServerUrl = null;
  if (schemeData != null) {
    initData = schemeData.data;
    mimeType = schemeData.mimeType;
    licenseServerUrl = schemeData.licenseServerUrl;
  }
  try {
    KeyRequest mediaDrmKeyRequest =
        mediaDrm.getKeyRequest(scope, initData, mimeType, type, optionalKeyRequestParameters);
    currentKeyRequest = Pair.create(mediaDrmKeyRequest, licenseServerUrl);
    postRequestHandler.post(MSG_KEYS, currentKeyRequest, allowRetry);
  } catch (Exception e) {
    onKeysError(e);
  }
}
 
Example #12
Source File: HttpMediaDrmCallback.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  String url = request.getLicenseServerUrl();
  if (forceDefaultLicenseUrl || TextUtils.isEmpty(url)) {
    url = defaultLicenseUrl;
  }
  Map<String, String> requestProperties = new HashMap<>();
  // Add standard request properties for supported schemes.
  String contentType = C.PLAYREADY_UUID.equals(uuid) ? "text/xml"
      : (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream");
  requestProperties.put("Content-Type", contentType);
  if (C.PLAYREADY_UUID.equals(uuid)) {
    requestProperties.put("SOAPAction",
        "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
  }
  // Add additional request properties.
  synchronized (keyRequestProperties) {
    requestProperties.putAll(keyRequestProperties);
  }
  return executePost(dataSourceFactory, url, request.getData(), requestProperties);
}
 
Example #13
Source File: DefaultDrmSession.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void handleMessage(Message msg) {
  Object request = msg.obj;
  Object response;
  try {
    switch (msg.what) {
      case MSG_PROVISION:
        response = callback.executeProvisionRequest(uuid, (ProvisionRequest) request);
        break;
      case MSG_KEYS:
        Pair<KeyRequest, String> keyRequest = (Pair<KeyRequest, String>) request;
        KeyRequest mediaDrmKeyRequest = keyRequest.first;
        String licenseServerUrl = keyRequest.second;
        response = callback.executeKeyRequest(uuid, mediaDrmKeyRequest, licenseServerUrl);
        break;
      default:
        throw new RuntimeException();
    }
  } catch (Exception e) {
    if (maybeRetryRequest(msg)) {
      return;
    }
    response = e;
  }
  postResponseHandler.obtainMessage(msg.what, Pair.create(request, response)).sendToTarget();
}
 
Example #14
Source File: DefaultDrmSessionManager.java    From K-Sonic with MIT License 5 votes vote down vote up
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);
  }
}
 
Example #15
Source File: DefaultDrmSession.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void handleMessage(Message msg) {
  Object request = msg.obj;
  Object response;
  try {
    switch (msg.what) {
      case MSG_PROVISION:
        response = callback.executeProvisionRequest(uuid, (ProvisionRequest) request);
        break;
      case MSG_KEYS:
        Pair<KeyRequest, String> keyRequest = (Pair<KeyRequest, String>) request;
        KeyRequest mediaDrmKeyRequest = keyRequest.first;
        String licenseServerUrl = keyRequest.second;
        response = callback.executeKeyRequest(uuid, mediaDrmKeyRequest, licenseServerUrl);
        break;
      default:
        throw new RuntimeException();
    }
  } catch (Exception e) {
    if (maybeRetryRequest(msg)) {
      return;
    }
    response = e;
  }
  postResponseHandler.obtainMessage(msg.what, Pair.create(request, response)).sendToTarget();
}
 
Example #16
Source File: LocalMediaDrmCallback.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public byte[] executeKeyRequest(
    UUID uuid, KeyRequest request, @Nullable String mediaProvidedLicenseServerUrl)
    throws Exception {
  return keyResponse;
}
 
Example #17
Source File: LocalMediaDrmCallback.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  return keyResponse;
}
 
Example #18
Source File: LocalMediaDrmCallback.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public byte[] executeKeyRequest(
    UUID uuid, KeyRequest request, @Nullable String mediaProvidedLicenseServerUrl)
    throws Exception {
  return keyResponse;
}
 
Example #19
Source File: LocalMediaDrmCallback.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  return keyResponse;
}
 
Example #20
Source File: LocalMediaDrmCallback.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  return keyResponse;
}
 
Example #21
Source File: MediaDrmCallback.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Executes a key request.
 *
 * @param uuid The UUID of the content protection scheme.
 * @param request The request generated by the content decryption module.
 * @param mediaProvidedLicenseServerUrl A license server URL provided by the media, or null if the
 *     media does not include any license server URL.
 * @return The response data.
 * @throws Exception If an error occurred executing the request.
 */
byte[] executeKeyRequest(
    UUID uuid, KeyRequest request, @Nullable String mediaProvidedLicenseServerUrl)
    throws Exception;
 
Example #22
Source File: MediaDrmCallback.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Executes a key request.
 *
 * @param uuid The UUID of the content protection scheme.
 * @param request The request.
 * @return The response data.
 * @throws Exception If an error occurred executing the request.
 */
byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception;
 
Example #23
Source File: MediaDrmCallback.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Executes a key request.
 *
 * @param uuid The UUID of the content protection scheme.
 * @param request The request generated by the content decryption module.
 * @param mediaProvidedLicenseServerUrl A license server URL provided by the media, or null if the
 *     media does not include any license server URL.
 * @return The response data.
 * @throws Exception If an error occurred executing the request.
 */
byte[] executeKeyRequest(
    UUID uuid, KeyRequest request, @Nullable String mediaProvidedLicenseServerUrl)
    throws Exception;
 
Example #24
Source File: MediaDrmCallback.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Executes a key request.
 *
 * @param uuid The UUID of the content protection scheme.
 * @param request The request.
 * @return The response data.
 * @throws Exception If an error occurred executing the request.
 */
byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception;
 
Example #25
Source File: MediaDrmCallback.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * Executes a key request.
 *
 * @param uuid The UUID of the content protection scheme.
 * @param request The request.
 * @return The response data.
 * @throws Exception If an error occurred executing the request.
 */
byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception;
 
Example #26
Source File: MediaDrmCallback.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Executes a key request.
 *
 * @param uuid The UUID of the content protection scheme.
 * @param request The request.
 * @return The response data.
 * @throws Exception If an error occurred executing the request.
 */
byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception;