Add expiration update and keys change events

In support of unprefixed EME

bug: 19771612
bug: 19771431
Change-Id: Ibb8471701a62dedfbf5231ad958e2c33ebb3c42f
This commit is contained in:
Jeff Tinker 2015-03-31 15:47:24 -07:00
parent 16af1b044e
commit 9a498ef115
2 changed files with 61 additions and 5 deletions

View File

@ -81,7 +81,9 @@ namespace android {
kDrmPluginEventKeyNeeded, kDrmPluginEventKeyNeeded,
kDrmPluginEventKeyExpired, kDrmPluginEventKeyExpired,
kDrmPluginEventVendorDefined, kDrmPluginEventVendorDefined,
kDrmPluginEventSessionReclaimed kDrmPluginEventSessionReclaimed,
kDrmPluginEventExpirationUpdate,
kDrmPluginEventKeysChange,
}; };
// Drm keys can be for offline content or for online streaming. // Drm keys can be for offline content or for online streaming.
@ -103,6 +105,24 @@ namespace android {
kKeyRequestType_Release 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() {} DrmPlugin() {}
virtual ~DrmPlugin() {} virtual ~DrmPlugin() {}
@ -326,11 +346,18 @@ namespace android {
} }
protected: 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, void sendEvent(EventType eventType, int extra,
Vector<uint8_t> const *sessionId, Vector<uint8_t> const *sessionId,
Vector<uint8_t> const *data); 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: private:
Mutex mEventLock; Mutex mEventLock;
sp<DrmPluginListener> mListener; sp<DrmPluginListener> mListener;
@ -342,14 +369,20 @@ namespace android {
{ {
public: public:
virtual void sendEvent(DrmPlugin::EventType eventType, int extra, virtual void sendEvent(DrmPlugin::EventType eventType, int extra,
Vector<uint8_t> const *sesionId, Vector<uint8_t> const *sessionId,
Vector<uint8_t> const *data) = 0; 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, inline void DrmPlugin::sendEvent(EventType eventType, int extra,
Vector<uint8_t> const *sessionId, Vector<uint8_t> const *sessionId,
Vector<uint8_t> const *data) { Vector<uint8_t> const *data) {
mEventLock.lock(); mEventLock.lock();
sp<DrmPluginListener> listener = mListener; sp<DrmPluginListener> listener = mListener;
mEventLock.unlock(); mEventLock.unlock();
@ -359,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 } // namespace android
#endif // DRM_API_H_ #endif // DRM_API_H_

View File

@ -68,7 +68,8 @@ struct CryptoPlugin {
// the resolution of the video being decrypted. The media player should // the resolution of the video being decrypted. The media player should
// call this method when the resolution is determined and any time it // call this method when the resolution is determined and any time it
// is subsequently changed. // 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 // If the error returned falls into the range
// ERROR_DRM_VENDOR_MIN..ERROR_DRM_VENDOR_MAX, errorDetailMsg should be // ERROR_DRM_VENDOR_MIN..ERROR_DRM_VENDOR_MAX, errorDetailMsg should be