#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/mojo/services/mojo_cdm_allocator.h"
#include <limits>
#include <memory>
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/numerics/safe_conversions.h"
#include "base/numerics/safe_math.h"
#include "media/base/video_frame.h"
#include "media/cdm/api/content_decryption_module.h"
#include "media/cdm/cdm_helpers.h"
#include "media/cdm/cdm_type_conversion.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
namespace media {
namespace {
RecycleRegionCB;
class MojoCdmBuffer final : public cdm::Buffer { … };
class MojoCdmVideoFrame final : public VideoFrameImpl { … };
}
MojoCdmAllocator::MojoCdmAllocator() { … }
MojoCdmAllocator::~MojoCdmAllocator() = default;
cdm::Buffer* MojoCdmAllocator::CreateCdmBuffer(size_t capacity) { … }
std::unique_ptr<VideoFrameImpl> MojoCdmAllocator::CreateCdmVideoFrame() { … }
std::unique_ptr<base::MappedReadOnlyRegion> MojoCdmAllocator::AllocateNewRegion(
size_t capacity) { … }
void MojoCdmAllocator::AddRegionToAvailableMap(
std::unique_ptr<base::MappedReadOnlyRegion> mapped_region) { … }
const base::MappedReadOnlyRegion& MojoCdmAllocator::GetRegionForTesting(
cdm::Buffer* buffer) const { … }
size_t MojoCdmAllocator::GetAvailableRegionCountForTesting() { … }
}