#include "media/gpu/chromeos/platform_video_frame_utils.h"
#include <drm_fourcc.h>
#include <xf86drm.h>
#include <limits>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/fixed_flat_set.h"
#include "base/dcheck_is_on.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/scoped_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/no_destructor.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
#include "media/base/color_plane_layout.h"
#include "media/base/format_utils.h"
#include "media/base/media_switches.h"
#include "media/base/video_frame_layout.h"
#include "media/base/video_util.h"
#include "media/gpu/buffer_validation.h"
#include "media/gpu/chromeos/chromeos_compressed_gpu_memory_buffer_video_frame_utils.h"
#include "media/gpu/macros.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/linux/drm_util_linux.h"
#include "ui/gfx/linux/gbm_buffer.h"
#include "ui/gfx/linux/gbm_defines.h"
#include "ui/gfx/linux/gbm_device.h"
#include "ui/gfx/linux/gbm_util.h"
#include "ui/gfx/linux/gbm_wrapper.h"
#include "ui/gfx/linux/native_pixmap_dmabuf.h"
#include "ui/gfx/native_pixmap.h"
#include "ui/gfx/switches.h"
namespace media {
namespace {
struct DrmVersionDeleter { … };
ScopedDrmVersionPtr;
static std::unique_ptr<ui::GbmDevice> CreateGbmDevice(
std::string_view drm_node_file_prefix,
int first_drm_file_index,
const char* only_supported_driver_name_for_testing = nullptr) { … }
class GbmDeviceWrapper { … };
}
gfx::GpuMemoryBufferHandle AllocateGpuMemoryBufferHandle(
VideoPixelFormat pixel_format,
const gfx::Size& coded_size,
gfx::BufferUsage buffer_usage) { … }
gfx::GpuMemoryBufferId GetNextGpuMemoryBufferId() { … }
scoped_refptr<VideoFrame> CreateGpuMemoryBufferVideoFrame(
VideoPixelFormat pixel_format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp,
gfx::BufferUsage buffer_usage) { … }
scoped_refptr<VideoFrame> CreateVideoFrameFromGpuMemoryBufferHandle(
gfx::GpuMemoryBufferHandle gmb_handle,
VideoPixelFormat pixel_format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp,
gfx::BufferUsage buffer_usage) { … }
scoped_refptr<VideoFrame> CreatePlatformVideoFrame(
VideoPixelFormat pixel_format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp,
gfx::BufferUsage buffer_usage) { … }
std::optional<VideoFrameLayout> GetPlatformVideoFrameLayout(
VideoPixelFormat pixel_format,
const gfx::Size& coded_size,
gfx::BufferUsage buffer_usage) { … }
gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferHandle(
const VideoFrame* video_frame) { … }
scoped_refptr<gfx::NativePixmapDmaBuf> CreateNativePixmapDmaBuf(
const VideoFrame* video_frame) { … }
gfx::GenericSharedMemoryId GetSharedMemoryId(const VideoFrame& frame) { … }
bool CanImportGpuMemoryBufferHandle(
const gfx::Size& size,
gfx::BufferFormat format,
const gfx::GpuMemoryBufferHandle& gmb_handle) { … }
}