diff options
Diffstat (limited to 'include/media/drm/DrmAPI.h')
-rw-r--r-- | include/media/drm/DrmAPI.h | 76 |
1 files changed, 71 insertions, 5 deletions
diff --git a/include/media/drm/DrmAPI.h b/include/media/drm/DrmAPI.h index 49939fd..272881b 100644 --- a/include/media/drm/DrmAPI.h +++ b/include/media/drm/DrmAPI.h @@ -80,7 +80,10 @@ namespace android { kDrmPluginEventProvisionRequired = 1, kDrmPluginEventKeyNeeded, kDrmPluginEventKeyExpired, - kDrmPluginEventVendorDefined + kDrmPluginEventVendorDefined, + kDrmPluginEventSessionReclaimed, + kDrmPluginEventExpirationUpdate, + kDrmPluginEventKeysChange, }; // Drm keys can be for offline content or for online streaming. @@ -93,6 +96,33 @@ namespace android { kKeyType_Release }; + // Enumerate KeyRequestTypes to allow an app to determine the + // type of a key request returned from getKeyRequest. + enum KeyRequestType { + kKeyRequestType_Unknown, + kKeyRequestType_Initial, + kKeyRequestType_Renewal, + 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<uint8_t> mKeyId; + KeyStatusType mType; + }; + DrmPlugin() {} virtual ~DrmPlugin() {} @@ -135,7 +165,8 @@ namespace android { Vector<uint8_t> const &initData, String8 const &mimeType, KeyType keyType, KeyedVector<String8, String8> const &optionalParameters, - Vector<uint8_t> &request, String8 &defaultUrl) = 0; + Vector<uint8_t> &request, String8 &defaultUrl, + KeyRequestType *keyRequestType) = 0; // // After a key response is received by the app, it is provided to the @@ -315,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<uint8_t> const *sessionId, Vector<uint8_t> const *data); + void sendExpirationUpdate(Vector<uint8_t> const *sessionId, + int64_t expiryTimeInMS); + + void sendKeysChange(Vector<uint8_t> const *sessionId, + Vector<DrmPlugin::KeyStatus> const *keyStatusList, + bool hasNewUsableKey); + private: Mutex mEventLock; sp<DrmPluginListener> mListener; @@ -331,14 +369,20 @@ namespace android { { public: virtual void sendEvent(DrmPlugin::EventType eventType, int extra, - Vector<uint8_t> const *sesionId, + Vector<uint8_t> const *sessionId, Vector<uint8_t> const *data) = 0; + + virtual void sendExpirationUpdate(Vector<uint8_t> const *sessionId, + int64_t expiryTimeInMS) = 0; + + virtual void sendKeysChange(Vector<uint8_t> const *sessionId, + Vector<DrmPlugin::KeyStatus> const *keyStatusList, + bool hasNewUsableKey) = 0; }; inline void DrmPlugin::sendEvent(EventType eventType, int extra, Vector<uint8_t> const *sessionId, Vector<uint8_t> const *data) { - mEventLock.lock(); sp<DrmPluginListener> listener = mListener; mEventLock.unlock(); @@ -348,6 +392,28 @@ namespace android { } } + inline void DrmPlugin::sendExpirationUpdate(Vector<uint8_t> const *sessionId, + int64_t expiryTimeInMS) { + mEventLock.lock(); + sp<DrmPluginListener> listener = mListener; + mEventLock.unlock(); + + if (listener != NULL) { + listener->sendExpirationUpdate(sessionId, expiryTimeInMS); + } + } + + inline void DrmPlugin::sendKeysChange(Vector<uint8_t> const *sessionId, + Vector<DrmPlugin::KeyStatus> const *keyStatusList, + bool hasNewUsableKey) { + mEventLock.lock(); + sp<DrmPluginListener> listener = mListener; + mEventLock.unlock(); + + if (listener != NULL) { + listener->sendKeysChange(sessionId, keyStatusList, hasNewUsableKey); + } + } } // namespace android #endif // DRM_API_H_ |