| OLD | NEW |
| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 #if defined(OS_ANDROID) | 142 #if defined(OS_ANDROID) |
| 143 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 143 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| 144 COMPILE_ASSERT(static_cast<int>(name) == \ | 144 COMPILE_ASSERT(static_cast<int>(name) == \ |
| 145 static_cast<int>(android::name), \ | 145 static_cast<int>(android::name), \ |
| 146 mismatching_enums) | 146 mismatching_enums) |
| 147 COMPILE_ASSERT_MATCHING_ENUM(WEBM_VP8_AND_VORBIS); | 147 COMPILE_ASSERT_MATCHING_ENUM(WEBM_VP8_AND_VORBIS); |
| 148 COMPILE_ASSERT_MATCHING_ENUM(MP4_AAC); | 148 COMPILE_ASSERT_MATCHING_ENUM(MP4_AAC); |
| 149 COMPILE_ASSERT_MATCHING_ENUM(MP4_AVC1); | 149 COMPILE_ASSERT_MATCHING_ENUM(MP4_AVC1); |
| 150 #undef COMPILE_ASSERT_MATCHING_ENUM | 150 #undef COMPILE_ASSERT_MATCHING_ENUM |
| 151 | |
| 152 static const uint8 kWidevineUuid[16] = { | |
| 153 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
| 154 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | |
| 155 #else | 151 #else |
| 156 static bool IsWidevineHrSupported() { | 152 static bool IsWidevineHrSupported() { |
| 157 // TODO(jrummell): Need to call CheckPlatformState() but it is | 153 // TODO(jrummell): Need to call CheckPlatformState() but it is |
| 158 // asynchronous, and needs to be done in the browser. | 154 // asynchronous, and needs to be done in the browser. |
| 159 return false; | 155 return false; |
| 160 } | 156 } |
| 161 #endif | 157 #endif |
| 162 | 158 |
| 163 // Return |name|'s parent key system. | 159 // Return |name|'s parent key system. |
| 164 static std::string GetDirectParentName(std::string name) { | 160 static std::string GetDirectParentName(std::string name) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 ""; | 202 ""; |
| 207 const char* audio_codecs = is_aac_supported ? kMp4a : ""; | 203 const char* audio_codecs = is_aac_supported ? kMp4a : ""; |
| 208 | 204 |
| 209 info.supported_types.push_back(std::make_pair(kAudioMp4, audio_codecs)); | 205 info.supported_types.push_back(std::make_pair(kAudioMp4, audio_codecs)); |
| 210 info.supported_types.push_back(std::make_pair(kVideoMp4, video_codecs)); | 206 info.supported_types.push_back(std::make_pair(kVideoMp4, video_codecs)); |
| 211 } | 207 } |
| 212 #endif // defined(USE_PROPRIETARY_CODECS) | 208 #endif // defined(USE_PROPRIETARY_CODECS) |
| 213 | 209 |
| 214 #if defined(ENABLE_PEPPER_CDMS) | 210 #if defined(ENABLE_PEPPER_CDMS) |
| 215 info.pepper_type = kWidevineCdmPluginMimeType; | 211 info.pepper_type = kWidevineCdmPluginMimeType; |
| 216 #elif defined(OS_ANDROID) | |
| 217 info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid)); | |
| 218 #endif // defined(ENABLE_PEPPER_CDMS) | 212 #endif // defined(ENABLE_PEPPER_CDMS) |
| 219 | 213 |
| 220 concrete_key_systems->push_back(info); | 214 concrete_key_systems->push_back(info); |
| 221 } | 215 } |
| 222 | 216 |
| 223 #if defined(ENABLE_PEPPER_CDMS) | 217 #if defined(ENABLE_PEPPER_CDMS) |
| 224 // When the adapter is registered, a name-value pair is inserted in | 218 // When the adapter is registered, a name-value pair is inserted in |
| 225 // additional_param_* that lists the supported codecs. The name is "codecs" and | 219 // additional_param_* that lists the supported codecs. The name is "codecs" and |
| 226 // the value is a comma-delimited list of codecs. | 220 // the value is a comma-delimited list of codecs. |
| 227 // This function finds "codecs" and parses the value into the vector |codecs|. | 221 // This function finds "codecs" and parses the value into the vector |codecs|. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 284 |
| 291 if (IsWidevineHrSupported()) | 285 if (IsWidevineHrSupported()) |
| 292 AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems); | 286 AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems); |
| 293 } | 287 } |
| 294 #elif defined(OS_ANDROID) | 288 #elif defined(OS_ANDROID) |
| 295 static void AddAndroidWidevine( | 289 static void AddAndroidWidevine( |
| 296 std::vector<KeySystemInfo>* concrete_key_systems) { | 290 std::vector<KeySystemInfo>* concrete_key_systems) { |
| 297 SupportedKeySystemRequest request; | 291 SupportedKeySystemRequest request; |
| 298 SupportedKeySystemResponse response; | 292 SupportedKeySystemResponse response; |
| 299 | 293 |
| 300 request.uuid.insert(request.uuid.begin(), kWidevineUuid, | 294 request.key_system = kWidevineKeySystem; |
| 301 kWidevineUuid + arraysize(kWidevineUuid)); | |
| 302 #if defined(USE_PROPRIETARY_CODECS) | 295 #if defined(USE_PROPRIETARY_CODECS) |
| 303 request.codecs = static_cast<android::SupportedCodecs>( | 296 request.codecs = static_cast<android::SupportedCodecs>( |
| 304 android::MP4_AAC | android::MP4_AVC1); | 297 android::MP4_AAC | android::MP4_AVC1); |
| 305 #endif // defined(USE_PROPRIETARY_CODECS) | 298 #endif // defined(USE_PROPRIETARY_CODECS) |
| 306 content::RenderThread::Get()->Send( | 299 content::RenderThread::Get()->Send( |
| 307 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response)); | 300 new ChromeViewHostMsg_GetSupportedKeySystems(request, &response)); |
| 308 DCHECK_EQ(response.compositing_codecs >> 3, 0) << "unrecognized codec"; | 301 DCHECK_EQ(response.compositing_codecs >> 3, 0) << "unrecognized codec"; |
| 309 DCHECK_EQ(response.non_compositing_codecs >> 3, 0) << "unrecognized codec"; | 302 DCHECK_EQ(response.non_compositing_codecs >> 3, 0) << "unrecognized codec"; |
| 310 if (response.compositing_codecs != android::NO_SUPPORTED_CODECS) { | 303 if (response.compositing_codecs != android::NO_SUPPORTED_CODECS) { |
| 311 AddWidevineWithCodecs( | 304 AddWidevineWithCodecs( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 330 #endif | 323 #endif |
| 331 | 324 |
| 332 #if defined(WIDEVINE_CDM_AVAILABLE) | 325 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 333 #if defined(ENABLE_PEPPER_CDMS) | 326 #if defined(ENABLE_PEPPER_CDMS) |
| 334 AddPepperBasedWidevine(key_systems_info); | 327 AddPepperBasedWidevine(key_systems_info); |
| 335 #elif defined(OS_ANDROID) | 328 #elif defined(OS_ANDROID) |
| 336 AddAndroidWidevine(key_systems_info); | 329 AddAndroidWidevine(key_systems_info); |
| 337 #endif | 330 #endif |
| 338 #endif | 331 #endif |
| 339 } | 332 } |
| OLD | NEW |