diff options
Diffstat (limited to 'drm/mediadrm/plugins/clearkey/DrmPlugin.cpp')
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/DrmPlugin.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp b/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp index 5fdac5cadf..ec07d87b1c 100644 --- a/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp +++ b/drm/mediadrm/plugins/clearkey/DrmPlugin.cpp @@ -25,10 +25,28 @@ #include "Session.h" +namespace { +const android::String8 kStreaming("Streaming"); +const android::String8 kOffline("Offline"); +const android::String8 kTrue("True"); + +const android::String8 kQueryKeyLicenseType("LicenseType"); + // Value: "Streaming" or "Offline" +const android::String8 kQueryKeyPlayAllowed("PlayAllowed"); + // Value: "True" or "False" +const android::String8 kQueryKeyRenewAllowed("RenewAllowed"); + // Value: "True" or "False" +}; + namespace clearkeydrm { using android::sp; +DrmPlugin::DrmPlugin(SessionLibrary* sessionLibrary) + : mSessionLibrary(sessionLibrary) { + mPlayPolicy.clear(); +} + status_t DrmPlugin::openSession(Vector<uint8_t>& sessionId) { sp<Session> session = mSessionLibrary->createSession(); sessionId = session->sessionId(); @@ -60,18 +78,28 @@ status_t DrmPlugin::getKeyRequest( if (scope.size() == 0) { return android::BAD_VALUE; } + if (keyType != kKeyType_Streaming) { return android::ERROR_DRM_CANNOT_HANDLE; } + *keyRequestType = DrmPlugin::kKeyRequestType_Initial; defaultUrl.clear(); sp<Session> session = mSessionLibrary->findSession(scope); if (!session.get()) { return android::ERROR_DRM_SESSION_NOT_OPENED; } + return session->getKeyRequest(initData, mimeType, &request); } +void DrmPlugin::setPlayPolicy() { + mPlayPolicy.clear(); + mPlayPolicy.add(kQueryKeyLicenseType, kStreaming); + mPlayPolicy.add(kQueryKeyPlayAllowed, kTrue); + mPlayPolicy.add(kQueryKeyRenewAllowed, kTrue); +} + status_t DrmPlugin::provideKeyResponse( const Vector<uint8_t>& scope, const Vector<uint8_t>& response, @@ -83,6 +111,8 @@ status_t DrmPlugin::provideKeyResponse( if (!session.get()) { return android::ERROR_DRM_SESSION_NOT_OPENED; } + + setPlayPolicy(); status_t res = session->provideKeyResponse(response); if (res == android::OK) { // This is for testing AMediaDrm_setOnEventListener only. @@ -111,4 +141,18 @@ status_t DrmPlugin::getPropertyString( return android::OK; } +status_t DrmPlugin::queryKeyStatus( + const Vector<uint8_t>& sessionId, + KeyedVector<String8, String8>& infoMap) const { + + if (sessionId.size() == 0) { + return android::BAD_VALUE; + } + + infoMap.clear(); + for (size_t i = 0; i < mPlayPolicy.size(); ++i) { + infoMap.add(mPlayPolicy.keyAt(i), mPlayPolicy.valueAt(i)); + } + return android::OK; +} } // namespace clearkeydrm |
