diff --git a/components/VideoFramePool.cpp b/components/VideoFramePool.cpp index 97eea134661e73624cbda9a331325c1f21c982ba..bb892a8c7241c24a64dd582792e3a40ddea57296 100644 --- a/components/VideoFramePool.cpp +++ b/components/VideoFramePool.cpp @@ -10,6 +10,9 @@ #include <stdint.h> #include <memory> +#include <C2BlockInternal.h> +#include <bufferpool/BufferPoolTypes.h> + #include <android/hardware/graphics/common/1.0/types.h> #include <base/bind.h> #include <base/memory/ptr_util.h> @@ -17,11 +20,11 @@ #include <log/log.h> #include <v4l2_codec2/common/VideoTypes.h> -#include <v4l2_codec2/plugin_store/C2VdaPooledBlockPool.h> #include <v4l2_codec2/plugin_store/DmabufHelpers.h> #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h> using android::hardware::graphics::common::V1_0::BufferUsage; +using android::hardware::media::bufferpool::BufferPoolData; namespace android { @@ -42,8 +45,20 @@ std::optional<uint32_t> VideoFramePool::getBufferIdFromGraphicBlock(C2BlockPool& } case V4L2AllocatorId::V4L2_BUFFERPOOL: FALLTHROUGH; - case V4L2AllocatorId::SECURE_LINEAR: - return C2VdaPooledBlockPool::getBufferIdFromGraphicBlock(block); + case V4L2AllocatorId::SECURE_LINEAR: { + std::shared_ptr<_C2BlockPoolData> blockPoolData = + _C2BlockFactory::GetGraphicBlockPoolData(block); + if (blockPoolData->getType() != _C2BlockPoolData::TYPE_BUFFERPOOL) { + ALOGE("Obtained C2GraphicBlock is not bufferpool-backed."); + return std::nullopt; + } + std::shared_ptr<BufferPoolData> bpData; + if (!_C2BlockFactory::GetBufferPoolData(blockPoolData, &bpData) || !bpData) { + ALOGE("BufferPoolData unavailable in block."); + return std::nullopt; + } + return bpData->mId; + } } ALOGE("%s(): unknown allocator ID: %u", __func__, blockPool.getAllocatorId()); @@ -54,13 +69,6 @@ std::optional<uint32_t> VideoFramePool::getBufferIdFromGraphicBlock(C2BlockPool& c2_status_t VideoFramePool::requestNewBufferSet(C2BlockPool& blockPool, int32_t bufferCount, const ui::Size& size, uint32_t format, C2MemoryUsage usage) { - ALOGV("%s() blockPool.getAllocatorId() = %u", __func__, blockPool.getAllocatorId()); - - if (blockPool.getAllocatorId() == android::V4L2AllocatorId::V4L2_BUFFERPOOL) { - C2VdaPooledBlockPool* bpPool = static_cast<C2VdaPooledBlockPool*>(&blockPool); - return bpPool->requestNewBufferSet(bufferCount); - } - ALOGE("%s(): unknown allocator ID: %u", __func__, blockPool.getAllocatorId()); return C2_BAD_VALUE; } diff --git a/plugin_store/V4L2PluginStore.cpp b/plugin_store/V4L2PluginStore.cpp index b116759383a952759133e16cbb94785666dfc34f..a8cdab69aa0824ae3d1f5602dd4a21d02b7180ed 100644 --- a/plugin_store/V4L2PluginStore.cpp +++ b/plugin_store/V4L2PluginStore.cpp @@ -16,7 +16,6 @@ #include <C2BufferPriv.h> #include <log/log.h> -#include <v4l2_codec2/plugin_store/C2VdaPooledBlockPool.h> #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h> #include <v4l2_codec2/plugin_store/VendorAllocatorLoader.h> @@ -68,7 +67,7 @@ C2BlockPool* createBlockPool(C2Allocator::id_t allocatorId, C2BlockPool::local_i switch (allocatorId) { case V4L2AllocatorId::V4L2_BUFFERPOOL: - return new C2VdaPooledBlockPool(allocator, poolId); + return new C2PooledBlockPool(allocator, poolId); case V4L2AllocatorId::SECURE_LINEAR: return new C2PooledBlockPool(allocator, poolId);