diff options
author | Robert Shih <robertshih@google.com> | 2019-07-16 16:29:44 -0700 |
---|---|---|
committer | Robert Shih <robertshih@google.com> | 2019-11-17 12:20:17 -0800 |
commit | 44f4acbc0e63b95c9c5f236280b08d87171028f8 (patch) | |
tree | 2b8202a8f5210d386eab197669c84806e420c421 | |
parent | a13b547c8a149f0c192413c8ac2bfb30a050702f (diff) | |
download | av-44f4acbc0e63b95c9c5f236280b08d87171028f8.tar.gz |
ICrypto: use hidl memory instead of binder memory
Bug: 134787536
Test: GtsMediaTestCases
Change-Id: I508cadec6aea04a6808dbdad86f3b68c04bfc2a5
-rw-r--r-- | media/sfplugin/Android.bp | 1 | ||||
-rw-r--r-- | media/sfplugin/CCodecBufferChannel.cpp | 24 | ||||
-rw-r--r-- | media/sfplugin/Codec2Buffer.cpp | 6 | ||||
-rw-r--r-- | media/sfplugin/Codec2Buffer.h | 4 |
4 files changed, 23 insertions, 12 deletions
diff --git a/media/sfplugin/Android.bp b/media/sfplugin/Android.bp index 95d2740..3565688 100644 --- a/media/sfplugin/Android.bp +++ b/media/sfplugin/Android.bp @@ -25,6 +25,7 @@ cc_library_shared { shared_libs: [ "android.hardware.cas.native@1.0", + "android.hardware.drm@1.0", "android.hardware.graphics.bufferqueue@1.0", "android.hardware.media.omx@1.0", "hardware.google.media.c2@1.0", diff --git a/media/sfplugin/CCodecBufferChannel.cpp b/media/sfplugin/CCodecBufferChannel.cpp index 455232c..0b1fa1d 100644 --- a/media/sfplugin/CCodecBufferChannel.cpp +++ b/media/sfplugin/CCodecBufferChannel.cpp @@ -27,10 +27,12 @@ #include <C2Debug.h> #include <android/hardware/cas/native/1.0/IDescrambler.h> +#include <android/hardware/drm/1.0/types.h> #include <android-base/stringprintf.h> #include <binder/MemoryDealer.h> #include <cutils/properties.h> #include <gui/Surface.h> +#include <hidlmemory/FrameworkUtils.h> #include <media/openmax/OMX_Core.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ALookup.h> @@ -52,10 +54,14 @@ using android::base::StringPrintf; using hardware::hidl_handle; using hardware::hidl_string; using hardware::hidl_vec; +using hardware::fromHeap; +using hardware::HidlMemory; + using namespace hardware::cas::V1_0; using namespace hardware::cas::native::V1_0; using CasStatus = hardware::cas::V1_0::Status; +using DrmBufferType = hardware::drm::V1_0::BufferType; /** * Base class for representation of buffers at one port. @@ -1733,15 +1739,16 @@ status_t CCodecBufferChannel::queueSecureInputBuffer( ssize_t result = -1; ssize_t codecDataOffset = 0; if (mCrypto != nullptr) { - ICrypto::DestinationBuffer destination; + hardware::drm::V1_0::DestinationBuffer destination; if (secure) { - destination.mType = ICrypto::kDestinationTypeNativeHandle; - destination.mHandle = encryptedBuffer->handle(); + destination.type = DrmBufferType::NATIVE_HANDLE; + destination.secureMemory = hidl_handle(encryptedBuffer->handle()); } else { - destination.mType = ICrypto::kDestinationTypeSharedMemory; - destination.mSharedMemory = mDecryptDestination; + destination.type = DrmBufferType::SHARED_MEMORY; + IMemoryToSharedBuffer( + mDecryptDestination, mHeapSeqNum, &destination.nonsecureMemory); } - ICrypto::SourceBuffer source; + hardware::drm::V1_0::SharedBuffer source; encryptedBuffer->fillSourceBuffer(&source); result = mCrypto->decrypt( key, iv, mode, pattern, source, buffer->offset(), @@ -1749,7 +1756,7 @@ status_t CCodecBufferChannel::queueSecureInputBuffer( if (result < 0) { return result; } - if (destination.mType == ICrypto::kDestinationTypeSharedMemory) { + if (destination.type == DrmBufferType::SHARED_MEMORY) { encryptedBuffer->copyDecryptedContent(mDecryptDestination, result); } } else { @@ -2188,7 +2195,8 @@ status_t CCodecBufferChannel::start( mDecryptDestination = mDealer->allocate((size_t)capacity); } if (mCrypto != nullptr && mHeapSeqNum < 0) { - mHeapSeqNum = mCrypto->setHeap(mDealer->getMemoryHeap()); + sp<HidlMemory> heap = fromHeap(mDealer->getMemoryHeap()); + mHeapSeqNum = mCrypto->setHeap(heap); } else { mHeapSeqNum = -1; } diff --git a/media/sfplugin/Codec2Buffer.cpp b/media/sfplugin/Codec2Buffer.cpp index ecc8c93..8db9110 100644 --- a/media/sfplugin/Codec2Buffer.cpp +++ b/media/sfplugin/Codec2Buffer.cpp @@ -20,6 +20,7 @@ #include <hidlmemory/FrameworkUtils.h> #include <media/hardware/HardwareAPI.h> +#include <media/stagefright/CodecBase.h> #include <media/stagefright/MediaCodecConstants.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/AMessage.h> @@ -773,9 +774,8 @@ std::shared_ptr<C2Buffer> EncryptedLinearBlockBuffer::asC2Buffer() { } void EncryptedLinearBlockBuffer::fillSourceBuffer( - ICrypto::SourceBuffer *source) { - source->mSharedMemory = mMemory; - source->mHeapSeqNum = mHeapSeqNum; + hardware::drm::V1_0::SharedBuffer *source) { + BufferChannelBase::IMemoryToSharedBuffer(mMemory, mHeapSeqNum, source); } void EncryptedLinearBlockBuffer::fillSourceBuffer( diff --git a/media/sfplugin/Codec2Buffer.h b/media/sfplugin/Codec2Buffer.h index d5d41a4..1cf3de1 100644 --- a/media/sfplugin/Codec2Buffer.h +++ b/media/sfplugin/Codec2Buffer.h @@ -21,6 +21,7 @@ #include <C2Buffer.h> #include <android/hardware/cas/native/1.0/types.h> +#include <android/hardware/drm/1.0/types.h> #include <binder/IMemory.h> #include <media/hardware/VideoAPI.h> #include <media/MediaCodecBuffer.h> @@ -358,7 +359,8 @@ public: * * \param source source buffer structure to fill. */ - void fillSourceBuffer(ICrypto::SourceBuffer *source); + void fillSourceBuffer( + hardware::drm::V1_0::SharedBuffer *source); void fillSourceBuffer( hardware::cas::native::V1_0::SharedBuffer *source); |