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
media / mojo / mojom / video_frame_metadata_mojom_traits.cc [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/mojo/mojom/video_frame_metadata_mojom_traits.h"
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "mojo/public/cpp/base/time_mojom_traits.h"
#include "mojo/public/cpp/base/unguessable_token_mojom_traits.h"
namespace {
// Deserializes has_field and field into a std::optional.
#define DESERIALIZE_INTO_OPT(field) \
if (input.has_##field()) \
output->field = input.field()
#define READ_AND_ASSIGN_OPT(type, field, FieldInCamelCase) \
std::optional<type> field; \
if (!input.Read##FieldInCamelCase(&field)) \
return false; \
\
output->field = field
std::optional<media::EffectInfo> FromMojom(media::mojom::EffectState input) {
switch (input) {
case media::mojom::EffectState::kUnknown:
return std::nullopt;
case media::mojom::EffectState::kDisabled:
return media::EffectInfo{.enabled = false};
case media::mojom::EffectState::kEnabled:
return media::EffectInfo{.enabled = true};
}
NOTREACHED();
}
} // namespace
namespace mojo {
// static
media::mojom::EffectState
EnumTraits<media::mojom::EffectState, intermediate::EffectState>::ToMojom(
intermediate::EffectState input) {
switch (input) {
case intermediate::EffectState::kUnknown:
return media::mojom::EffectState::kUnknown;
case intermediate::EffectState::kDisabled:
return media::mojom::EffectState::kDisabled;
case intermediate::EffectState::kEnabled:
return media::mojom::EffectState::kEnabled;
}
NOTREACHED();
}
// static
bool EnumTraits<media::mojom::EffectState, intermediate::EffectState>::
FromMojom(media::mojom::EffectState input,
intermediate::EffectState* output) {
switch (input) {
case media::mojom::EffectState::kUnknown:
*output = intermediate::EffectState::kUnknown;
return true;
case media::mojom::EffectState::kDisabled:
*output = intermediate::EffectState::kDisabled;
return true;
case media::mojom::EffectState::kEnabled:
*output = intermediate::EffectState::kEnabled;
return true;
}
NOTREACHED();
}
// static
bool StructTraits<media::mojom::VideoFrameMetadataDataView,
media::VideoFrameMetadata>::
Read(media::mojom::VideoFrameMetadataDataView input,
media::VideoFrameMetadata* output) {
// int.
DESERIALIZE_INTO_OPT(capture_counter);
output->sub_capture_target_version = input.sub_capture_target_version();
output->frame_sequence = input.frame_sequence();
// bool.
output->allow_overlay = input.allow_overlay();
output->copy_required = input.copy_required();
output->end_of_stream = input.end_of_stream();
output->texture_owner = input.texture_owner();
output->wants_promotion_hint = input.wants_promotion_hint();
output->protected_video = input.protected_video();
output->hw_protected = input.hw_protected();
output->needs_detiling = input.needs_detiling();
output->is_webgpu_compatible = input.is_webgpu_compatible();
output->power_efficient = input.power_efficient();
output->read_lock_fences_enabled = input.read_lock_fences_enabled();
output->interactive_content = input.interactive_content();
// double.
DESERIALIZE_INTO_OPT(device_scale_factor);
DESERIALIZE_INTO_OPT(page_scale_factor);
DESERIALIZE_INTO_OPT(root_scroll_offset_x);
DESERIALIZE_INTO_OPT(root_scroll_offset_y);
DESERIALIZE_INTO_OPT(top_controls_visible_height);
DESERIALIZE_INTO_OPT(frame_rate);
DESERIALIZE_INTO_OPT(rtp_timestamp);
READ_AND_ASSIGN_OPT(media::VideoTransformation, transformation,
Transformation);
READ_AND_ASSIGN_OPT(base::UnguessableToken, tracking_token, TrackingToken);
READ_AND_ASSIGN_OPT(gfx::Size, source_size, SourceSize);
READ_AND_ASSIGN_OPT(gfx::Rect, capture_update_rect, CaptureUpdateRect);
READ_AND_ASSIGN_OPT(gfx::Rect, region_capture_rect, RegionCaptureRect);
READ_AND_ASSIGN_OPT(base::TimeTicks, receive_time, ReceiveTime);
READ_AND_ASSIGN_OPT(base::TimeTicks, capture_begin_time, CaptureBeginTime);
READ_AND_ASSIGN_OPT(base::TimeTicks, capture_end_time, CaptureEndTime);
READ_AND_ASSIGN_OPT(base::TimeTicks, decode_begin_time, DecodeBeginTime);
READ_AND_ASSIGN_OPT(base::TimeTicks, decode_end_time, DecodeEndTime);
READ_AND_ASSIGN_OPT(base::TimeTicks, reference_time, ReferenceTime);
READ_AND_ASSIGN_OPT(base::TimeDelta, processing_time, ProcessingTime);
READ_AND_ASSIGN_OPT(base::TimeDelta, frame_duration, FrameDuration);
READ_AND_ASSIGN_OPT(base::TimeDelta, wallclock_frame_duration,
WallclockFrameDuration);
output->background_blur = FromMojom(input.background_blur());
output->frame_sequence = input.frame_sequence();
return true;
}
} // namespace mojo