android.media.NotProvisionedException Java Examples

The following examples show how to use android.media.NotProvisionedException. 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: FrameworkMediaDrm.java    From K-Sonic with MIT License 6 votes vote down vote up
@Override
public KeyRequest getKeyRequest(byte[] scope, byte[] init, String mimeType, int keyType,
    HashMap<String, String> optionalParameters) throws NotProvisionedException {
  final MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, init, mimeType, keyType,
      optionalParameters);
  return new KeyRequest() {
    @Override
    public byte[] getData() {
      return request.getData();
    }

    @Override
    public String getDefaultUrl() {
      return request.getDefaultUrl();
    }
  };
}
 
Example #2
Source File: FrameworkMediaDrm.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public KeyRequest getKeyRequest(
    byte[] scope,
    @Nullable List<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;
  }

  return new KeyRequest(requestData, licenseServerUrl);
}
 
Example #3
Source File: FrameworkMediaDrm.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
@Override
public byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException {
  if (C.CLEARKEY_UUID.equals(uuid)) {
    response = ClearKeyUtil.adjustResponseData(response);
  }

  return mediaDrm.provideKeyResponse(scope, response);
}
 
Example #4
Source File: FrameworkMediaDrm.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@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;
  }

  return new KeyRequest(requestData, licenseServerUrl);
}
 
Example #5
Source File: DefaultDrmSession.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void onKeysError(Exception e) {
  if (e instanceof NotProvisionedException) {
    provisioningManager.provisionRequired(this);
  } else {
    onError(e);
  }
}
 
Example #6
Source File: FrameworkMediaDrm.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
@Override
public byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException {
  if (C.CLEARKEY_UUID.equals(uuid)) {
    response = ClearKeyUtil.adjustResponseData(response);
  }

  return mediaDrm.provideKeyResponse(scope, response);
}
 
Example #7
Source File: FrameworkMediaDrm.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@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;
  }

  return new KeyRequest(requestData, licenseServerUrl);
}
 
Example #8
Source File: DefaultDrmSession.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void onKeysError(Exception e) {
  if (e instanceof NotProvisionedException) {
    provisioningManager.provisionRequired(this);
  } else {
    onError(e);
  }
}
 
Example #9
Source File: StreamingDrmSessionManager.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
private void onKeysError(Exception e) {
  if (e instanceof NotProvisionedException) {
    postProvisionRequest();
  } else {
    onError(e);
  }
}
 
Example #10
Source File: StreamingDrmSessionManager.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
private void postKeyRequest() {
  KeyRequest keyRequest;
  try {
    keyRequest = mediaDrm.getKeyRequest(sessionId, schemePsshData, mimeType,
        MediaDrm.KEY_TYPE_STREAMING, optionalKeyRequestParameters);
    postRequestHandler.obtainMessage(MSG_KEYS, keyRequest).sendToTarget();
  } catch (NotProvisionedException e) {
    onKeysError(e);
  }
}
 
Example #11
Source File: DefaultDrmSessionManager.java    From K-Sonic with MIT License 5 votes vote down vote up
private void onKeysError(Exception e) {
  if (e instanceof NotProvisionedException) {
    postProvisionRequest();
  } else {
    onError(e);
  }
}
 
Example #12
Source File: ExoMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/** @see MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap) */
KeyRequest getKeyRequest(
    byte[] scope,
    byte[] init,
    String mimeType,
    int keyType,
    HashMap<String, String> optionalParameters)
    throws NotProvisionedException;
 
