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
148
149
150
151
152
ash / components / arc / mojom / video_encode_accelerator_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 ASH_COMPONENTS_ARC_MOJOM_VIDEO_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
#define ASH_COMPONENTS_ARC_MOJOM_VIDEO_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
#include "ash/components/arc/mojom/video_encode_accelerator.mojom-shared.h"
#include "media/base/bitrate.h"
#include "media/video/video_encode_accelerator.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
// Needs to be included after 'video_encode_accelerator.h'.
#include "ash/components/arc/mojom/video_encode_accelerator.mojom.h"
namespace mojo {
template <>
struct EnumTraits<arc::mojom::VideoFrameStorageType,
media::VideoEncodeAccelerator::Config::StorageType> {
static arc::mojom::VideoFrameStorageType ToMojom(
media::VideoEncodeAccelerator::Config::StorageType input);
static bool FromMojom(
arc::mojom::VideoFrameStorageType input,
media::VideoEncodeAccelerator::Config::StorageType* output);
};
template <>
struct StructTraits<arc::mojom::VideoEncodeProfileDataView,
media::VideoEncodeAccelerator::SupportedProfile> {
static media::VideoCodecProfile profile(
const media::VideoEncodeAccelerator::SupportedProfile& r) {
return r.profile;
}
static const gfx::Size& max_resolution(
const media::VideoEncodeAccelerator::SupportedProfile& r) {
return r.max_resolution;
}
static uint32_t max_framerate_numerator(
const media::VideoEncodeAccelerator::SupportedProfile& r) {
return r.max_framerate_numerator;
}
static uint32_t max_framerate_denominator(
const media::VideoEncodeAccelerator::SupportedProfile& r) {
return r.max_framerate_denominator;
}
static bool Read(arc::mojom::VideoEncodeProfileDataView data,
media::VideoEncodeAccelerator::SupportedProfile* out) {
NOTIMPLEMENTED();
return false;
}
};
// TODO(b/198127993): Convert directly to media::Bitrate.
template <>
struct StructTraits<arc::mojom::ConstantBitrateDataView,
arc::mojom::ConstantBitrate> {
static uint32_t target(const arc::mojom::ConstantBitrate& input);
};
template <>
struct StructTraits<arc::mojom::VariableBitrateDataView,
arc::mojom::VariableBitrate> {
static uint32_t target(const arc::mojom::VariableBitrate& input);
static uint32_t peak(const arc::mojom::VariableBitrate& input);
};
template <>
struct UnionTraits<arc::mojom::BitrateDataView, media::Bitrate> {
static arc::mojom::BitrateDataView::Tag GetTag(const media::Bitrate& input);
static arc::mojom::ConstantBitrate constant(const media::Bitrate& input);
static arc::mojom::VariableBitrate variable(const media::Bitrate& input);
static bool Read(arc::mojom::BitrateDataView input, media::Bitrate* output);
};
template <>
struct StructTraits<arc::mojom::VideoEncodeAcceleratorConfigDataView,
media::VideoEncodeAccelerator::Config> {
static media::VideoPixelFormat input_format(
const media::VideoEncodeAccelerator::Config& input) {
return input.input_format;
}
static const gfx::Size& input_visible_size(
const media::VideoEncodeAccelerator::Config& input) {
return input.input_visible_size;
}
static media::VideoCodecProfile output_profile(
const media::VideoEncodeAccelerator::Config& input) {
return input.output_profile;
}
static uint32_t initial_bitrate_deprecated(
const media::VideoEncodeAccelerator::Config& input) {
return input.bitrate.target_bps();
}
static uint32_t initial_framerate(
const media::VideoEncodeAccelerator::Config& input) {
return input.framerate;
}
static uint32_t has_initial_framerate_deprecated(
const media::VideoEncodeAccelerator::Config& input) {
return true;
}
static uint32_t gop_length(
const media::VideoEncodeAccelerator::Config& input) {
return input.gop_length.value_or(0);
}
static bool has_gop_length(
const media::VideoEncodeAccelerator::Config& input) {
return input.gop_length.has_value();
}
static uint8_t h264_output_level(
const media::VideoEncodeAccelerator::Config& input) {
return input.h264_output_level.value_or(0);
}
static bool has_h264_output_level(
const media::VideoEncodeAccelerator::Config& input) {
return input.h264_output_level.has_value();
}
static arc::mojom::VideoFrameStorageType storage_type(
const media::VideoEncodeAccelerator::Config& input) {
switch (input.storage_type) {
case media::VideoEncodeAccelerator::Config::StorageType::kShmem:
return arc::mojom::VideoFrameStorageType::SHMEM;
case media::VideoEncodeAccelerator::Config::StorageType::kGpuMemoryBuffer:
return arc::mojom::VideoFrameStorageType::DMABUF;
}
}
static const media::Bitrate& bitrate(
const media::VideoEncodeAccelerator::Config& input) {
return input.bitrate;
}
static bool Read(arc::mojom::VideoEncodeAcceleratorConfigDataView input,
media::VideoEncodeAccelerator::Config* output);
};
} // namespace mojo
#endif // ASH_COMPONENTS_ARC_MOJOM_VIDEO_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_