diff options
author | Jeff Tinker <jtinker@google.com> | 2015-04-06 18:21:05 -0700 |
---|---|---|
committer | Jeff Tinker <jtinker@google.com> | 2015-04-08 18:33:59 -0700 |
commit | c481b5012a5f6cf72e5e93b36f1ed4c9169916f2 (patch) | |
tree | bbb7920204199b43cd24075d48b8fa387a43059f /media/libstagefright | |
parent | e41b5f31148f9cfb7316295c900c7d3c695510b2 (diff) | |
download | frameworks_av-c481b5012a5f6cf72e5e93b36f1ed4c9169916f2.zip frameworks_av-c481b5012a5f6cf72e5e93b36f1ed4c9169916f2.tar.gz frameworks_av-c481b5012a5f6cf72e5e93b36f1ed4c9169916f2.tar.bz2 |
Pass crypto source data using a shared buffer
MediaCodec was using a binder transaction buffer
to pass encryption source data for protected content.
On some 4K content, the max binder transaction buffer
size was being exceeded. This change uses a shared
buffer for the encryption source data instead of a
binder transaction buffer, which avoids the problem and
may be more efficient.
bug: 20027687
Change-Id: I36a24ebf600d7e1064b78e48b167fdc29b2c65e9
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/MediaCodec.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 0597f1d..8186f63 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -22,7 +22,9 @@ #include "include/SoftwareRenderer.h" #include <binder/IBatteryStats.h> +#include <binder/IMemory.h> #include <binder/IServiceManager.h> +#include <binder/MemoryDealer.h> #include <gui/Surface.h> #include <media/ICrypto.h> #include <media/stagefright/foundation/ABuffer.h> @@ -969,6 +971,17 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { size_t numBuffers = portDesc->countBuffers(); + size_t totalSize = 0; + for (size_t i = 0; i < numBuffers; ++i) { + if (portIndex == kPortIndexInput && mCrypto != NULL) { + totalSize += portDesc->bufferAt(i)->capacity(); + } + } + + if (totalSize) { + mDealer = new MemoryDealer(totalSize, "MediaCodec"); + } + for (size_t i = 0; i < numBuffers; ++i) { BufferInfo info; info.mBufferID = portDesc->bufferIDAt(i); @@ -976,8 +989,10 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { info.mData = portDesc->bufferAt(i); if (portIndex == kPortIndexInput && mCrypto != NULL) { + sp<IMemory> mem = mDealer->allocate(info.mData->capacity()); info.mEncryptedData = - new ABuffer(info.mData->capacity()); + new ABuffer(mem->pointer(), info.mData->capacity()); + info.mSharedEncryptedBuffer = mem; } buffers->push_back(info); @@ -1953,7 +1968,8 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) { key, iv, mode, - info->mEncryptedData->base() + offset, + info->mSharedEncryptedBuffer, + offset, subSamples, numSubSamples, info->mData->base(), |