/** * Generates the {@link DrmSessionManager} to use with the {@link RendererProvider}. This will * return null on API's < {@value Build.VERSION_CODES#JELLY_BEAN_MR2} * * @return The {@link DrmSessionManager} to use or <code>null</code> */ @Nullable protected DrmSessionManager<FrameworkMediaCrypto> generateDrmSessionManager() { // DRM is only supported on API 18 + in the ExoPlayer if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { return null; } // Widevine will capture the majority of use cases however playready is supported on all AndroidTV devices UUID uuid = C.WIDEVINE_UUID; try { return new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), new DelegatedMediaDrmCallback(), null, mainHandler, capabilitiesListener); } catch (Exception e) { Log.d(TAG, "Unable to create a DrmSessionManager due to an exception", e); return null; } }
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); }
@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()); } }
@Override public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener) { FrameworkMediaDrm frameworkMediaDrm = frameworkMediaDrmCreator.create(WIDEVINE_MODULAR_UUID); return new DefaultDrmSessionManager<>( WIDEVINE_MODULAR_UUID, frameworkMediaDrm, mediaDrmCallback, NO_OPTIONAL_PARAMETERS, handler, eventListener ); }
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); }
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); }
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; }