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
153
154
155
156
media / mojo / mojom / cdm_capability_mojom_traits.cc [blame]
// Copyright 2021 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/cdm_capability_mojom_traits.h"
#include <set>
#include <utility>
namespace mojo {
namespace {
template <typename T>
bool AreUnique(const std::vector<T>& values) {
std::set<T> unique_values;
for (const auto& value : values)
unique_values.emplace(value);
return values.size() == unique_values.size();
}
} // namespace
// static
bool StructTraits<media::mojom::VideoCodecInfoDataView, media::VideoCodecInfo>::
Read(media::mojom::VideoCodecInfoDataView input,
media::VideoCodecInfo* output) {
std::vector<media::VideoCodecProfile> supported_profiles;
if (!input.ReadSupportedProfiles(&supported_profiles)) {
return false;
}
*output = media::VideoCodecInfo(std::move(supported_profiles),
input.supports_clear_lead());
return true;
}
// static
bool StructTraits<media::mojom::CdmCapabilityDataView, media::CdmCapability>::
Read(media::mojom::CdmCapabilityDataView input,
media::CdmCapability* output) {
std::vector<media::AudioCodec> audio_codecs;
if (!input.ReadAudioCodecs(&audio_codecs))
return false;
media::CdmCapability::VideoCodecMap video_codecs;
if (!input.ReadVideoCodecs(&video_codecs))
return false;
std::vector<media::EncryptionScheme> encryption_schemes;
if (!input.ReadEncryptionSchemes(&encryption_schemes))
return false;
std::vector<media::CdmSessionType> session_types;
if (!input.ReadSessionTypes(&session_types))
return false;
// |encryption_schemes|, |session_types| and |audio_codecs| are converted
// to a base::flat_map implicitly.
*output = media::CdmCapability(
std::move(audio_codecs), std::move(video_codecs),
std::move(encryption_schemes), std::move(session_types));
return true;
}
// static
media::mojom::CdmCapabilityQueryStatus EnumTraits<
media::mojom::CdmCapabilityQueryStatus,
media::CdmCapabilityQueryStatus>::ToMojom(media::CdmCapabilityQueryStatus
input) {
switch (input) {
case media::CdmCapabilityQueryStatus::kSuccess:
return media::mojom::CdmCapabilityQueryStatus::kSuccess;
case media::CdmCapabilityQueryStatus::kUnknown:
return media::mojom::CdmCapabilityQueryStatus::kUnknown;
case media::CdmCapabilityQueryStatus::kHardwareSecureCodecNotSupported:
return media::mojom::CdmCapabilityQueryStatus::
kHardwareSecureCodecNotSupported;
case media::CdmCapabilityQueryStatus::kNoSupportedVideoCodec:
return media::mojom::CdmCapabilityQueryStatus::kNoSupportedVideoCodec;
case media::CdmCapabilityQueryStatus::kNoSupportedEncryptionScheme:
return media::mojom::CdmCapabilityQueryStatus::
kNoSupportedEncryptionScheme;
case media::CdmCapabilityQueryStatus::kUnsupportedKeySystem:
return media::mojom::CdmCapabilityQueryStatus::kUnsupportedKeySystem;
case media::CdmCapabilityQueryStatus::kMediaFoundationCdmNotSupported:
return media::mojom::CdmCapabilityQueryStatus::
kMediaFoundationCdmNotSupported;
case media::CdmCapabilityQueryStatus::kDisconnectionError:
return media::mojom::CdmCapabilityQueryStatus::kDisconnectionError;
case media::CdmCapabilityQueryStatus::kMediaFoundationGetCdmFactoryFailed:
return media::mojom::CdmCapabilityQueryStatus::
kMediaFoundationGetCdmFactoryFailed;
case media::CdmCapabilityQueryStatus::kCreateDummyMediaFoundationCdmFailed:
return media::mojom::CdmCapabilityQueryStatus::
kCreateDummyMediaFoundationCdmFailed;
case media::CdmCapabilityQueryStatus::kUnexpectedEmptyCapability:
return media::mojom::CdmCapabilityQueryStatus::kUnexpectedEmptyCapability;
}
NOTREACHED();
}
// static
bool EnumTraits<media::mojom::CdmCapabilityQueryStatus,
media::CdmCapabilityQueryStatus>::
FromMojom(media::mojom::CdmCapabilityQueryStatus input,
media::CdmCapabilityQueryStatus* output) {
switch (input) {
case media::mojom::CdmCapabilityQueryStatus::kSuccess:
*output = media::CdmCapabilityQueryStatus::kSuccess;
return true;
case media::mojom::CdmCapabilityQueryStatus::kUnknown:
*output = media::CdmCapabilityQueryStatus::kUnknown;
return true;
case media::mojom::CdmCapabilityQueryStatus::
kHardwareSecureCodecNotSupported:
*output =
media::CdmCapabilityQueryStatus::kHardwareSecureCodecNotSupported;
return true;
case media::mojom::CdmCapabilityQueryStatus::kNoSupportedVideoCodec:
*output = media::CdmCapabilityQueryStatus::kNoSupportedVideoCodec;
return true;
case media::mojom::CdmCapabilityQueryStatus::kNoSupportedEncryptionScheme:
*output = media::CdmCapabilityQueryStatus::kNoSupportedEncryptionScheme;
return true;
case media::mojom::CdmCapabilityQueryStatus::kUnsupportedKeySystem:
*output = media::CdmCapabilityQueryStatus::kUnsupportedKeySystem;
return true;
case media::mojom::CdmCapabilityQueryStatus::
kMediaFoundationCdmNotSupported:
*output =
media::CdmCapabilityQueryStatus::kMediaFoundationCdmNotSupported;
return true;
case media::mojom::CdmCapabilityQueryStatus::kDisconnectionError:
*output = media::CdmCapabilityQueryStatus::kDisconnectionError;
return true;
case media::mojom::CdmCapabilityQueryStatus::
kMediaFoundationGetCdmFactoryFailed:
*output =
media::CdmCapabilityQueryStatus::kMediaFoundationGetCdmFactoryFailed;
return true;
case media::mojom::CdmCapabilityQueryStatus::
kCreateDummyMediaFoundationCdmFailed:
*output =
media::CdmCapabilityQueryStatus::kCreateDummyMediaFoundationCdmFailed;
return true;
case media::mojom::CdmCapabilityQueryStatus::kUnexpectedEmptyCapability:
*output = media::CdmCapabilityQueryStatus::kUnexpectedEmptyCapability;
return true;
}
NOTREACHED();
}
} // namespace mojo