Commit c4c11664 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Convert media/mojo/mojom/media_types.mojom to handle<platform>

Bug: 710376
Change-Id: I40fe4b1aa37d9c1f334ade3b474135d7a7f9ccf2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078653Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745594}
parent 1f569bcc
......@@ -297,7 +297,7 @@ struct SharedBufferVideoFrameData {
// This defines video frame data stored in dmabuf.
struct DmabufVideoFrameData {
// Size depends on media::VideoFrame::NumPlanes with frame format.
array<handle> dmabuf_fds;
array<handle<platform>> dmabuf_fds;
};
struct GpuMemoryBufferVideoFrameData {
......
......@@ -16,7 +16,6 @@
#include "mojo/public/cpp/base/time_mojom_traits.h"
#include "mojo/public/cpp/base/values_mojom_traits.h"
#include "mojo/public/cpp/system/handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "ui/gfx/mojom/buffer_types_mojom_traits.h"
#include "ui/gfx/mojom/color_space_mojom_traits.h"
......@@ -64,13 +63,13 @@ media::mojom::VideoFrameDataPtr MakeVideoFrameData(
#if defined(OS_LINUX)
if (input->storage_type() == media::VideoFrame::STORAGE_DMABUFS) {
std::vector<mojo::ScopedHandle> dmabuf_fds;
std::vector<mojo::PlatformHandle> dmabuf_fds;
const size_t num_planes = media::VideoFrame::NumPlanes(input->format());
dmabuf_fds.reserve(num_planes);
for (size_t i = 0; i < num_planes; i++) {
const int dmabuf_fd = HANDLE_EINTR(dup(input->DmabufFds()[i].get()));
dmabuf_fds.emplace_back(mojo::WrapPlatformFile(dmabuf_fd));
dmabuf_fds.emplace_back(base::ScopedFD(dmabuf_fd));
DCHECK(dmabuf_fds.back().is_valid());
}
......@@ -170,7 +169,7 @@ bool StructTraits<media::mojom::VideoFrameDataView,
media::mojom::DmabufVideoFrameDataDataView dmabuf_data;
data.GetDmabufDataDataView(&dmabuf_data);
std::vector<mojo::ScopedHandle> dmabuf_fds_data;
std::vector<mojo::PlatformHandle> dmabuf_fds_data;
if (!dmabuf_data.ReadDmabufFds(&dmabuf_fds_data))
return false;
......@@ -198,9 +197,7 @@ bool StructTraits<media::mojom::VideoFrameDataView,
std::vector<base::ScopedFD> dmabuf_fds;
dmabuf_fds.reserve(num_planes);
for (size_t i = 0; i < num_planes; i++) {
base::PlatformFile platform_file;
mojo::UnwrapPlatformFile(std::move(dmabuf_fds_data[i]), &platform_file);
dmabuf_fds.emplace_back(platform_file);
dmabuf_fds.push_back(dmabuf_fds_data[i].TakeFD());
DCHECK(dmabuf_fds.back().is_valid());
}
frame = media::VideoFrame::WrapExternalDmabufs(
......
......@@ -13,6 +13,7 @@
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/interface_id.h"
#include "mojo/public/cpp/bindings/lib/template_util.h"
#include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/public/cpp/system/core.h"
namespace mojo {
......@@ -269,6 +270,14 @@ struct MojomTypeTraits<ScopedHandleBase<T>, false> {
static const MojomTypeCategory category = MojomTypeCategory::kHandle;
};
template <>
struct MojomTypeTraits<PlatformHandle, false> {
using Data = Handle_Data;
using DataAsArrayElement = Data;
static const MojomTypeCategory category = MojomTypeCategory::kHandle;
};
template <typename T>
struct MojomTypeTraits<InterfacePtrDataView<T>, false> {
using Data = Interface_Data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment