android.media.MediaCryptoException Java Examples

The following examples show how to use android.media.MediaCryptoException. 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: MediaCodecRenderer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(23)
private void updateDrmSessionOrReinitializeCodecV23() throws ExoPlaybackException {
  FrameworkMediaCrypto sessionMediaCrypto = sourceDrmSession.getMediaCrypto();
  if (sessionMediaCrypto == null) {
    // We'd only expect this to happen if the CDM from which the pending session is obtained needs
    // provisioning. This is unlikely to happen (it probably requires a switch from one DRM scheme
    // to another, where the new CDM hasn't been used before and needs provisioning). It would be
    // possible to handle this case more efficiently (i.e. with a new renderer state that waits
    // for provisioning to finish and then calls mediaCrypto.setMediaDrmSession), but the extra
    // complexity is not warranted given how unlikely the case is to occur.
    reinitializeCodec();
    return;
  }
  if (C.PLAYREADY_UUID.equals(sessionMediaCrypto.uuid)) {
    // The PlayReady CDM does not implement setMediaDrmSession.
    // TODO: Add API check once [Internal ref: b/128835874] is fixed.
    reinitializeCodec();
    return;
  }

  if (flushOrReinitializeCodec()) {
    // The codec was reinitialized. The new codec will be using the new DRM session, so there's
    // nothing more to do.
    return;
  }

  try {
    mediaCrypto.setMediaDrmSession(sessionMediaCrypto.sessionId);
  } catch (MediaCryptoException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
  setCodecDrmSession(sourceDrmSession);
  codecDrainState = DRAIN_STATE_NONE;
  codecDrainAction = DRAIN_ACTION_NONE;
}
 
Example #2
Source File: MediaCodecRenderer.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@TargetApi(23)
private void updateDrmSessionOrReinitializeCodecV23() throws ExoPlaybackException {
  FrameworkMediaCrypto sessionMediaCrypto = sourceDrmSession.getMediaCrypto();
  if (sessionMediaCrypto == null) {
    // We'd only expect this to happen if the CDM from which the pending session is obtained needs
    // provisioning. This is unlikely to happen (it probably requires a switch from one DRM scheme
    // to another, where the new CDM hasn't been used before and needs provisioning). It would be
    // possible to handle this case more efficiently (i.e. with a new renderer state that waits
    // for provisioning to finish and then calls mediaCrypto.setMediaDrmSession), but the extra
    // complexity is not warranted given how unlikely the case is to occur.
    reinitializeCodec();
    return;
  }
  if (C.PLAYREADY_UUID.equals(sessionMediaCrypto.uuid)) {
    // The PlayReady CDM does not implement setMediaDrmSession.
    // TODO: Add API check once [Internal ref: b/128835874] is fixed.
    reinitializeCodec();
    return;
  }

  if (flushOrReinitializeCodec()) {
    // The codec was reinitialized. The new codec will be using the new DRM session, so there's
    // nothing more to do.
    return;
  }

  try {
    mediaCrypto.setMediaDrmSession(sessionMediaCrypto.sessionId);
  } catch (MediaCryptoException e) {
    throw createRendererException(e, inputFormat);
  }
  setCodecDrmSession(sourceDrmSession);
  codecDrainState = DRAIN_STATE_NONE;
  codecDrainAction = DRAIN_ACTION_NONE;
}
 
Example #3
Source File: FrameworkMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
  // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
  // indicate that it required secure video decoders [Internal ref: b/11428937].
  boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
      && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel"));
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData),
      forceAllowInsecureDecoderComponents);
}
 
Example #4
Source File: FrameworkMediaDrm.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
  // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
  // indicate that it required secure video decoders [Internal ref: b/11428937].
  boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
      && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel"));
  return new FrameworkMediaCrypto(
      adjustUuid(uuid), initData, forceAllowInsecureDecoderComponents);
}
 
Example #5
Source File: FrameworkMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
  // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
  // indicate that it required secure video decoders [Internal ref: b/11428937].
  boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
      && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel"));
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData),
      forceAllowInsecureDecoderComponents);
}
 
Example #6
Source File: MediaCodecRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(23)
private void updateDrmSessionOrReinitializeCodecV23() throws ExoPlaybackException {
  FrameworkMediaCrypto sessionMediaCrypto = sourceDrmSession.getMediaCrypto();
  if (sessionMediaCrypto == null) {
    // We'd only expect this to happen if the CDM from which the pending session is obtained needs
    // provisioning. This is unlikely to happen (it probably requires a switch from one DRM scheme
    // to another, where the new CDM hasn't been used before and needs provisioning). It would be
    // possible to handle this case more efficiently (i.e. with a new renderer state that waits
    // for provisioning to finish and then calls mediaCrypto.setMediaDrmSession), but the extra
    // complexity is not warranted given how unlikely the case is to occur.
    reinitializeCodec();
    return;
  }
  if (C.PLAYREADY_UUID.equals(sessionMediaCrypto.uuid)) {
    // The PlayReady CDM does not implement setMediaDrmSession.
    // TODO: Add API check once [Internal ref: b/128835874] is fixed.
    reinitializeCodec();
    return;
  }

  if (flushOrReinitializeCodec()) {
    // The codec was reinitialized. The new codec will be using the new DRM session, so there's
    // nothing more to do.
    return;
  }

  try {
    mediaCrypto.setMediaDrmSession(sessionMediaCrypto.sessionId);
  } catch (MediaCryptoException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
  setCodecDrmSession(sourceDrmSession);
  codecDrainState = DRAIN_STATE_NONE;
  codecDrainAction = DRAIN_ACTION_NONE;
}
 
Example #7
Source File: LocalDrmSessionManagerTest.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws MediaDrmException, MediaCryptoException {
    frameworkMediaCrypto = FrameworkMediaCryptoFixture.aFrameworkMediaCrypto().build();
    given(mediaDrm.openSession()).willReturn(SESSION_ID.asBytes());

    localDrmSessionManager = new LocalDrmSessionManager(
            KEY_SET_ID_TO_RESTORE,
            mediaDrm,
            DRM_SCHEME,
            handler,
            eventListener
    );
}
 
Example #8
Source File: LocalDrmSessionManagerTest.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Test
public void givenValidMediaDrm_whenAcquiringSession_thenRestoresKeys() throws MediaCryptoException {
    given(mediaDrm.createMediaCrypto(SESSION_ID.asBytes())).willReturn(frameworkMediaCrypto);

    localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA);

    verify(mediaDrm).restoreKeys(SESSION_ID.asBytes(), KEY_SET_ID_TO_RESTORE.asBytes());
}
 
