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

Side by Side Diff: chrome/renderer/media/chrome_key_systems.cc

Issue 1953803002: Remove remaining uses of KeySystemInfo and InitDataTypeMask (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/media/chrome_key_systems.h" 5 #include "chrome/renderer/media/chrome_key_systems.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/common/render_messages.h" 17 #include "chrome/common/render_messages.h"
18 #include "components/cdm/renderer/widevine_key_system_properties.h" 18 #include "components/cdm/renderer/widevine_key_system_properties.h"
19 #include "content/public/renderer/render_thread.h" 19 #include "content/public/renderer/render_thread.h"
20 #include "media/base/eme_constants.h" 20 #include "media/base/eme_constants.h"
21 #include "media/base/key_system_info.h"
22 #include "media/base/key_system_properties.h" 21 #include "media/base/key_system_properties.h"
23 22
24 #include "media/media_features.h" 23 #include "media/media_features.h"
25 24
26 #if defined(OS_ANDROID) 25 #if defined(OS_ANDROID)
27 #include "components/cdm/renderer/android_key_systems.h" 26 #include "components/cdm/renderer/android_key_systems.h"
28 #endif 27 #endif
29 28
30 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 29 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
31 30
32 // The following must be after widevine_cdm_version.h. 31 // The following must be after widevine_cdm_version.h.
33 32
34 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 33 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
35 #include <gnu/libc-version.h> 34 #include <gnu/libc-version.h>
36 #include "base/version.h" 35 #include "base/version.h"
37 #endif 36 #endif
38 37
39 using media::KeySystemInfo;
40 using media::KeySystemProperties; 38 using media::KeySystemProperties;
41 using media::SupportedCodecs; 39 using media::SupportedCodecs;
42 40
43 #if defined(ENABLE_PEPPER_CDMS) 41 #if defined(ENABLE_PEPPER_CDMS)
42 static const char kExternalClearKeyPepperType[] =
43 "application/x-ppapi-clearkey-cdm";
44
44 static bool IsPepperCdmAvailable( 45 static bool IsPepperCdmAvailable(
45 const std::string& pepper_type, 46 const std::string& pepper_type,
46 std::vector<base::string16>* additional_param_names, 47 std::vector<base::string16>* additional_param_names,
47 std::vector<base::string16>* additional_param_values) { 48 std::vector<base::string16>* additional_param_values) {
48 bool is_available = false; 49 bool is_available = false;
49 content::RenderThread::Get()->Send( 50 content::RenderThread::Get()->Send(
50 new ChromeViewHostMsg_IsInternalPluginAvailableForMimeType( 51 new ChromeViewHostMsg_IsInternalPluginAvailableForMimeType(
51 pepper_type, 52 pepper_type,
52 &is_available, 53 &is_available,
53 additional_param_names, 54 additional_param_names,
54 additional_param_values)); 55 additional_param_values));
55 56
56 return is_available; 57 return is_available;
57 } 58 }
58 59
60 // KeySystemProperties implementation for registering external ClearKey systems.
ddorwin 2016/05/05 20:55:31 nit: External Clear Key drop "registering " to mak
halliwell 2016/05/05 22:44:10 Done.
61 class ExternalClearKeyProperties : public KeySystemProperties {
62 public:
63 explicit ExternalClearKeyProperties(const std::string& key_system_name)
64 : key_system_name_(key_system_name) {}
65
66 std::string GetKeySystemName() const override { return key_system_name_; }
67 bool IsSupportedInitDataType(
68 media::EmeInitDataType init_data_type) const override {
69 switch (init_data_type) {
70 case media::EmeInitDataType::WEBM:
71 case media::EmeInitDataType::KEYIDS:
72 return true;
73
74 case media::EmeInitDataType::CENC:
75 #if defined(USE_PROPRIETARY_CODECS)
76 return true;
77 #else
78 return false;
79 #endif // defined(USE_PROPRIETARY_CODECS)
80
81 case media::EmeInitDataType::UNKNOWN:
82 return false;
83 }
84 NOTREACHED();
85 return false;
86 }
87
88 SupportedCodecs GetSupportedCodecs() const override {
89 #if defined(USE_PROPRIETARY_CODECS)
90 return media::EME_CODEC_MP4_ALL | media::EME_CODEC_WEBM_ALL;
91 #else
92 return media::EME_CODEC_WEBM_ALL;
93 #endif
94 }
95
96 media::EmeConfigRule GetRobustnessConfigRule(
97 media::EmeMediaType media_type,
98 const std::string& requested_robustness) const override {
99 return requested_robustness.empty() ? media::EmeConfigRule::SUPPORTED
100 : media::EmeConfigRule::NOT_SUPPORTED;
101 }
102
103 // Persistent sessions are faked.
ddorwin 2016/05/05 20:55:31 Persistent license sessions...
halliwell 2016/05/05 22:44:10 Done.
104 media::EmeSessionTypeSupport GetPersistentLicenseSessionSupport()
105 const override {
106 return media::EmeSessionTypeSupport::SUPPORTED;
107 }
108 media::EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport()
ddorwin 2016/05/05 20:55:31 Might make sense to use newlines here since the re
halliwell 2016/05/05 22:44:10 Done.
109 const override {
110 return media::EmeSessionTypeSupport::NOT_SUPPORTED;
111 }
112 media::EmeFeatureSupport GetPersistentStateSupport() const override {
113 return media::EmeFeatureSupport::REQUESTABLE;
114 }
115 media::EmeFeatureSupport GetDistinctiveIdentifierSupport() const override {
116 return media::EmeFeatureSupport::NOT_SUPPORTED;
117 }
118
119 std::string GetPepperType() const override {
120 return kExternalClearKeyPepperType;
121 }
122
123 private:
124 const std::string key_system_name_;
125 };
126
59 // External Clear Key (used for testing). 127 // External Clear Key (used for testing).
60 static void AddExternalClearKey( 128 static void AddExternalClearKey(
61 std::vector<KeySystemInfo>* concrete_key_systems) { 129 std::vector<std::unique_ptr<KeySystemProperties>>* concrete_key_systems) {
62 static const char kExternalClearKeyKeySystem[] = 130 static const char kExternalClearKeyKeySystem[] =
63 "org.chromium.externalclearkey"; 131 "org.chromium.externalclearkey";
64 static const char kExternalClearKeyDecryptOnlyKeySystem[] = 132 static const char kExternalClearKeyDecryptOnlyKeySystem[] =
65 "org.chromium.externalclearkey.decryptonly"; 133 "org.chromium.externalclearkey.decryptonly";
66 static const char kExternalClearKeyFileIOTestKeySystem[] = 134 static const char kExternalClearKeyFileIOTestKeySystem[] =
67 "org.chromium.externalclearkey.fileiotest"; 135 "org.chromium.externalclearkey.fileiotest";
68 static const char kExternalClearKeyInitializeFailKeySystem[] = 136 static const char kExternalClearKeyInitializeFailKeySystem[] =
69 "org.chromium.externalclearkey.initializefail"; 137 "org.chromium.externalclearkey.initializefail";
70 static const char kExternalClearKeyCrashKeySystem[] = 138 static const char kExternalClearKeyCrashKeySystem[] =
71 "org.chromium.externalclearkey.crash"; 139 "org.chromium.externalclearkey.crash";
72 static const char kExternalClearKeyPepperType[] =
73 "application/x-ppapi-clearkey-cdm";
74 140
75 std::vector<base::string16> additional_param_names; 141 std::vector<base::string16> additional_param_names;
76 std::vector<base::string16> additional_param_values; 142 std::vector<base::string16> additional_param_values;
77 if (!IsPepperCdmAvailable(kExternalClearKeyPepperType, 143 if (!IsPepperCdmAvailable(kExternalClearKeyPepperType,
78 &additional_param_names, 144 &additional_param_names,
79 &additional_param_values)) { 145 &additional_param_values)) {
80 return; 146 return;
81 } 147 }
82 148
83 KeySystemInfo info; 149 concrete_key_systems->emplace_back(
84 info.key_system = kExternalClearKeyKeySystem; 150 new ExternalClearKeyProperties(kExternalClearKeyKeySystem));
85
86 info.supported_init_data_types =
87 media::kInitDataTypeMaskWebM | media::kInitDataTypeMaskKeyIds;
88 info.supported_codecs = media::EME_CODEC_WEBM_ALL;
89 #if defined(USE_PROPRIETARY_CODECS)
90 info.supported_init_data_types |= media::kInitDataTypeMaskCenc;
91 info.supported_codecs |= media::EME_CODEC_MP4_ALL;
92 #endif // defined(USE_PROPRIETARY_CODECS)
93
94 info.max_audio_robustness = media::EmeRobustness::EMPTY;
95 info.max_video_robustness = media::EmeRobustness::EMPTY;
96
97 // Persistent sessions are faked.
98 info.persistent_license_support = media::EmeSessionTypeSupport::SUPPORTED;
99 info.persistent_release_message_support =
100 media::EmeSessionTypeSupport::NOT_SUPPORTED;
101 info.persistent_state_support = media::EmeFeatureSupport::REQUESTABLE;
102 info.distinctive_identifier_support = media::EmeFeatureSupport::NOT_SUPPORTED;
103
104 info.pepper_type = kExternalClearKeyPepperType;
105
106 concrete_key_systems->push_back(info);
107 151
108 // Add support of decrypt-only mode in ClearKeyCdm. 152 // Add support of decrypt-only mode in ClearKeyCdm.
109 info.key_system = kExternalClearKeyDecryptOnlyKeySystem; 153 concrete_key_systems->emplace_back(
110 concrete_key_systems->push_back(info); 154 new ExternalClearKeyProperties(kExternalClearKeyDecryptOnlyKeySystem));
111 155
112 // A key system that triggers FileIO test in ClearKeyCdm. 156 // A key system that triggers FileIO test in ClearKeyCdm.
113 info.key_system = kExternalClearKeyFileIOTestKeySystem; 157 concrete_key_systems->emplace_back(
114 concrete_key_systems->push_back(info); 158 new ExternalClearKeyProperties(kExternalClearKeyFileIOTestKeySystem));
115 159
116 // A key system that Chrome thinks is supported by ClearKeyCdm, but actually 160 // A key system that Chrome thinks is supported by ClearKeyCdm, but actually
117 // will be refused by ClearKeyCdm. This is to test the CDM initialization 161 // will be refused by ClearKeyCdm. This is to test the CDM initialization
118 // failure case. 162 // failure case.
119 info.key_system = kExternalClearKeyInitializeFailKeySystem; 163 concrete_key_systems->emplace_back(
120 concrete_key_systems->push_back(info); 164 new ExternalClearKeyProperties(kExternalClearKeyInitializeFailKeySystem));
121 165
122 // A key system that triggers a crash in ClearKeyCdm. 166 // A key system that triggers a crash in ClearKeyCdm.
123 info.key_system = kExternalClearKeyCrashKeySystem; 167 concrete_key_systems->emplace_back(
124 concrete_key_systems->push_back(info); 168 new ExternalClearKeyProperties(kExternalClearKeyCrashKeySystem));
125 } 169 }
126 170
127 #if defined(WIDEVINE_CDM_AVAILABLE) 171 #if defined(WIDEVINE_CDM_AVAILABLE)
128 // This function finds "codecs" and parses the value into the vector |codecs|. 172 // This function finds "codecs" and parses the value into the vector |codecs|.
129 // Converts the codec strings to UTF-8 since we only expect ASCII strings and 173 // Converts the codec strings to UTF-8 since we only expect ASCII strings and
130 // this simplifies the rest of the code in this file. 174 // this simplifies the rest of the code in this file.
131 void GetSupportedCodecsForPepperCdm( 175 void GetSupportedCodecsForPepperCdm(
132 const std::vector<base::string16>& additional_param_names, 176 const std::vector<base::string16>& additional_param_names,
133 const std::vector<base::string16>& additional_param_values, 177 const std::vector<base::string16>& additional_param_values,
134 std::vector<std::string>* codecs) { 178 std::vector<std::string>* codecs) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. 263 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
220 media::EmeSessionTypeSupport:: 264 media::EmeSessionTypeSupport::
221 NOT_SUPPORTED, // persistent-release-message. 265 NOT_SUPPORTED, // persistent-release-message.
222 media::EmeFeatureSupport::REQUESTABLE, // Persistent state. 266 media::EmeFeatureSupport::REQUESTABLE, // Persistent state.
223 media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier. 267 media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier.
224 #endif // defined(OS_CHROMEOS) 268 #endif // defined(OS_CHROMEOS)
225 } 269 }
226 #endif // defined(WIDEVINE_CDM_AVAILABLE) 270 #endif // defined(WIDEVINE_CDM_AVAILABLE)
227 #endif // defined(ENABLE_PEPPER_CDMS) 271 #endif // defined(ENABLE_PEPPER_CDMS)
228 272
229 void AddChromeKeySystemsInfo(std::vector<KeySystemInfo>* key_systems_info) {
230 #if defined(ENABLE_PEPPER_CDMS)
231 AddExternalClearKey(key_systems_info);
232 #endif
233 }
234
235 void AddChromeKeySystems( 273 void AddChromeKeySystems(
236 std::vector<std::unique_ptr<KeySystemProperties>>* key_systems_properties) { 274 std::vector<std::unique_ptr<KeySystemProperties>>* key_systems_properties) {
237 #if defined(ENABLE_PEPPER_CDMS) 275 #if defined(ENABLE_PEPPER_CDMS)
276 AddExternalClearKey(key_systems_properties);
277
238 #if defined(WIDEVINE_CDM_AVAILABLE) 278 #if defined(WIDEVINE_CDM_AVAILABLE)
239 AddPepperBasedWidevine(key_systems_properties); 279 AddPepperBasedWidevine(key_systems_properties);
240 #endif // defined(WIDEVINE_CDM_AVAILABLE) 280 #endif // defined(WIDEVINE_CDM_AVAILABLE)
281
241 #endif // defined(ENABLE_PEPPER_CDMS) 282 #endif // defined(ENABLE_PEPPER_CDMS)
242 283
243 #if defined(OS_ANDROID) 284 #if defined(OS_ANDROID)
244 cdm::AddAndroidWidevine(key_systems_properties); 285 cdm::AddAndroidWidevine(key_systems_properties);
245 #endif // defined(OS_ANDROID) 286 #endif // defined(OS_ANDROID)
246 } 287 }
OLDNEW
« no previous file with comments | « chrome/renderer/media/chrome_key_systems.h ('k') | content/public/renderer/content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698