1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/mojo/mojom/cdm_capability_mojom_traits.h"
15 bool AreUnique(const std::vector<T>& values) {
16 std::set<T> unique_values;
17 for (const auto& value : values)
18 unique_values.emplace(value);
19 return values.size() == unique_values.size();
25 bool StructTraits<media::mojom::VideoCodecInfoDataView, media::VideoCodecInfo>::
26 Read(media::mojom::VideoCodecInfoDataView input,
27 media::VideoCodecInfo* output) {
28 std::vector<media::VideoCodecProfile> supported_profiles;
29 if (!input.ReadSupportedProfiles(&supported_profiles)) {
33 *output = media::VideoCodecInfo(std::move(supported_profiles),
34 input.supports_clear_lead());
39 bool StructTraits<media::mojom::CdmCapabilityDataView, media::CdmCapability>::
40 Read(media::mojom::CdmCapabilityDataView input,
41 media::CdmCapability* output) {
42 std::vector<media::AudioCodec> audio_codecs;
43 if (!input.ReadAudioCodecs(&audio_codecs))
46 media::CdmCapability::VideoCodecMap video_codecs;
47 if (!input.ReadVideoCodecs(&video_codecs))
50 std::vector<media::EncryptionScheme> encryption_schemes;
51 if (!input.ReadEncryptionSchemes(&encryption_schemes))
54 std::vector<media::CdmSessionType> session_types;
55 if (!input.ReadSessionTypes(&session_types))
58 // |encryption_schemes|, |session_types| and |audio_codecs| are converted
59 // to a base::flat_map implicitly.
60 *output = media::CdmCapability(
61 std::move(audio_codecs), std::move(video_codecs),
62 std::move(encryption_schemes), std::move(session_types));