Example #9
Source File: LocalDrmSessionManagerTest.java    From no-player with Apache License 2.0 5 votes vote down vote up
@Test
public void givenValidMediaDrm_whenAcquiringSession_thenReturnsLocalDrmSession() throws MediaCryptoException {
    given(mediaDrm.createMediaCrypto(SESSION_ID.asBytes())).willReturn(frameworkMediaCrypto);

    DrmSession<FrameworkMediaCrypto> drmSession = localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA);

    LocalDrmSession localDrmSession = new LocalDrmSession(frameworkMediaCrypto, KEY_SET_ID_TO_RESTORE, SESSION_ID);
    assertThat(drmSession).isEqualTo(localDrmSession);
}
 
Example #10
Source File: FrameworkMediaDrm.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
  // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
  // indicate that it required secure video decoders [Internal ref: b/11428937].
  boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
      && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel"));
  return new FrameworkMediaCrypto(
      adjustUuid(uuid), initData, forceAllowInsecureDecoderComponents);
}
 
Example #11
Source File: FrameworkMediaDrm.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
  // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
  // indicate that it required secure video decoders [Internal ref: b/11428937].
  boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
      && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel"));
  return new FrameworkMediaCrypto(
      adjustUuid(uuid), initData, forceAllowInsecureDecoderComponents);
}
 
Example #12
Source File: FrameworkMediaCryptoFixture.java    From no-player with Apache License 2.0 4 votes vote down vote up
private FrameworkMediaCryptoFixture() throws MediaCryptoException {
    // Static factory method.
}
 
Example #13
Source File: FrameworkMediaDrm.java    From K-Sonic with MIT License 4 votes vote down vote up
@Override
public FrameworkMediaCrypto createMediaCrypto(UUID uuid, byte[] initData)
    throws MediaCryptoException {
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData));
}
 
Example #14
Source File: FrameworkMediaCryptoFixture.java    From no-player with Apache License 2.0 4 votes vote down vote up
public static FrameworkMediaCryptoFixture aFrameworkMediaCrypto() throws MediaCryptoException {
    return new FrameworkMediaCryptoFixture();
}
 
Example #15
Source File: ExoMediaDrm.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * @see android.media.MediaCrypto#MediaCrypto(UUID, byte[])
 *
 * @param uuid The UUID of the crypto scheme.
 * @param initData Opaque initialization data specific to the crypto scheme.
 * @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
 * @throws MediaCryptoException
 */
T createMediaCrypto(UUID uuid, byte[] initData) throws MediaCryptoException;
 
Example #16
Source File: ExoMediaDrm.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @see android.media.MediaCrypto#MediaCrypto(UUID, byte[])
 * @param sessionId The DRM session ID.
 * @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
 * @throws MediaCryptoException If the instance can't be created.
 */
T createMediaCrypto(byte[] sessionId) throws MediaCryptoException;
 
Example #17
Source File: ExoMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @see android.media.MediaCrypto#MediaCrypto(UUID, byte[])
 *
 * @param initData Opaque initialization data specific to the crypto scheme.
 * @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
 * @throws MediaCryptoException If the instance can't be created.
 */
T createMediaCrypto(byte[] initData) throws MediaCryptoException;
 
Example #18
Source File: ExoMediaDrm.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @see android.media.MediaCrypto#MediaCrypto(UUID, byte[])
 *
 * @param initData Opaque initialization data specific to the crypto scheme.
 * @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
 * @throws MediaCryptoException If the instance can't be created.
 */
T createMediaCrypto(byte[] initData) throws MediaCryptoException;
 
Example #19
Source File: ExoMediaDrm.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @see android.media.MediaCrypto#MediaCrypto(UUID, byte[])
 * @param sessionId The DRM session ID.
 * @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
 * @throws MediaCryptoException If the instance can't be created.
 */
T createMediaCrypto(byte[] sessionId) throws MediaCryptoException;
 
Example #20
Source File: ExoMediaDrm.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * @see android.media.MediaCrypto#MediaCrypto(UUID, byte[])
 * @param sessionId The DRM session ID.
 * @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
 * @throws MediaCryptoException If the instance can't be created.
 */
T createMediaCrypto(byte[] sessionId) throws MediaCryptoException;