Implement secure API functions for large audio frames
Functions added
- queueSecureInputBuffers
- attachEncryptedBuffers
- cryptoAsync for multiple access units
Bug: 298052174
Test: atest android.media.drmframework.cts.MediaDrmCodecMultiAccessUnitTest
Change-Id: I8053f40c2e15d29132441de06bacf2fa2f9ac1f2
diff --git a/media/codec2/sfplugin/Codec2Buffer.cpp b/media/codec2/sfplugin/Codec2Buffer.cpp
index 4f466c5..9c514f2 100644
--- a/media/codec2/sfplugin/Codec2Buffer.cpp
+++ b/media/codec2/sfplugin/Codec2Buffer.cpp
@@ -1036,6 +1036,37 @@
return const_cast<native_handle_t *>(mBlock->handle());
}
+void EncryptedLinearBlockBuffer::getMappedBlock(
+ std::unique_ptr<MappedBlock> * const mappedBlock) const {
+ if (mappedBlock) {
+ mappedBlock->reset(new EncryptedLinearBlockBuffer::MappedBlock(mBlock));
+ }
+ return;
+}
+
+EncryptedLinearBlockBuffer::MappedBlock::MappedBlock(
+ const std::shared_ptr<C2LinearBlock> &block) : mView(block->map().get()) {
+}
+
+bool EncryptedLinearBlockBuffer::MappedBlock::copyDecryptedContent(
+ const sp<IMemory> &decrypted, size_t length) {
+ if (mView.error() != C2_OK) {
+ return false;
+ }
+ if (mView.size() < length) {
+ ALOGE("View size(%d) less than decrypted length(%zu)",
+ mView.size(), length);
+ return false;
+ }
+ memcpy(mView.data(), decrypted->unsecurePointer(), length);
+ mView.setOffset(mView.offset() + length);
+ return true;
+}
+
+EncryptedLinearBlockBuffer::MappedBlock::~MappedBlock() {
+ mView.setOffset(0);
+}
+
using ::aidl::android::hardware::graphics::common::Cta861_3;
using ::aidl::android::hardware::graphics::common::Smpte2086;