Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: components/cdm/renderer/widevine_key_system_properties.cc

Issue 1927953004: Reland of "Convert Widevine and Android platform key systems to KeySystemProperties" with fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/cdm/renderer/widevine_key_system_properties.h"
6
7 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
8
9 #if defined(WIDEVINE_CDM_AVAILABLE)
10
11 using media::EmeConfigRule;
12 using media::EmeFeatureSupport;
13 using media::EmeInitDataType;
14 using media::EmeMediaType;
15 using media::EmeRobustness;
16 using media::EmeSessionTypeSupport;
17 using media::SupportedCodecs;
18
19 namespace cdm {
20 namespace {
21
22 EmeRobustness ConvertRobustness(const std::string& robustness) {
23 if (robustness.empty())
24 return EmeRobustness::EMPTY;
25 if (robustness == "SW_SECURE_CRYPTO")
26 return EmeRobustness::SW_SECURE_CRYPTO;
27 if (robustness == "SW_SECURE_DECODE")
28 return EmeRobustness::SW_SECURE_DECODE;
29 if (robustness == "HW_SECURE_CRYPTO")
30 return EmeRobustness::HW_SECURE_CRYPTO;
31 if (robustness == "HW_SECURE_DECODE")
32 return EmeRobustness::HW_SECURE_DECODE;
33 if (robustness == "HW_SECURE_ALL")
34 return EmeRobustness::HW_SECURE_ALL;
35 return EmeRobustness::INVALID;
36 }
37
38 } // namespace
39
40 WidevineKeySystemProperties::WidevineKeySystemProperties(
41 media::SupportedCodecs supported_codecs,
42 #if defined(OS_ANDROID)
43 media::SupportedCodecs supported_secure_codecs,
44 #endif // defined(OS_ANDROID)
45 media::EmeRobustness max_audio_robustness,
46 media::EmeRobustness max_video_robustness,
47 media::EmeSessionTypeSupport persistent_license_support,
48 media::EmeSessionTypeSupport persistent_release_message_support,
49 media::EmeFeatureSupport persistent_state_support,
50 media::EmeFeatureSupport distinctive_identifier_support)
51 : supported_codecs_(supported_codecs),
52 #if defined(OS_ANDROID)
53 supported_secure_codecs_(supported_secure_codecs),
54 #endif // defined(OS_ANDROID)
55 max_audio_robustness_(max_audio_robustness),
56 max_video_robustness_(max_video_robustness),
57 persistent_license_support_(persistent_license_support),
58 persistent_release_message_support_(persistent_release_message_support),
59 persistent_state_support_(persistent_state_support),
60 distinctive_identifier_support_(distinctive_identifier_support) {
61 }
62
63 std::string WidevineKeySystemProperties::GetKeySystemName() const {
64 return kWidevineKeySystem;
65 }
66
67 bool WidevineKeySystemProperties::IsSupportedInitDataType(
68 EmeInitDataType init_data_type) const {
69 // Here we assume that support for a container imples support for the
70 // associated initialization data type. KeySystems handles validating
71 // |init_data_type| x |container| pairings.
72 if (init_data_type == EmeInitDataType::WEBM)
73 return (supported_codecs_ & media::EME_CODEC_WEBM_ALL) != 0;
74 #if defined(USE_PROPRIETARY_CODECS)
75 if (init_data_type == EmeInitDataType::CENC)
76 return (supported_codecs_ & media::EME_CODEC_MP4_ALL) != 0;
77 #endif // defined(USE_PROPRIETARY_CODECS)
78
79 return false;
80 }
81
82 SupportedCodecs WidevineKeySystemProperties::GetSupportedCodecs() const {
83 return supported_codecs_;
84 }
85
86 #if defined(OS_ANDROID)
87 SupportedCodecs WidevineKeySystemProperties::GetSupportedSecureCodecs() const {
88 return supported_secure_codecs_;
89 }
90 #endif
91
92 EmeConfigRule WidevineKeySystemProperties::GetRobustnessConfigRule(
93 EmeMediaType media_type,
94 const std::string& requested_robustness) const {
95 EmeRobustness robustness = ConvertRobustness(requested_robustness);
96 if (robustness == EmeRobustness::INVALID)
97 return EmeConfigRule::NOT_SUPPORTED;
98
99 EmeRobustness max_robustness = EmeRobustness::INVALID;
100 switch (media_type) {
101 case EmeMediaType::AUDIO:
102 max_robustness = max_audio_robustness_;
103 break;
104 case EmeMediaType::VIDEO:
105 max_robustness = max_video_robustness_;
106 break;
107 }
108
109 // We can compare robustness levels whenever they are not HW_SECURE_CRYPTO
110 // and SW_SECURE_DECODE in some order. If they are exactly those two then the
111 // robustness requirement is not supported.
112 if ((max_robustness == EmeRobustness::HW_SECURE_CRYPTO &&
113 robustness == EmeRobustness::SW_SECURE_DECODE) ||
114 (max_robustness == EmeRobustness::SW_SECURE_DECODE &&
115 robustness == EmeRobustness::HW_SECURE_CRYPTO) ||
116 robustness > max_robustness) {
117 return EmeConfigRule::NOT_SUPPORTED;
118 }
119
120 #if defined(OS_CHROMEOS)
121 // TODO(ddorwin): Remove this once we have confirmed it is not necessary.
122 // See https://crbug.com/482277
123 if (robustness == EmeRobustness::EMPTY)
124 return EmeConfigRule::SUPPORTED;
125
126 // Hardware security requires remote attestation.
127 if (robustness >= EmeRobustness::HW_SECURE_CRYPTO)
128 return EmeConfigRule::IDENTIFIER_REQUIRED;
129
130 // For video, recommend remote attestation if HW_SECURE_ALL is available,
131 // because it enables hardware accelerated decoding.
132 // TODO(sandersd): Only do this when hardware accelerated decoding is
133 // available for the requested codecs.
134 if (media_type == EmeMediaType::VIDEO &&
135 max_robustness == EmeRobustness::HW_SECURE_ALL) {
136 return EmeConfigRule::IDENTIFIER_RECOMMENDED;
137 }
138 #elif defined(OS_ANDROID)
139 // Require hardware secure codecs when SW_SECURE_DECODE or above is specified.
140 if (robustness >= EmeRobustness::SW_SECURE_DECODE) {
141 return EmeConfigRule::HW_SECURE_CODECS_REQUIRED;
142 }
143 #endif // defined(OS_CHROMEOS)
144
145 return EmeConfigRule::SUPPORTED;
146 }
147
148 EmeSessionTypeSupport
149 WidevineKeySystemProperties::GetPersistentLicenseSessionSupport() const {
150 return persistent_license_support_;
151 }
152
153 EmeSessionTypeSupport
154 WidevineKeySystemProperties::GetPersistentReleaseMessageSessionSupport() const {
155 return persistent_release_message_support_;
156 }
157
158 EmeFeatureSupport WidevineKeySystemProperties::GetPersistentStateSupport()
159 const {
160 return persistent_state_support_;
161 }
162
163 EmeFeatureSupport WidevineKeySystemProperties::GetDistinctiveIdentifierSupport()
164 const {
165 return distinctive_identifier_support_;
166 }
167
168 #if defined(ENABLE_PEPPER_CDMS)
169 std::string WidevineKeySystemProperties::GetPepperType() const {
170 return kWidevineCdmPluginMimeType;
171 }
172 #endif
173
174 } // namespace cdm
175
176 #endif // WIDEVINE_CDM_AVAILABLE
OLDNEW
« no previous file with comments | « components/cdm/renderer/widevine_key_system_properties.h ('k') | components/cdm/renderer/widevine_key_systems.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698