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

Side by Side Diff: webkit/media/crypto/key_systems.cc

Issue 11474037: Several updates to canPlayType() results for EME (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 5 #include <map>
6 6
7 #include "webkit/media/crypto/key_systems.h" 7 #include "webkit/media/crypto/key_systems.h"
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 20 matching lines...) Expand all
31 const char* mime_type; 31 const char* mime_type;
32 const char* codecs_list; 32 const char* codecs_list;
33 const char* key_system; 33 const char* key_system;
34 }; 34 };
35 35
36 struct KeySystemPluginTypePair { 36 struct KeySystemPluginTypePair {
37 const char* key_system; 37 const char* key_system;
38 const char* plugin_type; 38 const char* plugin_type;
39 }; 39 };
40 40
41 // TODO(xhwang): Remove this and ifdefs after fixing http://crbug.com/123421.
42 #define DECRYPT_ONLY_AUDIO_NOT_SUPPORTED
43
41 // Specifies the container and codec combinations supported by individual 44 // Specifies the container and codec combinations supported by individual
42 // key systems. Each line is a container-codecs combination and the key system 45 // key systems. Each line is a container-codecs combination and the key system
43 // that supports it. Multiple codecs can be listed. A trailing commas in 46 // that supports it. Multiple codecs can be listed. A trailing commas in
44 // the |codecs_list| allows the container to be specified without a codec. 47 // the |codecs_list| allows the container to be specified without a codec.
45 // This list is converted at runtime into individual container-codec-key system 48 // This list is converted at runtime into individual container-codec-key system
46 // entries in KeySystems::key_system_map_. 49 // entries in KeySystems::key_system_map_.
47 static const MediaFormatAndKeySystem 50 static const MediaFormatAndKeySystem
48 supported_format_key_system_combinations[] = { 51 supported_format_key_system_combinations[] = {
49 // Clear Key. 52 // Clear Key.
53 #if defined(DECRYPT_ONLY_AUDIO_NOT_SUPPORTED)
54 { "video/webm", "vp8,vp8.0,", kClearKeyKeySystem },
55 #else
50 { "video/webm", "vorbis,vp8,vp8.0,", kClearKeyKeySystem }, 56 { "video/webm", "vorbis,vp8,vp8.0,", kClearKeyKeySystem },
51 { "audio/webm", "vorbis,", kClearKeyKeySystem }, 57 { "audio/webm", "vorbis,", kClearKeyKeySystem },
58 #endif
52 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) 59 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
60 #if defined(DECRYPT_ONLY_AUDIO_NOT_SUPPORTED)
61 { "video/mp4", "avc1,", kClearKeyKeySystem },
62 #else
53 { "video/mp4", "avc1,mp4a,", kClearKeyKeySystem }, 63 { "video/mp4", "avc1,mp4a,", kClearKeyKeySystem },
54 { "audio/mp4", "mp4a,", kClearKeyKeySystem }, 64 { "audio/mp4", "mp4a,", kClearKeyKeySystem },
55 #endif 65 #endif
66 #endif
56 67
57 // External Clear Key (used for testing). 68 // External Clear Key (used for testing).
58 { "video/webm", "vorbis,vp8,vp8.0,", kExternalClearKeyKeySystem }, 69 { "video/webm", "vorbis,vp8,vp8.0,", kExternalClearKeyKeySystem },
59 { "audio/webm", "vorbis,", kExternalClearKeyKeySystem }, 70 { "audio/webm", "vorbis,", kExternalClearKeyKeySystem },
60 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) 71 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
61 { "video/mp4", "avc1,mp4a,", kExternalClearKeyKeySystem }, 72 { "video/mp4", "avc1,mp4a,", kExternalClearKeyKeySystem },
62 { "audio/mp4", "mp4a,", kExternalClearKeyKeySystem }, 73 { "audio/mp4", "mp4a,", kExternalClearKeyKeySystem },
63 #endif 74 #endif
64 75
65 #if defined(WIDEVINE_CDM_AVAILABLE) 76 #if defined(WIDEVINE_CDM_AVAILABLE)
66 // Widevine. 77 // Widevine.
67 { "video/webm", "vorbis,vp8,vp8.0,", kWidevineKeySystem }, 78 { "video/webm", "vorbis,vp8,vp8.0,", kWidevineKeySystem },
68 { "audio/webm", "vorbis,", kWidevineKeySystem }, 79 { "audio/webm", "vorbis,", kWidevineKeySystem },
80 // TODO(ddorwin): Eliminate Base entries: http://crbug.com/164303.
81 { "video/webm", "vorbis,vp8,vp8.0,", kWidevineBaseKeySystem },
82 { "audio/webm", "vorbis,", kWidevineBaseKeySystem },
83 #if defined(WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE)
84 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
85 { "video/mp4", "avc1,mp4a,", kWidevineKeySystem },
86 { "audio/mp4", "mp4a,", kWidevineKeySystem },
87 // TODO(ddorwin): Eliminate Base entries: http://crbug.com/164303.
88 { "video/mp4", "avc1,mp4a,", kWidevineBaseKeySystem },
89 { "audio/mp4", "mp4a,", kWidevineBaseKeySystem },
90 #endif
91 #endif
69 #endif // WIDEVINE_CDM_AVAILABLE 92 #endif // WIDEVINE_CDM_AVAILABLE
70 }; 93 };
71 94
72 static const KeySystemPluginTypePair key_system_to_plugin_type_mapping[] = { 95 static const KeySystemPluginTypePair key_system_to_plugin_type_mapping[] = {
73 // TODO(xhwang): Update this with the real plugin name. 96 // TODO(xhwang): Update this with the real plugin name.
74 { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm" }, 97 { kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm" },
75 #if defined(WIDEVINE_CDM_AVAILABLE) 98 #if defined(WIDEVINE_CDM_AVAILABLE)
76 { kWidevineKeySystem, kWidevineCdmPluginMimeType } 99 { kWidevineKeySystem, kWidevineCdmPluginMimeType }
77 #endif // WIDEVINE_CDM_AVAILABLE 100 #endif // WIDEVINE_CDM_AVAILABLE
78 }; 101 };
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 DCHECK(mime_types_map.find(combination.mime_type) == 157 DCHECK(mime_types_map.find(combination.mime_type) ==
135 mime_types_map.end()); 158 mime_types_map.end());
136 mime_types_map[combination.mime_type] = codecs; 159 mime_types_map[combination.mime_type] = codecs;
137 } 160 }
138 } 161 }
139 } 162 }
140 163
141 bool KeySystems::IsSupportedKeySystem(const std::string& key_system) { 164 bool KeySystems::IsSupportedKeySystem(const std::string& key_system) {
142 bool is_supported = key_system_map_.find(key_system) != key_system_map_.end(); 165 bool is_supported = key_system_map_.find(key_system) != key_system_map_.end();
143 166
144 DCHECK_EQ(is_supported,
145 (CanUseAesDecryptor(key_system) ||
146 !GetPluginType(key_system).empty()))
147 << "key_system_map_ & key_system_to_plugin_type_mapping are inconsistent";
148 return is_supported; 167 return is_supported;
149 } 168 }
150 169
151 bool KeySystems::IsSupportedKeySystemWithContainerAndCodec( 170 bool KeySystems::IsSupportedKeySystemWithContainerAndCodec(
152 const std::string& mime_type, 171 const std::string& mime_type,
153 const std::string& codec, 172 const std::string& codec,
154 const std::string& key_system) { 173 const std::string& key_system) {
155 174
156 KeySystemMappings::const_iterator key_system_iter = 175 KeySystemMappings::const_iterator key_system_iter =
157 key_system_map_.find(key_system); 176 key_system_map_.find(key_system);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 std::string GetPluginType(const std::string& key_system) { 240 std::string GetPluginType(const std::string& key_system) {
222 for (size_t i = 0; i < arraysize(key_system_to_plugin_type_mapping); ++i) { 241 for (size_t i = 0; i < arraysize(key_system_to_plugin_type_mapping); ++i) {
223 if (key_system_to_plugin_type_mapping[i].key_system == key_system) 242 if (key_system_to_plugin_type_mapping[i].key_system == key_system)
224 return key_system_to_plugin_type_mapping[i].plugin_type; 243 return key_system_to_plugin_type_mapping[i].plugin_type;
225 } 244 }
226 245
227 return std::string(); 246 return std::string();
228 } 247 }
229 248
230 } // namespace webkit_media 249 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698