Index: chrome/renderer/media/chrome_key_systems.cc |
diff --git a/chrome/renderer/media/chrome_key_systems.cc b/chrome/renderer/media/chrome_key_systems.cc |
index 90e6325de2c55a7a9a1cae0d45cfa898a904f048..300188bbe6a22f56a5dbe311ca4c2dda03139235 100644 |
--- a/chrome/renderer/media/chrome_key_systems.cc |
+++ b/chrome/renderer/media/chrome_key_systems.cc |
@@ -12,6 +12,7 @@ |
#include "base/strings/string_split.h" |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/common/render_messages.h" |
+#include "components/encrypted_media/renderer/widevine_key_systems.h" |
#include "content/public/renderer/render_thread.h" |
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
@@ -23,10 +24,6 @@ |
#include "base/version.h" |
#endif |
-#if defined(OS_ANDROID) |
-#include "chrome/common/encrypted_media_messages_android.h" |
-#endif |
- |
using content::KeySystemInfo; |
using content::SupportedCodecs; |
@@ -101,79 +98,25 @@ static void AddExternalClearKey( |
} |
#endif // defined(ENABLE_PEPPER_CDMS) |
- |
-#if defined(WIDEVINE_CDM_AVAILABLE) |
-enum WidevineCdmType { |
- WIDEVINE, |
- WIDEVINE_HR, |
-#if defined(OS_ANDROID) |
- WIDEVINE_HR_NON_COMPOSITING, |
-#endif |
-}; |
- |
-#if !defined(OS_ANDROID) |
+#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) |
static bool IsWidevineHrSupported() { |
// TODO(jrummell): Need to call CheckPlatformState() but it is |
// asynchronous, and needs to be done in the browser. |
return false; |
} |
-#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: |
- 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) |
// When the adapter is registered, a name-value pair is inserted in |
// additional_param_* that lists the supported codecs. The name is "codecs" and |
// the value is a comma-delimited list of codecs. |
// This function finds "codecs" and parses the value into the vector |codecs|. |
// Converts the codec strings to UTF-8 since we only expect ASCII strings and |
// this simplifies the rest of the code in this file. |
-void GetSupportedCodecs( |
+static void GetSupportedCodecs( |
const std::vector<base::string16>& additional_param_names, |
const std::vector<base::string16>& additional_param_values, |
- std::vector<std::string>* codecs) { |
- DCHECK(codecs->empty()); |
+ SupportedCodecs* result_supported_codecs) { |
DCHECK_EQ(additional_param_names.size(), additional_param_values.size()); |
+ std::vector<std::string> codecs; |
for (size_t i = 0; i < additional_param_names.size(); ++i) { |
if (additional_param_names[i] == |
base::ASCIIToUTF16(kCdmSupportedCodecsParamName)) { |
@@ -187,32 +130,10 @@ void GetSupportedCodecs( |
} |
base::SplitString(codecs_string, |
kCdmSupportedCodecsValueDelimiter, |
- codecs); |
+ &codecs); |
break; |
} |
} |
-} |
- |
-static void AddPepperBasedWidevine( |
- std::vector<KeySystemInfo>* concrete_key_systems) { |
-#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
- Version glibc_version(gnu_get_libc_version()); |
- DCHECK(glibc_version.IsValid()); |
- if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) |
- return; |
-#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
- |
- std::vector<base::string16> additional_param_names; |
- std::vector<base::string16> additional_param_values; |
- if (!IsPepperCdmRegistered(kWidevineCdmPluginMimeType, |
- &additional_param_names, |
- &additional_param_values)) { |
- DVLOG(1) << "Widevine CDM is not currently available."; |
- return; |
- } |
- |
- std::vector<std::string> codecs; |
- GetSupportedCodecs(additional_param_names, additional_param_values, &codecs); |
SupportedCodecs supported_codecs = content::EME_CODEC_NONE; |
for (size_t i = 0; i < codecs.size(); ++i) { |
@@ -227,42 +148,31 @@ static void AddPepperBasedWidevine( |
supported_codecs |= content::EME_CODEC_MP4_AVC1; |
#endif // defined(USE_PROPRIETARY_CODECS) |
} |
- |
- AddWidevineWithCodecs(WIDEVINE, supported_codecs, concrete_key_systems); |
- |
- if (IsWidevineHrSupported()) |
- AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems); |
+ *result_supported_codecs = supported_codecs; |
} |
-#elif defined(OS_ANDROID) |
-static 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); |
- } |
+static bool IsWidevineCdmAvailable(SupportedCodecs* supported_codecs) { |
xhwang
2014/05/01 22:41:22
The function name doesn't reflect what the functio
ycheo (away)
2014/05/01 23:27:32
Yes, the naming is difficult.
I have 3 options and
xhwang
2014/05/02 00:22:31
This is only used before calling AddPepperBasedWid
ycheo (away)
2014/05/02 00:30:26
That means I need to componentize PluginInfoMessag
ddorwin
2014/05/02 01:12:58
Since we have all the details in components, I thi
ycheo (away)
2014/05/02 10:05:46
I applied the second one.
|
+#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
+ Version glibc_version(gnu_get_libc_version()); |
+ DCHECK(glibc_version.IsValid()); |
+ if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) |
+ return false; |
+#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) |
- if (response.non_compositing_codecs != content::EME_CODEC_NONE) { |
- AddWidevineWithCodecs( |
- WIDEVINE_HR_NON_COMPOSITING, |
- static_cast<SupportedCodecs>(response.non_compositing_codecs), |
- concrete_key_systems); |
+ std::vector<base::string16> additional_param_names; |
+ std::vector<base::string16> additional_param_values; |
+ if (!IsPepperCdmRegistered(kWidevineCdmPluginMimeType, |
+ &additional_param_names, |
+ &additional_param_values)) { |
+ DVLOG(1) << "Widevine CDM is not currently available."; |
+ return false; |
} |
+ |
+ GetSupportedCodecs(additional_param_names, additional_param_values, |
+ supported_codecs); |
+ return true; |
} |
-#endif // defined(ENABLE_PEPPER_CDMS) |
-#endif // defined(WIDEVINE_CDM_AVAILABLE) |
+#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) |
void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) { |
#if defined(ENABLE_PEPPER_CDMS) |
@@ -271,9 +181,14 @@ void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) { |
#if defined(WIDEVINE_CDM_AVAILABLE) |
#if defined(ENABLE_PEPPER_CDMS) |
- AddPepperBasedWidevine(key_systems_info); |
+ SupportedCodecs supported_codecs; |
+ if (IsWidevineCdmAvailable(&supported_codecs)) { |
+ encrypted_media::AddPepperBasedWidevine(key_systems_info, |
+ IsWidevineHrSupported(), |
+ supported_codecs); |
+ } |
#elif defined(OS_ANDROID) |
- AddAndroidWidevine(key_systems_info); |
-#endif |
-#endif |
+ encrypted_media::AddAndroidWidevine(key_systems_info); |
+#endif // defined(ENABLE_PEPPER_CDMS) |
+#endif // defined(WIDEVINE_CDM_AVAILABLE) |
} |