Chromium Code Reviews| Index: components/encrypted_media/renderer/widevine_key_systems.cc |
| diff --git a/components/encrypted_media/renderer/widevine_key_systems.cc b/components/encrypted_media/renderer/widevine_key_systems.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d0ee9bec36024d103b97449cb82cdb6c7b6bc4cb |
| --- /dev/null |
| +++ b/components/encrypted_media/renderer/widevine_key_systems.cc |
| @@ -0,0 +1,116 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/encrypted_media/renderer/widevine_key_systems.h" |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/logging.h" |
| +#include "content/public/renderer/key_system_info.h" |
| +#include "content/public/renderer/render_thread.h" |
| + |
| +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| + |
| +#if defined(OS_ANDROID) |
| +#include "components/encrypted_media/common/encrypted_media_messages_android.h" |
| +#endif |
| + |
| +using content::KeySystemInfo; |
| +using content::SupportedCodecs; |
| + |
| +namespace encrypted_media { |
|
xhwang
2014/05/01 22:41:22
ddorwin: shall we use "encrypted_media" or "eme" f
ycheo (away)
2014/05/02 10:05:46
Changed to 'cdm' per ddorwin's advice.
|
| + |
| +#if defined(WIDEVINE_CDM_AVAILABLE) |
| +enum WidevineCdmType { |
| + WIDEVINE, |
| + WIDEVINE_HR, |
|
ddorwin
2014/05/02 01:12:58
Remove. Never used.
ycheo (away)
2014/05/02 10:05:46
Done.
|
| +#if defined(OS_ANDROID) |
| + WIDEVINE_HR_NON_COMPOSITING, |
| +#endif |
| +}; |
| + |
| +// Return |name|'s parent key system. |
| +static std::string GetDirectParentName(std::string name) { |
| + int last_period = name.find_last_of('.'); |
| + DCHECK_GT(last_period, 0); |
| + return name.substr(0, last_period); |
| +} |
| + |
| +static void AddWidevineWithCodecs( |
| + WidevineCdmType widevine_cdm_type, |
| + SupportedCodecs supported_codecs, |
| + std::vector<KeySystemInfo>* concrete_key_systems) { |
| + KeySystemInfo info(kWidevineKeySystem); |
| + |
| + switch (widevine_cdm_type) { |
| + case WIDEVINE: |
| + // For standard Widevine, add parent name. |
| + info.parent_key_system = GetDirectParentName(kWidevineKeySystem); |
| + break; |
| + case WIDEVINE_HR: |
|
ddorwin
2014/05/02 01:12:58
Remove See above.
ycheo (away)
2014/05/02 10:05:46
Done.
|
| + info.key_system.append(".hr"); |
| + break; |
| +#if defined(OS_ANDROID) |
| + case WIDEVINE_HR_NON_COMPOSITING: |
| + info.key_system.append(".hrnoncompositing"); |
| + break; |
| +#endif |
| + default: |
| + NOTREACHED(); |
| + } |
| + |
| + // TODO(xhwang): A container or an initDataType may be supported even though |
| + // there are no codecs supported in that container. Fix this when we support |
| + // initDataType. |
| + info.supported_codecs = supported_codecs; |
| + |
| +#if defined(ENABLE_PEPPER_CDMS) |
| + info.pepper_type = kWidevineCdmPluginMimeType; |
| +#endif // defined(ENABLE_PEPPER_CDMS) |
| + |
| + concrete_key_systems->push_back(info); |
| +} |
| + |
| +#if defined(ENABLE_PEPPER_CDMS) |
| +void AddPepperBasedWidevine(std::vector<KeySystemInfo>* concrete_key_systems, |
|
ddorwin
2014/05/02 01:12:58
Output parameter should be last.
ycheo (away)
2014/05/02 10:05:46
The function itself was removed.
|
| + bool is_widevine_hr_supported, |
|
ddorwin
2014/05/02 01:12:58
Unnecessary. See above.
ycheo (away)
2014/05/02 10:05:46
Done.
|
| + SupportedCodecs supported_codecs) { |
| + AddWidevineWithCodecs(WIDEVINE, supported_codecs, concrete_key_systems); |
| + |
| + if (is_widevine_hr_supported) |
| + AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems); |
| +} |
| +#elif defined(OS_ANDROID) |
| +void AddAndroidWidevine( |
| + std::vector<KeySystemInfo>* concrete_key_systems) { |
| + SupportedKeySystemRequest request; |
| + SupportedKeySystemResponse response; |
| + |
| + request.key_system = kWidevineKeySystem; |
| + request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL; |
| + content::RenderThread::Get()->Send( |
| + new ChromeViewHostMsg_GetSupportedKeySystems(request, &response)); |
| + DCHECK(response.compositing_codecs & content::EME_CODEC_ALL) |
| + << "unrecognized codec"; |
| + DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL) |
| + << "unrecognized codec"; |
| + if (response.compositing_codecs != content::EME_CODEC_NONE) { |
| + AddWidevineWithCodecs( |
| + WIDEVINE, |
| + static_cast<SupportedCodecs>(response.compositing_codecs), |
| + concrete_key_systems); |
| + } |
| + |
| + if (response.non_compositing_codecs != content::EME_CODEC_NONE) { |
| + AddWidevineWithCodecs( |
| + WIDEVINE_HR_NON_COMPOSITING, |
| + static_cast<SupportedCodecs>(response.non_compositing_codecs), |
| + concrete_key_systems); |
| + } |
| +} |
| +#endif // defined(ENABLE_PEPPER_CDMS) |
| +#endif // defined(WIDEVINE_CDM_AVAILABLE) |
| + |
| +} // namespace encrypted_media |