diff options
author | Jeff Tinker <jtinker@google.com> | 2013-04-02 13:16:21 -0700 |
---|---|---|
committer | Jeff Tinker <jtinker@google.com> | 2013-04-03 12:02:59 -0700 |
commit | 7eafcae5ffb7f6f12ee573dea685dc6989a0ee91 (patch) | |
tree | 6d2706bd5f42350d71a60e1afc69c299abff8763 /include/media/drm | |
parent | bcbd78bd246f1e68e44b4a6d6257dbfcec8e65b3 (diff) | |
download | frameworks_native-7eafcae5ffb7f6f12ee573dea685dc6989a0ee91.zip frameworks_native-7eafcae5ffb7f6f12ee573dea685dc6989a0ee91.tar.gz frameworks_native-7eafcae5ffb7f6f12ee573dea685dc6989a0ee91.tar.bz2 |
Implement async event callout from drm plugin to Java app
Change-Id: I83a7757a7b83676ce1a9ffa6ff0a8e495e31b859
Diffstat (limited to 'include/media/drm')
-rw-r--r-- | include/media/drm/DrmAPI.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/include/media/drm/DrmAPI.h b/include/media/drm/DrmAPI.h index 81d1ec0..c89f2d6 100644 --- a/include/media/drm/DrmAPI.h +++ b/include/media/drm/DrmAPI.h @@ -22,6 +22,7 @@ #include <utils/Vector.h> #include <utils/KeyedVector.h> #include <utils/RefBase.h> +#include <utils/Mutex.h> #include <media/stagefright/foundation/ABase.h> // Loadable DrmEngine shared libraries should define the entry points @@ -34,7 +35,8 @@ namespace android { - struct DrmPlugin; + class DrmPlugin; + class DrmPluginListener; // DRMs are implemented in DrmEngine plugins, which are dynamically // loadable shared libraries that implement the entry points @@ -70,7 +72,7 @@ namespace android { class DrmPlugin { public: enum EventType { - kDrmPluginEventProvisionRequired, + kDrmPluginEventProvisionRequired = 1, kDrmPluginEventKeyNeeded, kDrmPluginEventKeyExpired, kDrmPluginEventVendorDefined @@ -261,12 +263,46 @@ namespace android { bool &match) = 0; + status_t setListener(const sp<DrmPluginListener>& listener) { + Mutex::Autolock lock(mEventLock); + mListener = listener; + return OK; + } + + protected: + // Plugins call sendEvent to deliver events to the java app + void sendEvent(EventType eventType, int extra, + Vector<uint8_t> const *sessionId, + Vector<uint8_t> const *data); - // TODO: provide way to send an event private: + Mutex mEventLock; + sp<DrmPluginListener> mListener; + DISALLOW_EVIL_CONSTRUCTORS(DrmPlugin); }; + class DrmPluginListener: virtual public RefBase + { + public: + virtual void sendEvent(DrmPlugin::EventType eventType, int extra, + Vector<uint8_t> const *sesionId, + Vector<uint8_t> const *data) = 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(); + + if (listener != NULL) { + listener->sendEvent(eventType, extra, sessionId, data); + } + } + } // namespace android #endif // DRM_API_H_ |