Example #13
Source File: FrameworkMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public KeyRequest getKeyRequest(byte[] scope, byte[] init, String mimeType, int keyType,
    HashMap<String, String> optionalParameters) throws NotProvisionedException {

  // Prior to L the Widevine CDM required data to be extracted from the PSSH atom. Some Amazon
  // devices also required data to be extracted from the PSSH atom for PlayReady.
  if ((Util.SDK_INT < 21 && C.WIDEVINE_UUID.equals(uuid))
      || (C.PLAYREADY_UUID.equals(uuid)
          && "Amazon".equals(Util.MANUFACTURER)
          && ("AFTB".equals(Util.MODEL) // Fire TV Gen 1
              || "AFTS".equals(Util.MODEL) // Fire TV Gen 2
              || "AFTM".equals(Util.MODEL)))) { // Fire TV Stick Gen 1
    byte[] psshData = PsshAtomUtil.parseSchemeSpecificData(init, uuid);
    if (psshData == null) {
      // Extraction failed. schemeData isn't a PSSH atom, so leave it unchanged.
    } else {
      init = psshData;
    }
  }

  // Prior to API level 26 the ClearKey CDM only accepted "cenc" as the scheme for MP4.
  if (Util.SDK_INT < 26
      && C.CLEARKEY_UUID.equals(uuid)
      && (MimeTypes.VIDEO_MP4.equals(mimeType) || MimeTypes.AUDIO_MP4.equals(mimeType))) {
    mimeType = CENC_SCHEME_MIME_TYPE;
  }

  final MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, init, mimeType, keyType,
      optionalParameters);

  byte[] requestData = request.getData();
  if (C.CLEARKEY_UUID.equals(uuid)) {
    requestData = ClearKeyUtil.adjustRequestData(requestData);
  }

  return new DefaultKeyRequest(requestData, request.getDefaultUrl());
}
 
Example #14
Source File: DefaultDrmSession.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private void onKeysError(Exception e) {
  if (e instanceof NotProvisionedException) {
    provisioningManager.provisionRequired(this);
  } else {
    onError(e);
  }
}
 
Example #15
Source File: FrameworkMediaDrm.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException {
  if (C.CLEARKEY_UUID.equals(uuid)) {
    response = ClearKeyUtil.adjustResponseData(response);
  }

  return mediaDrm.provideKeyResponse(scope, response);
}
 
Example #16
Source File: DefaultDrmSession.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onKeysError(Exception e) {
  if (e instanceof NotProvisionedException) {
    provisioningManager.provisionRequired(this);
  } else {
    onError(e);
  }
}
 
Example #17
Source File: FrameworkMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public KeyRequest getKeyRequest(byte[] scope, byte[] init, String mimeType, int keyType,
    HashMap<String, String> optionalParameters) throws NotProvisionedException {

  // Prior to L the Widevine CDM required data to be extracted from the PSSH atom. Some Amazon
  // devices also required data to be extracted from the PSSH atom for PlayReady.
  if ((Util.SDK_INT < 21 && C.WIDEVINE_UUID.equals(uuid))
      || (C.PLAYREADY_UUID.equals(uuid)
          && "Amazon".equals(Util.MANUFACTURER)
          && ("AFTB".equals(Util.MODEL) // Fire TV Gen 1
              || "AFTS".equals(Util.MODEL) // Fire TV Gen 2
              || "AFTM".equals(Util.MODEL)))) { // Fire TV Stick Gen 1
    byte[] psshData = PsshAtomUtil.parseSchemeSpecificData(init, uuid);
    if (psshData == null) {
      // Extraction failed. schemeData isn't a PSSH atom, so leave it unchanged.
    } else {
      init = psshData;
    }
  }

  // Prior to API level 26 the ClearKey CDM only accepted "cenc" as the scheme for MP4.
  if (Util.SDK_INT < 26
      && C.CLEARKEY_UUID.equals(uuid)
      && (MimeTypes.VIDEO_MP4.equals(mimeType) || MimeTypes.AUDIO_MP4.equals(mimeType))) {
    mimeType = CENC_SCHEME_MIME_TYPE;
  }

  final MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, init, mimeType, keyType,
      optionalParameters);

  byte[] requestData = request.getData();
  if (C.CLEARKEY_UUID.equals(uuid)) {
    requestData = ClearKeyUtil.adjustRequestData(requestData);
  }

  return new DefaultKeyRequest(requestData, request.getDefaultUrl());
}
 
Example #18
Source File: FrameworkMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException {

  if (C.CLEARKEY_UUID.equals(uuid)) {
    response = ClearKeyUtil.adjustResponseData(response);
  }

  return mediaDrm.provideKeyResponse(scope, response);
}
 
Example #19
Source File: ExoMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/** @see MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap) */
KeyRequest getKeyRequest(
    byte[] scope,
    byte[] init,
    String mimeType,
    int keyType,
    HashMap<String, String> optionalParameters)
    throws NotProvisionedException;
 
Example #20
Source File: DefaultDrmSession.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onKeysError(Exception e) {
  if (e instanceof NotProvisionedException) {
    provisioningManager.provisionRequired(this);
  } else {
    onError(e);
  }
}
 
