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

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: rebase 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 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
98 static void AddWidevineWithCodecs( 108 static void AddWidevineWithCodecs(
99 SupportedCodecs supported_codecs, 109 SupportedCodecs supported_codecs,
100 std::vector<KeySystemInfo>* concrete_key_systems) { 110 std::vector<KeySystemInfo>* concrete_key_systems) {
101 static const char kWidevineParentKeySystem[] = "com.widevine"; 111 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 112
108 KeySystemInfo info(kWidevineKeySystem); 113 KeySystemInfo info(kWidevineKeySystem);
109 114
110 if (supported_codecs & WEBM_VP8_AND_VORBIS) { 115 if (supported_codecs & WEBM_VP8_AND_VORBIS) {
111 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); 116 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
112 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); 117 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
113 } 118 }
114 119
115 #if defined(USE_PROPRIETARY_CODECS) 120 #if defined(USE_PROPRIETARY_CODECS)
116 if (supported_codecs & MP4_AAC) 121 if (supported_codecs & MP4_AAC)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC); 161 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC);
157 #endif 162 #endif
158 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 163 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
159 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1); 164 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1);
160 #endif 165 #endif
161 #endif // defined(USE_PROPRIETARY_CODECS) 166 #endif // defined(USE_PROPRIETARY_CODECS)
162 167
163 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 168 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
164 } 169 }
165 #elif defined(OS_ANDROID) 170 #elif defined(OS_ANDROID)
171
172 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
173 COMPILE_ASSERT(static_cast<int>(name) == \
174 static_cast<int>(android::name), \
175 mismatching_enums)
176 COMPILE_ASSERT_MATCHING_ENUM(WEBM_VP8_AND_VORBIS);
177 COMPILE_ASSERT_MATCHING_ENUM(MP4_AAC);
178 COMPILE_ASSERT_MATCHING_ENUM(MP4_AVC1);
179 #undef COMPILE_ASSERT_MATCHING_ENUM
xhwang 2013/09/18 07:10:57 So there's no way to only define those enum in one
qinmin 2013/09/18 17:19:59 Ya, i agree this is not satisfactory. We have thes
180
166 static void AddAndroidWidevine( 181 static void AddAndroidWidevine(
167 std::vector<KeySystemInfo>* concrete_key_systems) { 182 std::vector<KeySystemInfo>* concrete_key_systems) {
183 android::SupportedKeySystemRequest request;
184 android::SupportedKeySystemResponse response;
185
186 request.uuid.insert(request.uuid.begin(), kWidevineUuid,
187 kWidevineUuid + arraysize(kWidevineUuid));
168 #if defined(USE_PROPRIETARY_CODECS) 188 #if defined(USE_PROPRIETARY_CODECS)
189 request.requested_codecs =
190 static_cast<android::SupportedCodecs>(
191 android::MP4_AAC | android::MP4_AVC1);
192 #endif // defined(USE_PROPRIETARY_CODECS)
193 content::RenderThread::Get()->Send(
194 new ChromeViewHostMsg_GetSupportedKeySystems(
195 request, &response));
xhwang 2013/09/18 07:10:57 fit in one line?
qinmin 2013/09/18 17:19:59 Done.
196 // TODO(qinmin): Use different key system types for compositing and
197 // non-compositing codecs. Need to ignore the extra bit masks defined in
198 // android if that happens.
169 SupportedCodecs supported_codecs = 199 SupportedCodecs supported_codecs =
170 static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1); 200 static_cast<SupportedCodecs>(
201 response.compositing_codecs | response.non_compositing_codecs);
171 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 202 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
172 #endif // defined(USE_PROPRIETARY_CODECS)
173 } 203 }
174 #endif // defined(ENABLE_PEPPER_CDMS) 204 #endif // defined(ENABLE_PEPPER_CDMS)
175 #endif // defined(WIDEVINE_CDM_AVAILABLE) 205 #endif // defined(WIDEVINE_CDM_AVAILABLE)
176 206
177 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) { 207 void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) {
178 AddClearKey(key_systems_info); 208 AddClearKey(key_systems_info);
179 209
180 #if defined(ENABLE_PEPPER_CDMS) 210 #if defined(ENABLE_PEPPER_CDMS)
181 AddExternalClearKey(key_systems_info); 211 AddExternalClearKey(key_systems_info);
182 #endif 212 #endif
183 213
184 #if defined(WIDEVINE_CDM_AVAILABLE) 214 #if defined(WIDEVINE_CDM_AVAILABLE)
185 #if defined(ENABLE_PEPPER_CDMS) 215 #if defined(ENABLE_PEPPER_CDMS)
186 AddPepperBasedWidevine(key_systems_info); 216 AddPepperBasedWidevine(key_systems_info);
187 #elif defined(OS_ANDROID) 217 #elif defined(OS_ANDROID)
188 AddAndroidWidevine(key_systems_info); 218 AddAndroidWidevine(key_systems_info);
189 #endif 219 #endif
190 #endif 220 #endif
191 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698