diff options
author | Jeff Tinker <jtinker@google.com> | 2013-04-02 13:08:05 -0700 |
---|---|---|
committer | Jeff Tinker <jtinker@google.com> | 2013-04-03 12:20:53 -0700 |
commit | 0cb126a34fe32f81c830858102471e7be2ce85b1 (patch) | |
tree | a20999e4b89a78375a1b69cb3a0bef96fab74362 /media/libmediaplayerservice/Drm.cpp | |
parent | 8856c8b8777d0e0de11b2de863a336b001024e29 (diff) | |
download | frameworks_av-0cb126a34fe32f81c830858102471e7be2ce85b1.zip frameworks_av-0cb126a34fe32f81c830858102471e7be2ce85b1.tar.gz frameworks_av-0cb126a34fe32f81c830858102471e7be2ce85b1.tar.bz2 |
Implement async event callout from drm plugin to Java app
Change-Id: I007f147d693664e777b8758be2bb8a4c7ec0236b
Diffstat (limited to 'media/libmediaplayerservice/Drm.cpp')
-rw-r--r-- | media/libmediaplayerservice/Drm.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/media/libmediaplayerservice/Drm.cpp b/media/libmediaplayerservice/Drm.cpp index 5fdb9f4..1e6cd94 100644 --- a/media/libmediaplayerservice/Drm.cpp +++ b/media/libmediaplayerservice/Drm.cpp @@ -47,6 +47,7 @@ static bool operator<(const Vector<uint8_t> &lhs, const Vector<uint8_t> &rhs) { Drm::Drm() : mInitCheck(NO_INIT), + mListener(NULL), mFactory(NULL), mPlugin(NULL) { } @@ -67,6 +68,41 @@ status_t Drm::initCheck() const { return mInitCheck; } +status_t Drm::setListener(const sp<IDrmClient>& listener) +{ + Mutex::Autolock lock(mEventLock); + mListener = listener; + return NO_ERROR; +} + +void Drm::sendEvent(DrmPlugin::EventType eventType, int extra, + Vector<uint8_t> const *sessionId, + Vector<uint8_t> const *data) +{ + mEventLock.lock(); + sp<IDrmClient> listener = mListener; + mEventLock.unlock(); + + if (listener != NULL) { + Parcel obj; + if (sessionId && sessionId->size()) { + obj.writeInt32(sessionId->size()); + obj.write(sessionId->array(), sessionId->size()); + } else { + obj.writeInt32(0); + } + + if (data && data->size()) { + obj.writeInt32(data->size()); + obj.write(data->array(), data->size()); + } else { + obj.writeInt32(0); + } + + Mutex::Autolock lock(mNotifyLock); + listener->notify(eventType, extra, &obj); + } +} /* * Search the plugins directory for a plugin that supports the scheme @@ -195,7 +231,9 @@ status_t Drm::createPlugin(const uint8_t uuid[16]) { return mInitCheck; } - return mFactory->createDrmPlugin(uuid, &mPlugin); + status_t result = mFactory->createDrmPlugin(uuid, &mPlugin); + mPlugin->setListener(this); + return result; } status_t Drm::destroyPlugin() { |