Example #21
Source File: FrameworkMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException {

  if (C.CLEARKEY_UUID.equals(uuid)) {
    response = ClearKeyUtil.adjustResponseData(response);
  }

  return mediaDrm.provideKeyResponse(scope, response);
}
 
Example #22
Source File: FrameworkMediaDrm.java    From K-Sonic with MIT License 4 votes vote down vote up
@Override
public byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException {
  return mediaDrm.provideKeyResponse(scope, response);
}
 
Example #23
Source File: ExoMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/** @see MediaDrm#provideKeyResponse(byte[], byte[]) */
byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException;
 
Example #24
Source File: FrameworkMediaDrm.java    From K-Sonic with MIT License 4 votes vote down vote up
@Override
public byte[] openSession() throws NotProvisionedException, ResourceBusyException {
  return mediaDrm.openSession();
}
 
Example #25
Source File: ExoMediaDrm.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/** @see MediaDrm#provideKeyResponse(byte[], byte[]) */
@Nullable
byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException;
 
Example #26
Source File: ExoMediaDrm.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/** @see MediaDrm#provideKeyResponse(byte[], byte[]) */
@Nullable
byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException;
 
Example #27
Source File: ExoMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/** @see MediaDrm#provideKeyResponse(byte[], byte[]) */
byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException;
 
Example #28
Source File: ExoMediaDrm.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/** @see MediaDrm#provideKeyResponse(byte[], byte[]) */
@Nullable
byte[] provideKeyResponse(byte[] scope, byte[] response)
    throws NotProvisionedException, DeniedByServerException;
 
Example #29
Source File: ExoMediaDrm.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Generates a key request.
 *
 * @param scope If {@code keyType} is {@link #KEY_TYPE_STREAMING} or {@link #KEY_TYPE_OFFLINE},
 *     the session id that the keys will be provided to. If {@code keyType} is {@link
 *     #KEY_TYPE_RELEASE}, the keySetId of the keys to release.
 * @param schemeDatas If key type is {@link #KEY_TYPE_STREAMING} or {@link #KEY_TYPE_OFFLINE}, a
 *     list of {@link SchemeData} instances extracted from the media. Null otherwise.
 * @param keyType The type of the request. Either {@link #KEY_TYPE_STREAMING} to acquire keys for
 *     streaming, {@link #KEY_TYPE_OFFLINE} to acquire keys for offline usage, or {@link
 *     #KEY_TYPE_RELEASE} to release acquired keys. Releasing keys invalidates them for all
 *     sessions.
 * @param optionalParameters Are included in the key request message to allow a client application
 *     to provide additional message parameters to the server. This may be {@code null} if no
 *     additional parameters are to be sent.
 * @return The generated key request.
 * @see MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)
 */
KeyRequest getKeyRequest(
    byte[] scope,
    @Nullable List<SchemeData> schemeDatas,
    int keyType,
    @Nullable HashMap<String, String> optionalParameters)
    throws NotProvisionedException;
 
Example #30
Source File: ExoMediaDrm.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Generates a key request.
 *
 * @param scope If {@code keyType} is {@link #KEY_TYPE_STREAMING} or {@link #KEY_TYPE_OFFLINE},
 *     the session id that the keys will be provided to. If {@code keyType} is {@link
 *     #KEY_TYPE_RELEASE}, the keySetId of the keys to release.
 * @param schemeDatas If key type is {@link #KEY_TYPE_STREAMING} or {@link #KEY_TYPE_OFFLINE}, a
 *     list of {@link SchemeData} instances extracted from the media. Null otherwise.
 * @param keyType The type of the request. Either {@link #KEY_TYPE_STREAMING} to acquire keys for
 *     streaming, {@link #KEY_TYPE_OFFLINE} to acquire keys for offline usage, or {@link
 *     #KEY_TYPE_RELEASE} to release acquired keys. Releasing keys invalidates them for all
 *     sessions.
 * @param optionalParameters Are included in the key request message to allow a client application
 *     to provide additional message parameters to the server. This may be {@code null} if no
 *     additional parameters are to be sent.
 * @return The generated key request.
 * @see MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)
 */
KeyRequest getKeyRequest(
        byte[] scope,
        @Nullable List<SchemeData> schemeDatas,
        int keyType,
        @Nullable HashMap<String, String> optionalParameters)
    throws NotProvisionedException;