1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_MOJO_MOJOM_VIDEO_FRAME_MOJOM_TRAITS_H_
6 #define MEDIA_MOJO_MOJOM_VIDEO_FRAME_MOJOM_TRAITS_H_
8 #include "base/memory/scoped_refptr.h"
9 #include "gpu/ipc/common/mailbox_holder_mojom_traits.h"
10 #include "gpu/ipc/common/vulkan_ycbcr_info_mojom_traits.h"
11 #include "media/base/ipc/media_param_traits_macros.h"
12 #include "media/base/video_frame.h"
13 #include "media/mojo/mojom/media_types.mojom.h"
14 #include "mojo/public/cpp/bindings/enum_traits.h"
15 #include "mojo/public/cpp/bindings/struct_traits.h"
16 #include "third_party/abseil-cpp/absl/types/optional.h"
17 #include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
18 #include "ui/gfx/ipc/color/gfx_param_traits.h"
23 struct EnumTraits<media::mojom::SharedImageFormatType,
24 media::SharedImageFormatType> {
25 static media::mojom::SharedImageFormatType ToMojom(
26 media::SharedImageFormatType type);
28 static bool FromMojom(media::mojom::SharedImageFormatType input,
29 media::SharedImageFormatType* out);
33 struct StructTraits<media::mojom::VideoFrameDataView,
34 scoped_refptr<media::VideoFrame>> {
35 static bool IsNull(const scoped_refptr<media::VideoFrame>& input) {
39 static void SetToNull(scoped_refptr<media::VideoFrame>* input) {
43 static media::VideoPixelFormat format(
44 const scoped_refptr<media::VideoFrame>& input) {
45 return input->format();
48 static const gfx::Size& coded_size(
49 const scoped_refptr<media::VideoFrame>& input) {
50 return input->coded_size();
53 static const gfx::Rect& visible_rect(
54 const scoped_refptr<media::VideoFrame>& input) {
55 return input->visible_rect();
58 static const gfx::Size& natural_size(
59 const scoped_refptr<media::VideoFrame>& input) {
60 return input->natural_size();
63 static base::TimeDelta timestamp(
64 const scoped_refptr<media::VideoFrame>& input) {
65 return input->timestamp();
68 // TODO(hubbe): Return const ref when VideoFrame::ColorSpace()
70 static gfx::ColorSpace color_space(
71 const scoped_refptr<media::VideoFrame>& input) {
72 return input->ColorSpace();
75 static const absl::optional<gfx::HDRMetadata>& hdr_metadata(
76 const scoped_refptr<media::VideoFrame>& input) {
77 return input->hdr_metadata();
80 static media::SharedImageFormatType shared_image_format_type(
81 const scoped_refptr<media::VideoFrame>& input) {
82 return input->shared_image_format_type();
85 static const absl::optional<gpu::VulkanYCbCrInfo>& ycbcr_info(
86 const scoped_refptr<media::VideoFrame>& input) {
87 return input->ycbcr_info();
90 static media::mojom::VideoFrameDataPtr data(
91 const scoped_refptr<media::VideoFrame>& input);
93 static const media::VideoFrameMetadata& metadata(
94 const scoped_refptr<media::VideoFrame>& input) {
95 return input->metadata();
98 static bool Read(media::mojom::VideoFrameDataView input,
99 scoped_refptr<media::VideoFrame>* output);
104 #endif // MEDIA_MOJO_MOJOM_VIDEO_FRAME_MOJOM_TRAITS_H_