Java 类com.google.android.exoplayer2.drm.UnsupportedDrmException 实例源码

项目:ExoPlayer-Offline    文件:DashTest.java   
@Override
protected final DefaultDrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(
    final String userAgent) {
  DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;
  if (parameters.isWidevineEncrypted) {
    try {
      MediaDrmCallback drmCallback = new HttpMediaDrmCallback(parameters.widevineLicenseUrl,
          new DefaultHttpDataSourceFactory(userAgent));
      drmSessionManager = DefaultDrmSessionManager.newWidevineInstance(drmCallback, null,
          null, null);
      if (!parameters.useL1Widevine) {
        drmSessionManager.setPropertyString(SECURITY_LEVEL_PROPERTY, WIDEVINE_SECURITY_LEVEL_3);
      }
      if (offlineLicenseKeySetId != null) {
        drmSessionManager.setMode(DefaultDrmSessionManager.MODE_PLAYBACK,
            offlineLicenseKeySetId);
      }
    } catch (UnsupportedDrmException e) {
      throw new IllegalStateException(e);
    }
  }
  return drmSessionManager;
}
项目:transistor    文件:DemoUtil.java   
/**
 * Derives a DRM {@link UUID} from {@code drmScheme}.
 *
 * @param drmScheme A protection scheme UUID string; or {@code "widevine"}, {@code "playready"} or
 *     {@code "clearkey"}.
 * @return The derived {@link UUID}.
 * @throws UnsupportedDrmException If no {@link UUID} could be derived from {@code drmScheme}.
 */
