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

Side by Side Diff: content/renderer/media/crypto/key_systems_info.cc

Issue 23464005: Explicitly register each key system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback Created 7 years, 3 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 | Annotate | Revision Log
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 "content/renderer/media/crypto/key_systems_info.h" 5 #include "content/renderer/media/crypto/key_systems_info.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/renderer/media/crypto/key_systems.h"
8 #include "third_party/WebKit/public/platform/WebString.h" 9 #include "third_party/WebKit/public/platform/WebString.h"
9 10
10 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 11 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
11 12
12 // The following must be after widevine_cdm_version.h. 13 // The following must be after widevine_cdm_version.h.
13 14
14 #if defined(WIDEVINE_CDM_AVAILABLE) && \ 15 #if defined(WIDEVINE_CDM_AVAILABLE) && \
15 defined(OS_LINUX) && !defined(OS_CHROMEOS) 16 defined(OS_LINUX) && !defined(OS_CHROMEOS)
16 #include <gnu/libc-version.h> 17 #include <gnu/libc-version.h>
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/version.h" 19 #include "base/version.h"
19 #endif 20 #endif
20 21
21 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) 22 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
22 #include "base/command_line.h" 23 #include "base/command_line.h"
23 #include "media/base/media_switches.h" 24 #include "media/base/media_switches.h"
24 #endif 25 #endif
25 26
26 namespace content { 27 namespace content {
27 28
28 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; 29 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
29 30
30 #if defined(ENABLE_PEPPER_CDMS) 31 #if defined(ENABLE_PEPPER_CDMS)
31 static const char kExternalClearKeyKeySystem[] = 32 static const char kExternalClearKeyKeySystem[] =
32 "org.chromium.externalclearkey"; 33 "org.chromium.externalclearkey";
33 #endif // defined(ENABLE_PEPPER_CDMS) 34 #elif defined(OS_ANDROID)
35 static const uint8 uuid[16] kEmptyUuid =
36 { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
37 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
38 #endif
34 39
35 #if defined(WIDEVINE_CDM_AVAILABLE) 40 #if defined(WIDEVINE_CDM_AVAILABLE)
36 // TODO(ddorwin): Automatically support parent systems: http://crbug.com/164303.
37 static const char kWidevineBaseKeySystem[] = "com.widevine";
38 41
39 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) 42 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
40 // The supported codecs depend on what the CDM provides. 43 // The supported codecs depend on what the CDM provides.
41 static const char kWidevineVideoMp4Codecs[] = 44 static const char kWidevineVideoMp4Codecs[] =
42 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \ 45 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) && \
43 defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) 46 defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
44 "avc1,mp4a"; 47 "avc1,mp4a";
45 #elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 48 #elif defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
46 "avc1"; 49 "avc1";
47 #else 50 #else
48 ""; // No codec strings are supported. 51 ""; // No codec strings are supported.
49 #endif 52 #endif
50 53
51 static const char kWidevineAudioMp4Codecs[] = 54 static const char kWidevineAudioMp4Codecs[] =
52 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) 55 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
53 "mp4a"; 56 "mp4a";
54 #else 57 #else
55 ""; // No codec strings are supported. 58 ""; // No codec strings are supported.
56 #endif 59 #endif
57 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE) 60 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
58 61
59 static inline bool IsWidevine(const std::string& key_system) { 62 static void RegisterWidevine() {
60 return key_system == kWidevineKeySystem || 63 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
61 key_system == kWidevineBaseKeySystem; 64 Version glibc_version(gnu_get_libc_version());
65 DCHECK(glibc_version.IsValid());
66 if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION))
67 return;
68 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
69
70 AddConcreteSupportedKeySystem(
71 kWidevineKeySystem,
72 false,
73 #if defined(ENABLE_PEPPER_CDMS)
74 kWidevineCdmPluginMimeType,
75 #elif defined(OS_ANDROID)
76 { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
77 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED },
78 #endif // defined(ENABLE_PEPPER_CDMS)
79 "com.widevine");
80 AddSupportedType(kWidevineKeySystem, "video/webm", "vorbis,vp8,vp8.0");
81 AddSupportedType(kWidevineKeySystem, "audio/webm", "vorbis");
82 #if defined(USE_PROPRIETARY_CODECS) && \
83 defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
84 AddSupportedType(kWidevineKeySystem, "video/mp4", kWidevineVideoMp4Codecs);
85 AddSupportedType(kWidevineKeySystem, "audio/mp4", kWidevineAudioMp4Codecs);
86 #endif // defined(USE_PROPRIETARY_CODECS) &&
87 // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
62 } 88 }
63 #endif // defined(WIDEVINE_CDM_AVAILABLE) 89 #endif // WIDEVINE_CDM_AVAILABLE
64 90
65 const MediaFormatAndKeySystem kSupportedFormatKeySystemCombinations[] = { 91
92 void RegisterKeySystems() {
66 // Clear Key. 93 // Clear Key.
67 { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, 94 AddConcreteSupportedKeySystem(
68 { "audio/webm", "vorbis", kClearKeyKeySystem }, 95 kClearKeyKeySystem,
96 true,
97 #if defined(ENABLE_PEPPER_CDMS)
98 std::string(),
99 #elif defined(OS_ANDROID)
100 kEmptyUuid,
ddorwin 2013/08/29 21:44:04 Hopefully addressing "extended initializer lists o
101 #endif // defined(ENABLE_PEPPER_CDMS)
102 std::string());
103 AddSupportedType(kClearKeyKeySystem, "video/webm", "vorbis,vp8,vp8.0");
104 AddSupportedType(kClearKeyKeySystem, "audio/webm", "vorbis");
69 #if defined(USE_PROPRIETARY_CODECS) 105 #if defined(USE_PROPRIETARY_CODECS)
70 { "video/mp4", "avc1,mp4a", kClearKeyKeySystem }, 106 AddSupportedType(kClearKeyKeySystem, "video/mp4", "avc1,mp4a");
71 { "audio/mp4", "mp4a", kClearKeyKeySystem }, 107 AddSupportedType(kClearKeyKeySystem, "audio/mp4", "mp4a");
72 #endif // defined(USE_PROPRIETARY_CODECS) 108 #endif // defined(USE_PROPRIETARY_CODECS)
73 109
74 #if defined(ENABLE_PEPPER_CDMS) 110 #if defined(ENABLE_PEPPER_CDMS)
75 // External Clear Key (used for testing). 111 // External Clear Key (used for testing).
76 { "video/webm", "vorbis,vp8,vp8.0", kExternalClearKeyKeySystem }, 112 AddConcreteSupportedKeySystem(kExternalClearKeyKeySystem, false,
77 { "audio/webm", "vorbis", kExternalClearKeyKeySystem }, 113 "application/x-ppapi-clearkey-cdm",
114 std::string());
115 AddSupportedType(kExternalClearKeyKeySystem,
116 "video/webm", "vorbis,vp8,vp8.0");
117 AddSupportedType(kExternalClearKeyKeySystem, "audio/webm", "vorbis");
78 #if defined(USE_PROPRIETARY_CODECS) 118 #if defined(USE_PROPRIETARY_CODECS)
79 { "video/mp4", "avc1,mp4a", kExternalClearKeyKeySystem }, 119 AddSupportedType(kExternalClearKeyKeySystem, "video/mp4", "avc1,mp4a");
80 { "audio/mp4", "mp4a", kExternalClearKeyKeySystem }, 120 AddSupportedType(kExternalClearKeyKeySystem, "audio/mp4", "mp4a");
81 #endif // defined(USE_PROPRIETARY_CODECS) 121 #endif // defined(USE_PROPRIETARY_CODECS)
82 #endif // defined(ENABLE_PEPPER_CDMS) 122 #endif // defined(ENABLE_PEPPER_CDMS)
83 123
84 #if defined(WIDEVINE_CDM_AVAILABLE) 124 #if defined(WIDEVINE_CDM_AVAILABLE)
85 // Widevine. 125 RegisterWidevine();
86 { "video/webm", "vorbis,vp8,vp8.0", kWidevineKeySystem },
87 { "audio/webm", "vorbis", kWidevineKeySystem },
88 #if defined(USE_PROPRIETARY_CODECS)
89 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
90 { "video/mp4", kWidevineVideoMp4Codecs, kWidevineKeySystem },
91 { "audio/mp4", kWidevineAudioMp4Codecs, kWidevineKeySystem },
92 #endif // defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
93 #endif // defined(USE_PROPRIETARY_CODECS)
94 #endif // WIDEVINE_CDM_AVAILABLE 126 #endif // WIDEVINE_CDM_AVAILABLE
95 };
96
97 const int kNumSupportedFormatKeySystemCombinations =
98 arraysize(kSupportedFormatKeySystemCombinations);
99
100 #if defined(ENABLE_PEPPER_CDMS)
101 const KeySystemPepperTypePair kKeySystemToPepperTypeMapping[] = {
102 { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm"},
103 #if defined(WIDEVINE_CDM_AVAILABLE)
104 { kWidevineKeySystem, kWidevineCdmPluginMimeType}
105 #endif // WIDEVINE_CDM_AVAILABLE
106 };
107
108 const int kNumKeySystemToPepperTypeMapping =
109 arraysize(kKeySystemToPepperTypeMapping);
110 #endif // defined(ENABLE_PEPPER_CDMS)
111
112 #if defined(OS_ANDROID)
113 // TODO(qinmin): add UUIDs for other key systems.
114 const KeySystemUUIDPair kKeySystemToUUIDMapping[] = {
115 #if defined(WIDEVINE_CDM_AVAILABLE)
116 { kWidevineKeySystem, { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
117 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }
118 }
119 #endif // defined(WIDEVINE_CDM_AVAILABLE)
120 };
121
122 // arraySize() does not work if the array is empty, so use ARRAYSIZE_UNSAFE().
123 const int kNumKeySystemToUUIDMapping =
124 ARRAYSIZE_UNSAFE(kKeySystemToUUIDMapping);
125 #endif // defined(OS_ANDROID)
126
127 bool IsOSIncompatible(const std::string& concrete_key_system) {
128 DCHECK(IsConcreteKeySystem(concrete_key_system))
129 << concrete_key_system << " is not a concrete system";
130 #if defined(WIDEVINE_CDM_AVAILABLE) && \
131 defined(OS_LINUX) && !defined(OS_CHROMEOS)
132 if (IsWidevine(concrete_key_system)) {
133 Version glibc_version(gnu_get_libc_version());
134 DCHECK(glibc_version.IsValid());
135 return glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION);
136 }
137 #endif
138 return false;
139 }
140
141 std::string EnsureConcreteKeySystem(const std::string& key_system) {
142 #if defined(WIDEVINE_CDM_AVAILABLE)
143 if (key_system == kWidevineKeySystem || key_system == kWidevineBaseKeySystem)
144 return kWidevineKeySystem;
145 #endif // WIDEVINE_CDM_AVAILABLE
146 // No parent names for Clear Key.
147 if (key_system == kClearKeyKeySystem)
148 return kClearKeyKeySystem;
149 #if defined(ENABLE_PEPPER_CDMS)
150 // No parent names for External Clear Key.
151 if (key_system == kExternalClearKeyKeySystem)
152 return kExternalClearKeyKeySystem;
153 #endif // defined(ENABLE_PEPPER_CDMS)
154 return std::string();
155 } 127 }
156 128
157 bool IsCanPlayTypeSuppressed(const std::string& key_system) { 129 bool IsCanPlayTypeSuppressed(const std::string& key_system) {
158 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE) 130 #if defined(DISABLE_WIDEVINE_CDM_CANPLAYTYPE)
159 // See http://crbug.com/237627. 131 // See http://crbug.com/237627.
160 if (IsWidevine(key_system) && 132 if (key_system == kWidevineKeySystem &&
161 !CommandLine::ForCurrentProcess()->HasSwitch( 133 !CommandLine::ForCurrentProcess()->HasSwitch(
162 switches::kOverrideEncryptedMediaCanPlayType)) 134 switches::kOverrideEncryptedMediaCanPlayType))
163 return true; 135 return true;
164 #endif 136 #endif
165 return false; 137 return false;
166 } 138 }
167 139
168 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) { 140 std::string KeySystemNameForUMAInternal(const WebKit::WebString& key_system) {
169 if (key_system == kClearKeyKeySystem) 141 if (key_system == kClearKeyKeySystem)
170 return "ClearKey"; 142 return "ClearKey";
171 #if defined(WIDEVINE_CDM_AVAILABLE) 143 #if defined(WIDEVINE_CDM_AVAILABLE)
172 if (key_system == kWidevineKeySystem) 144 if (key_system == kWidevineKeySystem)
173 return "Widevine"; 145 return "Widevine";
174 #endif // WIDEVINE_CDM_AVAILABLE 146 #endif // WIDEVINE_CDM_AVAILABLE
175 return "Unknown"; 147 return "Unknown";
176 } 148 }
177 149
178 bool CanUseAesDecryptorInternal(const std::string& key_system) {
179 return key_system == kClearKeyKeySystem;
180 }
181
182 } // namespace content 150 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/crypto/key_systems_info.h ('k') | content/renderer/media/crypto/key_systems_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698