Set correct Content-Type for ClearKey requests

Issue: #3138

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164434858
This commit is contained in:
olly 2017-08-07 01:53:09 -07:00 committed by Oliver Woodman
parent 1f66f30ccd
commit df05195f5f

View File

@ -38,14 +38,6 @@ import java.util.UUID;
@TargetApi(18)
public final class HttpMediaDrmCallback implements MediaDrmCallback {
private static final Map<String, String> PLAYREADY_KEY_REQUEST_PROPERTIES;
static {
PLAYREADY_KEY_REQUEST_PROPERTIES = new HashMap<>();
PLAYREADY_KEY_REQUEST_PROPERTIES.put("Content-Type", "text/xml");
PLAYREADY_KEY_REQUEST_PROPERTIES.put("SOAPAction",
"http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
}
private final HttpDataSource.Factory dataSourceFactory;
private final String defaultUrl;
private final Map<String, String> keyRequestProperties;
@ -124,10 +116,15 @@ public final class HttpMediaDrmCallback implements MediaDrmCallback {
url = defaultUrl;
}
Map<String, String> requestProperties = new HashMap<>();
requestProperties.put("Content-Type", "application/octet-stream");
// Add standard request properties for supported schemes.
String contentType = C.PLAYREADY_UUID.equals(uuid) ? "text/xml"
: (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream");
requestProperties.put("Content-Type", contentType);
if (C.PLAYREADY_UUID.equals(uuid)) {
requestProperties.putAll(PLAYREADY_KEY_REQUEST_PROPERTIES);
requestProperties.put("SOAPAction",
"http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
}
// Add additional request properties.
synchronized (keyRequestProperties) {
requestProperties.putAll(keyRequestProperties);
}