Revert "Add possibility of forcing a specific license URL in HttpMediaDrmCallback"

This reverts commit 768a73b377d842aeefdd466cf7a5904f858cc8a4.
This commit is contained in:
Oliver Woodman 2017-08-10 12:57:06 +01:00
parent 3f31cec742
commit ceb1e87219
2 changed files with 22 additions and 45 deletions

View File

@ -39,29 +39,29 @@ import java.util.UUID;
public final class HttpMediaDrmCallback implements MediaDrmCallback { public final class HttpMediaDrmCallback implements MediaDrmCallback {
private final HttpDataSource.Factory dataSourceFactory; private final HttpDataSource.Factory dataSourceFactory;
private final String defaultLicenseUrl; private final String defaultUrl;
private final boolean forceDefaultLicenseUrl;
private final Map<String, String> keyRequestProperties; private final Map<String, String> keyRequestProperties;
/** /**
* @param defaultLicenseUrl The default license URL. * @param defaultUrl The default license URL.
* @param dataSourceFactory A factory from which to obtain {@link HttpDataSource} instances. * @param dataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
*/ */
public HttpMediaDrmCallback(String defaultLicenseUrl, HttpDataSource.Factory dataSourceFactory) { public HttpMediaDrmCallback(String defaultUrl, HttpDataSource.Factory dataSourceFactory) {
this(defaultLicenseUrl, false, dataSourceFactory, null); this(defaultUrl, dataSourceFactory, null);
} }
/** /**
* @param defaultLicenseUrl The default license URL. * @deprecated Use {@link HttpMediaDrmCallback#HttpMediaDrmCallback(String, Factory)}. Request
* @param forceDefaultLicenseUrl Whether to force use of {@code defaultLicenseUrl} even for key * properties can be set by calling {@link #setKeyRequestProperty(String, String)}.
* requests that include their own license URL. * @param defaultUrl The default license URL.
* @param dataSourceFactory A factory from which to obtain {@link HttpDataSource} instances. * @param dataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
* @param keyRequestProperties Request properties to set when making key requests, or null.
*/ */
public HttpMediaDrmCallback(String defaultLicenseUrl, boolean forceDefaultLicenseUrl, @Deprecated
HttpDataSource.Factory dataSourceFactory, Map<String, String> keyRequestProperties) { public HttpMediaDrmCallback(String defaultUrl, HttpDataSource.Factory dataSourceFactory,
Map<String, String> keyRequestProperties) {
this.dataSourceFactory = dataSourceFactory; this.dataSourceFactory = dataSourceFactory;
this.defaultLicenseUrl = defaultLicenseUrl; this.defaultUrl = defaultUrl;
this.forceDefaultLicenseUrl = forceDefaultLicenseUrl;
this.keyRequestProperties = new HashMap<>(); this.keyRequestProperties = new HashMap<>();
if (keyRequestProperties != null) { if (keyRequestProperties != null) {
this.keyRequestProperties.putAll(keyRequestProperties); this.keyRequestProperties.putAll(keyRequestProperties);
@ -112,8 +112,8 @@ public final class HttpMediaDrmCallback implements MediaDrmCallback {
@Override @Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception { public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
String url = request.getDefaultUrl(); String url = request.getDefaultUrl();
if (forceDefaultLicenseUrl || TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
url = defaultLicenseUrl; url = defaultUrl;
} }
Map<String, String> requestProperties = new HashMap<>(); Map<String, String> requestProperties = new HashMap<>();
// Add standard request properties for supported schemes. // Add standard request properties for supported schemes.

View File

@ -43,44 +43,23 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
* Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
* is no longer required. * is no longer required.
* *
* @param defaultLicenseUrl The default license URL. * @param licenseUrl The default license URL.
* @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances. * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
* @return A new instance which uses Widevine CDM. * @return A new instance which uses Widevine CDM.
* @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
* instantiated. * instantiated.
*/ */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance( public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
String defaultLicenseUrl, Factory httpDataSourceFactory) String licenseUrl, Factory httpDataSourceFactory) throws UnsupportedDrmException {
throws UnsupportedDrmException { return newWidevineInstance(
return newWidevineInstance(defaultLicenseUrl, false, httpDataSourceFactory, null); new HttpMediaDrmCallback(licenseUrl, httpDataSourceFactory), null);
} }
/** /**
* Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
* is no longer required. * is no longer required.
* *
* @param defaultLicenseUrl The default license URL. * @param callback Performs key and provisioning requests.
* @param forceDefaultLicenseUrl Whether to force use of {@code defaultLicenseUrl} even for key
* requests that include their own license URL.
* @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
* @return A new instance which uses Widevine CDM.
* @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
* instantiated.
*/
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory)
throws UnsupportedDrmException {
return newWidevineInstance(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory,
null);
}
/**
* Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
* is no longer required.
*
* @param defaultLicenseUrl The default license URL.
* @param forceDefaultLicenseUrl Whether to force use of {@code defaultLicenseUrl} even for key
* requests that include their own license URL.
* @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
* to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null. * to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null.
* @return A new instance which uses Widevine CDM. * @return A new instance which uses Widevine CDM.
@ -90,12 +69,10 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
* MediaDrmCallback, HashMap, Handler, EventListener) * MediaDrmCallback, HashMap, Handler, EventListener)
*/ */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance( public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory, MediaDrmCallback callback, HashMap<String, String> optionalKeyRequestParameters)
HashMap<String, String> optionalKeyRequestParameters)
throws UnsupportedDrmException { throws UnsupportedDrmException {
return new OfflineLicenseHelper<>(FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID), return new OfflineLicenseHelper<>(FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID), callback,
new HttpMediaDrmCallback(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory, optionalKeyRequestParameters);
null), optionalKeyRequestParameters);
} }
/** /**