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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
ash / components / arc / mojom / video_accelerator_mojom_traits.h [blame]
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_COMPONENTS_ARC_MOJOM_VIDEO_ACCELERATOR_MOJOM_TRAITS_H_
#define ASH_COMPONENTS_ARC_MOJOM_VIDEO_ACCELERATOR_MOJOM_TRAITS_H_
#include <memory>
#include "ash/components/arc/mojom/video_common.mojom-shared.h"
#include "ash/components/arc/mojom/video_decoder.mojom-shared.h"
#include "ash/components/arc/video_accelerator/video_frame_plane.h"
#include "media/base/color_plane_layout.h"
#include "media/base/decoder_status.h"
#include "media/base/status.h"
#include "media/base/video_codecs.h"
#include "media/base/video_frame_layout.h"
#include "media/base/video_types.h"
#include "ui/gfx/geometry/size.h"
namespace mojo {
template <>
struct EnumTraits<arc::mojom::VideoCodecProfile, media::VideoCodecProfile> {
static arc::mojom::VideoCodecProfile ToMojom(media::VideoCodecProfile input);
static bool FromMojom(arc::mojom::VideoCodecProfile input,
media::VideoCodecProfile* output);
};
template <>
struct StructTraits<arc::mojom::VideoFramePlaneDataView, arc::VideoFramePlane> {
static int32_t offset(const arc::VideoFramePlane& r) {
DCHECK_GE(r.offset, 0);
return r.offset;
}
static int32_t stride(const arc::VideoFramePlane& r) {
DCHECK_GE(r.stride, 0);
return r.stride;
}
static bool Read(arc::mojom::VideoFramePlaneDataView data,
arc::VideoFramePlane* out);
};
template <>
struct StructTraits<arc::mojom::SizeDataView, gfx::Size> {
static int width(const gfx::Size& r) {
DCHECK_GE(r.width(), 0);
return r.width();
}
static int height(const gfx::Size& r) {
DCHECK_GE(r.height(), 0);
return r.height();
}
static bool Read(arc::mojom::SizeDataView data, gfx::Size* out);
};
template <>
struct EnumTraits<arc::mojom::VideoPixelFormat, media::VideoPixelFormat> {
static arc::mojom::VideoPixelFormat ToMojom(media::VideoPixelFormat input);
static bool FromMojom(arc::mojom::VideoPixelFormat input,
media::VideoPixelFormat* output);
};
template <>
struct StructTraits<arc::mojom::ColorPlaneLayoutDataView,
media::ColorPlaneLayout> {
static int32_t stride(const media::ColorPlaneLayout& r) { return r.stride; }
static uint32_t offset(const media::ColorPlaneLayout& r) { return r.offset; }
static uint32_t size(const media::ColorPlaneLayout& r) { return r.size; }
static bool Read(arc::mojom::ColorPlaneLayoutDataView data,
media::ColorPlaneLayout* out);
};
// Because `media::VideoFrameLayout` doesn't have default constructor, we cannot
// convert from mojo struct directly. Instead, we map to the type
// `std::unique_ptr<media::VideoFrameLayout>`.
template <>
struct StructTraits<arc::mojom::VideoFrameLayoutDataView,
std::unique_ptr<media::VideoFrameLayout>> {
static bool IsNull(const std::unique_ptr<media::VideoFrameLayout>& input) {
return input.get() == nullptr;
}
static void SetToNull(std::unique_ptr<media::VideoFrameLayout>* output) {
output->reset();
}
static media::VideoPixelFormat format(
const std::unique_ptr<media::VideoFrameLayout>& input) {
DCHECK(input);
return input->format();
}
static const gfx::Size& coded_size(
const std::unique_ptr<media::VideoFrameLayout>& input) {
DCHECK(input);
return input->coded_size();
}
static const std::vector<media::ColorPlaneLayout>& planes(
const std::unique_ptr<media::VideoFrameLayout>& input) {
DCHECK(input);
return input->planes();
}
static bool is_multi_planar(
const std::unique_ptr<media::VideoFrameLayout>& input) {
DCHECK(input);
return input->is_multi_planar();
}
static uint32_t buffer_addr_align(
const std::unique_ptr<media::VideoFrameLayout>& input) {
DCHECK(input);
return input->buffer_addr_align();
}
static uint64_t modifier(
const std::unique_ptr<media::VideoFrameLayout>& input) {
DCHECK(input);
return input->modifier();
}
static bool Read(arc::mojom::VideoFrameLayoutDataView data,
std::unique_ptr<media::VideoFrameLayout>* out);
};
template <>
struct EnumTraits<arc::mojom::DecoderStatus, media::DecoderStatus> {
static arc::mojom::DecoderStatus ToMojom(media::DecoderStatus input);
static bool FromMojom(arc::mojom::DecoderStatus input,
media::DecoderStatus* output);
};
} // namespace mojo
#endif // ASH_COMPONENTS_ARC_MOJOM_VIDEO_ACCELERATOR_MOJOM_TRAITS_H_