public static UUID getDrmUuid(String drmScheme) throws UnsupportedDrmException {
  switch (Util.toLowerInvariant(drmScheme)) {
    case "widevine":
      return C.WIDEVINE_UUID;
    case "playready":
      return C.PLAYREADY_UUID;
    case "clearkey":
      return C.CLEARKEY_UUID;
    default:
      try {
        return UUID.fromString(drmScheme);
      } catch (RuntimeException e) {
        throw new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME);
      }
  }
}
项目:transistor    文件:DashTestRunner.java   
@Override
protected DefaultDrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(
    final String userAgent) {
  if (widevineLicenseUrl == null) {
    return null;
  }
  try {
    MediaDrmCallback drmCallback = new HttpMediaDrmCallback(widevineLicenseUrl,
        new DefaultHttpDataSourceFactory(userAgent));
    DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager =
        DefaultDrmSessionManager.newWidevineInstance(drmCallback, null, null, null);
    if (!useL1Widevine) {
      drmSessionManager.setPropertyString(
          SECURITY_LEVEL_PROPERTY, WIDEVINE_SECURITY_LEVEL_3);
    }
    if (offlineLicenseKeySetId != null) {
      drmSessionManager.setMode(DefaultDrmSessionManager.MODE_PLAYBACK,
          offlineLicenseKeySetId);
    }
    return drmSessionManager;
  } catch (UnsupportedDrmException e) {
    throw new IllegalStateException(e);
  }
}
项目:ExoPlayer-Offline    文件:PlayerActivity.java   
private DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(UUID uuid,
                                                                       String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException {
    if (Util.SDK_INT < 18) {
        return null;
    }
    HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl,
            buildHttpDataSourceFactory(false), keyRequestProperties);
    return new DefaultDrmSessionManager<>(uuid,
            FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, eventLogger);
}
项目:ExoPlayer-Offline    文件:DashTest.java   
public TestOfflineLicenseHelper(DashHostedTestEncParameters parameters)
    throws UnsupportedDrmException {
  this.parameters = parameters;
  httpDataSourceFactory = new DefaultHttpDataSourceFactory("ExoPlayerPlaybackTests");
  offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(
      parameters.widevineLicenseUrl, httpDataSourceFactory);
}
项目:no-player    文件:FrameworkMediaDrmCreator.java   
@SuppressWarnings("PMD.PreserveStackTrace")  // We just unwrap the exception because we don't care about the UnsupportedDrmException itself
FrameworkMediaDrm create(UUID uuid) {
    try {
        return FrameworkMediaDrm.newInstance(uuid);
    } catch (UnsupportedDrmException e) {
        throw new FrameworkMediaDrmException(e.getMessage(), e.getCause());
    }
}
项目:MDVideo    文件:PlayerActivityV2.java   
private DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(UUID uuid,
                                                                       String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException {
    if (Util.SDK_INT < 18) {
        return null;
    }
    HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl,
            buildHttpDataSourceFactory(false), keyRequestProperties);
    return new StreamingDrmSessionManager<>(uuid,
            FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, eventLogger);
}
项目:Komica    文件:PlayerActivity.java   
private DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(UUID uuid,
                                                                       String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException {
  if (Util.SDK_INT < 18) {
    return null;
  }
  HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl,
      buildHttpDataSourceFactory(false), keyRequestProperties);
  return new StreamingDrmSessionManager<>(uuid,
      FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, eventLogger);
}
项目:transistor    文件:PlayerActivity.java   
private DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManagerV18(UUID uuid,
    String licenseUrl, String[] keyRequestPropertiesArray, boolean multiSession)
    throws UnsupportedDrmException {
  HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl,
      buildHttpDataSourceFactory(false));
  if (keyRequestPropertiesArray != null) {
    for (int i = 0; i < keyRequestPropertiesArray.length - 1; i += 2) {
      drmCallback.setKeyRequestProperty(keyRequestPropertiesArray[i],
          keyRequestPropertiesArray[i + 1]);
    }
  }
  return new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), drmCallback,
      null, mainHandler, eventLogger, multiSession);
}
项目:ExoPlayer-Offline    文件:PlayerActivity.java   
private DrmSessionManager<FrameworkMediaCrypto> buildOfflineDrmSessionManager(UUID uuid,
                                                                              String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException, IOException, DrmSession.DrmSessionException, InterruptedException {
    if (Util.SDK_INT < 18) {
        return null;
    }

    customDrmCallback = new CustomDrmCallback(
            DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()),
            licenseUrl
    );

    DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = new DefaultDrmSessionManager<>(uuid,
            FrameworkMediaDrm.newInstance(uuid), customDrmCallback, null, mainHandler, eventLogger);

    String offlineAssetKeyIdStr = DemoApplication.getAppInstance().
            getSharedPreferences().getString(DemoApplication.KEY_OFFLINE_OFFSET_ID,DemoApplication.EMPTY);
    byte[] offlineAssetKeyId = Base64.decode(offlineAssetKeyIdStr, Base64.DEFAULT);
    this.offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(customDrmCallback, null);
    Pair<Long, Long> remainingSecPair = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId);
    Log.e(TAG," License remaining Play time : "+remainingSecPair.first+", Purchase time : "+remainingSecPair.second);
    if(DemoApplication.EMPTY.equals(offlineAssetKeyIdStr) || ( remainingSecPair.first == 0 || remainingSecPair.second == 0)) {
        String path = getIntent().getStringExtra(EXTRA_OFFLINE_URI);
        File file = getUriForManifest(path);
        Uri uri = Uri.fromFile(file);
        InputStream is = new FileInputStream(file);
        Log.e(TAG, "will start download now");
        offlineAssetKeyId = offlineLicenseHelper.download(
                DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()).createDataSource(),
                new DashManifestParser().parse(uri, is));
        Pair<Long, Long> p = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId);
        Log.e(TAG, "download done : " + p.toString());

        SharedPreferences sharedPreferences = DemoApplication.getAppInstance().getSharedPreferences();
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(DemoApplication.KEY_OFFLINE_OFFSET_ID,
                Base64.encodeToString(offlineAssetKeyId, Base64.DEFAULT));
        editor.commit();
    }


    drmSessionManager.setMode(DefaultDrmSessionManager.MODE_QUERY,offlineAssetKeyId);
    return drmSessionManager;
}