Support Offline Licenses
Bug: 8621588 Merge of the following CLs from the Widevine CDM repository: https://widevine-internal-review.googlesource.com/#/c/5602/ https://widevine-internal-review.googlesource.com/#/c/5431/ https://widevine-internal-review.googlesource.com/#/c/5660/ Change-Id: If37940e2535e1a1eca95e4394d8cf9bf689e9c3a
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "WVDrmPlugin.h"
|
||||
|
||||
#include <endian.h>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -115,7 +116,7 @@ status_t WVDrmPlugin::closeSession(const Vector<uint8_t>& sessionId) {
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::getKeyRequest(
|
||||
const Vector<uint8_t>& sessionId,
|
||||
const Vector<uint8_t>& scope,
|
||||
const Vector<uint8_t>& initData,
|
||||
const String8& mimeType,
|
||||
KeyType keyType,
|
||||
@@ -123,14 +124,20 @@ status_t WVDrmPlugin::getKeyRequest(
|
||||
Vector<uint8_t>& request,
|
||||
String8& defaultUrl) {
|
||||
CdmLicenseType cdmLicenseType;
|
||||
CdmSessionId cdmSessionId;
|
||||
CdmKeySetId cdmKeySetId;
|
||||
if (keyType == kKeyType_Offline) {
|
||||
cdmLicenseType = kLicenseTypeOffline;
|
||||
cdmSessionId.assign(scope.begin(), scope.end());
|
||||
} else if (keyType == kKeyType_Streaming) {
|
||||
cdmLicenseType = kLicenseTypeStreaming;
|
||||
cdmSessionId.assign(scope.begin(), scope.end());
|
||||
} else if (keyType == kKeyType_Release) {
|
||||
cdmLicenseType = kLicenseTypeRelease;
|
||||
cdmKeySetId.assign(scope.begin(), scope.end());
|
||||
} else {
|
||||
return android::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
||||
|
||||
// Build PSSH box for PSSH data in initData.
|
||||
static const char psshPrefix[] = {
|
||||
@@ -163,8 +170,8 @@ status_t WVDrmPlugin::getKeyRequest(
|
||||
CdmKeyMessage keyRequest;
|
||||
string cdmDefaultUrl;
|
||||
|
||||
CdmResponseType res = mCDM->GenerateKeyRequest(cdmSessionId, psshBox,
|
||||
cdmLicenseType,
|
||||
CdmResponseType res = mCDM->GenerateKeyRequest(cdmSessionId, cdmKeySetId,
|
||||
psshBox, cdmLicenseType,
|
||||
cdmParameters, &keyRequest,
|
||||
&cdmDefaultUrl);
|
||||
|
||||
@@ -177,31 +184,69 @@ status_t WVDrmPlugin::getKeyRequest(
|
||||
keyRequest.size());
|
||||
}
|
||||
|
||||
return mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
if (keyType == kKeyType_Release) {
|
||||
// When releasing keys, we do not have a session ID.
|
||||
return mapCdmResponseType(res);
|
||||
} else {
|
||||
// For all other requests, we have a session ID.
|
||||
return mapAndNotifyOfCdmResponseType(scope, res);
|
||||
}
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::provideKeyResponse(
|
||||
const Vector<uint8_t>& sessionId,
|
||||
const Vector<uint8_t>& scope,
|
||||
const Vector<uint8_t>& response,
|
||||
Vector<uint8_t>& keySetId) {
|
||||
// TODO: return keySetId for persisted offline content
|
||||
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
||||
CdmSessionId cdmSessionId;
|
||||
CdmKeyResponse cdmResponse(response.begin(), response.end());
|
||||
CdmKeySetId cdmKeySetId;
|
||||
|
||||
CdmResponseType res = mCDM->AddKey(cdmSessionId, cdmResponse);
|
||||
bool isRequest = (memcmp(scope.array(), SESSION_ID_PREFIX.data(),
|
||||
SESSION_ID_PREFIX.size()) == 0);
|
||||
bool isRelease = (memcmp(scope.array(), KEY_SET_ID_PREFIX.data(),
|
||||
KEY_SET_ID_PREFIX.size()) == 0);
|
||||
|
||||
return mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
if (isRequest) {
|
||||
cdmSessionId.assign(scope.begin(), scope.end());
|
||||
} else if (isRelease) {
|
||||
cdmKeySetId.assign(scope.begin(), scope.end());
|
||||
} else {
|
||||
return android::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
CdmResponseType res = mCDM->AddKey(cdmSessionId, cdmResponse, cdmKeySetId);
|
||||
|
||||
if (isRequest && isCdmResponseTypeSuccess(res)) {
|
||||
keySetId.clear();
|
||||
keySetId.appendArray(reinterpret_cast<const uint8_t*>(cdmKeySetId.data()),
|
||||
cdmKeySetId.size());
|
||||
}
|
||||
|
||||
if (isRelease) {
|
||||
// When releasing keys, we do not have a session ID.
|
||||
return mapCdmResponseType(res);
|
||||
} else {
|
||||
// For all other requests, we have a session ID.
|
||||
return mapAndNotifyOfCdmResponseType(scope, res);
|
||||
}
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::removeKeys(const Vector<uint8_t>& keySetId) {
|
||||
// TODO: remove persisted offline keys associated with keySetId
|
||||
return android::ERROR_UNSUPPORTED;
|
||||
status_t WVDrmPlugin::removeKeys(const Vector<uint8_t>& sessionId) {
|
||||
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
||||
|
||||
CdmResponseType res = mCDM->CancelKeyRequest(cdmSessionId);
|
||||
|
||||
return mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::restoreKeys(const Vector<uint8_t>& sessionId,
|
||||
const Vector<uint8_t>& keySetId) {
|
||||
// TODO: restore persisted offline keys associated with keySetId
|
||||
return android::ERROR_UNSUPPORTED;
|
||||
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
||||
CdmKeySetId cdmKeySetId(keySetId.begin(), keySetId.end());
|
||||
|
||||
CdmResponseType res = mCDM->RestoreKey(cdmSessionId, cdmKeySetId);
|
||||
|
||||
return mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::queryKeyStatus(
|
||||
|
||||
Reference in New Issue
Block a user