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

Unified 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: fixing commnets 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 side-by-side diff with in-line comments
Download patch
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 1fa26eb2ec5f0249e7ca656f9f8d1fcbe2ee1066..fed94afd270cb081cd9d0242b5335d902391d0c2 100644
--- a/chrome/renderer/media/chrome_key_systems.cc
+++ b/chrome/renderer/media/chrome_key_systems.cc
@@ -19,6 +19,10 @@
#include "base/version.h"
#endif
+#if defined(OS_ANDROID)
+#include "chrome/common/encrypted_media_messages_android.h"
+#endif
+
using content::KeySystemInfo;
static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
@@ -87,6 +91,12 @@ static void AddExternalClearKey(
#if defined(WIDEVINE_CDM_AVAILABLE)
+enum WidevineCdmType {
+ WIDEVINE,
+ WIDEVINE_HR,
+ WIDEVINE_HRSURFACE,
+};
+
// Defines bitmask values used to specify supported codecs.
// Each value represents a codec within a specific container.
enum SupportedCodecs {
@@ -97,16 +107,26 @@ enum SupportedCodecs {
#endif // defined(USE_PROPRIETARY_CODECS)
};
-enum WidevineCdmType {
- WIDEVINE,
- WIDEVINE_HR,
-};
-
+#if defined(OS_ANDROID)
+#define COMPILE_ASSERT_MATCHING_ENUM(name) \
+ COMPILE_ASSERT(static_cast<int>(name) == \
+ static_cast<int>(android::name), \
+ mismatching_enums)
+COMPILE_ASSERT_MATCHING_ENUM(WEBM_VP8_AND_VORBIS);
+COMPILE_ASSERT_MATCHING_ENUM(MP4_AAC);
+COMPILE_ASSERT_MATCHING_ENUM(MP4_AVC1);
+#undef COMPILE_ASSERT_MATCHING_ENUM
+
+static const uint8 kWidevineUuid[16] = {
+ 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
+ 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
+#else
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) {
@@ -130,6 +150,9 @@ static void AddWidevineWithCodecs(
case WIDEVINE_HR:
info.key_system.append(".hr");
break;
+ case WIDEVINE_HRSURFACE:
ddorwin 2013/09/19 06:31:51 Should we ifdef ANDROID this since it only applies
qinmin 2013/09/19 14:37:29 hmm... so then we should also ifdef on the enum de
+ info.key_system.append(".hrsurface");
ddorwin 2013/09/19 06:31:51 We need to add an istypesupported test for this li
qinmin 2013/09/19 14:37:29 ok, will add that later. On 2013/09/19 06:31:51, d
+ break;
default:
NOTREACHED();
}
@@ -152,9 +175,6 @@ static void AddWidevineWithCodecs(
#if defined(ENABLE_PEPPER_CDMS)
info.pepper_type = kWidevineCdmPluginMimeType;
#elif defined(OS_ANDROID)
- static const uint8 kWidevineUuid[16] = {
- 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
- 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid));
#endif // defined(ENABLE_PEPPER_CDMS)
@@ -196,14 +216,32 @@ static void AddPepperBasedWidevine(
#elif defined(OS_ANDROID)
static void AddAndroidWidevine(
std::vector<KeySystemInfo>* concrete_key_systems) {
-#if defined(USE_PROPRIETARY_CODECS)
- SupportedCodecs supported_codecs =
- static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1);
- AddWidevineWithCodecs(WIDEVINE, supported_codecs, concrete_key_systems);
+ android::SupportedKeySystemRequest request;
+ android::SupportedKeySystemResponse response;
- if (IsWidevineHrSupported())
- AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems);
+ request.uuid.insert(request.uuid.begin(), kWidevineUuid,
+ kWidevineUuid + arraysize(kWidevineUuid));
+#if defined(USE_PROPRIETARY_CODECS)
+ request.codecs = static_cast<android::SupportedCodecs>(
+ android::MP4_AAC | android::MP4_AVC1);
#endif // defined(USE_PROPRIETARY_CODECS)
+ content::RenderThread::Get()->Send(
+ new ChromeViewHostMsg_GetSupportedKeySystems(request, &response));
+ DCHECK_EQ(response.compositing_codecs >> 3, 0) << "unrecognized codec";
+ DCHECK_EQ(response.non_compositing_codecs >> 3, 0) << "unrecognized codec";
+ if (response.compositing_codecs > 0) {
ddorwin 2013/09/19 00:38:17 This should be !=, but we can fix that later.
qinmin 2013/09/19 14:37:29 makes sense, will change this On 2013/09/19 00:38:
+ AddWidevineWithCodecs(
+ WIDEVINE,
+ static_cast<SupportedCodecs>(response.compositing_codecs),
+ concrete_key_systems);
+ }
+
+ if (response.non_compositing_codecs > 0) {
+ AddWidevineWithCodecs(
+ WIDEVINE_HRSURFACE,
+ static_cast<SupportedCodecs>(response.non_compositing_codecs),
+ concrete_key_systems);
+ }
}
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // defined(WIDEVINE_CDM_AVAILABLE)

Powered by Google App Engine
This is Rietveld 408576698