From 9a498ef11566a5ae82c24b0651c58280309dfd04 Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Tue, 31 Mar 2015 15:47:24 -0700 Subject: [PATCH] Add expiration update and keys change events In support of unprefixed EME bug: 19771612 bug: 19771431 Change-Id: Ibb8471701a62dedfbf5231ad958e2c33ebb3c42f --- include/media/drm/DrmAPI.h | 63 ++++++++++++++++++++++++++++-- include/media/hardware/CryptoAPI.h | 3 +- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/include/media/drm/DrmAPI.h b/include/media/drm/DrmAPI.h index b01476a92..272881b9f 100644 --- a/include/media/drm/DrmAPI.h +++ b/include/media/drm/DrmAPI.h @@ -81,7 +81,9 @@ namespace android { kDrmPluginEventKeyNeeded, kDrmPluginEventKeyExpired, kDrmPluginEventVendorDefined, - kDrmPluginEventSessionReclaimed + kDrmPluginEventSessionReclaimed, + kDrmPluginEventExpirationUpdate, + kDrmPluginEventKeysChange, }; // Drm keys can be for offline content or for online streaming. @@ -103,6 +105,24 @@ namespace android { kKeyRequestType_Release }; + // Enumerate KeyStatusTypes which indicate the state of a key + enum KeyStatusType + { + kKeyStatusType_Usable, + kKeyStatusType_Expired, + kKeyStatusType_OutputNotAllowed, + kKeyStatusType_StatusPending, + kKeyStatusType_InternalError + }; + + // Used by sendKeysChange to report the usability status of each + // key to the app. + struct KeyStatus + { + Vector mKeyId; + KeyStatusType mType; + }; + DrmPlugin() {} virtual ~DrmPlugin() {} @@ -326,11 +346,18 @@ namespace android { } protected: - // Plugins call sendEvent to deliver events to the java app + // Plugins call these methods to deliver events to the java app void sendEvent(EventType eventType, int extra, Vector const *sessionId, Vector const *data); + void sendExpirationUpdate(Vector const *sessionId, + int64_t expiryTimeInMS); + + void sendKeysChange(Vector const *sessionId, + Vector const *keyStatusList, + bool hasNewUsableKey); + private: Mutex mEventLock; sp mListener; @@ -342,14 +369,20 @@ namespace android { { public: virtual void sendEvent(DrmPlugin::EventType eventType, int extra, - Vector const *sesionId, + Vector const *sessionId, Vector const *data) = 0; + + virtual void sendExpirationUpdate(Vector const *sessionId, + int64_t expiryTimeInMS) = 0; + + virtual void sendKeysChange(Vector const *sessionId, + Vector const *keyStatusList, + bool hasNewUsableKey) = 0; }; inline void DrmPlugin::sendEvent(EventType eventType, int extra, Vector const *sessionId, Vector const *data) { - mEventLock.lock(); sp listener = mListener; mEventLock.unlock(); @@ -359,6 +392,28 @@ namespace android { } } + inline void DrmPlugin::sendExpirationUpdate(Vector const *sessionId, + int64_t expiryTimeInMS) { + mEventLock.lock(); + sp listener = mListener; + mEventLock.unlock(); + + if (listener != NULL) { + listener->sendExpirationUpdate(sessionId, expiryTimeInMS); + } + } + + inline void DrmPlugin::sendKeysChange(Vector const *sessionId, + Vector const *keyStatusList, + bool hasNewUsableKey) { + mEventLock.lock(); + sp listener = mListener; + mEventLock.unlock(); + + if (listener != NULL) { + listener->sendKeysChange(sessionId, keyStatusList, hasNewUsableKey); + } + } } // namespace android #endif // DRM_API_H_ diff --git a/include/media/hardware/CryptoAPI.h b/include/media/hardware/CryptoAPI.h index c800825a3..ab8e2e277 100644 --- a/include/media/hardware/CryptoAPI.h +++ b/include/media/hardware/CryptoAPI.h @@ -68,7 +68,8 @@ struct CryptoPlugin { // the resolution of the video being decrypted. The media player should // call this method when the resolution is determined and any time it // is subsequently changed. - virtual void notifyResolution(uint32_t width, uint32_t height) {} + + virtual void notifyResolution(uint32_t /* width */, uint32_t /* height */) {} // If the error returned falls into the range // ERROR_DRM_VENDOR_MIN..ERROR_DRM_VENDOR_MAX, errorDetailMsg should be