summaryrefslogtreecommitdiff
path: root/drm/1.0/default/CryptoPlugin.cpp
diff options
context:
space:
mode:
authorJeff Tinker <jtinker@google.com>2017-02-16 12:20:30 -0800
committerJeff Tinker <jtinker@google.com>2017-02-17 19:51:03 +0000
commit0b3f41ec8d2420aef8328e00cfbeb8bdbd183dd1 (patch)
tree17773fc939599bcf28fb4f0a7ac2c60aa057ca18 /drm/1.0/default/CryptoPlugin.cpp
parent7ddf7abff5b33eb294cf8cd896a99a1c6ca4fcbc (diff)
Support multiple codecs per crypto instance
The initial drm hidl hal implementation assumed one codec per crypto instance, but in fact there can be multiple codecs per crypto instance. This change extends the drm hal to allow multiple memory heaps per crypto plugin. It fixes the issue of mapping memory frequently during playback. bug:35275191 Test: manual verification with Play Movies on angler and in binderized mode on marlin Change-Id: I0ec36856248623d2ad8acb8ce9873e9274883a40
Diffstat (limited to 'drm/1.0/default/CryptoPlugin.cpp')
-rw-r--r--drm/1.0/default/CryptoPlugin.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/drm/1.0/default/CryptoPlugin.cpp b/drm/1.0/default/CryptoPlugin.cpp
index fb61ede14f..4a4171b66d 100644
--- a/drm/1.0/default/CryptoPlugin.cpp
+++ b/drm/1.0/default/CryptoPlugin.cpp
@@ -49,8 +49,9 @@ namespace implementation {
return toStatus(mLegacyPlugin->setMediaDrmSession(toVector(sessionId)));
}
- Return<void> CryptoPlugin::setSharedBufferBase(const hidl_memory& base) {
- mSharedBufferBase = mapMemory(base);
+ Return<void> CryptoPlugin::setSharedBufferBase(const hidl_memory& base,
+ uint32_t bufferId) {
+ mSharedBufferMap[bufferId] = mapMemory(base);
return Void();
}
@@ -62,11 +63,19 @@ namespace implementation {
const DestinationBuffer& destination,
decrypt_cb _hidl_cb) {
- if (mSharedBufferBase == NULL) {
- _hidl_cb(Status::BAD_VALUE, 0, "decrypt buffer base not set");
+ if (mSharedBufferMap.find(source.bufferId) == mSharedBufferMap.end()) {
+ _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "source decrypt buffer base not set");
return Void();
}
+ if (destination.type == BufferType::SHARED_MEMORY) {
+ const SharedBuffer& dest = destination.nonsecureMemory;
+ if (mSharedBufferMap.find(dest.bufferId) == mSharedBufferMap.end()) {
+ _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "destination decrypt buffer base not set");
+ return Void();
+ }
+ }
+
android::CryptoPlugin::Mode legacyMode;
switch(mode) {
case Mode::UNENCRYPTED:
@@ -97,20 +106,22 @@ namespace implementation {
}
AString detailMessage;
+ sp<IMemory> sourceBase = mSharedBufferMap[source.bufferId];
- if (source.offset + offset + source.size > mSharedBufferBase->getSize()) {
+ if (source.offset + offset + source.size > sourceBase->getSize()) {
_hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size");
return Void();
}
uint8_t *base = static_cast<uint8_t *>
- (static_cast<void *>(mSharedBufferBase->getPointer()));
+ (static_cast<void *>(sourceBase->getPointer()));
void *srcPtr = static_cast<void *>(base + source.offset + offset);
void *destPtr = NULL;
if (destination.type == BufferType::SHARED_MEMORY) {
const SharedBuffer& destBuffer = destination.nonsecureMemory;
- if (destBuffer.offset + destBuffer.size > mSharedBufferBase->getSize()) {
+ sp<IMemory> destBase = mSharedBufferMap[destBuffer.bufferId];
+ if (destBuffer.offset + destBuffer.size > destBase->getSize()) {
_hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size");
return Void();
}