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

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

Issue 23513055: Populate canPlayType to renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add dcheck 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 "chrome/renderer/media/chrome_key_systems.h" 5 #include "chrome/renderer/media/chrome_key_systems.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 10
11 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 11 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
12 12
13 // The following must be after widevine_cdm_version.h. 13 // The following must be after widevine_cdm_version.h.
14 14
15 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 15 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
16 #include <gnu/libc-version.h> 16 #include <gnu/libc-version.h>
17 #include "base/version.h" 17 #include "base/version.h"
18 #endif 18 #endif
19 19
20 #if defined(OS_ANDROID)
21 #include "chrome/common/encrypted_media_messages_android.h"
22 #endif
23
20 using content::KeySystemInfo; 24 using content::KeySystemInfo;
21 25
22 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; 26 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
23 27
24 static const char kAudioWebM[] = "audio/webm"; 28 static const char kAudioWebM[] = "audio/webm";
25 static const char kVideoWebM[] = "video/webm"; 29 static const char kVideoWebM[] = "video/webm";
26 static const char kVorbis[] = "vorbis"; 30 static const char kVorbis[] = "vorbis";
27 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; 31 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0";
28 32
29 static const char kAudioMp4[] = "audio/mp4"; 33 static const char kAudioMp4[] = "audio/mp4";
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // Defines bitmask values used to specify supported codecs. 92 // Defines bitmask values used to specify supported codecs.
89 // Each value represents a codec within a specific container. 93 // Each value represents a codec within a specific container.
90 enum SupportedCodecs { 94 enum SupportedCodecs {
91 WEBM_VP8_AND_VORBIS = 1 << 0, 95 WEBM_VP8_AND_VORBIS = 1 << 0,
92 #if defined(USE_PROPRIETARY_CODECS) 96 #if defined(USE_PROPRIETARY_CODECS)
93 MP4_AAC = 1 << 1, 97 MP4_AAC = 1 << 1,
94 MP4_AVC1 = 1 << 2, 98 MP4_AVC1 = 1 << 2,
95 #endif // defined(USE_PROPRIETARY_CODECS) 99 #endif // defined(USE_PROPRIETARY_CODECS)
96 }; 100 };
97 101
102 #if defined(OS_ANDROID)
103 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
104 COMPILE_ASSERT(static_cast<int>(name) == \
105 static_cast<int>(android::name), \
106 mismatching_enums)
107 COMPILE_ASSERT_MATCHING_ENUM(WEBM_VP8_AND_VORBIS);
108 COMPILE_ASSERT_MATCHING_ENUM(MP4_AAC);
109 COMPILE_ASSERT_MATCHING_ENUM(MP4_AVC1);
110 #undef COMPILE_ASSERT_MATCHING_ENUM
111
112 static const uint8 kWidevineUuid[16] = {
113 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
114 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
115 #endif
116
98 static void AddWidevineWithCodecs( 117 static void AddWidevineWithCodecs(
99 SupportedCodecs supported_codecs, 118 SupportedCodecs supported_codecs,
100 std::vector<KeySystemInfo>* concrete_key_systems) { 119 std::vector<KeySystemInfo>* concrete_key_systems) {
101 static const char kWidevineParentKeySystem[] = "com.widevine"; 120 static const char kWidevineParentKeySystem[] = "com.widevine";
102 #if defined(OS_ANDROID)
103 static const uint8 kWidevineUuid[16] = {
104 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
105 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
106 #endif
107 121
108 KeySystemInfo info(kWidevineKeySystem); 122 KeySystemInfo info(kWidevineKeySystem);
109 123
110 if (supported_codecs & WEBM_VP8_AND_VORBIS) { 124 if (supported_codecs & WEBM_VP8_AND_VORBIS) {
111 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); 125 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
112 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); 126 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
113 } 127 }
114 128
115 #if defined(USE_PROPRIETARY_CODECS) 129 #if defined(USE_PROPRIETARY_CODECS)
116 if (supported_codecs & MP4_AAC) 130 if (supported_codecs & MP4_AAC)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 172 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
159 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1); 173 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1);
160 #endif 174 #endif
161 #endif // defined(USE_PROPRIETARY_CODECS) 175 #endif // defined(USE_PROPRIETARY_CODECS)
162 176
163 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 177 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
164 } 178 }
165 #elif defined(OS_ANDROID) 179 #elif defined(OS_ANDROID)
166 static void AddAndroidWidevine( 180 static void AddAndroidWidevine(
167 std::vector<KeySystemInfo>* concrete_key_systems) { 181 std::vector<KeySystemInfo>* concrete_key_systems) {
182 android::SupportedKeySystemRequest request;
183 android::SupportedKeySystemResponse response;
184
185 request.uuid.insert(request.uuid.begin(), kWidevineUuid,
186 kWidevineUuid + arraysize(kWidevineUuid));
168 #if defined(USE_PROPRIETARY_CODECS) 187 #if defined(USE_PROPRIETARY_CODECS)
169 SupportedCodecs supported_codecs = 188 request.codecs = static_cast<android::SupportedCodecs>(
170 static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1); 189 android::MP4_AAC | android::MP4_AVC1);
190 #endif // defined(USE_PROPRIETARY_CODECS)
191 content::RenderThread::Get()->Send(
192 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response));
193 // TODO(qinmin): Use different key system types for compositing and
194 // non-compositing codecs.
195 SupportedCodecs supported_codecs = static_cast<SupportedCodecs>(
196 response.compositing_codecs | response.non_compositing_codecs);
197 DCHECK_EQ(supported_codecs >> 3, 0);
ddorwin 2013/09/18 18:13:02 Add something like: << "unrecognized codec";
qinmin 2013/09/18 18:52:20 Done.
171 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 198 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
172 #endif // defined(USE_PROPRIETARY_CODECS)
173 } 199 }
174 #endif // defined(ENABLE_PEPPER_CDMS) 200 #endif // defined(ENABLE_PEPPER_CDMS)
175 #endif // defined(WIDEVINE_CDM_AVAILABLE) 201 #endif // defined(WIDEVINE_CDM_AVAILABLE)
176 202
177 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) { 203 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) {
178 AddClearKey(key_systems_info); 204 AddClearKey(key_systems_info);
179 205
180 #if defined(ENABLE_PEPPER_CDMS) 206 #if defined(ENABLE_PEPPER_CDMS)
181 AddExternalClearKey(key_systems_info); 207 AddExternalClearKey(key_systems_info);
182 #endif 208 #endif
183 209
184 #if defined(WIDEVINE_CDM_AVAILABLE) 210 #if defined(WIDEVINE_CDM_AVAILABLE)
185 #if defined(ENABLE_PEPPER_CDMS) 211 #if defined(ENABLE_PEPPER_CDMS)
186 AddPepperBasedWidevine(key_systems_info); 212 AddPepperBasedWidevine(key_systems_info);
187 #elif defined(OS_ANDROID) 213 #elif defined(OS_ANDROID)
188 AddAndroidWidevine(key_systems_info); 214 AddAndroidWidevine(key_systems_info);
189 #endif 215 #endif
190 #endif 216 #endif
191 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698