1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
media / mojo / mojom / video_frame_mojom_traits.h [blame]
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_MOJO_MOJOM_VIDEO_FRAME_MOJOM_TRAITS_H_
#define MEDIA_MOJO_MOJOM_VIDEO_FRAME_MOJOM_TRAITS_H_
#include <optional>
#include "base/memory/scoped_refptr.h"
#include "gpu/ipc/common/mailbox_holder_mojom_traits.h"
#include "gpu/ipc/common/vulkan_ycbcr_info_mojom_traits.h"
#include "media/base/ipc/media_param_traits_macros.h"
#include "media/base/video_frame.h"
#include "media/mojo/mojom/media_types.mojom.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
#include "ui/gfx/ipc/color/gfx_param_traits.h"
namespace mojo {
template <>
struct StructTraits<media::mojom::VideoFrameDataView,
scoped_refptr<media::VideoFrame>> {
static bool IsNull(const scoped_refptr<media::VideoFrame>& input) {
return !input;
}
static void SetToNull(scoped_refptr<media::VideoFrame>* input) {
*input = nullptr;
}
static media::VideoPixelFormat format(
const scoped_refptr<media::VideoFrame>& input) {
return input->format();
}
static const gfx::Size& coded_size(
const scoped_refptr<media::VideoFrame>& input) {
return input->coded_size();
}
static const gfx::Rect& visible_rect(
const scoped_refptr<media::VideoFrame>& input) {
return input->visible_rect();
}
static const gfx::Size& natural_size(
const scoped_refptr<media::VideoFrame>& input) {
return input->natural_size();
}
static base::TimeDelta timestamp(
const scoped_refptr<media::VideoFrame>& input) {
return input->timestamp();
}
// TODO(hubbe): Return const ref when VideoFrame::ColorSpace()
// returns const ref.
static gfx::ColorSpace color_space(
const scoped_refptr<media::VideoFrame>& input) {
return input->ColorSpace();
}
static const std::optional<gfx::HDRMetadata>& hdr_metadata(
const scoped_refptr<media::VideoFrame>& input) {
return input->hdr_metadata();
}
static const std::optional<gpu::VulkanYCbCrInfo>& ycbcr_info(
const scoped_refptr<media::VideoFrame>& input) {
return input->ycbcr_info();
}
static media::mojom::VideoFrameDataPtr data(
const scoped_refptr<media::VideoFrame>& input);
static const media::VideoFrameMetadata& metadata(
const scoped_refptr<media::VideoFrame>& input) {
return input->metadata();
}
static bool Read(media::mojom::VideoFrameDataView input,
scoped_refptr<media::VideoFrame>* output);
};
} // namespace mojo
#endif // MEDIA_MOJO_MOJOM_VIDEO_FRAME_MOJOM_TRAITS_H_